Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
bvh::v2::Index< Bits, PrimCountBits > Struct Template Reference

template<size_t Bits, size_t PrimCountBits>
struct bvh::v2::Index< Bits, PrimCountBits >

Packed index data structure.

This index can either refer to a range of primitives for a BVH leaf, or to the children of a BVH node. In either case, the index corresponds to a contiguous range, which means that:

  • For leaves, primitives in a BVH node should be accessed via:

    size_t begin = index.first_id(); size_t end = begin + index.prim_count(); for (size_t i = begin; i < end; ++i) { size_t prim_id = bvh.prim_ids[i]; // ... }

    Note that for efficiency, reordering the original data to avoid the indirection via bvh.prim_ids is preferable.

  • For inner nodes, children should be accessed via:

    auto& left_child = bvh.nodes[index.first_id()]; auto& right_child = bvh.nodes[index.first_id() + 1];

Definition at line 33 of file index.h.

Public Types

using Type = UnsignedIntType< Bits >
 

Public Member Functions

 Index ()=default
 
 Index (Type value)
 
BVH_ALWAYS_INLINE Type first_id () const
 
BVH_ALWAYS_INLINE bool is_inner () const
 
BVH_ALWAYS_INLINE bool is_leaf () const
 
bool operator!= (const Index &other) const
 
bool operator== (const Index &other) const
 
BVH_ALWAYS_INLINE Type prim_count () const
 
BVH_ALWAYS_INLINE void set_first_id (size_t first_id)
 
BVH_ALWAYS_INLINE void set_prim_count (size_t prim_count)
 

Static Public Member Functions

static BVH_ALWAYS_INLINE Index make_inner (size_t first_child)
 
static BVH_ALWAYS_INLINE Index make_leaf (size_t first_prim, size_t prim_count)
 

Public Attributes

Type value
 

Static Public Attributes

static constexpr size_t bits = Bits
 
static constexpr Type max_first_id = make_bitmask<Type>(bits - prim_count_bits)
 
static constexpr Type max_prim_count = make_bitmask<Type>(prim_count_bits)
 
static constexpr size_t prim_count_bits = PrimCountBits
 

Private Member Functions

 Index (size_t first_id, size_t prim_count)
 

#include <bvh/v2/index.h>

Member Typedef Documentation

◆ Type

template<size_t Bits, size_t PrimCountBits>
using bvh::v2::Index< Bits, PrimCountBits >::Type = UnsignedIntType<Bits>

Definition at line 34 of file index.h.

Constructor & Destructor Documentation

◆ Index() [1/3]

template<size_t Bits, size_t PrimCountBits>
bvh::v2::Index< Bits, PrimCountBits >::Index ( )
default

◆ Index() [2/3]

template<size_t Bits, size_t PrimCountBits>
bvh::v2::Index< Bits, PrimCountBits >::Index ( Type  value)
inlineexplicit

Definition at line 46 of file index.h.

◆ Index() [3/3]

template<size_t Bits, size_t PrimCountBits>
bvh::v2::Index< Bits, PrimCountBits >::Index ( size_t  first_id,
size_t  prim_count 
)
inlineexplicitprivate

Definition at line 80 of file index.h.

Member Function Documentation

◆ first_id()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE Type bvh::v2::Index< Bits, PrimCountBits >::first_id ( ) const
inline

Definition at line 57 of file index.h.

◆ is_inner()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE bool bvh::v2::Index< Bits, PrimCountBits >::is_inner ( ) const
inline

Definition at line 60 of file index.h.

◆ is_leaf()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE bool bvh::v2::Index< Bits, PrimCountBits >::is_leaf ( ) const
inline

Definition at line 59 of file index.h.

◆ make_inner()

template<size_t Bits, size_t PrimCountBits>
static BVH_ALWAYS_INLINE Index bvh::v2::Index< Bits, PrimCountBits >::make_inner ( size_t  first_child)
inlinestatic

Definition at line 75 of file index.h.

◆ make_leaf()

template<size_t Bits, size_t PrimCountBits>
static BVH_ALWAYS_INLINE Index bvh::v2::Index< Bits, PrimCountBits >::make_leaf ( size_t  first_prim,
size_t  prim_count 
)
inlinestatic

Definition at line 70 of file index.h.

◆ operator!=()

template<size_t Bits, size_t PrimCountBits>
bool bvh::v2::Index< Bits, PrimCountBits >::operator!= ( const Index< Bits, PrimCountBits > &  other) const
inline

Definition at line 53 of file index.h.

◆ operator==()

template<size_t Bits, size_t PrimCountBits>
bool bvh::v2::Index< Bits, PrimCountBits >::operator== ( const Index< Bits, PrimCountBits > &  other) const
inline

Definition at line 50 of file index.h.

◆ prim_count()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE Type bvh::v2::Index< Bits, PrimCountBits >::prim_count ( ) const
inline

Definition at line 58 of file index.h.

◆ set_first_id()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE void bvh::v2::Index< Bits, PrimCountBits >::set_first_id ( size_t  first_id)
inline

Definition at line 62 of file index.h.

◆ set_prim_count()

template<size_t Bits, size_t PrimCountBits>
BVH_ALWAYS_INLINE void bvh::v2::Index< Bits, PrimCountBits >::set_prim_count ( size_t  prim_count)
inline

Definition at line 66 of file index.h.

Member Data Documentation

◆ bits

template<size_t Bits, size_t PrimCountBits>
constexpr size_t bvh::v2::Index< Bits, PrimCountBits >::bits = Bits
staticconstexpr

Definition at line 36 of file index.h.

◆ max_first_id

template<size_t Bits, size_t PrimCountBits>
constexpr Type bvh::v2::Index< Bits, PrimCountBits >::max_first_id = make_bitmask<Type>(bits - prim_count_bits)
staticconstexpr

Definition at line 39 of file index.h.

◆ max_prim_count

template<size_t Bits, size_t PrimCountBits>
constexpr Type bvh::v2::Index< Bits, PrimCountBits >::max_prim_count = make_bitmask<Type>(prim_count_bits)
staticconstexpr

Definition at line 38 of file index.h.

◆ prim_count_bits

template<size_t Bits, size_t PrimCountBits>
constexpr size_t bvh::v2::Index< Bits, PrimCountBits >::prim_count_bits = PrimCountBits
staticconstexpr

Definition at line 37 of file index.h.

◆ value

template<size_t Bits, size_t PrimCountBits>
Type bvh::v2::Index< Bits, PrimCountBits >::value

Definition at line 43 of file index.h.

Collaboration diagram for bvh::v2::Index< Bits, PrimCountBits >:
[legend]

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