Blender V5.3
mathutils_bvhtree.cc File Reference
#include <Python.h>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.hh"
#include "BLI_kdopbvh.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_memarena.hh"
#include "BLI_polyfill_2d.hh"
#include "BLI_utildefines.hh"
#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.hh"

Go to the source code of this file.

Classes

struct  blender::PyBVHTree
struct  blender::PyBVH_RangeData
struct  blender::PyBVHTree_OverlapData

Namespaces

namespace  blender
 BMesh Iterators.

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 blender::py_bvhtree__tp_dealloc (PyBVHTree *self)
Utility helper functions
static PyObject * blender::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 blender::py_bvhtree_raycast_to_py_tuple (const BVHTreeRayHit *hit, PyObject *py_retval)
static PyObject * blender::py_bvhtree_raycast_to_py (const BVHTreeRayHit *hit)
static PyObject * blender::py_bvhtree_raycast_to_py_none ()
BVHTreeNearest to Python utilities
static void blender::py_bvhtree_nearest_to_py_tuple (const BVHTreeNearest *nearest, PyObject *py_retval)
static PyObject * blender::py_bvhtree_nearest_to_py (const BVHTreeNearest *nearest)
static PyObject * blender::py_bvhtree_nearest_to_py_none ()
Methods
static void blender::py_bvhtree_raycast_cb (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
static void blender::py_bvhtree_nearest_point_cb (void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
 blender::PyDoc_STRVAR (py_bvhtree_ray_cast_doc, ".. method:: ray_cast(origin, direction, distance=sys.float_info.max, /)\n" "\n" " Cast a ray onto the geometry.\n" "\n" " :param origin: Start location of the ray.\n" " :type origin: :class:`Vector`\n" " :param direction: Direction of the ray (normalized internally).\n" " :type direction: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_DOC)
static PyObject * blender::py_bvhtree_ray_cast (PyBVHTree *self, PyObject *args)
 blender::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" " :param origin: Find nearest element to this point.\n" " :type origin: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_DOC)
static PyObject * blender::py_bvhtree_find_nearest (PyBVHTree *self, PyObject *args)
static void blender::py_bvhtree_nearest_point_range_cb (void *userdata, int index, const float co[3], float)
 blender::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" " :param origin: Find nearest elements to this point.\n" " :type origin: :class:`Vector`\n" PYBVH_FIND_GENERIC_DISTANCE_DOC PYBVH_FIND_GENERIC_RETURN_LIST_DOC)
static PyObject * blender::py_bvhtree_find_nearest_range (PyBVHTree *self, PyObject *args)
BLI_INLINE uint blender::overlap_hash (const void *overlap_v)
BLI_INLINE bool blender::overlap_cmp (const void *a_v, const void *b_v)
static bool blender::py_bvhtree_overlap_cb (void *userdata, int index_a, int index_b, int)
 blender::PyDoc_STRVAR (py_bvhtree_overlap_doc, ".. method:: overlap(other_tree, /)\n" "\n" " Find overlapping indices between 2 trees.\n" "\n" " :param 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 * blender::py_bvhtree_overlap (PyBVHTree *self, PyBVHTree *other)
Class Methods
 blender::PyDoc_STRVAR (C_BVHTree_FromPolygons_doc, ".. classmethod:: FromPolygons(vertices, polygons, *, all_triangles=False, epsilon=0.0)\n" "\n" " BVH tree constructed from geometry passed in as arguments.\n" "\n" " :param vertices: float triplets each representing ``(x, y, z)`` coordinates.\n" " :type vertices: Sequence[Sequence[float]]\n" " :param polygons: Sequence of polygons, each containing indices to the vertices argument.\n" " :type polygons: Sequence[Sequence[int]]\n" " :param all_triangles: Use when all **polygons** are triangles for more efficient " "conversion.\n" " :type all_triangles: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC " :return: BVHTree from polygon data.\n" " :rtype: :class:`BVHTree`\n")
static PyObject * blender::C_BVHTree_FromPolygons (PyObject *, PyObject *args, PyObject *kwargs)
 blender::PyDoc_STRVAR (C_BVHTree_FromBMesh_doc, ".. classmethod:: FromBMesh(bmesh, *, epsilon=0.0)\n" "\n" " BVH tree based on :class:`BMesh` data.\n" "\n" " :param bmesh: BMesh data.\n" " :type bmesh: :class:`BMesh`\n" PYBVH_FROM_GENERIC_EPSILON_DOC " :return: BVHTree from BMesh data.\n" " :rtype: :class:`BVHTree`\n")
static PyObject * blender::C_BVHTree_FromBMesh (PyObject *, PyObject *args, PyObject *kwargs)
static const Mesh * blender::bvh_get_mesh (const char *funcname, Depsgraph *depsgraph, Scene *scene, Object *ob, const bool use_deform, const bool use_cage, bool *r_free_mesh)
 blender::PyDoc_STRVAR (C_BVHTree_FromObject_doc, ".. classmethod:: FromObject(object, depsgraph, *, deform=True, " "cage=False, epsilon=0.0)\n" "\n" " BVH tree based on :class:`Object` data.\n" "\n" " :param object: Mesh object.\n" " :type object: :class:`Object`\n" " :param depsgraph: Depsgraph to use for evaluating the mesh.\n" " :type depsgraph: :class:`Depsgraph`\n" " :param deform: Use mesh with deformations.\n" " :type deform: bool\n" " :param cage: Use modifiers cage.\n" " :type cage: bool\n" PYBVH_FROM_GENERIC_EPSILON_DOC " :return: BVHTree from Object data.\n" " :rtype: :class:`BVHTree`\n")
static PyObject * blender::C_BVHTree_FromObject (PyObject *, PyObject *args, PyObject *kwargs)

Variables

static const float blender::max_dist_default = 1.844674352395373e+19f
static const char blender::PY_BVH_TREE_TYPE_DEFAULT = 4
static const char blender::PY_BVH_AXIS_DEFAULT = 6

Module & Type definition

static PyMethodDef blender::py_bvhtree_methods []
PyTypeObject blender::PyBVHTree_Type
static PyModuleDef blender::bvhtree_moduledef
 blender::PyDoc_STRVAR (py_bvhtree_doc, "BVH tree structures for proximity searches and ray casts on geometry.")
PyMODINIT_FUNC blender::PyInit_mathutils_bvhtree ()

Detailed Description

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.

Macro Definition Documentation

◆ PYBVH_FIND_GENERIC_DISTANCE_DOC

#define PYBVH_FIND_GENERIC_DISTANCE_DOC
Value:
" :param distance: Maximum distance threshold.\n" \
" :type distance: float\n"

Definition at line 58 of file mathutils_bvhtree.cc.

Referenced by blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYBVH_FIND_GENERIC_RETURN_DOC

#define PYBVH_FIND_GENERIC_RETURN_DOC
Value:
" :return: Returns a tuple: (position, normal, index, distance),\n" \
" Values will all be None if no hit is found.\n" \
" :rtype: tuple[:class:`Vector` | None, :class:`Vector` | None, int | None, float | None]\n"

Definition at line 62 of file mathutils_bvhtree.cc.

Referenced by blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYBVH_FIND_GENERIC_RETURN_LIST_DOC

#define PYBVH_FIND_GENERIC_RETURN_LIST_DOC
Value:
" :return: Returns a list of tuples (position, normal, index, distance)\n" \
" :rtype: list[tuple[:class:`Vector`, :class:`Vector`, int, float]]\n"

Definition at line 67 of file mathutils_bvhtree.cc.

Referenced by blender::PyDoc_STRVAR().

◆ PYBVH_FROM_GENERIC_EPSILON_DOC

#define PYBVH_FROM_GENERIC_EPSILON_DOC
Value:
" :param epsilon: Increase the threshold for detecting overlap and raycast hits.\n" \
" :type epsilon: float\n"

Definition at line 71 of file mathutils_bvhtree.cc.

Referenced by blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYBVH_MAX_DIST_STR

#define PYBVH_MAX_DIST_STR   "1.84467e+19"

Definition at line 78 of file mathutils_bvhtree.cc.

Referenced by blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().