Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
bvh::v2::Bvh< Node > Struct Template Reference

template<typename Node>
struct bvh::v2::Bvh< Node >

Definition at line 17 of file bvh.h.

Public Types

using Index = typename Node::Index
 
using Ray = bvh::v2::Ray<Scalar, Node::dimension>
 
using Scalar = typename Node::Scalar
 

Public Member Functions

 Bvh ()=default
 
 Bvh (Bvh &&)=default
 
Bvh extract_bvh (size_t root_id) const
 Extracts the BVH rooted at the given node index.
 
BVH_ALWAYS_INLINE const Nodeget_root () const
 Returns the root node of this BVH.
 
template<bool IsAnyHit, bool IsRobust, typename Stack , typename LeafFn , typename InnerFn = IgnoreArgs>
void intersect (const Ray &ray, Index start, Stack &, LeafFn &&, InnerFn &&={}) const
 Intersects the BVH with a single ray, using the given function to intersect the contents of a leaf.
 
bool operator!= (const Bvh &other) const
 
Bvhoperator= (Bvh &&)=default
 
bool operator== (const Bvh &other) const
 
template<typename LeafFn = IgnoreArgs>
void refit (LeafFn &&={})
 Refits the BVH, using the given function object to recompute the bounding box of the leaves.
 
void serialize (OutputStream &) const
 
template<typename LeafFn = IgnoreArgs, typename InnerFn = IgnoreArgs>
void traverse_bottom_up (LeafFn &&={}, InnerFn &&={})
 Traverses this BVH from the bottom to the top, using the given function objects to process leaves and inner nodes.
 
template<bool IsAnyHit, typename Stack , typename LeafFn , typename InnerFn >
void traverse_top_down (Index start, Stack &, LeafFn &&, InnerFn &&) const
 Traverses the BVH from the given index in start using the provided stack.
 

Static Public Member Functions

static Bvh deserialize (InputStream &)
 
static BVH_ALWAYS_INLINE size_t get_left_sibling_id (size_t node_id)
 Returns the index of the left sibling of the node.
 
static BVH_ALWAYS_INLINE size_t get_right_sibling_id (size_t node_id)
 Returns the index of the right sibling of the node.
 
static BVH_ALWAYS_INLINE size_t get_sibling_id (size_t node_id)
 Returns the index of a sibling of a node.
 
static BVH_ALWAYS_INLINE bool is_left_sibling (size_t node_id)
 Returns whether the node located at the given index is the left child of its parent.
 

Public Attributes

std::vector< Nodenodes
 
std::vector< size_t > prim_ids
 

#include <bvh/v2/bvh.h>

Member Typedef Documentation

◆ Index

Definition at line 18 of file bvh.h.

◆ Ray

Definition at line 20 of file bvh.h.

◆ Scalar

Definition at line 19 of file bvh.h.

Constructor & Destructor Documentation

◆ Bvh() [1/2]

template<typename Node >
bvh::v2::Bvh< Node >::Bvh ( )
default

◆ Bvh() [2/2]

template<typename Node >
bvh::v2::Bvh< Node >::Bvh ( Bvh< Node > && )
default

Member Function Documentation

◆ deserialize()

template<typename Node >
Bvh< Node > bvh::v2::Bvh< Node >::deserialize ( InputStream & stream)
inlinestatic

Definition at line 235 of file bvh.h.

◆ extract_bvh()

template<typename Node >
Bvh< Node > bvh::v2::Bvh< Node >::extract_bvh ( size_t root_id) const
inline

Extracts the BVH rooted at the given node index.

Definition at line 95 of file bvh.h.

◆ get_left_sibling_id()

template<typename Node >
static BVH_ALWAYS_INLINE size_t bvh::v2::Bvh< Node >::get_left_sibling_id ( size_t node_id)
inlinestatic

Returns the index of the left sibling of the node.

This effectively returns the given index unchanged if the node is the left sibling, or the other sibling index otherwise.

Definition at line 49 of file bvh.h.

◆ get_right_sibling_id()

template<typename Node >
static BVH_ALWAYS_INLINE size_t bvh::v2::Bvh< Node >::get_right_sibling_id ( size_t node_id)
inlinestatic

Returns the index of the right sibling of the node.

This effectively returns the given index unchanged if the node is the right sibling, or the other sibling index otherwise.

Definition at line 55 of file bvh.h.

◆ get_root()

template<typename Node >
BVH_ALWAYS_INLINE const Node & bvh::v2::Bvh< Node >::get_root ( ) const
inline

Returns the root node of this BVH.

Definition at line 60 of file bvh.h.

◆ get_sibling_id()

template<typename Node >
static BVH_ALWAYS_INLINE size_t bvh::v2::Bvh< Node >::get_sibling_id ( size_t node_id)
inlinestatic

Returns the index of a sibling of a node.

Definition at line 43 of file bvh.h.

◆ intersect()

template<typename Node >
template<bool IsAnyHit, bool IsRobust, typename Stack , typename LeafFn , typename InnerFn >
void bvh::v2::Bvh< Node >::intersect ( const Ray & ray,
Index start,
Stack & stack,
LeafFn && leaf_fn,
InnerFn && inner_fn = {} ) const
inline

Intersects the BVH with a single ray, using the given function to intersect the contents of a leaf.

The algorithm starts at the node index start and uses the given stack object. When IsAnyHit is true, the function stops at the first intersection (useful for shadow rays), otherwise it finds the closest intersection. When IsRobust is true, a slower but numerically robust ray-box test is used, otherwise a fast, but less precise test is used.

Definition at line 166 of file bvh.h.

◆ is_left_sibling()

template<typename Node >
static BVH_ALWAYS_INLINE bool bvh::v2::Bvh< Node >::is_left_sibling ( size_t node_id)
inlinestatic

Returns whether the node located at the given index is the left child of its parent.

Definition at line 40 of file bvh.h.

◆ operator!=()

template<typename Node >
bool bvh::v2::Bvh< Node >::operator!= ( const Bvh< Node > & other) const
inline

Definition at line 35 of file bvh.h.

◆ operator=()

template<typename Node >
Bvh & bvh::v2::Bvh< Node >::operator= ( Bvh< Node > && )
default

◆ operator==()

template<typename Node >
bool bvh::v2::Bvh< Node >::operator== ( const Bvh< Node > & other) const
inline

Definition at line 32 of file bvh.h.

◆ refit()

template<typename Node >
template<typename LeafFn >
void bvh::v2::Bvh< Node >::refit ( LeafFn && leaf_fn = {})
inline

Refits the BVH, using the given function object to recompute the bounding box of the leaves.

Definition at line 216 of file bvh.h.

◆ serialize()

template<typename Node >
void bvh::v2::Bvh< Node >::serialize ( OutputStream & stream) const
inline

Definition at line 225 of file bvh.h.

◆ traverse_bottom_up()

template<typename Node >
void bvh::v2::Bvh< Node >::traverse_bottom_up ( LeafFn && leaf_fn = {},
InnerFn && inner_fn = {} )
inline

Traverses this BVH from the bottom to the top, using the given function objects to process leaves and inner nodes.

Definition at line 190 of file bvh.h.

◆ traverse_top_down()

template<typename Node >
template<bool IsAnyHit, typename Stack , typename LeafFn , typename InnerFn >
void bvh::v2::Bvh< Node >::traverse_top_down ( Index start,
Stack & stack,
LeafFn && leaf_fn,
InnerFn && inner_fn ) const
inline

Traverses the BVH from the given index in start using the provided stack.

Every leaf encountered on the way is processed using the given LeafFn function, and every pair of nodes is processed with the function in HitFn, which returns a triplet of booleans indicating whether the first child should be processed, whether the second child should be processed, and whether to traverse the second child first instead of the other way around.

Definition at line 129 of file bvh.h.

Member Data Documentation

◆ nodes

template<typename Node >
std::vector<Node> bvh::v2::Bvh< Node >::nodes

Definition at line 22 of file bvh.h.

◆ prim_ids

template<typename Node >
std::vector<size_t> bvh::v2::Bvh< Node >::prim_ids

Definition at line 23 of file bvh.h.

Collaboration diagram for bvh::v2::Bvh< Node >:
[legend]

The documentation for this struct was generated from the following file: