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];
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>
| using bvh::v2::Index< Bits, PrimCountBits >::Type = UnsignedIntType<Bits> | 
      
  | 
  default | 
      
  | 
  inlineexplicit | 
      
  | 
  inlineexplicitprivate | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inlinestatic | 
      
  | 
  inlinestatic | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  staticconstexpr | 
      
  | 
  staticconstexpr | 
      
  | 
  staticconstexpr | 
      
  | 
  staticconstexpr | 
| Type bvh::v2::Index< Bits, PrimCountBits >::value |