Blender V5.3
blender::bke::bvh::Tree Class Reference

#include <BKE_bvh.hh>

Classes

struct  FallbackTree
struct  UserGeometryData

Public Types

enum class  ElemType : int8_t { Tris , Points , Edges }

Public Member Functions

 Tree ()
 Tree (const Tree &)=delete
Tree & operator= (const Tree &)=delete
 Tree (Tree &&)
Tree & operator= (Tree &&)
 ~Tree ()
std::optional< RayHit > ray_intersect (const Ray &ray) const
void ray_intersect_all (const Ray &ray, FunctionRef< void(const RayHit &)> fn) const
std::optional< ClosestPointResult > closest_point (const float3 &point, float radius=std::numeric_limits< float >::max()) const
void range_query (const float3 &point, const float radius, FunctionRef< bool(int)> fn) const

Static Public Member Functions

static Tree from_tris (const Mesh &mesh, const IndexMask &mask, bool map_global_indices)
static Tree from_single_mesh (const Mesh &mesh)
static Tree from_points (Span< float3 > positions, const IndexMask &mask)
static Tree from_edges (Span< float3 > positions, Span< int2 > edges, const IndexMask &mask)

Detailed Description

A wrapper around Embree's BVH tree and #BLI_kdopbvh.hh. Besides a simpler and more friendly API compared to Embree, this provides storage for index mapping for trees created from subsets of a geometry.

Definition at line 73 of file BKE_bvh.hh.

Member Enumeration Documentation

◆ ElemType

The type of element the tree is built from, which query results refer to.

Enumerator
Tris 
Points 
Edges 

Definition at line 81 of file BKE_bvh.hh.

Constructor & Destructor Documentation

◆ Tree() [1/3]

blender::bke::bvh::Tree::Tree ( )
default

◆ Tree() [2/3]

blender::bke::bvh::Tree::Tree ( const Tree & )
delete

References Tree().

◆ Tree() [3/3]

blender::bke::bvh::Tree::Tree ( Tree && other)

Definition at line 41 of file bvh.cc.

References Tree().

◆ ~Tree()

blender::bke::bvh::Tree::~Tree ( )

Definition at line 63 of file bvh.cc.

Member Function Documentation

◆ closest_point()

◆ from_edges()

Tree blender::bke::bvh::Tree::from_edges ( Span< float3 > positions,
Span< int2 > edges,
const IndexMask & mask )
static

Create a BVH tree from a subset of the given edges. Query results reference indices in the full #edges array rather than indices in the mask.

Note
Memory referenced by the span must live at least as long as the tree.

Definition at line 415 of file bvh.cc.

References blender::bke::bvhtree_from_mesh_edges_ex(), Edges, blender::Span< T >::size(), and Tree().

Referenced by blender::nodes::node_geo_proximity_cc::ProximityFunction::init_for_mesh(), and operator=().

◆ from_points()

Tree blender::bke::bvh::Tree::from_points ( Span< float3 > positions,
const IndexMask & mask )
static

Create a BVH tree from a subset of the given points. Query results reference indices in the full #positions array rather than indices in the mask.

Note
Memory referenced by the span must live at least as long as the tree.

Definition at line 391 of file bvh.cc.

References blender::bke::bvhtree_from_mesh_verts_ex(), Points, blender::Span< T >::size(), and Tree().

Referenced by blender::BKE_mesh_remap_calc_loops_from_mesh(), blender::nodes::node_geo_proximity_cc::ProximityFunction::init_for_mesh(), blender::nodes::node_geo_proximity_cc::ProximityFunction::init_for_pointcloud(), and operator=().

◆ from_single_mesh()

Tree blender::bke::bvh::Tree::from_single_mesh ( const Mesh & mesh)
static

Create a BVH tree from the entire mesh.

Definition at line 352 of file bvh.cc.

References blender::bke::bvhtree_from_mesh_corner_tris_ex(), and Tree().

Referenced by from_tris(), and operator=().

◆ from_tris()

Tree blender::bke::bvh::Tree::from_tris ( const Mesh & mesh,
const IndexMask & mask,
bool map_global_indices )
static

Create a BVH tree from a subset of the mesh faces. from_single_mesh should be used when all faces are contained in the mask.

Parameters
map_global_indicesRecord and later return the indices from the full mesh rather than the index in the masked faces.

Definition at line 325 of file bvh.cc.

References blender::bke::bvhtree_from_mesh_corner_tris_ex(), from_single_mesh(), blender::index_mask::IndexMask::size(), and Tree().

Referenced by blender::nodes::node_geo_proximity_cc::ProximityFunction::init_for_mesh(), operator=(), and blender::nodes::node_geo_sample_nearest_surface_cc::SampleNearestSurfaceFunction::prepare_for_execution().

◆ operator=() [1/2]

Tree & blender::bke::bvh::Tree::operator= ( const Tree & )
delete

◆ operator=() [2/2]

Tree & blender::bke::bvh::Tree::operator= ( Tree && other)

Definition at line 54 of file bvh.cc.

References Tree().

◆ range_query()

void blender::bke::bvh::Tree::range_query ( const float3 & point,
const float radius,
FunctionRef< bool(int)> fn ) const

◆ ray_intersect()

◆ ray_intersect_all()


The documentation for this class was generated from the following files: