23 #include "../generic/py_capi_utils.h"
24 #include "../generic/python_utildefines.h"
29 #ifndef MATH_STANDALONE
44 # include "../bmesh/bmesh_py_types.h"
53 #define PYBVH_FIND_GENERIC_DISTANCE_DOC \
54 " :arg distance: Maximum distance threshold.\n" \
55 " :type distance: float\n"
57 #define PYBVH_FIND_GENERIC_RETURN_DOC \
58 " :return: Returns a tuple\n" \
59 " (:class:`Vector` location, :class:`Vector` normal, int index, float distance),\n" \
60 " Values will all be None if no hit is found.\n" \
61 " :rtype: :class:`tuple`\n"
63 #define PYBVH_FIND_GENERIC_RETURN_LIST_DOC \
64 " :return: Returns a list of tuples\n" \
65 " (:class:`Vector` location, :class:`Vector` normal, int index, float distance),\n" \
66 " :rtype: :class:`list`\n"
68 #define PYBVH_FROM_GENERIC_EPSILON_DOC \
69 " :arg epsilon: Increase the threshold for detecting overlap and raycast hits.\n" \
70 " :type epsilon: float\n"
75 #define PYBVH_MAX_DIST_STR "1.84467e+19"
111 float (*orig_normal)[3])
120 result->coords_len = coords_len;
121 result->tris_len = tris_len;
123 result->orig_index = orig_index;
124 result->orig_normal = orig_normal;
126 return (PyObject *)
result;
143 PyLong_FromLong(hit->
index),
144 PyFloat_FromDouble(hit->
dist));
149 PyObject *py_retval = PyTuple_New(4);
158 PyObject *py_retval = PyTuple_New(4);
166 static PyObject *py_bvhtree_raycast_to_py_and_check(
const BVHTreeRayHit *hit)
170 py_retval = PyTuple_New(4);
172 if (hit->
index != -1) {
197 PyLong_FromLong(nearest->
index),
203 PyObject *py_retval = PyTuple_New(4);
212 PyObject *py_retval = PyTuple_New(4);
220 static PyObject *py_bvhtree_nearest_to_py_and_check(
const BVHTreeNearest *nearest)
224 py_retval = PyTuple_New(4);
226 if (nearest->
index != -1) {
251 Py_TYPE(
self)->tp_free((PyObject *)
self);
266 const uint *tri =
self->tris[index];
267 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
270 if (
self->epsilon == 0.0f) {
277 if (dist >= 0 && dist < hit->dist) {
278 hit->
index =
self->orig_index ?
self->orig_index[index] : index;
281 if (
self->orig_normal) {
298 const uint *tri =
self->tris[index];
299 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
300 float nearest_tmp[3], dist_sq;
305 if (dist_sq < nearest->dist_sq) {
306 nearest->
index =
self->orig_index ?
self->orig_index[index] : index;
309 if (
self->orig_normal) {
319 ".. method:: ray_cast(origin, direction, distance=sys.float_info.max)\n"
321 " Cast a ray onto the mesh.\n"
323 " :arg origin: Start location of the ray in object space.\n"
324 " :type origin: :class:`Vector`\n"
325 " :arg direction: Direction of the ray in object space.\n"
330 const char *error_prefix =
"ray_cast";
331 float co[3], direction[3];
332 float max_dist = FLT_MAX;
337 PyObject *py_co, *py_direction;
339 if (!PyArg_ParseTuple(args,
"OO|f:ray_cast", &py_co, &py_direction, &max_dist)) {
370 " Find the nearest element (typically face index) to a point.\n"
372 " :arg co: Find nearest element to this point.\n"
377 const char *error_prefix =
"find_nearest";
387 if (!PyArg_ParseTuple(args,
"O|f:find_nearest", &py_co, &max_dist)) {
397 nearest.
dist_sq = max_dist * max_dist;
419 float UNUSED(dist_sq_bvh))
424 const float(*coords)[3] =
self->coords;
425 const uint *tri =
self->tris[index];
426 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
434 nearest.
index =
self->orig_index ?
self->orig_index[index] : index;
437 if (
self->orig_normal) {
449 py_bvhtree_find_nearest_range_doc,
453 " Find the nearest elements (typically face index) to a point in the distance range.\n"
455 " :arg co: Find nearest elements to this point.\n"
460 const char *error_prefix =
"find_nearest_range";
468 if (!PyArg_ParseTuple(args,
"O|f:find_nearest_range", &py_co, &max_dist)) {
477 PyObject *
ret = PyList_New(0);
503 return (memcmp(
a,
b,
sizeof(*
a)) != 0);
516 const uint *tri_a = tree_a->
tris[index_a];
517 const uint *tri_b = tree_b->
tris[index_b];
518 const float *tri_a_co[3] = {
520 const float *tri_b_co[3] = {
523 int verts_shared = 0;
525 if (tree_a == tree_b) {
534 if (verts_shared >= 2) {
544 py_bvhtree_overlap_doc,
545 ".. method:: overlap(other_tree)\n"
547 " Find overlapping indices between 2 trees.\n"
549 " :arg other_tree: Other tree to perform overlap test on.\n"
550 " :type other_tree: :class:`BVHTree`\n"
551 " :return: Returns a list of unique index pairs,"
552 " the first index referencing this tree, the second referencing the **other_tree**.\n"
553 " :rtype: :class:`list`\n");
558 uint overlap_len = 0;
562 PyErr_SetString(PyExc_ValueError,
"Expected a BVHTree argument");
566 data.tree_pair[0] =
self;
567 data.tree_pair[1] = other;
575 if (overlap ==
NULL) {
579 const bool use_unique = (
self->orig_index || other->
orig_index);
580 GSet *pair_test = use_unique ?
586 for (i = 0; i < overlap_len; i++) {
589 if (
self->orig_index) {
590 overlap[i].indexA =
self->orig_index[overlap[i].indexA];
593 overlap[i].indexB = other->
orig_index[overlap[i].indexB];
602 item = PyTuple_New(2);
604 item, PyLong_FromLong(overlap[i].indexA), PyLong_FromLong(overlap[i].indexB));
606 PyList_Append(
ret, item);
629 C_BVHTree_FromPolygons_doc,
630 ".. classmethod:: FromPolygons(vertices, polygons, all_triangles=False, epsilon=0.0)\n"
632 " BVH tree constructed geometry passed in as arguments.\n"
634 " :arg vertices: float triplets each representing ``(x, y, z)``\n"
635 " :type vertices: float triplet sequence\n"
636 " :arg polygons: Sequence of polyugons, each containing indices to the vertices argument.\n"
637 " :type polygons: Sequence of sequences containing ints\n"
638 " :arg all_triangles: Use when all **polygons** are triangles for more efficient "
643 const char *error_prefix =
"BVHTree.FromPolygons";
644 const char *keywords[] = {
"vertices",
"polygons",
"all_triangles",
"epsilon",
NULL};
646 PyObject *py_coords, *py_tris;
647 PyObject *py_coords_fast =
NULL, *py_tris_fast =
NULL;
654 uint coords_len, tris_len;
656 bool all_triangles =
false;
659 int *orig_index =
NULL;
665 if (!PyArg_ParseTupleAndKeywords(args,
667 "OO|$O&f:BVHTree.FromPolygons",
677 if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) ||
678 !(py_tris_fast = PySequence_Fast(py_tris, error_prefix))) {
679 Py_XDECREF(py_coords_fast);
684 PyObject **py_coords_fast_items = PySequence_Fast_ITEMS(py_coords_fast);
685 coords_len = (
uint)PySequence_Fast_GET_SIZE(py_coords_fast);
686 coords =
MEM_mallocN((
size_t)coords_len *
sizeof(*coords), __func__);
688 for (i = 0; i < coords_len; i++) {
689 PyObject *py_vert = py_coords_fast_items[i];
698 if (valid ==
false) {
701 else if (all_triangles) {
703 PyObject **py_tris_fast_items = PySequence_Fast_ITEMS(py_tris_fast);
704 tris_len = (
uint)PySequence_Fast_GET_SIZE(py_tris_fast);
705 tris =
MEM_mallocN((
size_t)tris_len *
sizeof(*tris), __func__);
707 for (i = 0; i < tris_len; i++) {
708 PyObject *py_tricoords = py_tris_fast_items[i];
709 PyObject *py_tricoords_fast;
710 PyObject **py_tricoords_fast_items;
714 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
719 if (PySequence_Fast_GET_SIZE(py_tricoords_fast) != 3) {
720 Py_DECREF(py_tricoords_fast);
721 PyErr_Format(PyExc_ValueError,
722 "%s: non triangle found at index %d with length of %d",
725 PySequence_Fast_GET_SIZE(py_tricoords_fast));
730 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
732 for (j = 0; j < 3; j++) {
735 PyErr_Format(PyExc_ValueError,
736 "%s: index %d must be less than %d",
747 Py_DECREF(py_tricoords_fast);
752 const uint polys_len = (
uint)PySequence_Fast_GET_SIZE(py_tris_fast);
754 struct PolyLink *
next;
757 } *plink_first =
NULL, **p_plink_prev = &plink_first, *plink =
NULL;
764 for (i = 0; i < polys_len; i++) {
765 PyObject *py_tricoords = PySequence_Fast_GET_ITEM(py_tris_fast, i);
766 PyObject *py_tricoords_fast;
767 PyObject **py_tricoords_fast_items;
768 uint py_tricoords_len;
771 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
776 py_tricoords_len = (
uint)PySequence_Fast_GET_SIZE(py_tricoords_fast);
777 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
780 sizeof(*plink) + (
sizeof(
int) * (
size_t)py_tricoords_len));
782 plink->len = (
uint)py_tricoords_len;
783 *p_plink_prev = plink;
784 p_plink_prev = &plink->next;
786 for (j = 0; j < py_tricoords_len; j++) {
789 PyErr_Format(PyExc_ValueError,
790 "%s: index %d must be less than %d",
800 Py_DECREF(py_tricoords_fast);
802 if (py_tricoords_len >= 3) {
803 tris_len += (py_tricoords_len - 2);
806 *p_plink_prev =
NULL;
811 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
813 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
814 orig_normal =
MEM_mallocN(
sizeof(*orig_normal) * (
size_t)polys_len, __func__);
816 for (plink = plink_first, poly_index = 0, i = 0; plink; plink = plink->next, poly_index++) {
817 if (plink->len == 3) {
819 memcpy(tri, plink->poly,
sizeof(
uint[3]));
820 orig_index[i] = poly_index;
821 normal_tri_v3(orig_normal[poly_index], coords[tri[0]], coords[tri[1]], coords[tri[2]]);
824 else if (plink->len > 3) {
826 float *
normal = orig_normal[poly_index];
827 const float *co_prev;
828 const float *co_curr;
829 float axis_mat[3][3];
830 uint(*tris_offset)[3] = &tris[i];
835 co_prev = coords[plink->poly[plink->len - 1]];
836 for (j = 0; j < plink->len; j++) {
837 co_curr = coords[plink->poly[j]];
845 for (j = 0; j < plink->len; j++) {
846 mul_v2_m3v3(proj_coords[j], axis_mat, coords[plink->poly[j]]);
853 uint *tri = tris_offset[j];
855 tri[0] = plink->poly[tri[0]];
856 tri[1] = plink->poly[tri[1]];
857 tri[2] = plink->poly[tri[2]];
859 orig_index[i] = poly_index;
866 zero_v3(orig_normal[poly_index]);
871 Py_DECREF(py_coords_fast);
872 Py_DECREF(py_tris_fast);
887 for (i = 0; i < tris_len; i++) {
901 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
914 #ifndef MATH_STANDALONE
917 ".. classmethod:: FromBMesh(bmesh, epsilon=0.0)\n"
919 " BVH tree based on :class:`BMesh` data.\n"
921 " :arg bmesh: BMesh data.\n"
925 const char *keywords[] = {
"bmesh",
"epsilon",
NULL};
931 uint coords_len, tris_len;
937 if (!PyArg_ParseTupleAndKeywords(args,
939 "O!|$f:BVHTree.FromBMesh",
954 coords =
MEM_mallocN(
sizeof(*coords) * (
size_t)coords_len, __func__);
955 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
957 looptris =
MEM_mallocN(
sizeof(*looptris) * (
size_t)tris_len, __func__);
967 int *orig_index =
NULL;
975 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
988 for (i = 0; i < tris_len; i++) {
1009 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1018 const bool use_deform,
1019 const bool use_cage,
1026 *r_free_mesh =
false;
1034 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1039 *r_free_mesh =
true;
1042 if (ob_eval !=
NULL) {
1050 PyErr_Format(PyExc_ValueError,
1051 "%s(...): Cannot get evaluated data from given dependency graph / object pair",
1061 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1066 *r_free_mesh =
true;
1071 PyErr_Format(PyExc_ValueError,
1072 "%s(...): cage arg is unsupported when deform=False and dependency graph "
1073 "evaluation mode is not RENDER",
1078 *r_free_mesh =
true;
1083 ".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, "
1084 "cage=False, epsilon=0.0)\n"
1086 " BVH tree based on :class:`Object` data.\n"
1088 " :arg object: Object data.\n"
1089 " :type object: :class:`Object`\n"
1090 " :arg depsgraph: Depsgraph to use for evaluating the mesh.\n"
1091 " :type depsgraph: :class:`Depsgraph`\n"
1092 " :arg deform: Use mesh with deformations.\n"
1093 " :type deform: bool\n"
1094 " :arg cage: Use modifiers cage.\n"
1099 const char *keywords[] = {
"object",
"depsgraph",
"deform",
"cage",
"epsilon",
NULL};
1101 PyObject *py_ob, *py_depsgraph;
1106 bool use_deform =
true;
1107 bool use_cage =
false;
1108 bool free_mesh =
false;
1115 uint coords_len, tris_len;
1118 if (!PyArg_ParseTupleAndKeywords(args,
1120 "OO|$O&O&f:BVHTree.FromObject",
1148 coords =
MEM_mallocN(
sizeof(*coords) * (size_t)coords_len, __func__);
1149 tris =
MEM_mallocN(
sizeof(*tris) * (
size_t)tris_len, __func__);
1163 int *orig_index =
NULL;
1168 orig_index =
MEM_mallocN(
sizeof(*orig_index) * (
size_t)tris_len, __func__);
1173 for (i = 0; i < tris_len; i++, lt++) {
1176 tris[i][0] = mloop[lt->
tri[0]].
v;
1177 tris[i][1] = mloop[lt->
tri[1]].
v;
1178 tris[i][2] = mloop[lt->
tri[2]].
v;
1185 orig_index[i] = (int)lt->
poly;
1196 tree,
epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1212 py_bvhtree_find_nearest_doc},
1213 {
"find_nearest_range",
1216 py_bvhtree_find_nearest_range_doc},
1222 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1223 C_BVHTree_FromPolygons_doc},
1224 #ifndef MATH_STANDALONE
1227 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1228 C_BVHTree_FromBMesh_doc},
1231 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1232 C_BVHTree_FromObject_doc},
1238 PyVarObject_HEAD_INIT(
NULL, 0)
"BVHTree",
1274 (allocfunc)PyType_GenericAlloc,
1275 (newfunc)PyType_GenericNew,
1290 "BVH tree structures for proximity searches and ray casts on geometry.");
1292 PyModuleDef_HEAD_INIT,
1293 "mathutils.bvhtree",
typedef float(TangentPoint)[2]
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, 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, 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 BKE_id_free(struct Main *bmain, void *idv)
const float(* BKE_mesh_poly_normals_ensure(const struct Mesh *mesh))[3]
bool BKE_mesh_poly_normals_are_dirty(const struct Mesh *mesh)
struct Mesh * mesh_get_eval_deform(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
const struct MLoopTri * BKE_mesh_runtime_looptri_ensure(const struct Mesh *mesh)
struct Mesh * mesh_create_eval_final(struct Depsgraph *depsgraph, const 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_no_deform_render(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_create_eval_no_deform(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
GSet * BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, 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_num, 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)
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])
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
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)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#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 void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
#define BLI_POLYFILL_ARENA_SIZE
void BLI_polyfill_calc_arena(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3], struct MemArena *arena)
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])
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_num_min, int array_num_max, PyObject *value, const char *error_prefix)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, 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)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
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