pub struct SpatialIndex3D { /* private fields */ }Expand description
3D spatial index using a simple AABB list with efficient queries.
For small to medium numbers of objects, a simple list with AABB tests outperforms tree-based structures due to cache locality. For larger numbers (>1000), a BVH would be more efficient.
Implementations§
Source§impl SpatialIndex3D
impl SpatialIndex3D
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a spatial index with the given capacity.
Sourcepub fn insert(&mut self, entry: SpatialEntry3D)
pub fn insert(&mut self, entry: SpatialEntry3D)
Inserts a new entry into the spatial index.
Sourcepub fn insert_geometry(
&mut self,
index: usize,
geometry: &Geometry3D,
position: Vector3<f64>,
orientation: usize,
)
pub fn insert_geometry( &mut self, index: usize, geometry: &Geometry3D, position: Vector3<f64>, orientation: usize, )
Inserts a placed geometry into the spatial index.
Sourcepub fn query_aabb(&self, query_aabb: &Aabb3D) -> Vec<&SpatialEntry3D>
pub fn query_aabb(&self, query_aabb: &Aabb3D) -> Vec<&SpatialEntry3D>
Finds all entries whose bounding boxes intersect with the given AABB.
Sourcepub fn query_geometry(
&self,
geometry: &Geometry3D,
position: Vector3<f64>,
orientation: usize,
) -> Vec<&SpatialEntry3D>
pub fn query_geometry( &self, geometry: &Geometry3D, position: Vector3<f64>, orientation: usize, ) -> Vec<&SpatialEntry3D>
Finds all entries that potentially intersect with a geometry at the given position.
Sourcepub fn query_with_margin(
&self,
geometry: &Geometry3D,
position: Vector3<f64>,
orientation: usize,
margin: f64,
) -> Vec<&SpatialEntry3D>
pub fn query_with_margin( &self, geometry: &Geometry3D, position: Vector3<f64>, orientation: usize, margin: f64, ) -> Vec<&SpatialEntry3D>
Finds all entries that potentially intersect with the given geometry AABB expanded by a margin (for spacing).
Sourcepub fn iter(&self) -> impl Iterator<Item = &SpatialEntry3D>
pub fn iter(&self) -> impl Iterator<Item = &SpatialEntry3D>
Returns an iterator over all entries in the index.
Sourcepub fn get_potential_collisions(
&self,
geometry: &Geometry3D,
position: Vector3<f64>,
orientation: usize,
spacing: f64,
) -> Vec<usize>
pub fn get_potential_collisions( &self, geometry: &Geometry3D, position: Vector3<f64>, orientation: usize, spacing: f64, ) -> Vec<usize>
Returns the indices of potentially colliding geometries for a query geometry.
Sourcepub fn has_collision(
&self,
geometry: &Geometry3D,
position: Vector3<f64>,
orientation: usize,
spacing: f64,
) -> bool
pub fn has_collision( &self, geometry: &Geometry3D, position: Vector3<f64>, orientation: usize, spacing: f64, ) -> bool
Checks if a geometry at the given position would collide with any existing entries.
Trait Implementations§
Source§impl Debug for SpatialIndex3D
impl Debug for SpatialIndex3D
Auto Trait Implementations§
impl Freeze for SpatialIndex3D
impl RefUnwindSafe for SpatialIndex3D
impl Send for SpatialIndex3D
impl Sync for SpatialIndex3D
impl Unpin for SpatialIndex3D
impl UnwindSafe for SpatialIndex3D
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.