axiolid_spatial/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Spatial acceleration contracts.
4//!
5//! # What this crate provides
6//!
7//! Two indices, both deterministic and callback-based:
8//!
9//! - [`Bvh`] over bounded *objects* -- triangles, solids, anything with an
10//!   AABB. Adapts to how geometry is distributed, so empty space costs
11//!   nothing. This is what clash, ray casting, and healing use.
12//! - [`PointIndex`] over *points*, on a uniform grid. Exact KNN and radius
13//!   search for scattered samples, where every query has the same radius and
14//!   cell arithmetic beats tree descent.
15//!
16//! An octree, k-d tree, GPU broad phase, or foreign index can implement the
17//! same [`SpatialIndex`] callback API. None is provided here: the BVH covers
18//! object queries and the grid covers point queries, and a third structure
19//! should arrive with a measured workload that needs it, not before.
20//!
21//! Narrow-phase geometry remains outside the index: these answer *which
22//! candidates*, never *what the intersection is*.
23//!
24//! Beside the indices, [`barycentric`] locates a point in a triangle,
25//! tetrahedron or polygon by weights of its corners, for interpolating
26//! values given there.
27
28pub mod barycentric;
29pub mod bvh;
30pub mod index;
31pub mod points;
32
33pub use barycentric::{
34    mean_value_coordinates2, tetrahedron_barycentric, triangle_barycentric2, triangle_barycentric3,
35    BarycentricError,
36};
37pub use bvh::{Bvh, CandidatePair, NearestCandidate, PairCandidates, SpatialQueryStats};
38pub use index::{RayHit, SpatialIndex, SpatialItem};
39pub use points::{PointHit, PointIndex, PointQueryError};