33#ifndef MATH_STANDALONE
58#define PYBVH_FIND_GENERIC_DISTANCE_DOC \
59 " :param distance: Maximum distance threshold.\n" \
60 " :type distance: float\n"
62#define PYBVH_FIND_GENERIC_RETURN_DOC \
63 " :return: Returns a tuple: (position, normal, index, distance),\n" \
64 " Values will all be None if no hit is found.\n" \
65 " :rtype: tuple[:class:`Vector` | None, :class:`Vector` | None, int | None, float | None]\n"
67#define PYBVH_FIND_GENERIC_RETURN_LIST_DOC \
68 " :return: Returns a list of tuples (position, normal, index, distance)\n" \
69 " :rtype: list[tuple[:class:`Vector`, :class:`Vector`, int, float]]\n"
71#define PYBVH_FROM_GENERIC_EPSILON_DOC \
72 " :param epsilon: Increase the threshold for detecting overlap and raycast hits.\n" \
73 " :type epsilon: float\n"
78#define PYBVH_MAX_DIST_STR "1.84467e+19"
114 float (*orig_normal)[3])
119 result->epsilon = epsilon;
123 result->coords_len = coords_len;
124 result->tris_len = tris_len;
126 result->orig_index = orig_index;
127 result->orig_normal = orig_normal;
129 return reinterpret_cast<PyObject *
>(
result);
146 PyLong_FromLong(hit->
index),
147 PyFloat_FromDouble(hit->
dist));
152 PyObject *py_retval = PyTuple_New(4);
161 PyObject *py_retval = PyTuple_New(4);
169static PyObject *py_bvhtree_raycast_to_py_and_check(
const BVHTreeRayHit *hit)
173 py_retval = PyTuple_New(4);
175 if (hit->index != -1) {
200 PyLong_FromLong(nearest->
index),
206 PyObject *py_retval = PyTuple_New(4);
215 PyObject *py_retval = PyTuple_New(4);
223static PyObject *py_bvhtree_nearest_to_py_and_check(
const BVHTreeNearest *nearest)
227 py_retval = PyTuple_New(4);
229 if (nearest->index != -1) {
248 MEM_SAFE_DELETE(self->
coords);
249 MEM_SAFE_DELETE(self->
tris);
254 Py_TYPE(self)->tp_free(
reinterpret_cast<PyObject *
>(self));
270 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
280 if (dist >= 0 && dist < hit->dist) {
300 const float (*coords)[3] =
const_cast<const float (*)[3]
>(self->
coords);
302 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
303 float nearest_tmp[3], dist_sq;
308 if (dist_sq < nearest->dist_sq) {
323 py_bvhtree_ray_cast_doc,
324 ".. method:: ray_cast(origin, direction, distance=sys.float_info.max, /)\n"
326 " Cast a ray onto the geometry.\n"
328 " :param origin: Start location of the ray.\n"
329 " :type origin: :class:`Vector`\n"
330 " :param direction: Direction of the ray (normalized internally).\n"
335 const char *error_prefix =
"ray_cast";
336 float co[3], direction[3];
342 PyObject *py_co, *py_direction;
344 if (!PyArg_ParseTuple(args,
383 py_bvhtree_find_nearest_doc,
387 " Find the nearest element (typically face index) to a point.\n"
389 " :param origin: Find nearest element to this point.\n"
394 const char *error_prefix =
"find_nearest";
404 if (!PyArg_ParseTuple(args,
421 nearest.
dist_sq = max_dist * max_dist;
451 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
452 float nearest_tmp[3], dist_sq;
457 if (dist_sq < data->dist_sq) {
475 py_bvhtree_find_nearest_range_doc,
479 " Find the nearest elements (typically face index) to a point in the distance range.\n"
481 " :param origin: Find nearest elements to this point.\n"
486 const char *error_prefix =
"find_nearest_range";
494 if (!PyArg_ParseTuple(args,
498 ":find_nearest_range",
510 PyObject *
ret = PyList_New(0);
534 return (memcmp(a,
b,
sizeof(*a)) != 0);
547 const uint *tri_a = tree_a->
tris[index_a];
548 const uint *tri_b = tree_b->
tris[index_b];
549 const float *tri_a_co[3] = {
551 const float *tri_b_co[3] = {
554 int verts_shared = 0;
556 if (tree_a == tree_b) {
557 if (index_a == index_b) [[unlikely]] {
565 if (verts_shared >= 2) {
576 py_bvhtree_overlap_doc,
577 ".. method:: overlap(other_tree, /)\n"
579 " Find overlapping indices between 2 trees.\n"
581 " :param other_tree: Other tree to perform overlap test on.\n"
582 " :type other_tree: :class:`BVHTree`\n"
583 " :return: Returns a list of unique index pairs,"
584 " the first index referencing this tree, the second referencing the **other_tree**.\n"
585 " :rtype: list[tuple[int, int]]\n");
590 uint overlap_len = 0;
594 PyErr_SetString(PyExc_ValueError,
"Expected a BVHTree argument");
598 data.tree_pair[0] = self;
599 data.tree_pair[1] = other;
607 if (overlap ==
nullptr) {
614 pair_test.
reserve(overlap_len);
619 for (i = 0; i < overlap_len; i++) {
630 if (!pair_test.
add(overlap[i])) {
635 item = PyTuple_New(2);
637 item, PyLong_FromLong(overlap[i].indexA), PyLong_FromLong(overlap[i].indexB));
639 PyList_Append(
ret, item);
659 C_BVHTree_FromPolygons_doc,
660 ".. classmethod:: FromPolygons(vertices, polygons, *, all_triangles=False, epsilon=0.0)\n"
662 " BVH tree constructed from geometry passed in as arguments.\n"
664 " :param vertices: float triplets each representing ``(x, y, z)`` coordinates.\n"
665 " :type vertices: Sequence[Sequence[float]]\n"
666 " :param polygons: Sequence of polygons, each containing indices to the vertices argument.\n"
667 " :type polygons: Sequence[Sequence[int]]\n"
668 " :param all_triangles: Use when all **polygons** are triangles for more efficient "
671 " :return: BVHTree from polygon data.\n"
672 " :rtype: :class:`BVHTree`\n");
675 const char *error_prefix =
"BVHTree.FromPolygons";
676 const char *keywords[] = {
"vertices",
"polygons",
"all_triangles",
"epsilon",
nullptr};
678 PyObject *py_coords, *py_tris;
679 PyObject *py_coords_fast =
nullptr, *py_tris_fast =
nullptr;
684 float (*coords)[3] =
nullptr;
685 uint(*tris)[3] =
nullptr;
686 uint coords_len, tris_len;
687 float epsilon = 0.0f;
688 bool all_triangles =
false;
691 int *orig_index =
nullptr;
692 float (*orig_normal)[3] =
nullptr;
697 if (!PyArg_ParseTupleAndKeywords(args,
704 ":BVHTree.FromPolygons",
705 const_cast<char **
>(keywords),
715 if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) ||
716 !(py_tris_fast = PySequence_Fast(py_tris, error_prefix)))
718 Py_XDECREF(py_coords_fast);
723 PyObject **py_coords_fast_items = PySequence_Fast_ITEMS(py_coords_fast);
724 coords_len =
uint(PySequence_Fast_GET_SIZE(py_coords_fast));
727 for (i = 0; i < coords_len; i++) {
728 PyObject *py_vert = py_coords_fast_items[i];
737 if (valid ==
false) {
740 else if (all_triangles) {
742 PyObject **py_tris_fast_items = PySequence_Fast_ITEMS(py_tris_fast);
743 tris_len =
uint(PySequence_Fast_GET_SIZE(py_tris_fast));
746 for (i = 0; i < tris_len; i++) {
747 PyObject *py_tricoords = py_tris_fast_items[i];
748 PyObject *py_tricoords_fast;
749 PyObject **py_tricoords_fast_items;
753 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
758 const Py_ssize_t py_tricoords_num = PySequence_Fast_GET_SIZE(py_tricoords_fast);
759 if (py_tricoords_num != 3) {
760 Py_DECREF(py_tricoords_fast);
761 PyErr_Format(PyExc_ValueError,
762 "%s: non triangle found at index %d with length of %d",
770 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
772 for (j = 0; j < 3; j++) {
774 if (tri[j] >=
uint(coords_len)) [[unlikely]] {
775 PyErr_Format(PyExc_ValueError,
776 "%s: index %d must be less than %d",
787 Py_DECREF(py_tricoords_fast);
797 const uint polys_len =
uint(PySequence_Fast_GET_SIZE(py_tris_fast));
802 } *plink_first =
nullptr, **p_plink_prev = &plink_first, *plink =
nullptr;
809 for (i = 0; i < polys_len; i++) {
810 PyObject *py_tricoords = PySequence_Fast_GET_ITEM(py_tris_fast, i);
811 PyObject *py_tricoords_fast;
812 PyObject **py_tricoords_fast_items;
813 uint py_tricoords_len;
816 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
821 py_tricoords_len =
uint(PySequence_Fast_GET_SIZE(py_tricoords_fast));
822 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
825 poly_arena,
sizeof(*plink) + (
sizeof(
int) *
size_t(py_tricoords_len))));
827 plink->len = py_tricoords_len;
828 *p_plink_prev = plink;
829 p_plink_prev = &plink->next;
831 for (j = 0; j < py_tricoords_len; j++) {
833 if (plink->poly[j] >=
uint(coords_len)) [[unlikely]] {
834 PyErr_Format(PyExc_ValueError,
835 "%s: index %d must be less than %d",
845 Py_DECREF(py_tricoords_fast);
851 if (py_tricoords_len >= 3) {
852 tris_len += (py_tricoords_len - 2);
855 *p_plink_prev =
nullptr;
867 for (plink = plink_first, poly_index = 0, i = 0; plink; plink = plink->next, poly_index++) {
868 if (plink->len == 3) {
870 memcpy(tri, plink->poly,
sizeof(
uint[3]));
871 orig_index[i] = poly_index;
872 normal_tri_v3(orig_normal[poly_index], coords[tri[0]], coords[tri[1]], coords[tri[2]]);
875 else if (plink->len > 3) {
876 float (*proj_coords)[2] =
static_cast<float (*)[2]
>(
878 float *normal = orig_normal[poly_index];
879 const float *co_prev;
880 const float *co_curr;
881 float axis_mat[3][3];
882 uint(*tris_offset)[3] = &tris[i];
887 co_prev = coords[plink->poly[plink->len - 1]];
888 for (j = 0; j < plink->len; j++) {
889 co_curr = coords[plink->poly[j]];
897 for (j = 0; j < plink->len; j++) {
898 mul_v2_m3v3(proj_coords[j], axis_mat, coords[plink->poly[j]]);
905 uint *tri = tris_offset[j];
907 tri[0] = plink->poly[tri[0]];
908 tri[1] = plink->poly[tri[1]];
909 tri[2] = plink->poly[tri[2]];
911 orig_index[i] = poly_index;
918 zero_v3(orig_normal[poly_index]);
924 Py_DECREF(py_coords_fast);
925 Py_DECREF(py_tris_fast);
940 for (i = 0; i < tris_len; i++) {
954 tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
967#ifndef MATH_STANDALONE
971 C_BVHTree_FromBMesh_doc,
972 ".. classmethod:: FromBMesh(bmesh, *, epsilon=0.0)\n"
974 " BVH tree based on :class:`BMesh` data.\n"
976 " :param bmesh: BMesh data.\n"
978 " :return: BVHTree from BMesh data.\n"
979 " :rtype: :class:`BVHTree`\n");
982 const char *keywords[] = {
"bmesh",
"epsilon",
nullptr};
986 float (*coords)[3] =
nullptr;
987 uint(*tris)[3] =
nullptr;
988 uint coords_len, tris_len;
989 float epsilon = 0.0f;
993 if (!PyArg_ParseTupleAndKeywords(args,
998 ":BVHTree.FromBMesh",
999 const_cast<char **
>(keywords),
1025 int *orig_index =
nullptr;
1026 float (*orig_normal)[3] =
nullptr;
1046 for (i = 0; i < tris_len; i++) {
1065 tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1071 Depsgraph *depsgraph,
1074 const bool use_deform,
1075 const bool use_cage,
1082 *r_free_mesh =
false;
1091 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1097 if (
mesh ==
nullptr) {
1098 PyErr_Format(PyExc_ValueError,
1099 "%s(...): Cannot get a mesh from object '%s'",
1105 *r_free_mesh =
true;
1108 if (ob_eval !=
nullptr) {
1115 if (
mesh ==
nullptr) {
1116 PyErr_Format(PyExc_ValueError,
1117 "%s(...): Cannot get a mesh from object '%s'",
1125 PyErr_Format(PyExc_ValueError,
1126 "%s(...): Cannot get evaluated data from given dependency graph / object pair",
1136 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1141 if (
mesh ==
nullptr) {
1142 PyErr_Format(PyExc_ValueError,
1143 "%s(...): Cannot get a mesh from object '%s'",
1148 *r_free_mesh =
true;
1153 PyErr_Format(PyExc_ValueError,
1154 "%s(...): cage arg is unsupported when deform=False and dependency graph "
1155 "evaluation mode is not RENDER",
1161 if (
mesh ==
nullptr) {
1162 PyErr_Format(PyExc_ValueError,
1163 "%s(...): Cannot get a mesh from object '%s'",
1168 *r_free_mesh =
true;
1174 C_BVHTree_FromObject_doc,
1175 ".. classmethod:: FromObject(object, depsgraph, *, deform=True, "
1176 "cage=False, epsilon=0.0)\n"
1178 " BVH tree based on :class:`Object` data.\n"
1180 " :param object: Mesh object.\n"
1181 " :type object: :class:`Object`\n"
1182 " :param depsgraph: Depsgraph to use for evaluating the mesh.\n"
1183 " :type depsgraph: :class:`Depsgraph`\n"
1184 " :param deform: Use mesh with deformations.\n"
1185 " :type deform: bool\n"
1186 " :param cage: Use modifiers cage.\n"
1188 " :return: BVHTree from Object data.\n"
1189 " :rtype: :class:`BVHTree`\n");
1193 const char *keywords[] = {
"object",
"depsgraph",
"deform",
"cage",
"epsilon",
nullptr};
1195 PyObject *py_ob, *py_depsgraph;
1197 Depsgraph *depsgraph;
1200 bool use_deform =
true;
1201 bool use_cage =
false;
1202 bool free_mesh =
false;
1204 float epsilon = 0.0f;
1206 if (!PyArg_ParseTupleAndKeywords(args,
1214 ":BVHTree.FromObject",
1215 const_cast<char **
>(keywords),
1224 ((depsgraph =
static_cast<Depsgraph *
>(
PyC_RNA_AsPointer(py_depsgraph,
"Depsgraph"))) ==
1231 mesh =
bvh_get_mesh(
"BVHTree", depsgraph, scene, ob, use_deform, use_cage, &free_mesh);
1233 if (
mesh ==
nullptr) {
1247 memcpy(coords,
mesh->vert_positions().data(),
sizeof(
float[3]) *
size_t(
mesh->verts_num));
1251 int *orig_index =
nullptr;
1252 float3 *orig_normal =
nullptr;
1261 MutableSpan(orig_normal, face_normals.
size()).copy_from(face_normals);
1267 tris[i][0] =
uint(corner_verts[corner_tris[i][0]]);
1268 tris[i][1] =
uint(corner_verts[corner_tris[i][1]]);
1269 tris[i][2] =
uint(corner_verts[corner_tris[i][2]]);
1276 orig_index[i] = int(tri_faces[i]);
1293 reinterpret_cast<float (*)[3]
>(orig_normal));
1305# pragma clang diagnostic push
1306# pragma clang diagnostic ignored "-Wcast-function-type"
1308# pragma GCC diagnostic push
1309# pragma GCC diagnostic ignored "-Wcast-function-type"
1317 py_bvhtree_ray_cast_doc},
1321 py_bvhtree_find_nearest_doc},
1322 {
"find_nearest_range",
1325 py_bvhtree_find_nearest_range_doc},
1326 {
"overlap",
reinterpret_cast<PyCFunction
>(
py_bvhtree_overlap), METH_O, py_bvhtree_overlap_doc},
1331 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1332 C_BVHTree_FromPolygons_doc},
1333#ifndef MATH_STANDALONE
1336 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1337 C_BVHTree_FromBMesh_doc},
1340 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1341 C_BVHTree_FromObject_doc},
1343 {
nullptr,
nullptr, 0,
nullptr},
1348# pragma clang diagnostic pop
1350# pragma GCC diagnostic pop
1355 PyVarObject_HEAD_INIT(
nullptr, 0)
1391 static_cast<allocfunc
>(PyType_GenericAlloc),
1392 static_cast<newfunc
>(PyType_GenericNew),
1393 static_cast<freefunc
>(
nullptr),
1400 static_cast<destructor
>(
nullptr),
1412 "BVH tree structures for proximity searches and ray casts on geometry.");
1415 "mathutils.bvhtree",
CustomData interface, see also DNA_customdata_types.h.
General operations, lookup, etc. for blender objects.
#define BLI_MEMARENA_STD_BUFSIZE
#define BLI_POLYFILL_ARENA_SIZE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BM_elem_index_get(ele)
#define BM_elem_index_set(ele, index)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
constexpr MutableSpan()=default
void reserve(const int64_t n)
constexpr int64_t size() const
constexpr IndexRange index_range() const
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
#define PYBVH_FIND_GENERIC_RETURN_DOC
#define PYBVH_MAX_DIST_STR
#define PYBVH_FROM_GENERIC_EPSILON_DOC
#define PYBVH_FIND_GENERIC_DISTANCE_DOC
#define PYBVH_FIND_GENERIC_RETURN_LIST_DOC
#define PyBVHTree_CheckExact(v)
float bvhtree_sphereray_tri_intersection(const BVHTreeRay *ray, float radius, float m_dist, const float v0[3], const float v1[3], const float v2[3])
Mesh * mesh_create_eval_no_deform_render(Depsgraph *depsgraph, const Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
Mesh * mesh_create_eval_no_deform(Depsgraph *depsgraph, const Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, float m_dist, const float v0[3], const float v1[3], const float v2[3])
const Mesh * mesh_get_eval_deform(Depsgraph *depsgraph, const Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
Mesh * mesh_create_eval_final(Depsgraph *depsgraph, const Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
static void py_bvhtree_nearest_to_py_tuple(const BVHTreeNearest *nearest, PyObject *py_retval)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static PyObject * py_bvhtree_find_nearest(PyBVHTree *self, PyObject *args)
BLI_INLINE bool overlap_cmp(const void *a_v, const void *b_v)
const CustomData_MeshMasks CD_MASK_BAREMESH
int PyC_ParseBool(PyObject *o, void *p)
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
bool isect_tri_tri_v3(const float t_a0[3], const float t_a1[3], const float t_a2[3], const float t_b0[3], const float t_b1[3], const float t_b2[3], float r_i1[3], float r_i2[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
BVHTreeOverlap * BLI_bvhtree_overlap(const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_num, BVHTree_OverlapCallback callback, void *userdata)
void BLI_bvhtree_free(BVHTree *tree)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
void BLI_bvhtree_balance(BVHTree *tree)
static const char PY_BVH_TREE_TYPE_DEFAULT
static const Mesh * bvh_get_mesh(const char *funcname, Depsgraph *depsgraph, Scene *scene, Object *ob, const bool use_deform, const bool use_cage, bool *r_free_mesh)
void BLI_polyfill_calc_arena(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3], struct MemArena *arena)
ATTR_WARN_UNUSED_RESULT const BMVert * v
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
static PyObject * C_BVHTree_FromPolygons(PyObject *, PyObject *args, PyObject *kwargs)
static PyObject * py_bvhtree_raycast_to_py_none()
static PyObject * py_bvhtree_ray_cast(PyBVHTree *self, PyObject *args)
PyTypeObject BPy_BMesh_Type
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
static void py_bvhtree_raycast_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
BMesh const char void * data
static PyMethodDef py_bvhtree_methods[]
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
static void py_bvhtree_nearest_point_range_cb(void *userdata, int index, const float co[3], float)
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
int BLI_bvhtree_range_query(const BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
PyMODINIT_FUNC PyInit_mathutils_bvhtree()
static void py_bvhtree_nearest_point_cb(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
static PyObject * C_BVHTree_FromObject(PyObject *, PyObject *args, PyObject *kwargs)
void BM_mesh_calc_tessellation(BMesh *bm, MutableSpan< std::array< BMLoop *, 3 > > looptris)
static PyObject * py_bvhtree_nearest_to_py_none()
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
MINLINE void zero_v3(float r[3])
void BKE_id_free(Main *bmain, void *idv)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
static PyObject * py_bvhtree_find_nearest_range(PyBVHTree *self, PyObject *args)
static PyObject * C_BVHTree_FromBMesh(PyObject *, PyObject *args, PyObject *kwargs)
static const float max_dist_default
static const char PY_BVH_AXIS_DEFAULT
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
MINLINE float normalize_v3(float n[3])
static PyObject * py_bvhtree_raycast_to_py(const BVHTreeRayHit *hit)
uint32_t PyC_Long_AsU32(PyObject *value)
void * PyC_RNA_AsPointer(PyObject *value, const char *type_name)
void PyC_Tuple_Fill(PyObject *tuple, PyObject *value)
MINLINE float max_ff(float a, float b)
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
static void py_bvhtree__tp_dealloc(PyBVHTree *self)
MINLINE float square_f(float a)
BLI_INLINE uint overlap_hash(const void *overlap_v)
VecBase< float, 3 > float3
static PyObject * py_bvhtree_nearest_to_py(const BVHTreeNearest *nearest)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
static PyModuleDef bvhtree_moduledef
static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int)
static PyObject * py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
bool BKE_mesh_face_normals_are_dirty(const Mesh *mesh)
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3])
static void py_bvhtree_raycast_to_py_tuple(const BVHTreeRayHit *hit, PyObject *py_retval)
static PyObject * bvhtree_CreatePyObject(BVHTree *tree, float epsilon, float(*coords)[3], uint coords_len, uint(*tris)[3], uint tris_len, int *orig_index, float(*orig_normal)[3])
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
PyTypeObject PyBVHTree_Type
#define PyTuple_SET_ITEMS(op_arg,...)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
PyObject_HEAD BVHTree * tree