template<class T, class P, class BV, size_t K>
class BVH::LinearNodeT< T, P, BV, K >
Forward declare linear node class.
Node type for linearized (flattened) BVH. This will be constructed from the other (conventional) BVH type.
T is the precision used in the BVH computations, P is the enclosing primitive and BV is the bounding volume used in the BVH. K is the tree degree.
T is the precision for Vec3, P is the primitive type you want to enclose, BV is the bounding volume you use for it.
- Note
- P MUST supply function signedDistance(...) BV must supply a function getDistance (had this been C++20, we would have use concepts to enforce this). Note that LinearNode is the result of a flattened BVH hierarchy where nodes are stored with depth-first ordering for improved cache-location in the downward traversal.
-
This class exists so that we can fit the nodes with a smaller memory footprint. The standard BVH node (NodeT) is very useful when building the tree but less useful when traversing it since it stores references to the primitives in the node itself. It will span multiple cache lines. This node exists so that we can fit all the BVH info onto fewer cache lines. The number of cache lines will depend on the tree degree, precision, and bounding volume that is chosen.
- Todo:
- There's a minor optimization that can be made to the memory alignment, which is as follows: For a leaf node we never really need the m_childOffsets array, and for a regular node we never really need the m_primitivesOffset member. Moreover, m_childOffsets could be made into a K-1 sized array because we happen to know that the linearized hierarchy will store the first child node immediately after the regular node. We could shave off 16 bytes of storage, which would mean that a double-precision binary tree only takes up one word of CPU memory.