pub struct SpatialHashGrid2D { /* private fields */ }Expand description
O(1) uniform-cell 2D spatial hash grid with reusable scratch buffers and zero steady-state allocations.
Implementations§
Source§impl SpatialHashGrid2D
Zero-allocation open-addressed uniform-cell 2D spatial hash grid operations.
impl SpatialHashGrid2D
Zero-allocation open-addressed uniform-cell 2D spatial hash grid operations.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all entries in O(active_cells) time while retaining every internal buffer’s capacity.
Sourcepub fn insert_bounds(&mut self, id: u64, bounds: Bounds2D)
pub fn insert_bounds(&mut self, id: u64, bounds: Bounds2D)
Inserts an item (id, bounds) into every cell overlapped by bounds.
§Arguments
u64- Entity identifier.Bounds2D- World-space 2D bounding rectangle.
Sourcepub fn insert_point(&mut self, id: u64, position: Vec2)
pub fn insert_point(&mut self, id: u64, position: Vec2)
Inserts a point item (id, position) into its enclosing cell.
§Arguments
u64- Entity identifier.Vec2- World-space 2D position.
Sourcepub fn query_rect_into(&self, query_bounds: Bounds2D, out: &mut Vec<u64>)
pub fn query_rect_into(&self, query_bounds: Bounds2D, out: &mut Vec<u64>)
Queries all items overlapping query_bounds, writing deduplicated IDs into out.
§Arguments
Bounds2D- Query rectangle.&mut Vec<u64>- Reusable output buffer (cleared and deduplicated).
Sourcepub fn query_radius_into(&self, center: Vec2, radius: f32, out: &mut Vec<u64>)
pub fn query_radius_into(&self, center: Vec2, radius: f32, out: &mut Vec<u64>)
Queries all items overlapping circle (center, radius), writing deduplicated IDs into out.
§Arguments
Vec2- Query circle center.f32- Query radius.&mut Vec<u64>- Reusable output buffer (cleared and deduplicated).
Sourcepub fn query_radius(&mut self, center: Vec2, radius: f32) -> &[u64]
pub fn query_radius(&mut self, center: Vec2, radius: f32) -> &[u64]
Source§impl SpatialHashGrid2D
Implements impl #impl_generics #name #ty_generics #where_clause.
impl SpatialHashGrid2D
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_cell_size(&self) -> f32
pub fn get_mut_cell_size(&mut self) -> &mut f32
pub fn set_cell_size(&mut self, val: f32) -> &mut Self
pub fn get_inv_cell_size(&self) -> f32
pub fn get_mut_inv_cell_size(&mut self) -> &mut f32
pub fn set_inv_cell_size(&mut self, val: f32) -> &mut Self
pub fn get_occupied_buckets(&self) -> usize
pub fn get_mut_occupied_buckets(&mut self) -> &mut usize
pub fn set_occupied_buckets(&mut self, val: usize) -> &mut Self
Trait Implementations§
Source§impl Clone for SpatialHashGrid2D
impl Clone for SpatialHashGrid2D
Auto Trait Implementations§
impl Forget for SpatialHashGrid2D
impl Freeze for SpatialHashGrid2Dwhere
*const u8 is !null: Freeze,
PhantomData<SpatialHashBucket2D>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<SpatialHashEntry2D>: Freeze,
PhantomData<u64>: Freeze,
impl Move for SpatialHashGrid2D
impl RefUnwindSafe for SpatialHashGrid2D
impl Send for SpatialHashGrid2Dwhere
RawVecInner: Send,
impl Sync for SpatialHashGrid2Dwhere
RawVecInner: Sync,
impl Unpin for SpatialHashGrid2D
impl UnsafeUnpin for SpatialHashGrid2Dwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<SpatialHashBucket2D>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<SpatialHashEntry2D>: UnsafeUnpin,
PhantomData<u64>: UnsafeUnpin,
impl UnwindSafe for SpatialHashGrid2Dwhere
RawVecInner: 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