|
Blender V4.3
|
#include <Python.h>#include "MEM_guardedalloc.h"#include "BLI_ghash.h"#include "BLI_kdopbvh.h"#include "BLI_math_geom.h"#include "BLI_math_matrix.h"#include "BLI_math_vector.h"#include "BLI_memarena.h"#include "BLI_polyfill_2d.h"#include "BLI_utildefines.h"#include "BKE_bvhutils.hh"#include "../generic/py_capi_utils.hh"#include "../generic/python_utildefines.hh"#include "mathutils.hh"#include "mathutils_bvhtree.hh"#include "DNA_mesh_types.h"#include "DNA_object_types.h"#include "BKE_customdata.hh"#include "BKE_lib_id.hh"#include "BKE_mesh.hh"#include "BKE_mesh_runtime.hh"#include "BKE_object.hh"#include "DEG_depsgraph_query.hh"#include "bmesh.hh"#include "../bmesh/bmesh_py_types.hh"#include "BLI_strict_flags.h"Go to the source code of this file.
Classes | |
| struct | PyBVHTree |
| struct | PyBVH_RangeData |
| struct | PyBVHTree_OverlapData |
Macros | |
| #define | PYBVH_MAX_DIST_STR "1.84467e+19" |
Documentation String (snippets) | |
| #define | PYBVH_FIND_GENERIC_DISTANCE_DOC |
| #define | PYBVH_FIND_GENERIC_RETURN_DOC |
| #define | PYBVH_FIND_GENERIC_RETURN_LIST_DOC |
| #define | PYBVH_FROM_GENERIC_EPSILON_DOC |
Functions | |
| static void | py_bvhtree__tp_dealloc (PyBVHTree *self) |
Utility helper functions | |
| 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]) |
BVHTreeRayHit to Python utilities | |
| static void | py_bvhtree_raycast_to_py_tuple (const BVHTreeRayHit *hit, PyObject *py_retval) |
| static PyObject * | py_bvhtree_raycast_to_py (const BVHTreeRayHit *hit) |
| static PyObject * | py_bvhtree_raycast_to_py_none () |
BVHTreeNearest to Python utilities | |
| static void | py_bvhtree_nearest_to_py_tuple (const BVHTreeNearest *nearest, PyObject *py_retval) |
| static PyObject * | py_bvhtree_nearest_to_py (const BVHTreeNearest *nearest) |
| static PyObject * | py_bvhtree_nearest_to_py_none () |
Methods | |
| static void | py_bvhtree_raycast_cb (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) |
| static void | py_bvhtree_nearest_point_cb (void *userdata, int index, const float co[3], BVHTreeNearest *nearest) |
| 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) | |
| static PyObject * | py_bvhtree_ray_cast (PyBVHTree *self, PyObject *args) |
| PyDoc_STRVAR (py_bvhtree_find_nearest_doc, ".. method:: find_nearest(origin, distance=" PYBVH_MAX_DIST_STR ")\n" "\n" " Find the nearest element (typically face index) to a point.\n" "\n" " :arg co: Find nearest element to this point.\n" " :type co: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_DOC) | |
| static PyObject * | py_bvhtree_find_nearest (PyBVHTree *self, PyObject *args) |
| static void | py_bvhtree_nearest_point_range_cb (void *userdata, int index, const float co[3], float) |
| PyDoc_STRVAR (py_bvhtree_find_nearest_range_doc, ".. method:: find_nearest_range(origin, distance=" PYBVH_MAX_DIST_STR ")\n" "\n" " Find the nearest elements (typically face index) to a point in the distance range.\n" "\n" " :arg co: Find nearest elements to this point.\n" " :type co: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_LIST_DOC) | |
| static PyObject * | py_bvhtree_find_nearest_range (PyBVHTree *self, PyObject *args) |
| BLI_INLINE uint | overlap_hash (const void *overlap_v) |
| BLI_INLINE bool | overlap_cmp (const void *a_v, const void *b_v) |
| static bool | py_bvhtree_overlap_cb (void *userdata, int index_a, int index_b, int) |
| PyDoc_STRVAR (py_bvhtree_overlap_doc, ".. method:: overlap(other_tree)\n" "\n" " Find overlapping indices between 2 trees.\n" "\n" " :arg other_tree: Other tree to perform overlap test on.\n" " :type other_tree: :class:`BVHTree`\n" " :return: Returns a list of unique index pairs," " the first index referencing this tree, the second referencing the **other_tree**.\n" " :rtype: list[tuple[int, int]]\n") | |
| static PyObject * | py_bvhtree_overlap (PyBVHTree *self, PyBVHTree *other) |
Class Methods | |
| PyDoc_STRVAR (C_BVHTree_FromPolygons_doc, ".. classmethod:: FromPolygons(vertices, polygons, all_triangles=False, epsilon=0.0)\n" "\n" " BVH tree constructed geometry passed in as arguments.\n" "\n" " :arg vertices: float triplets each representing ``(x, y, z)``\n" " :type vertices: Sequence[Sequence[float]]\n" " :arg polygons: Sequence of polygons, each containing indices to the vertices argument.\n" " :type polygons: Sequence[Sequence[int]]\n" " :arg all_triangles: Use when all **polygons** are triangles for more efficient " "conversion.\n" " :type all_triangles: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC) | |
| static PyObject * | C_BVHTree_FromPolygons (PyObject *, PyObject *args, PyObject *kwargs) |
| PyDoc_STRVAR (C_BVHTree_FromBMesh_doc, ".. classmethod:: FromBMesh(bmesh, epsilon=0.0)\n" "\n" " BVH tree based on :class:`BMesh` data.\n" "\n" " :arg bmesh: BMesh data.\n" " :type bmesh: :class:`BMesh`\n" PYBVH_FROM_GENERIC_EPSILON_DOC) | |
| static PyObject * | C_BVHTree_FromBMesh (PyObject *, PyObject *args, PyObject *kwargs) |
| 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 (C_BVHTree_FromObject_doc, ".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, " "cage=False, epsilon=0.0)\n" "\n" " BVH tree based on :class:`Object` data.\n" "\n" " :arg object: Object data.\n" " :type object: :class:`Object`\n" " :arg depsgraph: Depsgraph to use for evaluating the mesh.\n" " :type depsgraph: :class:`Depsgraph`\n" " :arg deform: Use mesh with deformations.\n" " :type deform: bool\n" " :arg cage: Use modifiers cage.\n" " :type cage: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC) | |
| static PyObject * | C_BVHTree_FromObject (PyObject *, PyObject *args, PyObject *kwargs) |
Variables | |
| static const float | max_dist_default = 1.844674352395373e+19f |
| static const char | PY_BVH_TREE_TYPE_DEFAULT = 4 |
| static const char | PY_BVH_AXIS_DEFAULT = 6 |
Module & Type definition | |
| static PyMethodDef | py_bvhtree_methods [] |
| PyTypeObject | PyBVHTree_Type |
| static PyModuleDef | bvhtree_moduledef |
| PyDoc_STRVAR (py_bvhtree_doc, "BVH tree structures for proximity searches and ray casts on geometry.") | |
| PyMODINIT_FUNC | PyInit_mathutils_bvhtree () |
This file defines the 'mathutils.bvhtree' module, a general purpose module to access blenders bvhtree for mesh surface nearest-element search and ray casting.
Definition in file mathutils_bvhtree.cc.
| #define PYBVH_FIND_GENERIC_DISTANCE_DOC |
Definition at line 56 of file mathutils_bvhtree.cc.
| #define PYBVH_FIND_GENERIC_RETURN_DOC |
Definition at line 60 of file mathutils_bvhtree.cc.
| #define PYBVH_FIND_GENERIC_RETURN_LIST_DOC |
Definition at line 65 of file mathutils_bvhtree.cc.
| #define PYBVH_FROM_GENERIC_EPSILON_DOC |
Definition at line 69 of file mathutils_bvhtree.cc.
| #define PYBVH_MAX_DIST_STR "1.84467e+19" |
Definition at line 76 of file mathutils_bvhtree.cc.
|
static |
Return various evaluated meshes based on requested settings.
Definition at line 1026 of file mathutils_bvhtree.cc.
References BKE_object_get_evaluated_mesh(), CD_MASK_BAREMESH, DAG_EVAL_RENDER, DEG_get_evaluated_object(), DEG_get_mode(), depsgraph, blender::bke::mesh_create_eval_final(), blender::bke::mesh_create_eval_no_deform(), blender::bke::mesh_create_eval_no_deform_render(), and blender::bke::mesh_get_eval_deform().
Referenced by C_BVHTree_FromObject().
|
static |
Definition at line 102 of file mathutils_bvhtree.cc.
References PyBVHTree_Type, result, and tree.
Referenced by C_BVHTree_FromBMesh(), C_BVHTree_FromObject(), and C_BVHTree_FromPolygons().
|
static |
Definition at line 937 of file mathutils_bvhtree.cc.
References BLI_bvhtree_balance(), BLI_bvhtree_insert(), BLI_bvhtree_new(), bm, BPy_BMesh::bm, BM_elem_index_get, BM_elem_index_set, BM_FACE, BM_FACES_OF_MESH, BM_ITER_MESH_INDEX, BM_mesh_calc_tessellation(), BM_VERT, BM_VERTS_OF_MESH, BPy_BMesh_Type, bvhtree_CreatePyObject(), BMVert::co, copy_v3_v3(), BMesh::elem_index_dirty, float, MEM_mallocN, BMFace::no, poly_to_tri_count(), PY_BVH_AXIS_DEFAULT, PY_BVH_TREE_TYPE_DEFAULT, BMesh::totface, BMesh::totloop, BMesh::totvert, tree, and v.
|
static |
Definition at line 1110 of file mathutils_bvhtree.cc.
References BKE_id_free(), BKE_mesh_face_normals_are_dirty(), BLI_bvhtree_balance(), BLI_bvhtree_insert(), BLI_bvhtree_new(), bvh_get_mesh(), bvhtree_CreatePyObject(), blender::MutableSpan< T >::copy_from(), copy_v3_v3(), DEG_get_evaluated_scene(), depsgraph, float, blender::Span< T >::index_range(), int, MEM_malloc_arrayN, MEM_mallocN, mesh, PY_BVH_AXIS_DEFAULT, PY_BVH_TREE_TYPE_DEFAULT, PyC_ParseBool(), PyC_RNA_AsPointer(), scene, blender::Span< T >::size(), and tree.
|
static |
Definition at line 649 of file mathutils_bvhtree.cc.
References add_newell_cross_v3_v3v3(), axis_dominant_v3_to_m3_negate(), BLI_bvhtree_balance(), BLI_bvhtree_insert(), BLI_bvhtree_new(), BLI_memarena_alloc(), BLI_memarena_clear(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_POLYFILL_ARENA_SIZE, BLI_polyfill_calc_arena(), bvhtree_CreatePyObject(), copy_v3_v3(), float, len, mathutils_array_parse(), MEM_freeN(), MEM_mallocN, mul_v2_m3v3(), next, normal_tri_v3(), normalize_v3(), PY_BVH_AXIS_DEFAULT, PY_BVH_TREE_TYPE_DEFAULT, PyC_Long_AsU32(), PyC_ParseBool(), tree, UNLIKELY, and zero_v3().
| BLI_INLINE bool overlap_cmp | ( | const void * | a_v, |
| const void * | b_v ) |
Definition at line 505 of file mathutils_bvhtree.cc.
References b.
Referenced by py_bvhtree_overlap().
| BLI_INLINE uint overlap_hash | ( | const void * | overlap_v | ) |
Definition at line 498 of file mathutils_bvhtree.cc.
References BVHTreeOverlap::indexA.
Referenced by py_bvhtree_overlap().
|
static |
Definition at line 240 of file mathutils_bvhtree.cc.
References BLI_bvhtree_free(), MEM_SAFE_FREE, and self.
|
static |
Definition at line 381 of file mathutils_bvhtree.cc.
References BLI_bvhtree_find_nearest(), BVHTreeNearest::index, mathutils_array_parse(), max_dist_default, MU_ARRAY_ZERO, py_bvhtree_nearest_point_cb(), py_bvhtree_nearest_to_py(), py_bvhtree_nearest_to_py_none(), and self.
|
static |
Definition at line 466 of file mathutils_bvhtree.cc.
References BLI_bvhtree_range_query(), mathutils_array_parse(), max_dist_default, MU_ARRAY_ZERO, py_bvhtree_nearest_point_range_cb(), ret, PyBVH_RangeData::self, self, and square_f().
|
static |
Definition at line 291 of file mathutils_bvhtree.cc.
References closest_on_tri_to_point_v3(), PyBVHTree::coords, copy_v3_v3(), float, len_squared_v3v3(), normal_tri_v3(), self, and UNPACK3.
Referenced by py_bvhtree_find_nearest().
|
static |
Definition at line 423 of file mathutils_bvhtree.cc.
References closest_on_tri_to_point_v3(), PyBVHTree::coords, copy_v3_v3(), float, BVHTreeNearest::index, len_squared_v3v3(), normal_tri_v3(), py_bvhtree_nearest_to_py(), self, and UNPACK3.
Referenced by py_bvhtree_find_nearest_range().
|
static |
Definition at line 202 of file mathutils_bvhtree.cc.
References py_bvhtree_nearest_to_py_tuple().
Referenced by py_bvhtree_find_nearest(), and py_bvhtree_nearest_point_range_cb().
|
static |
Definition at line 211 of file mathutils_bvhtree.cc.
References PyC_Tuple_Fill().
Referenced by py_bvhtree_find_nearest().
|
static |
Definition at line 190 of file mathutils_bvhtree.cc.
References BLI_assert, PyTuple_SET_ITEMS, sqrtf, and Vector_CreatePyObject().
Referenced by py_bvhtree_nearest_to_py().
Definition at line 561 of file mathutils_bvhtree.cc.
References BLI_bvhtree_overlap(), BLI_gset_add(), BLI_gset_free(), BLI_gset_new_ex(), data, BVHTreeOverlap::indexA, BVHTreeOverlap::indexB, max_ff(), MEM_freeN(), overlap_cmp(), overlap_hash(), py_bvhtree_overlap_cb(), PyBVHTree_CheckExact, PyTuple_SET_ITEMS, ret, and self.
Definition at line 517 of file mathutils_bvhtree.cc.
References PyBVHTree::coords, ELEM, isect_tri_tri_v3(), len_squared_v3v3(), PyBVHTree::tris, UNLIKELY, and UNPACK3.
Referenced by py_bvhtree_overlap().
|
static |
Definition at line 331 of file mathutils_bvhtree.cc.
References BLI_bvhtree_ray_cast(), FLT_MAX, mathutils_array_parse(), MU_ARRAY_ZERO, normalize_v3(), py_bvhtree_raycast_cb(), py_bvhtree_raycast_to_py(), py_bvhtree_raycast_to_py_none(), and self.
|
static |
Definition at line 259 of file mathutils_bvhtree.cc.
References bvhtree_ray_tri_intersection(), bvhtree_sphereray_tri_intersection(), PyBVHTree::coords, copy_v3_v3(), float, madd_v3_v3v3fl(), normal_tri_v3(), self, and UNPACK3.
Referenced by py_bvhtree_ray_cast().
|
static |
Definition at line 148 of file mathutils_bvhtree.cc.
References py_bvhtree_raycast_to_py_tuple().
Referenced by py_bvhtree_ray_cast().
|
static |
Definition at line 157 of file mathutils_bvhtree.cc.
References PyC_Tuple_Fill().
Referenced by py_bvhtree_ray_cast().
|
static |
Definition at line 136 of file mathutils_bvhtree.cc.
References BLI_assert, PyTuple_SET_ITEMS, and Vector_CreatePyObject().
Referenced by py_bvhtree_raycast_to_py().
| PyDoc_STRVAR | ( | C_BVHTree_FromBMesh_doc | , |
| ".. classmethod:: FromBMesh(bmesh, epsilon=0.0)\n" "\n" " BVH tree based on :class:`BMesh` data.\n" "\n" " :arg bmesh: BMesh data.\n" " :type bmesh: :class:`BMesh`\n" | PYBVH_FROM_GENERIC_EPSILON_DOC ) |
| PyDoc_STRVAR | ( | C_BVHTree_FromObject_doc | , |
| ".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, " "cage=False, epsilon=0.0)\n" "\n" " BVH tree based on :class:`Object` data.\n" "\n" " :arg object: Object data.\n" " :type object: :class:`Object`\n" " :arg depsgraph: Depsgraph to use for evaluating the mesh.\n" " :type depsgraph: :class:`Depsgraph`\n" " :arg deform: Use mesh with deformations.\n" " :type deform: bool\n" " :arg cage: Use modifiers cage.\n" " :type cage: bool\n" | PYBVH_FROM_GENERIC_EPSILON_DOC ) |
| PyDoc_STRVAR | ( | C_BVHTree_FromPolygons_doc | , |
| ".. classmethod:: FromPolygons(vertices, polygons, all_triangles=False, epsilon=0.0)\n" "\n" " BVH tree constructed geometry passed in as arguments.\n" "\n" " :arg vertices: float triplets each representing ``(x, y, z)``\n" " :type vertices: Sequence]\n" " :arg polygons: Sequence of | polygons[Sequence[float], | ||
| each containing indices to the vertices argument.\n" " :type polygons:Sequence]\n" " :arg all_triangles:Use when all **polygons **are triangles for more efficient " "conversion.\n" " :type all_triangles:bool\n" | PYBVH_FROM_GENERIC_EPSILON_DOC[Sequence[int] ) |
| PyDoc_STRVAR | ( | py_bvhtree_doc | , |
| "BVH tree structures for proximity searches and ray casts on geometry." | ) |
| PyDoc_STRVAR | ( | py_bvhtree_find_nearest_doc | , |
| ".. method:: find_nearest(origin, distance=" PYBVH_MAX_DIST_STR ")\n" "\n" " Find the nearest element (typically face index) to a point.\n" "\n" " :arg co: Find nearest element to this point.\n" " :type co: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC | PYBVH_FIND_GENERIC_RETURN_DOC ) |
| PyDoc_STRVAR | ( | py_bvhtree_find_nearest_range_doc | , |
| ".. method:: find_nearest_range(origin, distance=" PYBVH_MAX_DIST_STR ")\n" "\n" " Find the nearest elements (typically face index) to a point in the distance range.\n" "\n" " :arg co: Find nearest elements to this point.\n" " :type co: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC | PYBVH_FIND_GENERIC_RETURN_LIST_DOC ) |
| PyDoc_STRVAR | ( | py_bvhtree_overlap_doc | , |
| ".. method:: overlap(other_tree)\n" "\n" " Find overlapping indices between 2 trees.\n" "\n" " :arg other_tree: Other tree to perform overlap test on.\n" " :type other_tree: :class:`BVHTree`\n" " :return: Returns a list of unique index | pairs, | ||
| " " the first index referencing this | tree, | ||
| the second referencing the **other_tree **.\n" " :rtype:list]\n" | [tuple[int, int] ) |
| 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 ) |
| PyMODINIT_FUNC PyInit_mathutils_bvhtree | ( | ) |
Definition at line 1334 of file mathutils_bvhtree.cc.
References bvhtree_moduledef, and PyBVHTree_Type.
Referenced by PyInit_mathutils().
|
static |
Definition at line 1322 of file mathutils_bvhtree.cc.
Referenced by PyInit_mathutils_bvhtree().
Definition at line 77 of file mathutils_bvhtree.cc.
Referenced by py_bvhtree_find_nearest(), and py_bvhtree_find_nearest_range().
|
static |
Definition at line 80 of file mathutils_bvhtree.cc.
Referenced by C_BVHTree_FromBMesh(), C_BVHTree_FromObject(), and C_BVHTree_FromPolygons().
|
static |
Definition at line 79 of file mathutils_bvhtree.cc.
Referenced by C_BVHTree_FromBMesh(), C_BVHTree_FromObject(), and C_BVHTree_FromPolygons().
|
static |
Definition at line 1226 of file mathutils_bvhtree.cc.
| PyTypeObject PyBVHTree_Type |
Definition at line 1263 of file mathutils_bvhtree.cc.
Referenced by bvhtree_CreatePyObject(), and PyInit_mathutils_bvhtree().