pub struct PersistentSpatialHash<T: Clone> { /* private fields */ }Expand description
A spatial hash that persists across frames.
Tracks the last known position of each object so that insert_or_update
correctly removes the object from its old cell before re-inserting.
Implementations§
Source§impl<T: Clone> PersistentSpatialHash<T>
impl<T: Clone> PersistentSpatialHash<T>
Sourcepub fn insert_or_update(&mut self, id: usize, pos: [f64; 3], data: T)
pub fn insert_or_update(&mut self, id: usize, pos: [f64; 3], data: T)
Insert a new object or update an existing one.
If the object already exists, it is first removed from its old cell.
Sourcepub fn query_radius(&self, center: [f64; 3], radius: f64) -> Vec<(usize, &T)>
pub fn query_radius(&self, center: [f64; 3], radius: f64) -> Vec<(usize, &T)>
Query all items within radius of center.
Sourcepub fn query_aabb(&self, min: [f64; 3], max: [f64; 3]) -> Vec<(usize, &T)>
pub fn query_aabb(&self, min: [f64; 3], max: [f64; 3]) -> Vec<(usize, &T)>
Query all items in an AABB.
Sourcepub fn advance_frame(&mut self)
pub fn advance_frame(&mut self)
Advance the frame counter (call once per simulation step).
Sourcepub fn current_frame(&self) -> u64
pub fn current_frame(&self) -> u64
Current frame number.
Sourcepub fn statistics(&self) -> SpatialHashStats
pub fn statistics(&self) -> SpatialHashStats
Compute statistics.
Auto Trait Implementations§
impl<T> Freeze for PersistentSpatialHash<T>
impl<T> RefUnwindSafe for PersistentSpatialHash<T>where
T: RefUnwindSafe,
impl<T> Send for PersistentSpatialHash<T>where
T: Send,
impl<T> Sync for PersistentSpatialHash<T>where
T: Sync,
impl<T> Unpin for PersistentSpatialHash<T>where
T: Unpin,
impl<T> UnsafeUnpin for PersistentSpatialHash<T>
impl<T> UnwindSafe for PersistentSpatialHash<T>where
T: 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
Mutably borrows from an owned value. Read more
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.