Expand description
Incrementally updatable bounding volume hierarchy for meshes stored in
fast_mesh_store.
Bvh::buildbuilds over a mesh’s alive triangles in mesh-local space, with a binned SAH (Quality::Sah) or Morton-code (Quality::Fast) split.Bvh::updatetakes the store’sfast_mesh_store::ChangeSetand refits, rebuilds the affected treelets, or rebuilds everything, whichever is cheapest.Bvh::query_aabbfinds the triangles whose boxes overlap a box.Bvh::root,Bvh::node,Bvh::parent,Bvh::traverse,Bvh::traverse_from,Bvh::traverse_by_keyandBvh::traverse_orderedexpose the tree read-only, for building other queries on top of it. No traversal allocates on the heap or fails.
Every fallible operation is failure-atomic: all memory it needs is reserved
before the tree is touched, so on error the BVH is left as it was. The two
optional follow-up steps of Bvh::update (rebuilding degraded treelets and
compacting storage) never report errors: if memory runs out they are skipped
and the tree stays correct.
Structs§
- Aabb
- Axis-aligned bounding box in mesh-local coordinates.
- Build
Options - Options for building (and rebuilding parts of) a BVH.
- Bvh
- Bounding volume hierarchy over the alive triangles of one
Mesh, in mesh-local coordinates. Keep it current withBvh::update. - BvhBuild
Bvh::buildcut into steps, so that a caller can yield between them: the triangles’ boxes are collected, then the tree is built a bounded amount of work per step, then its treelets are assigned (subtree counts, roots and costs), also a bounded amount per step.- NodeId
- Identifies a node of one
Bvh. Only valid until that BVH is next modified (updated, refit or rebuilt). - Node
View - A node’s bounds and contents.
- Update
Policy - When
updatefalls back to heavier strategies. - Update
Report - What
updatedid, for diagnostics and benchmarks.
Enums§
- BvhError
- Errors returned by BVH operations. On any error the BVH is left exactly as it was before the call: every operation reserves the memory it needs before it changes the tree (best-effort steps that run afterwards are skipped silently instead of failing).
- Node
Kind - What a node holds.
- Quality
- How the tree is split when it is built.
- Strategy
- How
updatebrought the tree up to date.