Skip to main content

fast_mesh_bvh/
lib.rs

1//! Incrementally updatable bounding volume hierarchy for meshes stored in
2//! [`fast_mesh_store`].
3//!
4//! - [`Bvh::build`] builds over a mesh's alive triangles in mesh-local space,
5//!   with a binned SAH ([`Quality::Sah`]) or Morton-code ([`Quality::Fast`]) split.
6//! - [`Bvh::update`] takes the store's [`fast_mesh_store::ChangeSet`] and refits,
7//!   rebuilds the affected treelets, or rebuilds everything, whichever is cheapest.
8//! - [`Bvh::query_aabb`] finds the triangles whose boxes overlap a box.
9//! - [`Bvh::root`], [`Bvh::node`], [`Bvh::parent`], [`Bvh::traverse`],
10//!   [`Bvh::traverse_from`], [`Bvh::traverse_by_key`] and
11//!   [`Bvh::traverse_ordered`] expose the tree read-only, for building other
12//!   queries on top of it. No traversal allocates on the heap or fails.
13//!
14//! Every fallible operation is failure-atomic: all memory it needs is reserved
15//! before the tree is touched, so on error the BVH is left as it was. The two
16//! optional follow-up steps of [`Bvh::update`] (rebuilding degraded treelets and
17//! compacting storage) never report errors: if memory runs out they are skipped
18//! and the tree stays correct.
19
20mod aabb;
21mod arena;
22mod build;
23mod error;
24mod node;
25mod options;
26mod tree;
27mod update;
28
29pub use aabb::Aabb;
30pub use error::{BvhError, Result};
31#[doc(hidden)]
32pub use node::TRAVERSE_STACK;
33pub use node::{NodeId, NodeKind, NodeView};
34pub use options::{BuildOptions, Quality, UpdatePolicy};
35pub use tree::{Bvh, BvhBuild};
36pub use update::{Strategy, UpdateReport};