Struct veloren_common::util::SpatialGrid
source · pub struct SpatialGrid {
grid: HashMap<Vec2<i32>, Vec<Entity>, GridHasher>,
large_grid: HashMap<Vec2<i32>, Vec<Entity>, GridHasher>,
lg2_cell_size: usize,
lg2_large_cell_size: usize,
radius_cutoff: u32,
largest_large_radius: u32,
}
Fields§
§grid: HashMap<Vec2<i32>, Vec<Entity>, GridHasher>
§large_grid: HashMap<Vec2<i32>, Vec<Entity>, GridHasher>
§lg2_cell_size: usize
§lg2_large_cell_size: usize
§radius_cutoff: u32
§largest_large_radius: u32
Implementations§
source§impl SpatialGrid
impl SpatialGrid
pub fn new( lg2_cell_size: usize, lg2_large_cell_size: usize, radius_cutoff: u32, ) -> Self
sourcepub fn insert(&mut self, pos: Vec2<i32>, radius: u32, entity: Entity)
pub fn insert(&mut self, pos: Vec2<i32>, radius: u32, entity: Entity)
Add an entity at the provided 2d pos into the spatial grid
sourcepub fn in_aabr<'a>(
&'a self,
aabr: Aabr<i32>,
) -> impl Iterator<Item = Entity> + 'a
pub fn in_aabr<'a>( &'a self, aabr: Aabr<i32>, ) -> impl Iterator<Item = Entity> + 'a
Get an iterator over the entities overlapping the provided axis aligned
bounding region.
NOTE: for best optimization of the iterator use
for_each
rather than a for loop.
sourcepub fn in_circle_aabr(
&self,
center: Vec2<f32>,
radius: f32,
) -> impl Iterator<Item = Entity> + '_
pub fn in_circle_aabr( &self, center: Vec2<f32>, radius: f32, ) -> impl Iterator<Item = Entity> + '_
Get an iterator over the entities overlapping the
axis aligned bounding region that contains the provided circle
NOTE: for best optimization of the iterator use for_each
rather than a
for loop
pub fn clear(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpatialGrid
impl RefUnwindSafe for SpatialGrid
impl Send for SpatialGrid
impl Sync for SpatialGrid
impl Unpin for SpatialGrid
impl UnwindSafe for SpatialGrid
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<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