pub struct SpatialIndex2D { /* private fields */ }Expand description
2D spatial index using R*-tree for efficient collision queries.
Implementations§
Source§impl SpatialIndex2D
impl SpatialIndex2D
Sourcepub fn with_entries(entries: Vec<SpatialEntry2D>) -> Self
pub fn with_entries(entries: Vec<SpatialEntry2D>) -> Self
Creates a spatial index with the given entries.
Sourcepub fn insert(&mut self, entry: SpatialEntry2D)
pub fn insert(&mut self, entry: SpatialEntry2D)
Inserts a new entry into the spatial index.
Sourcepub fn insert_geometry(
&mut self,
index: usize,
geometry: &Geometry2D,
position: (f64, f64),
rotation: f64,
)
pub fn insert_geometry( &mut self, index: usize, geometry: &Geometry2D, position: (f64, f64), rotation: f64, )
Inserts a placed geometry into the spatial index.
Sourcepub fn query_aabb(&self, min: [f64; 2], max: [f64; 2]) -> Vec<&SpatialEntry2D>
pub fn query_aabb(&self, min: [f64; 2], max: [f64; 2]) -> Vec<&SpatialEntry2D>
Finds all entries whose bounding boxes intersect with the given AABB.
This is the primary broad-phase collision detection method.
Sourcepub fn query_geometry(
&self,
geometry: &Geometry2D,
position: (f64, f64),
rotation: f64,
) -> Vec<&SpatialEntry2D>
pub fn query_geometry( &self, geometry: &Geometry2D, position: (f64, f64), rotation: f64, ) -> Vec<&SpatialEntry2D>
Finds all entries that potentially intersect with a geometry at the given position.
Sourcepub fn query_with_margin(
&self,
geometry: &Geometry2D,
position: (f64, f64),
rotation: f64,
margin: f64,
) -> Vec<&SpatialEntry2D>
pub fn query_with_margin( &self, geometry: &Geometry2D, position: (f64, f64), rotation: f64, margin: f64, ) -> Vec<&SpatialEntry2D>
Finds all entries that potentially intersect with the given geometry AABB expanded by a margin (for spacing).
Sourcepub fn iter(&self) -> impl Iterator<Item = &SpatialEntry2D>
pub fn iter(&self) -> impl Iterator<Item = &SpatialEntry2D>
Returns an iterator over all entries in the index.
Sourcepub fn get_potential_collisions(
&self,
geometry: &Geometry2D,
position: (f64, f64),
rotation: f64,
spacing: f64,
) -> Vec<usize>
pub fn get_potential_collisions( &self, geometry: &Geometry2D, position: (f64, f64), rotation: f64, spacing: f64, ) -> Vec<usize>
Returns the indices of potentially colliding geometries for a query geometry.
Trait Implementations§
Source§impl Debug for SpatialIndex2D
impl Debug for SpatialIndex2D
Auto Trait Implementations§
impl Freeze for SpatialIndex2D
impl RefUnwindSafe for SpatialIndex2D
impl Send for SpatialIndex2D
impl Sync for SpatialIndex2D
impl Unpin for SpatialIndex2D
impl UnwindSafe for SpatialIndex2D
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
Mutably borrows from an owned value. Read more
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>
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 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>
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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.