Antkeeper  0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | List of all members
geom::bvh Class Reference

Bounding volume hierarchy (BVH). More...

#include <bvh.hpp>

Public Types

using visitor_type = std::function< void(std::uint32_t)>
 

Public Member Functions

 bvh (std::span< const bvh_primitive > primitives)
 Constructs a BVH from a set of primitives. More...
 
 bvh (const brep_mesh &mesh)
 Constructs a BVH from a B-rep mesh. More...
 
constexpr bvh () noexcept=default
 Constructs an empty BVH. More...
 
void build (std::span< const bvh_primitive > primitives)
 Constructs a BVH from a set of primitives. More...
 
void build (const brep_mesh &mesh)
 Constructs a BVH from a B-rep mesh. More...
 
void clear ()
 Clears the BVH. More...
 
void visit (const geom::ray< float, 3 > &ray, const visitor_type &f) const
 Visits the primitive indices of all BVH nodes that intersect a ray. More...
 
constexpr const std::vector< bvh_node > & nodes () const noexcept
 Returns the BVH nodes. More...
 

Detailed Description

Bounding volume hierarchy (BVH).

Definition at line 38 of file bvh.hpp.

Member Typedef Documentation

◆ visitor_type

using geom::bvh::visitor_type = std::function<void(std::uint32_t)>

Definition at line 41 of file bvh.hpp.

Constructor & Destructor Documentation

◆ bvh() [1/3]

geom::bvh::bvh ( std::span< const bvh_primitive primitives)
explicit

Constructs a BVH from a set of primitives.

Parameters
primitivesAxis-aligned bounding boxes.

Definition at line 29 of file bvh.cpp.

◆ bvh() [2/3]

geom::bvh::bvh ( const brep_mesh mesh)
explicit

Constructs a BVH from a B-rep mesh.

Parameters
meshB-rep mesh from which to build the BVH.

Definition at line 34 of file bvh.cpp.

◆ bvh() [3/3]

constexpr geom::bvh::bvh ( )
constexprdefaultnoexcept

Constructs an empty BVH.

Member Function Documentation

◆ build() [1/2]

void geom::bvh::build ( const brep_mesh mesh)

Constructs a BVH from a B-rep mesh.

Parameters
meshB-rep mesh from which to build the BVH.

Definition at line 66 of file bvh.cpp.

◆ build() [2/2]

void geom::bvh::build ( std::span< const bvh_primitive primitives)

Constructs a BVH from a set of primitives.

Parameters
primitivesBVH primitives.

Definition at line 39 of file bvh.cpp.

◆ clear()

void geom::bvh::clear ( )

Clears the BVH.

Definition at line 96 of file bvh.cpp.

◆ nodes()

constexpr const std::vector<bvh_node>& geom::bvh::nodes ( ) const
inlineconstexprnoexcept

Returns the BVH nodes.

Definition at line 92 of file bvh.hpp.

◆ visit()

void geom::bvh::visit ( const geom::ray< float, 3 > &  ray,
const visitor_type f 
) const
inline

Visits the primitive indices of all BVH nodes that intersect a ray.

Parameters
rayQuery ray.
fUnary visitor function which operates on a BVH primitive index.

Definition at line 83 of file bvh.hpp.


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