Не подтверждена Коммит 04dc09c8 создал по автору Victor Doval's avatar Victor Doval Зафиксировано автором GitHub
Просмотр файлов

Ensure BVH tree is not built with numpy arrays (#4111)

владелец 0ab145cb
......@@ -6,15 +6,25 @@
# License-Filename: LICENSE
from mathutils.bvhtree import BVHTree
import numpy as np
def bvh_safe_check(verts, pols):
len_v = len(verts)
for p in pols:
for c in p:
if c > len_v:
raise Exception(f"Index {c} should be less than vertices length ({len_v})")
if isinstance(pols, np.ndarray):
max_c = np.amax(pols)
if max_c > len_v:
raise Exception(f"Index {max_c} should be less than vertices length ({len_v})")
else:
for p in pols:
for c in p:
if c > len_v:
raise Exception(f"Index {c} should be less than vertices length ({len_v})")
def bvh_tree_from_polygons(vertices, polygons, all_triangles=False, epsilon=0.0, safe_check=True):
if safe_check:
bvh_safe_check(vertices, polygons)
if isinstance(vertices, np.ndarray):
vertices = vertices.tolist()
if isinstance(polygons, np.ndarray):
polygons = polygons.tolist()
return BVHTree.FromPolygons(vertices, polygons, all_triangles=all_triangles, epsilon=epsilon)
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать