Открыть боковую панель
nikitronn
sverchok
Коммиты
04dc09c8
Не подтверждена
Коммит
04dc09c8
создал
Май 21, 2021
по автору
Victor Doval
Зафиксировано автором
GitHub
Май 21, 2021
Просмотр файлов
Ensure BVH tree is not built with numpy arrays (#4111)
владелец
0ab145cb
Изменения
1
Скрыть пробелы
Построчно
Рядом
utils/bvh_tree.py
Просмотр файла @
04dc09c8
...
@@ -6,15 +6,25 @@
...
@@ -6,15 +6,25 @@
# License-Filename: LICENSE
# License-Filename: LICENSE
from
mathutils.bvhtree
import
BVHTree
from
mathutils.bvhtree
import
BVHTree
import
numpy
as
np
def
bvh_safe_check
(
verts
,
pols
):
def
bvh_safe_check
(
verts
,
pols
):
len_v
=
len
(
verts
)
len_v
=
len
(
verts
)
for
p
in
pols
:
if
isinstance
(
pols
,
np
.
ndarray
):
for
c
in
p
:
max_c
=
np
.
amax
(
pols
)
if
c
>
len_v
:
if
max_c
>
len_v
:
raise
Exception
(
f
"Index
{
c
}
should be less than vertices length (
{
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
):
def
bvh_tree_from_polygons
(
vertices
,
polygons
,
all_triangles
=
False
,
epsilon
=
0.0
,
safe_check
=
True
):
if
safe_check
:
if
safe_check
:
bvh_safe_check
(
vertices
,
polygons
)
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
)
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.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать