Struct Bvh

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

Source

pub fn build(items: impl IntoIterator<Item = SpatialItem<K>>) -> Bvh<K>

Build a deterministic median-split hierarchy.

Source

pub fn len(&self) -> usize

Number of accepted items.

Source

pub fn is_empty(&self) -> bool

Whether the hierarchy has no accepted items.

Source

pub fn rejected_items(&self) -> usize

Number of source items rejected for empty or non-finite bounds.

Source

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,

Source

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.

Source

pub fn overlap_pairs(&self, min_penetration: f64) -> PairCandidates<K>

Source

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.

Source

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> Debug for Bvh<K>
where K: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<K> SpatialIndex<K> for Bvh<K>
where K: Debug + Send + Sync,

Source§

fn visit_aabb( &self, query: &Aabb, visitor: &mut dyn FnMut(&K) -> ControlFlow<()>, )

Visit keys whose stored bounds overlap query. Returning Break stops.
Source§

fn visit_ray( &self, ray: &Ray3, visitor: &mut dyn FnMut(RayHit<&K>) -> ControlFlow<()>, )

Visit broad-phase ray candidates.
Source§

fn len(&self) -> usize

Number of indexed items.
Source§

fn is_empty(&self) -> bool

Whether no items are indexed.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,