pub struct ColliderSet { /* private fields */ }Expand description
The world’s colliders, bucketed into a uniform grid for broadphase.
The grid’s cell size is the caller’s choice: it is a spatial hash bucket,
not a tile size. Cells near the typical collider size keep queries small;
much larger cells simply return more candidates, and much smaller cells make
each collider occupy more buckets. Either way the result is only a candidate
list — query reports colliders whose cells meet the
region, not colliders that actually overlap it.
Implementations§
Source§impl ColliderSet
impl ColliderSet
Sourcepub fn new(cell_size: f32) -> Self
pub fn new(cell_size: f32) -> Self
An empty set bucketed at cell_size world units per grid cell.
§Panics
If cell_size is not positive and finite — an authoring error, not a
runtime condition. A zero, negative, or non-finite cell size cannot
address a grid at all.
Sourcepub fn insert(&mut self, aabb: Aabb, flags: ColliderFlags) -> usize
pub fn insert(&mut self, aabb: Aabb, flags: ColliderFlags) -> usize
Inserts a world-space collider, bucketing it into every grid cell its box overlaps, and returns its index.
Sourcepub fn get(&self, index: usize) -> Option<&Collider>
pub fn get(&self, index: usize) -> Option<&Collider>
Borrows a collider by index, as returned by query.
Sourcepub fn query(&self, region: &Aabb) -> Vec<usize>
pub fn query(&self, region: &Aabb) -> Vec<usize>
Broadphase candidates: the indices of colliders bucketed into any grid
cell that region touches.
Each index appears exactly once, in ascending order, so a caller that breaks ties by “first candidate wins” behaves identically run to run.