pub struct GridHashIndex { /* private fields */ }Expand description
Uniform grid spatial hash. Each item is bucketed into every cell
its AABB overlaps; queries union all items from the cells the
query rect overlaps. Items whose AABB would span more than
MAX_CELLS_PER_ITEM cells are NOT bucketed — see oversized
below and the module doc’s “Oversized items” section.
Implementations§
Source§impl GridHashIndex
impl GridHashIndex
Sourcepub fn new(cell_size: f32) -> Self
pub fn new(cell_size: f32) -> Self
Create a grid with cell_size logical pixels per cell.
Clamped to a minimum of 1.0 to avoid pathological huge bucket
counts.
Sourcepub fn cell_count(&self) -> usize
pub fn cell_count(&self) -> usize
Number of cells currently storing at least one item. Useful
for diagnostics; not part of the public SpatialIndex trait.
Oversized items (see MAX_CELLS_PER_ITEM) never occupy a
cell, so they never contribute to this count.
Trait Implementations§
Source§impl Debug for GridHashIndex
impl Debug for GridHashIndex
Source§impl Default for GridHashIndex
impl Default for GridHashIndex
Source§impl SpatialIndex for GridHashIndex
impl SpatialIndex for GridHashIndex
Source§fn insert(&mut self, id: ItemId, bounds: Rect)
fn insert(&mut self, id: ItemId, bounds: Rect)
Insert or update an item’s bounds. Calling
insert again with
the same id replaces the previous bounds (re-buckets the
item). Equivalent to remove(id); insert(id, bounds); on
implementations that need an explicit update path.Source§fn query(&self, scene_rect: Rect) -> Vec<ItemId>
fn query(&self, scene_rect: Rect) -> Vec<ItemId>
Items whose bounds intersect
scene_rect, in implementation-
defined order. The result is deduplicated. May include false
positives (items in cells the rect overlaps but whose bounds
don’t actually intersect) — callers that need exact
intersection narrow with a per-item check.Auto Trait Implementations§
impl Freeze for GridHashIndex
impl RefUnwindSafe for GridHashIndex
impl Send for GridHashIndex
impl Sync for GridHashIndex
impl Unpin for GridHashIndex
impl UnsafeUnpin for GridHashIndex
impl UnwindSafe for GridHashIndex
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.