Expand description
CPU BVH (Bounding Volume Hierarchy) tree for broad-phase acceleration.
Provides axis-aligned bounding box (AABB) structures, a recursive BVH tree built with a SAH-inspired median split, ray and AABB queries, and a linearised flat representation for cache-friendly traversal.
Structs§
- Aabb
- An axis-aligned bounding box stored as two
[f32; 3]corners. - Bvh
- A BVH tree built from a flat list of
BvhPrimitives. - BvhNode
- A node in the recursive BVH tree.
- BvhPrimitive
- A leaf primitive: an AABB together with the logical object it belongs to.
- BvhStats
- Runtime statistics about a BVH tree.
- BvhTree
Statistics - Extended BVH tree statistics including average fan-out.
- Flat
BvhNode - A single node in the linearised (flat) BVH representation.
- Lbvh
Primitive - LBVH primitive: AABB + Morton code.
- Morton
Cluster - A cluster of Morton-coded primitives, with a pre-computed bounding radius.
- RayHit
- Result of a closest-hit ray traversal.
Functions§
- build_
morton_ clusters - Compute clusters by grouping Morton-sorted
LbvhPrimitives into chunks ofcluster_sizeand returning aMortonClusterper group. - bvh_
closest_ hit - Traverse the BVH returning the closest hit (smallest positive t).
- compute_
bvh_ from_ sorted - Build a flat BVH from a pre-sorted (by Morton code) slice of
LbvhPrimitives using a radix-sort-inspired clustering strategy. - compute_
cluster_ radius - Compute the bounding sphere radius for a cluster of
LbvhPrimitives. - flatten
- Flatten a
Bvhinto aVec<FlatBvhNode>(DFS pre-order) together with a reordered primitive-index slice. - hlbvh_
split - Find the split index for a slice of Morton-code-sorted primitives using the highest differing bit (HLBVH strategy).
- lbvh_
build - Build an LBVH (Linear BVH) from a set of primitives using Morton-code sorting and a recursive binary splitting strategy.
- morton_
code - Compute a 30-bit Morton code for a 3D point normalised to [0, 1]^3.
- query_
flat - Iterative AABB query over a flat BVH.
- ray_
aabb_ intersect - Test whether a ray defined by
origin+ t * direction intersectsaabbwithin[0, max_t]. - refit
- Refit the bounding boxes of an existing BVH after primitives have moved.
- sah_
cost - Surface Area Heuristic cost:
C = (SA_left / SA_parent) * N_left + (SA_right / SA_parent) * N_right