veloren_common/cached_spatial_grid.rs
1use crate::util::SpatialGrid;
2
3/// Cached [`SpatialGrid`] for reuse within different ecs systems during a tick.
4/// This is used to accelerate queries on entities within a specific area.
5/// Updated within the physics system [`crate::sys::phys::Sys`] after new entity
6/// positions are calculated for the tick. So any position modifications outside
7/// the physics system will not be reflected here until the next tick when the
8/// physics system runs.
9pub struct CachedSpatialGrid(pub SpatialGrid);
10
11impl Default for CachedSpatialGrid {
12 fn default() -> Self {
13 let lg2_cell_size = 5; // 32
14 let lg2_large_cell_size = 6; // 64
15 let radius_cutoff = 8;
16
17 let spatial_grid = SpatialGrid::new(lg2_cell_size, lg2_large_cell_size, radius_cutoff);
18
19 Self(spatial_grid)
20 }
21}