Skip to main content

Module bvh

Module bvh 

Source
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.

§Module layout

  • types — Core data types: Aabb, BvhPrimitive, BvhNode, FlatBvhNode, GpuRay, RayHit, statistics types, Morton/LBVH types.
  • cpu — CPU builder (Bvh::build), query helpers, flat traversal, LBVH construction, statistics.
  • gpu — GPU-accelerated ray traversal (BvhGpuTraverser) backed by WgpuBackendReal; falls back to CPU when no GPU is present.

Re-exports§

pub use cpu::Bvh;
pub use cpu::build_morton_clusters;
pub use cpu::bvh_closest_hit;
pub use cpu::compute_bvh_from_sorted;
pub use cpu::compute_cluster_radius;
pub use cpu::flatten;
pub use cpu::hlbvh_split;
pub use cpu::lbvh_build;
pub use cpu::morton_code;
pub use cpu::query_flat;
pub use cpu::ray_aabb_intersect;
pub use cpu::refit;
pub use cpu::sah_cost;
pub use gpu::BvhGpuTraverser;
pub use types::Aabb;
pub use types::BvhNode;
pub use types::BvhPrimitive;
pub use types::BvhStats;
pub use types::BvhTreeStatistics;
pub use types::FlatBvhNode;
pub use types::GpuRay;
pub use types::LbvhPrimitive;
pub use types::MortonCluster;
pub use types::RayHit;

Modules§

cpu
CPU BVH construction, query, traversal, and LBVH helpers.
gpu
GPU-accelerated BVH traversal using a persistent WgpuBackendReal instance.
types
Core BVH types: AABB, primitives, nodes, flat nodes, and ray-hit results.