Skip to main content

SpatialIndex3D

Struct SpatialIndex3D 

Source
pub struct SpatialIndex3D<T: Copy>(/* private fields */);
Expand description

Owned 3D collider snapshot with the same lifecycle as SpatialIndex2D.

Implementations§

Source§

impl<T: Copy> SpatialIndex3D<T>

Source

pub fn new() -> Self

Creates an empty index without allocating.

Source

pub fn len(&self) -> usize

Number of indexed colliders in the last successful snapshot.

Source

pub fn is_empty(&self) -> bool

Whether the snapshot is empty.

Source

pub fn rebuild( &mut self, source: impl IntoIterator<Item = (T, Aabb3)>, ) -> Result<usize, SpatialError>

Copies (id, bounds) pairs and atomically replaces the snapshot. Invalid input returns its original position and preserves old data. Build cost is O(n log n); query cost depends on overlap distribution.

Source

pub fn nearest( &self, ray: Ray3, max_distance: f32, ) -> Result<Option<SpatialHit3<T>>, SpatialError>

Nearest ray contact within an inclusive world-unit distance. Exact-distance ties use original input order. Infinity is allowed.

Source

pub fn visit_overlapping( &self, area: Aabb3, emit: impl FnMut(T), ) -> Result<(), SpatialError>

Visits boxes with positive-volume overlap. Touching alone is excluded. Visitor order follows the hierarchy, not input order. No allocation.

Source

pub fn overlapping(&self, area: Aabb3) -> Result<Vec<T>, SpatialError>

Collects positive-volume overlaps for convenience.

Source

pub fn visit_visible(&self, view: &Frustum3D, emit: impl FnMut(T))

Visits boxes that may be visible in this camera. No allocation.

Source

pub fn visible(&self, view: &Frustum3D) -> Vec<T>

Collects potentially visible boxes for convenience.

Trait Implementations§

Source§

impl<T: Copy> Default for SpatialIndex3D<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SpatialIndex3D<T>
where Bvh<T, 3>: Freeze,

§

impl<T> RefUnwindSafe for SpatialIndex3D<T>
where Bvh<T, 3>: RefUnwindSafe,

§

impl<T> Send for SpatialIndex3D<T>
where Bvh<T, 3>: Send,

§

impl<T> Sync for SpatialIndex3D<T>
where Bvh<T, 3>: Sync,

§

impl<T> Unpin for SpatialIndex3D<T>
where Bvh<T, 3>: Unpin,

§

impl<T> UnsafeUnpin for SpatialIndex3D<T>
where Bvh<T, 3>: UnsafeUnpin,

§

impl<T> UnwindSafe for SpatialIndex3D<T>
where Bvh<T, 3>: 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> Component for T
where T: Send + Sync + 'static,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.