pub struct Bvh<K> { /* private fields */ }Expand description
Immutable median-split AABB hierarchy over opaque caller keys.
Invalid input bounds are not silently indexed: empty and non-finite boxes
are rejected during construction and counted by Self::rejected_items.
Accepted keys keep their input position, which makes pair output stable even
though node layout is optimized for pruning.
Implementations§
Source§impl<K> Bvh<K>
impl<K> Bvh<K>
Sourcepub fn build(items: impl IntoIterator<Item = SpatialItem<K>>) -> Bvh<K>
pub fn build(items: impl IntoIterator<Item = SpatialItem<K>>) -> Bvh<K>
Build a deterministic median-split hierarchy.
Sourcepub fn rejected_items(&self) -> usize
pub fn rejected_items(&self) -> usize
Number of source items rejected for empty or non-finite bounds.
Sourcepub fn item(&self, index: usize) -> Option<&SpatialItem<K>>
pub fn item(&self, index: usize) -> Option<&SpatialItem<K>>
Access an accepted item by its stable input position.
Source§impl<K> Bvh<K>where
K: Clone,
impl<K> Bvh<K>where
K: Clone,
Sourcepub fn query_aabb(&self, probe: &Aabb, out: &mut Vec<usize>)
pub fn query_aabb(&self, probe: &Aabb, out: &mut Vec<usize>)
Return pairs whose AABBs overlap with at least min_penetration on all
axes. A zero threshold includes touching boxes.
§Panics
Panics when min_penetration is negative or non-finite; an invalid query
must not masquerade as an evaluated empty result.
Keys whose bounds overlap probe.
The existing pair queries are self-joins within one tree. A clash test joins TWO meshes, so it probes one tree with the other’s boxes. Without this a caller has no option but a quadratic scan.
pub fn overlap_pairs(&self, min_penetration: f64) -> PairCandidates<K>
Sourcepub fn pairs_within_distance(&self, max_distance: f64) -> PairCandidates<K>
pub fn pairs_within_distance(&self, max_distance: f64) -> PairCandidates<K>
Return pairs whose AABB lower-bound distance is at most max_distance.
§Panics
Panics when max_distance is negative or non-finite; an invalid query
must not masquerade as an evaluated empty result.
Sourcepub fn nearest_to(
&self,
query: &Aabb,
accept: impl Fn(&K) -> bool,
) -> Option<NearestCandidate<K>>
pub fn nearest_to( &self, query: &Aabb, accept: impl Fn(&K) -> bool, ) -> Option<NearestCandidate<K>>
Find the accepted key with the smallest AABB lower-bound distance.
Equal distances resolve to the earliest accepted input item. Invalid query bounds panic rather than being misreported as an evaluated empty result.
Trait Implementations§
Source§impl<K> SpatialIndex<K> for Bvh<K>
impl<K> SpatialIndex<K> for Bvh<K>
Auto Trait Implementations§
impl<K> Freeze for Bvh<K>
impl<K> RefUnwindSafe for Bvh<K>where
K: RefUnwindSafe,
impl<K> Send for Bvh<K>where
K: Send,
impl<K> Sync for Bvh<K>where
K: Sync,
impl<K> Unpin for Bvh<K>where
K: Unpin,
impl<K> UnwindSafe for Bvh<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more