pub struct Collisions { /* private fields */ }Expand description
The colliders of the entities that have a Collider and a
Transform, in a CollisionWorld: a resource that the engine
rebuilds each tick, in the system nadir::movement.
Systems query it through Collisions::world, whose answers are
collider indices: Collisions::entity turns them into entities, and
Collisions::index an entity into the index to ignore in a cast.
The tile grid is set here too.
What it holds during a tick:
- From
nadir::movementon, the colliders of this tick, each moved as its entity moved. nadir::triggerscopies every collider’s position from itsTransformbefore it looks for overlaps, so a system that moves an entity inMovementafter the engine’s movement, or inPostMovementbeforenadir::triggers, moves its collider too.- After that, and until the next tick’s
nadir::movement(in theInputandGameplaystages, and in frames), it is as the last tick left it. An entity despawned since still answers, and one spawned since is missing: check whatCollisions::entitygives withWorld::is_alive.
Implementations§
Source§impl Collisions
impl Collisions
Sourcepub fn new() -> Self
pub fn new() -> Self
No colliders and an empty tile grid, hashing in cells of
CollisionWorld::DEFAULT_CELL_SIZE.
Sourcepub fn with_cell_size(cell_size: f32) -> Self
pub fn with_cell_size(cell_size: f32) -> Self
No colliders and an empty tile grid, hashing in cells of
cell_size pixels: use at least twice the size of a typical
collider. Insert it as a resource to replace the engine’s.
§Panics
If cell_size is not a finite number above 0.
Sourcepub fn world(&self) -> &CollisionWorld
pub fn world(&self) -> &CollisionWorld
The collision world, for queries and casts.