|
Blender V5.3
|
#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) |
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.
|
strong |
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.
|
default |
Referenced by from_edges(), from_points(), from_single_mesh(), from_tris(), operator=(), operator=(), Tree(), and Tree().
|
delete |
References Tree().
| blender::bke::bvh::Tree::Tree | ( | Tree && | other | ) |
| std::optional< ClosestPointResult > blender::bke::bvh::Tree::closest_point | ( | const float3 & | point, |
| float | radius = std::numeric_limits<float>::max() ) const |
Find the closest surface point to a given position.
| radius | Elements at or farther than this distance are ignored. |
Definition at line 709 of file bvh.cc.
References blender::BLI_bvhtree_find_nearest(), closest_point(), blender::BVHTreeNearest::co, blender::bke::mesh_surface_sample::compute_bary_coord_in_triangle(), blender::data, blender::BVHTreeNearest::dist_sq, blender::bke::bvh::fallback_mesh_data(), blender::BVHTreeNearest::index, blender::result, Tris, and float3::x.
Referenced by blender::BKE_shrinkwrap_find_nearest_surface(), blender::nodes::node_geo_proximity_cc::ProximityFunction::call(), closest_point(), blender::closest_point_on_surface(), blender::distance_to_closest_point(), blender::bke::find_nearest_tris(), blender::nodes::node_geo_sample_nearest_cc::get_closest_mesh_edges(), blender::nodes::node_geo_sample_nearest_cc::get_closest_mesh_points(), blender::nodes::node_geo_sample_nearest_cc::get_closest_mesh_tris(), blender::nodes::node_geo_sample_nearest_cc::get_closest_pointcloud_points(), blender::mesh_remap_bvh_query_nearest(), operator=(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), blender::remap_hair_emitter(), blender::shrinkwrap_calc_nearest_vertex_cb_ex(), and blender::ed::curves::convert_to_particle_system::try_convert_single_object().
|
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.
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=().
|
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.
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=().
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=().
|
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.
| map_global_indices | Record 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().
References closest_point(), from_edges(), from_points(), from_single_mesh(), from_tris(), operator=(), range_query(), ray_intersect(), ray_intersect_all(), and Tree().
Referenced by operator=().
| void blender::bke::bvh::Tree::range_query | ( | const float3 & | point, |
| const float | radius, | ||
| FunctionRef< bool(int)> | fn ) const |
Call a callback for every element within a given radius.
Definition at line 762 of file bvh.cc.
References blender::BLI_bvhtree_range_query_cpp(), blender::data, blender::bke::bvh::fallback_mesh_data(), and range_query().
Referenced by operator=(), range_query(), blender::ed::sculpt_paint::AddOperationExecutor::sample_spherical(), and blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_spherical_with_symmetry().
Intersect a single ray against the tree. Only supported for #ElemType::Tris.
Definition at line 439 of file bvh.cc.
References blender::bke::bvh::RayHit::bary_coord, blender::BLI_assert(), blender::BLI_bvhtree_ray_cast(), blender::bke::mesh_surface_sample::compute_bary_coord_in_triangle(), blender::data, blender::bke::bvh::Ray::direction, blender::BVHTreeRayHit::dist, blender::bke::bvh::Ray::dist_max, blender::bke::bvh::RayHit::distance, blender::bke::bvh::fallback_mesh_data(), blender::bke::bvh::RayHit::index, blender::BVHTreeRayHit::index, blender::BVHTreeRayHit::no, blender::bke::bvh::RayHit::normal, blender::bke::bvh::Ray::origin, blender::bke::bvh::RayHit::position(), and Tris.
Referenced by blender::cast_ray_highpoly(), blender::find_internal_spring_target_vertex(), blender::followtrack_project_to_depth_object_if_needed(), blender::ed::sculpt_paint::imapaint_pick_face(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), operator=(), blender::nodes::node_geo_raycast_cc::raycast_to_mesh(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::sculpt_paint::sample_curves_surface_3d_brush(), blender::ed::sculpt_paint::AddOperationExecutor::sample_in_center(), blender::bke::mesh_surface_sample::sample_surface_points_projected(), blender::geometry::curve_constraints::solve_length_and_collision_constraints(), and blender::draw::statvis_calc_thickness().
| void blender::bke::bvh::Tree::ray_intersect_all | ( | const Ray & | ray, |
| FunctionRef< void(const RayHit &)> | fn ) const |
Call a callback for every ray intersection. Only supported for #ElemType::Tris.
Definition at line 501 of file bvh.cc.
References blender::bke::bvh::RayHit::bary_coord, blender::BLI_assert(), blender::BLI_bvhtree_ray_cast_all(), blender::bke::mesh_surface_sample::compute_bary_coord_in_triangle(), blender::data, blender::bke::bvh::Ray::direction, blender::bke::bvh::Ray::dist_max, blender::bke::bvh::RayHit::distance, blender::bke::bvh::fallback_mesh_data(), blender::bke::bvh::RayHit::index, blender::bke::bvh::RayHit::normal, blender::bke::bvh::Ray::origin, blender::result, and Tris.
Referenced by operator=().