Skip to main content

Module cpu

Module cpu 

Source
Expand description

CPU BVH construction, query, traversal, and LBVH helpers.

Structs§

Bvh
A BVH tree built from a flat list of BvhPrimitives.

Functions§

build_morton_clusters
Compute clusters by grouping Morton-sorted LbvhPrimitives into chunks of cluster_size and returning a MortonCluster per 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 Bvh into a Vec<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 intersects aabb within [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