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 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