37 #include "../generic/py_capi_utils.h"
38 #include "../generic/python_utildefines.h"
43 #ifndef MATH_STANDALONE
58 # include "../bmesh/bmesh_py_types.h"
67 #define PYBVH_FIND_GENERIC_DISTANCE_DOC \
68 " :arg distance: Maximum distance threshold.\n" \
69 " :type distance: float\n"
71 #define PYBVH_FIND_GENERIC_RETURN_DOC \
72 " :return: Returns a tuple\n" \
73 " (:class:`Vector` location, :class:`Vector` normal, int index, float distance),\n" \
74 " Values will all be None if no hit is found.\n" \
75 " :rtype: :class:`tuple`\n"
77 #define PYBVH_FIND_GENERIC_RETURN_LIST_DOC \
78 " :return: Returns a list of tuples\n" \
79 " (:class:`Vector` location, :class:`Vector` normal, int index, float distance),\n" \
80 " :rtype: :class:`list`\n"
82 #define PYBVH_FROM_GENERIC_EPSILON_DOC \
83 " :arg epsilon: Increase the threshold for detecting overlap and raycast hits.\n" \
84 " :type epsilon: float\n"
89 #define PYBVH_MAX_DIST_STR "1.84467e+19"
124 float (*orig_normal)[3])
133 result->coords_len = coords_len;
134 result->tris_len = tris_len;
136 result->orig_index = orig_index;
137 result->orig_normal = orig_normal;
139 return (PyObject *)
result;
156 PyLong_FromLong(hit->
index),
157 PyFloat_FromDouble(hit->
dist));
162 PyObject *py_retval = PyTuple_New(4);
171 PyObject *py_retval = PyTuple_New(4);
179 static PyObject *py_bvhtree_raycast_to_py_and_check(
const BVHTreeRayHit *hit)
183 py_retval = PyTuple_New(4);
185 if (hit->
index != -1) {
210 PyLong_FromLong(nearest->
index),
216 PyObject *py_retval = PyTuple_New(4);
225 PyObject *py_retval = PyTuple_New(4);
233 static PyObject *py_bvhtree_nearest_to_py_and_check(
const BVHTreeNearest *nearest)
237 py_retval = PyTuple_New(4);
239 if (nearest->
index != -1) {
264 Py_TYPE(
self)->tp_free((PyObject *)
self);
279 const uint *tri =
self->tris[index];
280 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
283 if (
self->epsilon == 0.0f) {
290 if (dist >= 0 && dist < hit->dist) {
291 hit->
index =
self->orig_index ?
self->orig_index[index] : index;
294 if (
self->orig_normal) {
311 const uint *tri =
self->tris[index];
312 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
313 float nearest_tmp[3], dist_sq;
318 if (dist_sq < nearest->dist_sq) {
319 nearest->
index =
self->orig_index ?
self->orig_index[index] : index;
322 if (
self->orig_normal) {
332 ".. method:: ray_cast(origin, direction, distance=sys.float_info.max)\n"
334 " Cast a ray onto the mesh.\n"
336 " :arg origin: Start location of the ray in object space.\n"
337 " :type origin: :class:`Vector`\n"
338 " :arg direction: Direction of the ray in object space.\n"
343 const char *error_prefix =
"ray_cast";
344 float co[3], direction[3];
345 float max_dist = FLT_MAX;
350 PyObject *py_co, *py_direction;
352 if (!PyArg_ParseTuple(args,
"OO|f:ray_cast", &py_co, &py_direction, &max_dist)) {
383 " Find the nearest element (typically face index) to a point.\n"
385 " :arg co: Find nearest element to this point.\n"
390 const char *error_prefix =
"find_nearest";
400 if (!PyArg_ParseTuple(args,
"O|f:find_nearest", &py_co, &max_dist)) {
410 nearest.
dist_sq = max_dist * max_dist;
432 float UNUSED(dist_sq_bvh))
438 const uint *tri =
self->tris[index];
439 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
447 nearest.
index =
self->orig_index ?
self->orig_index[index] : index;
450 if (
self->orig_normal) {
462 py_bvhtree_find_nearest_range_doc,
466 " Find the nearest elements (typically face index) to a point in the distance range.\n"
468 " :arg co: Find nearest elements to this point.\n"
473 const char *error_prefix =
"find_nearest_range";
481 if (!PyArg_ParseTuple(args,
"O|f:find_nearest_range", &py_co, &max_dist)) {
490 PyObject *
ret = PyList_New(0);
516 return (memcmp(
a, b,
sizeof(*
a)) != 0);
529 const uint *tri_a = tree_a->
tris[index_a];
530 const uint *tri_b = tree_b->
tris[index_b];
531 const float *tri_a_co[3] = {
533 const float *tri_b_co[3] = {
536 int verts_shared = 0;
538 if (tree_a == tree_b) {
547 if (verts_shared >= 2) {
557 py_bvhtree_overlap_doc,
558 ".. method:: overlap(other_tree)\n"
560 " Find overlapping indices between 2 trees.\n"
562 " :arg other_tree: Other tree to perform overlap test on.\n"
563 " :type other_tree: :class:`BVHTree`\n"
564 " :return: Returns a list of unique index pairs,"
565 " the first index referencing this tree, the second referencing the **other_tree**.\n"
566 " :rtype: :class:`list`\n");
571 uint overlap_len = 0;
575 PyErr_SetString(PyExc_ValueError,
"Expected a BVHTree argument");
579 data.tree_pair[0] =
self;
580 data.tree_pair[1] = other;
588 if (overlap ==
NULL) {
592 const bool use_unique = (
self->orig_index || other->
orig_index);
593 GSet *pair_test = use_unique ?
599 for (i = 0; i < overlap_len; i++) {
602 if (
self->orig_index) {
603 overlap[i].indexA =
self->orig_index[overlap[i].indexA];
606 overlap[i].indexB = other->
orig_index[overlap[i].indexB];
615 item = PyTuple_New(2);
617 item, PyLong_FromLong(overlap[i].indexA), PyLong_FromLong(overlap[i].indexB));
619 PyList_Append(
ret, item);
642 C_BVHTree_FromPolygons_doc,
643 ".. classmethod:: FromPolygons(vertices, polygons, all_triangles=False, epsilon=0.0)\n"
645 " BVH tree constructed geometry passed in as arguments.\n"
647 " :arg vertices: float triplets each representing ``(x, y, z)``\n"
648 " :type vertices: float triplet sequence\n"
649 " :arg polygons: Sequence of polyugons, each containing indices to the vertices argument.\n"
650 " :type polygons: Sequence of sequences containing ints\n"
651 " :arg all_triangles: Use when all **polygons** are triangles for more efficient "
656 const char *error_prefix =
"BVHTree.FromPolygons";
657 const char *keywords[] = {
"vertices",
"polygons",
"all_triangles",
"epsilon",
NULL};
659 PyObject *py_coords, *py_tris;
660 PyObject *py_coords_fast =
NULL, *py_tris_fast =
NULL;
667 uint coords_len, tris_len;
669 bool all_triangles =
false;
672 int *orig_index =
NULL;
678 if (!PyArg_ParseTupleAndKeywords(args,
680 "OO|$O&f:BVHTree.FromPolygons",
690 if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) ||
691 !(py_tris_fast = PySequence_Fast(py_tris, error_prefix))) {
692 Py_XDECREF(py_coords_fast);
697 PyObject **py_coords_fast_items = PySequence_Fast_ITEMS(py_coords_fast);
698 coords_len = (
uint)PySequence_Fast_GET_SIZE(py_coords_fast);
699 coords =
MEM_mallocN((
size_t)coords_len *
sizeof(*coords), __func__);
701 for (i = 0; i < coords_len; i++) {
702 PyObject *py_vert = py_coords_fast_items[i];
711 if (valid ==
false) {
714 else if (all_triangles) {
716 PyObject **py_tris_fast_items = PySequence_Fast_ITEMS(py_tris_fast);
717 tris_len = (
uint)PySequence_Fast_GET_SIZE(py_tris_fast);
718 tris =
MEM_mallocN((
size_t)tris_len *
sizeof(*tris), __func__);
720 for (i = 0; i < tris_len; i++) {
721 PyObject *py_tricoords = py_tris_fast_items[i];
722 PyObject *py_tricoords_fast;
723 PyObject **py_tricoords_fast_items;
727 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
732 if (PySequence_Fast_GET_SIZE(py_tricoords_fast) != 3) {
733 Py_DECREF(py_tricoords_fast);
734 PyErr_Format(PyExc_ValueError,
735 "%s: non triangle found at index %d with length of %d",
738 PySequence_Fast_GET_SIZE(py_tricoords_fast));
743 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
745 for (j = 0; j < 3; j++) {
748 PyErr_Format(PyExc_ValueError,
749 "%s: index %d must be less than %d",
760 Py_DECREF(py_tricoords_fast);
765 const uint polys_len = (
uint)PySequence_Fast_GET_SIZE(py_tris_fast);
767 struct PolyLink *
next;
770 } *plink_first =
NULL, **p_plink_prev = &plink_first, *plink =
NULL;
777 for (i = 0; i < polys_len; i++) {
778 PyObject *py_tricoords = PySequence_Fast_GET_ITEM(py_tris_fast, i);
779 PyObject *py_tricoords_fast;
780 PyObject **py_tricoords_fast_items;
781 uint py_tricoords_len;
784 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
789 py_tricoords_len = (
uint)PySequence_Fast_GET_SIZE(py_tricoords_fast);
790 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
793 sizeof(*plink) + (
sizeof(
int) * (
size_t)py_tricoords_len));
795 plink->len = (
uint)py_tricoords_len;
796 *p_plink_prev = plink;
797 p_plink_prev = &plink->next;
799 for (j = 0; j < py_tricoords_len; j++) {
802 PyErr_Format(PyExc_ValueError,
803 "%s: index %d must be less than %d",
813 Py_DECREF(py_tricoords_fast);
815 if (py_tricoords_len >= 3) {
816 tris_len += (py_tricoords_len - 2);
819 *p_plink_prev =
NULL;
824 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
826 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
827 orig_normal =
MEM_mallocN(
sizeof(*orig_normal) * (
size_t)polys_len, __func__);
829 for (plink = plink_first, poly_index = 0, i = 0; plink; plink = plink->next, poly_index++) {
830 if (plink->len == 3) {
832 memcpy(tri, plink->poly,
sizeof(
uint[3]));
833 orig_index[i] = poly_index;
834 normal_tri_v3(orig_normal[poly_index], coords[tri[0]], coords[tri[1]], coords[tri[2]]);
837 else if (plink->len > 3) {
839 float *
normal = orig_normal[poly_index];
840 const float *co_prev;
841 const float *co_curr;
842 float axis_mat[3][3];
843 uint(*tris_offset)[3] = &tris[i];
848 co_prev = coords[plink->poly[plink->len - 1]];
849 for (j = 0; j < plink->len; j++) {
850 co_curr = coords[plink->poly[j]];
858 for (j = 0; j < plink->len; j++) {
859 mul_v2_m3v3(proj_coords[j], axis_mat, coords[plink->poly[j]]);
866 uint *tri = tris_offset[j];
868 tri[0] = plink->poly[tri[0]];
869 tri[1] = plink->poly[tri[1]];
870 tri[2] = plink->poly[tri[2]];
872 orig_index[i] = poly_index;
879 zero_v3(orig_normal[poly_index]);
884 Py_DECREF(py_coords_fast);
885 Py_DECREF(py_tris_fast);
900 for (i = 0; i < tris_len; i++) {
914 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
927 #ifndef MATH_STANDALONE
930 ".. classmethod:: FromBMesh(bmesh, epsilon=0.0)\n"
932 " BVH tree based on :class:`BMesh` data.\n"
934 " :arg bmesh: BMesh data.\n"
938 const char *keywords[] = {
"bmesh",
"epsilon",
NULL};
944 uint coords_len, tris_len;
950 if (!PyArg_ParseTupleAndKeywords(args,
952 "O!|$f:BVHTree.FromBMesh",
969 coords =
MEM_mallocN(
sizeof(*coords) * (
size_t)coords_len, __func__);
970 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
972 looptris =
MEM_mallocN(
sizeof(*looptris) * (
size_t)tris_len, __func__);
983 int *orig_index =
NULL;
991 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
1004 for (i = 0; i < tris_len; i++) {
1025 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1034 const bool use_deform,
1035 const bool use_cage,
1042 *r_free_mesh =
false;
1050 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1055 *r_free_mesh =
true;
1058 if (ob_eval !=
NULL) {
1066 PyErr_Format(PyExc_ValueError,
1067 "%s(...): Cannot get evaluated data from given dependency graph / object pair",
1077 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1082 *r_free_mesh =
true;
1087 PyErr_Format(PyExc_ValueError,
1088 "%s(...): cage arg is unsupported when deform=False and dependency graph "
1089 "evaluation mode is not RENDER",
1094 *r_free_mesh =
true;
1099 ".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, "
1100 "cage=False, epsilon=0.0)\n"
1102 " BVH tree based on :class:`Object` data.\n"
1104 " :arg object: Object data.\n"
1105 " :type object: :class:`Object`\n"
1106 " :arg depsgraph: Depsgraph to use for evaluating the mesh.\n"
1107 " :type depsgraph: :class:`Depsgraph`\n"
1108 " :arg deform: Use mesh with deformations.\n"
1109 " :type deform: bool\n"
1110 " :arg cage: Use modifiers cage.\n"
1115 const char *keywords[] = {
"object",
"depsgraph",
"deform",
"cage",
"epsilon",
NULL};
1117 PyObject *py_ob, *py_depsgraph;
1122 bool use_deform =
true;
1123 bool use_cage =
false;
1124 bool free_mesh =
false;
1131 uint coords_len, tris_len;
1134 if (!PyArg_ParseTupleAndKeywords(args,
1136 "OO|$O&O&f:BVHTree.FromObject",
1164 coords =
MEM_mallocN(
sizeof(*coords) * (size_t)coords_len, __func__);
1165 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
1179 int *orig_index =
NULL;
1184 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
1191 for (i = 0; i < tris_len; i++, lt++) {
1194 tris[i][0] = mloop[lt->
tri[0]].
v;
1195 tris[i][1] = mloop[lt->
tri[1]].
v;
1196 tris[i][2] = mloop[lt->
tri[2]].
v;
1203 orig_index[i] = (int)lt->
poly;
1214 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1230 py_bvhtree_find_nearest_doc},
1231 {
"find_nearest_range",
1234 py_bvhtree_find_nearest_range_doc},
1240 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1241 C_BVHTree_FromPolygons_doc},
1242 #ifndef MATH_STANDALONE
1245 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1246 C_BVHTree_FromBMesh_doc},
1249 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1250 C_BVHTree_FromObject_doc},
1256 PyVarObject_HEAD_INIT(
NULL, 0)
"BVHTree",
1292 (allocfunc)PyType_GenericAlloc,
1293 (newfunc)PyType_GenericNew,
1308 "BVH tree structures for proximity searches and ray casts on geometry.");
1310 PyModuleDef_HEAD_INIT,
1311 "mathutils.bvhtree",
typedef float(TangentPoint)[2]
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
float bvhtree_sphereray_tri_intersection(const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
CustomData interface, see also DNA_customdata_types.h.
const CustomData_MeshMasks CD_MASK_BAREMESH
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_id_free(struct Main *bmain, void *idv)
struct Mesh * mesh_get_eval_deform(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_create_eval_no_deform(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
const struct MLoopTri * BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh)
struct Mesh * mesh_create_eval_no_deform_render(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh)
struct Mesh * mesh_create_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
GSet * BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
bool BLI_gset_add(GSet *gs, void *key)
int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata)
BVHTreeOverlap * BLI_bvhtree_overlap(const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_tot, BVHTree_OverlapCallback callback, void *userdata)
void BLI_bvhtree_balance(BVHTree *tree)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
MINLINE float max_ff(float a, float b)
MINLINE float square_f(float a)
MINLINE int poly_to_tri_count(const int poly_count, const int corner_count)
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 axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3])
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])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
MINLINE float normalize_v3(float r[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
void BLI_polyfill_calc_arena(const float(*coords)[2], const unsigned int coords_tot, const int coords_sign, unsigned int(*r_tris)[3], struct MemArena *arena)
#define BLI_POLYFILL_ARENA_SIZE
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
struct Depsgraph Depsgraph
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define BM_elem_index_get(ele)
#define BM_elem_index_set(ele, index)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot)
BM_mesh_calc_tessellation get the looptris and its number from a certain bmesh.
PyTypeObject BPy_BMesh_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
IconTextureDrawCall normal
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
PyObject * Vector_CreatePyObject(const float *vec, const int size, PyTypeObject *base_type)
static PyObject * py_bvhtree_raycast_to_py_none(void)
static PyObject * C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
PyDoc_STRVAR(py_bvhtree_ray_cast_doc, ".. method:: ray_cast(origin, direction, distance=sys.float_info.max)\n" "\n" " Cast a ray onto the mesh.\n" "\n" " :arg origin: Start location of the ray in object space.\n" " :type origin: :class:`Vector`\n" " :arg direction: Direction of the ray in object space.\n" " :type direction: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_DOC)
#define PYBVH_FIND_GENERIC_RETURN_DOC
static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(thread))
static PyObject * py_bvhtree_find_nearest(PyBVHTree *self, PyObject *args)
static void py_bvhtree_raycast_to_py_tuple(const BVHTreeRayHit *hit, PyObject *py_retval)
BLI_INLINE bool overlap_cmp(const void *a_v, const void *b_v)
static void py_bvhtree__tp_dealloc(PyBVHTree *self)
static PyObject * py_bvhtree_nearest_to_py(const BVHTreeNearest *nearest)
static PyObject * py_bvhtree_find_nearest_range(PyBVHTree *self, PyObject *args)
static void py_bvhtree_nearest_point_cb(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
static const char PY_BVH_AXIS_DEFAULT
static PyObject * C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
#define PYBVH_MAX_DIST_STR
static struct PyModuleDef bvhtree_moduledef
#define PYBVH_FROM_GENERIC_EPSILON_DOC
static void py_bvhtree_raycast_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
static PyObject * py_bvhtree_raycast_to_py(const BVHTreeRayHit *hit)
BLI_INLINE uint overlap_hash(const void *overlap_v)
static PyMethodDef py_bvhtree_methods[]
static const char PY_BVH_TREE_TYPE_DEFAULT
static Mesh * bvh_get_mesh(const char *funcname, struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, const bool use_deform, const bool use_cage, bool *r_free_mesh)
PyMODINIT_FUNC PyInit_mathutils_bvhtree(void)
PyTypeObject PyBVHTree_Type
static PyObject * C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
static PyObject * py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
#define PYBVH_FIND_GENERIC_DISTANCE_DOC
#define PYBVH_FIND_GENERIC_RETURN_LIST_DOC
static void py_bvhtree_nearest_to_py_tuple(const BVHTreeNearest *nearest, PyObject *py_retval)
static PyObject * py_bvhtree_ray_cast(PyBVHTree *self, PyObject *args)
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])
static const float max_dist_default
static void py_bvhtree_nearest_point_range_cb(void *userdata, int index, const float co[3], float UNUSED(dist_sq_bvh))
static PyObject * py_bvhtree_nearest_to_py_none(void)
#define PyBVHTree_CheckExact(v)
void * PyC_RNA_AsPointer(PyObject *value, const char *type_name)
uint32_t PyC_Long_AsU32(PyObject *value)
int PyC_ParseBool(PyObject *o, void *p)
void PyC_Tuple_Fill(PyObject *tuple, PyObject *value)
#define PyTuple_SET_ITEMS(op_arg,...)
PyObject_VAR_HEAD struct BMesh * bm
PyObject_HEAD BVHTree * tree