33#ifndef MATH_STANDALONE
56#define PYBVH_FIND_GENERIC_DISTANCE_DOC \
57 " :arg distance: Maximum distance threshold.\n" \
58 " :type distance: float\n"
60#define PYBVH_FIND_GENERIC_RETURN_DOC \
61 " :return: Returns a tuple: (position, normal, index, distance),\n" \
62 " Values will all be None if no hit is found.\n" \
63 " :rtype: tuple[:class:`Vector` | None, :class:`Vector` | None, int | None, float | None]\n"
65#define PYBVH_FIND_GENERIC_RETURN_LIST_DOC \
66 " :return: Returns a list of tuples (position, normal, index, distance)\n" \
67 " :rtype: list[tuple[:class:`Vector`, :class:`Vector`, int, float]]\n"
69#define PYBVH_FROM_GENERIC_EPSILON_DOC \
70 " :arg epsilon: Increase the threshold for detecting overlap and raycast hits.\n" \
71 " :type epsilon: float\n"
76#define PYBVH_MAX_DIST_STR "1.84467e+19"
112 float (*orig_normal)[3])
117 result->epsilon = epsilon;
119 result->coords = coords;
121 result->coords_len = coords_len;
122 result->tris_len = tris_len;
124 result->orig_index = orig_index;
125 result->orig_normal = orig_normal;
127 return (PyObject *)
result;
144 PyLong_FromLong(hit->index),
145 PyFloat_FromDouble(hit->dist));
150 PyObject *py_retval = PyTuple_New(4);
159 PyObject *py_retval = PyTuple_New(4);
167static PyObject *py_bvhtree_raycast_to_py_and_check(
const BVHTreeRayHit *hit)
171 py_retval = PyTuple_New(4);
173 if (hit->index != -1) {
198 PyLong_FromLong(nearest->index),
199 PyFloat_FromDouble(
sqrtf(nearest->dist_sq)));
204 PyObject *py_retval = PyTuple_New(4);
213 PyObject *py_retval = PyTuple_New(4);
221static PyObject *py_bvhtree_nearest_to_py_and_check(
const BVHTreeNearest *nearest)
225 py_retval = PyTuple_New(4);
227 if (nearest->index != -1) {
252 Py_TYPE(
self)->tp_free((PyObject *)
self);
267 const uint *tri =
self->tris[index];
268 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
271 if (
self->epsilon == 0.0f) {
278 if (dist >= 0 && dist < hit->dist) {
279 hit->index =
self->orig_index ?
self->orig_index[index] : index;
282 if (
self->orig_normal) {
299 const uint *tri =
self->tris[index];
300 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
301 float nearest_tmp[3], dist_sq;
306 if (dist_sq < nearest->dist_sq) {
307 nearest->index =
self->orig_index ?
self->orig_index[index] : index;
308 nearest->dist_sq = dist_sq;
310 if (
self->orig_normal) {
321 py_bvhtree_ray_cast_doc,
322 ".. method:: ray_cast(origin, direction, distance=sys.float_info.max)\n"
324 " Cast a ray onto the mesh.\n"
326 " :arg origin: Start location of the ray in object space.\n"
327 " :type origin: :class:`Vector`\n"
328 " :arg direction: Direction of the ray in object space.\n"
333 const char *error_prefix =
"ray_cast";
334 float co[3], direction[3];
340 PyObject *py_co, *py_direction;
342 if (!PyArg_ParseTuple(args,
"OO|f:ray_cast", &py_co, &py_direction, &max_dist)) {
372 py_bvhtree_find_nearest_doc,
376 " Find the nearest element (typically face index) to a point.\n"
378 " :arg co: Find nearest element to this point.\n"
383 const char *error_prefix =
"find_nearest";
393 if (!PyArg_ParseTuple(args,
"O|f:find_nearest", &py_co, &max_dist)) {
403 nearest.dist_sq = max_dist * max_dist;
432 const uint *tri =
self->tris[index];
433 const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
434 float nearest_tmp[3], dist_sq;
439 if (dist_sq < data->dist_sq) {
441 nearest.
index =
self->orig_index ?
self->orig_index[index] : index;
442 nearest.dist_sq = dist_sq;
444 if (
self->orig_normal) {
457 py_bvhtree_find_nearest_range_doc,
461 " Find the nearest elements (typically face index) to a point in the distance range.\n"
463 " :arg co: Find nearest elements to this point.\n"
468 const char *error_prefix =
"find_nearest_range";
476 if (!PyArg_ParseTuple(args,
"O|f:find_nearest_range", &py_co, &max_dist)) {
485 PyObject *
ret = PyList_New(0);
509 return (memcmp(a,
b,
sizeof(*a)) != 0);
522 const uint *tri_a = tree_a->
tris[index_a];
523 const uint *tri_b = tree_b->
tris[index_b];
524 const float *tri_a_co[3] = {
526 const float *tri_b_co[3] = {
529 int verts_shared = 0;
531 if (tree_a == tree_b) {
540 if (verts_shared >= 2) {
546 ((verts_shared == 0) || (
len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
551 py_bvhtree_overlap_doc,
552 ".. method:: overlap(other_tree)\n"
554 " Find overlapping indices between 2 trees.\n"
556 " :arg other_tree: Other tree to perform overlap test on.\n"
557 " :type other_tree: :class:`BVHTree`\n"
558 " :return: Returns a list of unique index pairs,"
559 " the first index referencing this tree, the second referencing the **other_tree**.\n"
560 " :rtype: list[tuple[int, int]]\n");
565 uint overlap_len = 0;
569 PyErr_SetString(PyExc_ValueError,
"Expected a BVHTree argument");
573 data.tree_pair[0] =
self;
574 data.tree_pair[1] = other;
575 data.epsilon =
max_ff(
self->epsilon, other->epsilon);
582 if (overlap ==
nullptr) {
586 const bool use_unique = (
self->orig_index || other->orig_index);
587 GSet *pair_test = use_unique ?
593 for (i = 0; i < overlap_len; i++) {
596 if (
self->orig_index) {
599 if (other->orig_index) {
600 overlap[i].
indexB = other->orig_index[overlap[i].
indexB];
609 item = PyTuple_New(2);
611 item, PyLong_FromLong(overlap[i].indexA), PyLong_FromLong(overlap[i].indexB));
613 PyList_Append(
ret, item);
637 C_BVHTree_FromPolygons_doc,
638 ".. classmethod:: FromPolygons(vertices, polygons, all_triangles=False, epsilon=0.0)\n"
640 " BVH tree constructed geometry passed in as arguments.\n"
642 " :arg vertices: float triplets each representing ``(x, y, z)``\n"
643 " :type vertices: Sequence[Sequence[float]]\n"
644 " :arg polygons: Sequence of polygons, each containing indices to the vertices argument.\n"
645 " :type polygons: Sequence[Sequence[int]]\n"
646 " :arg all_triangles: Use when all **polygons** are triangles for more efficient "
651 const char *error_prefix =
"BVHTree.FromPolygons";
652 const char *keywords[] = {
"vertices",
"polygons",
"all_triangles",
"epsilon",
nullptr};
654 PyObject *py_coords, *py_tris;
655 PyObject *py_coords_fast =
nullptr, *py_tris_fast =
nullptr;
660 float(*coords)[3] =
nullptr;
661 uint(*tris)[3] =
nullptr;
662 uint coords_len, tris_len;
663 float epsilon = 0.0f;
664 bool all_triangles =
false;
667 int *orig_index =
nullptr;
668 float(*orig_normal)[3] =
nullptr;
673 if (!PyArg_ParseTupleAndKeywords(args,
675 "OO|$O&f:BVHTree.FromPolygons",
686 if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) ||
687 !(py_tris_fast = PySequence_Fast(py_tris, error_prefix)))
689 Py_XDECREF(py_coords_fast);
694 PyObject **py_coords_fast_items = PySequence_Fast_ITEMS(py_coords_fast);
695 coords_len =
uint(PySequence_Fast_GET_SIZE(py_coords_fast));
696 coords =
static_cast<float(*)[3]
>(
MEM_mallocN(
size_t(coords_len) *
sizeof(*coords), __func__));
698 for (i = 0; i < coords_len; i++) {
699 PyObject *py_vert = py_coords_fast_items[i];
708 if (valid ==
false) {
711 else if (all_triangles) {
713 PyObject **py_tris_fast_items = PySequence_Fast_ITEMS(py_tris_fast);
714 tris_len =
uint(PySequence_Fast_GET_SIZE(py_tris_fast));
715 tris =
static_cast<uint(*)[3]
>(
MEM_mallocN(
size_t(tris_len) *
sizeof(*tris), __func__));
717 for (i = 0; i < tris_len; i++) {
718 PyObject *py_tricoords = py_tris_fast_items[i];
719 PyObject *py_tricoords_fast;
720 PyObject **py_tricoords_fast_items;
724 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
729 if (PySequence_Fast_GET_SIZE(py_tricoords_fast) != 3) {
730 Py_DECREF(py_tricoords_fast);
731 PyErr_Format(PyExc_ValueError,
732 "%s: non triangle found at index %d with length of %d",
735 PySequence_Fast_GET_SIZE(py_tricoords_fast));
740 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
742 for (j = 0; j < 3; j++) {
745 PyErr_Format(PyExc_ValueError,
746 "%s: index %d must be less than %d",
757 Py_DECREF(py_tricoords_fast);
762 const uint polys_len =
uint(PySequence_Fast_GET_SIZE(py_tris_fast));
767 } *plink_first =
nullptr, **p_plink_prev = &plink_first, *plink =
nullptr;
774 for (i = 0; i < polys_len; i++) {
775 PyObject *py_tricoords = PySequence_Fast_GET_ITEM(py_tris_fast, i);
776 PyObject *py_tricoords_fast;
777 PyObject **py_tricoords_fast_items;
778 uint py_tricoords_len;
781 if (!(py_tricoords_fast = PySequence_Fast(py_tricoords, error_prefix))) {
786 py_tricoords_len =
uint(PySequence_Fast_GET_SIZE(py_tricoords_fast));
787 py_tricoords_fast_items = PySequence_Fast_ITEMS(py_tricoords_fast);
790 poly_arena,
sizeof(*plink) + (
sizeof(
int) *
size_t(py_tricoords_len))));
792 plink->len =
uint(py_tricoords_len);
793 *p_plink_prev = plink;
794 p_plink_prev = &plink->next;
796 for (j = 0; j < py_tricoords_len; j++) {
799 PyErr_Format(PyExc_ValueError,
800 "%s: index %d must be less than %d",
810 Py_DECREF(py_tricoords_fast);
812 if (py_tricoords_len >= 3) {
813 tris_len += (py_tricoords_len - 2);
816 *p_plink_prev =
nullptr;
821 tris =
static_cast<uint(*)[3]
>(
MEM_mallocN(
sizeof(*tris) *
size_t(tris_len), __func__));
823 orig_index =
static_cast<int *
>(
MEM_mallocN(
sizeof(*orig_index) *
size_t(tris_len), __func__));
824 orig_normal =
static_cast<float(*)[3]
>(
825 MEM_mallocN(
sizeof(*orig_normal) *
size_t(polys_len), __func__));
827 for (plink = plink_first, poly_index = 0, i = 0; plink; plink = plink->next, poly_index++) {
828 if (plink->len == 3) {
830 memcpy(tri, plink->poly,
sizeof(
uint[3]));
831 orig_index[i] = poly_index;
832 normal_tri_v3(orig_normal[poly_index], coords[tri[0]], coords[tri[1]], coords[tri[2]]);
835 else if (plink->len > 3) {
836 float(*proj_coords)[2] =
static_cast<float(*)[2]
>(
838 float *normal = orig_normal[poly_index];
839 const float *co_prev;
840 const float *co_curr;
841 float axis_mat[3][3];
842 uint(*tris_offset)[3] = &tris[i];
847 co_prev = coords[plink->poly[plink->len - 1]];
848 for (j = 0; j < plink->len; j++) {
849 co_curr = coords[plink->poly[j]];
857 for (j = 0; j < plink->len; j++) {
858 mul_v2_m3v3(proj_coords[j], axis_mat, coords[plink->poly[j]]);
865 uint *tri = tris_offset[j];
867 tri[0] = plink->poly[tri[0]];
868 tri[1] = plink->poly[tri[1]];
869 tri[2] = plink->poly[tri[2]];
871 orig_index[i] = poly_index;
878 zero_v3(orig_normal[poly_index]);
883 Py_DECREF(py_coords_fast);
884 Py_DECREF(py_tris_fast);
899 for (i = 0; i < tris_len; i++) {
913 tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
926#ifndef MATH_STANDALONE
930 C_BVHTree_FromBMesh_doc,
931 ".. classmethod:: FromBMesh(bmesh, epsilon=0.0)\n"
933 " BVH tree based on :class:`BMesh` data.\n"
935 " :arg bmesh: BMesh data.\n"
939 const char *keywords[] = {
"bmesh",
"epsilon",
nullptr};
943 float(*coords)[3] =
nullptr;
944 uint(*tris)[3] =
nullptr;
945 uint coords_len, tris_len;
946 float epsilon = 0.0f;
950 if (!PyArg_ParseTupleAndKeywords(args,
952 "O!|$f:BVHTree.FromBMesh",
968 coords =
static_cast<float(*)[3]
>(
MEM_mallocN(
sizeof(*coords) *
size_t(coords_len), __func__));
969 tris =
static_cast<uint(*)[3]
>(
MEM_mallocN(
sizeof(*tris) *
size_t(tris_len), __func__));
979 int *orig_index =
nullptr;
980 float(*orig_normal)[3] =
nullptr;
987 orig_index =
static_cast<int *
>(
988 MEM_mallocN(
sizeof(*orig_index) *
size_t(tris_len), __func__));
989 orig_normal =
static_cast<float(*)[3]
>(
1002 for (i = 0; i < tris_len; i++) {
1021 tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
1030 const bool use_deform,
1031 const bool use_cage,
1038 *r_free_mesh =
false;
1046 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1051 *r_free_mesh =
true;
1054 if (ob_eval !=
nullptr) {
1062 PyErr_Format(PyExc_ValueError,
1063 "%s(...): Cannot get evaluated data from given dependency graph / object pair",
1073 "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
1078 *r_free_mesh =
true;
1083 PyErr_Format(PyExc_ValueError,
1084 "%s(...): cage arg is unsupported when deform=False and dependency graph "
1085 "evaluation mode is not RENDER",
1090 *r_free_mesh =
true;
1096 C_BVHTree_FromObject_doc,
1097 ".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, "
1098 "cage=False, epsilon=0.0)\n"
1100 " BVH tree based on :class:`Object` data.\n"
1102 " :arg object: Object data.\n"
1103 " :type object: :class:`Object`\n"
1104 " :arg depsgraph: Depsgraph to use for evaluating the mesh.\n"
1105 " :type depsgraph: :class:`Depsgraph`\n"
1106 " :arg deform: Use mesh with deformations.\n"
1107 " :type deform: bool\n"
1108 " :arg cage: Use modifiers cage.\n"
1113 const char *keywords[] = {
"object",
"depsgraph",
"deform",
"cage",
"epsilon",
nullptr};
1115 PyObject *py_ob, *py_depsgraph;
1120 bool use_deform =
true;
1121 bool use_cage =
false;
1122 bool free_mesh =
false;
1124 float epsilon = 0.0f;
1126 if (!PyArg_ParseTupleAndKeywords(args,
1128 "OO|$O&O&f:BVHTree.FromObject",
1147 if (mesh ==
nullptr) {
1157 const uint coords_len =
uint(mesh->verts_num);
1159 float(*coords)[3] =
static_cast<float(*)[3]
>(
1160 MEM_mallocN(
sizeof(*coords) *
size_t(coords_len), __func__));
1161 uint(*tris)[3] =
static_cast<uint(*)[3]
>(
1163 memcpy(coords, mesh->vert_positions().data(),
sizeof(
float[3]) *
size_t(mesh->verts_num));
1167 int *orig_index =
nullptr;
1173 orig_index =
static_cast<int *
>(
1174 MEM_mallocN(
sizeof(*orig_index) *
size_t(corner_tris.
size()), __func__));
1185 tris[i][0] =
uint(corner_verts[corner_tris[i][0]]);
1186 tris[i][1] =
uint(corner_verts[corner_tris[i][1]]);
1187 tris[i][2] =
uint(corner_verts[corner_tris[i][2]]);
1194 orig_index[i] =
int(tri_faces[i]);
1211 reinterpret_cast<float(*)[3]
>(orig_normal));
1221#if (defined(__GNUC__) && !defined(__clang__))
1222# pragma GCC diagnostic push
1223# pragma GCC diagnostic ignored "-Wcast-function-type"
1230 py_bvhtree_ray_cast_doc},
1234 py_bvhtree_find_nearest_doc},
1235 {
"find_nearest_range",
1238 py_bvhtree_find_nearest_range_doc},
1239 {
"overlap",
reinterpret_cast<PyCFunction
>(
py_bvhtree_overlap), METH_O, py_bvhtree_overlap_doc},
1244 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1245 C_BVHTree_FromPolygons_doc},
1246#ifndef MATH_STANDALONE
1249 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1250 C_BVHTree_FromBMesh_doc},
1253 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
1254 C_BVHTree_FromObject_doc},
1256 {
nullptr,
nullptr, 0,
nullptr},
1259#if (defined(__GNUC__) && !defined(__clang__))
1260# pragma GCC diagnostic pop
1264 PyVarObject_HEAD_INIT(
nullptr, 0)
1300 (allocfunc)PyType_GenericAlloc,
1301 (newfunc)PyType_GenericNew,
1309 (destructor)
nullptr,
1321 "BVH tree structures for proximity searches and ray casts on geometry.");
1323 PyModuleDef_HEAD_INIT,
1324 "mathutils.bvhtree",
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(Main *bmain, void *idv)
bool BKE_mesh_face_normals_are_dirty(const Mesh *mesh)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
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)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void BLI_bvhtree_balance(BVHTree *tree)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
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)
int BLI_bvhtree_range_query(const 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)
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 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])
MINLINE float normalize_v3(float n[3])
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_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 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)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
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, MutableSpan< std::array< BMLoop *, 3 > > looptris)
PyTypeObject BPy_BMesh_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr void copy_from(Span< T > values) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
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 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)
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 PyObject * py_bvhtree_raycast_to_py(const BVHTreeRayHit *hit)
static PyObject * py_bvhtree_find_nearest_range(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 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_FromPolygons(PyObject *, PyObject *args, PyObject *kwargs)
#define PYBVH_MAX_DIST_STR
static PyObject * C_BVHTree_FromBMesh(PyObject *, PyObject *args, PyObject *kwargs)
#define PYBVH_FROM_GENERIC_EPSILON_DOC
static PyObject * py_bvhtree_nearest_to_py_none()
static PyObject * py_bvhtree_nearest_to_py(const BVHTreeNearest *nearest)
static void py_bvhtree_nearest_point_range_cb(void *userdata, int index, const float co[3], float)
static void py_bvhtree_raycast_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
static PyObject * py_bvhtree_raycast_to_py_none()
BLI_INLINE uint overlap_hash(const void *overlap_v)
static PyMethodDef py_bvhtree_methods[]
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 char PY_BVH_TREE_TYPE_DEFAULT
PyTypeObject PyBVHTree_Type
static PyObject * py_bvhtree_find_nearest(PyBVHTree *self, PyObject *args)
static PyObject * py_bvhtree_overlap(PyBVHTree *self, PyBVHTree *other)
PyMODINIT_FUNC PyInit_mathutils_bvhtree()
#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 PyModuleDef bvhtree_moduledef
static const float max_dist_default
static PyObject * py_bvhtree_ray_cast(PyBVHTree *self, PyObject *args)
static PyObject * C_BVHTree_FromObject(PyObject *, PyObject *args, PyObject *kwargs)
static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int)
#define PyBVHTree_CheckExact(v)
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)
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)
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 BMesh * bm
PyObject_HEAD BVHTree * tree