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 [`phys::Sys`]
6/// after new entity positions are calculated for the tick. So any position
7/// modifications outside the physics system will not be reflected here until
8/// the next tick when the physics system runs.
9///
10/// [`phys::Sys`]: veloren_common_systems::phys::Sys
11pub struct CachedSpatialGrid(pub SpatialGrid);
12
13impl Default for CachedSpatialGrid {
14 fn default() -> Self {
15 let lg2_cell_size = 5; // 32
16 let lg2_large_cell_size = 6; // 64
17 let radius_cutoff = 8;
18
19 let spatial_grid = SpatialGrid::new(lg2_cell_size, lg2_large_cell_size, radius_cutoff);
20
21 Self(spatial_grid)
22 }
23}