pub struct CollisionManager<C: Collider, S, D> { /* private fields */ }Expand description
The collision manager, which manages collisions. Can contain multiple bodies and other colliders. Collisions between colliders are not checked.
Implementations§
Source§impl<C: Collider, S: Copy, D: Copy> CollisionManager<C, S, D>
impl<C: Collider, S: Copy, D: Copy> CollisionManager<C, S, D>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new collision manager with the capacity of expected bodies specified.
Sourcepub fn insert_collider(&mut self, collider: C, index: S) -> usize
pub fn insert_collider(&mut self, collider: C, index: S) -> usize
Inserts a new collider and returns its index. An object index needs to be specified.
Sourcepub fn insert_body(&mut self, body: Body<C>, index: D) -> usize
pub fn insert_body(&mut self, body: Body<C>, index: D) -> usize
Inserts a new body and returns its index. An object index needs to be specified.
Sourcepub fn replace_collider(&mut self, index: usize, collider: C)
pub fn replace_collider(&mut self, index: usize, collider: C)
Replaces the existing collider at the specified index by a new collider.
Sourcepub fn replace_body(&mut self, index: usize, body: Body<C>)
pub fn replace_body(&mut self, index: usize, body: Body<C>)
Replaces the existing body at the specified index by a new body.
Sourcepub fn remove_collider(&mut self, index: usize)
pub fn remove_collider(&mut self, index: usize)
Removes an existing collider, so the index is usable for a new collect again.
Sourcepub fn remove_body(&mut self, index: usize)
pub fn remove_body(&mut self, index: usize)
Removes an existing body, so the index is usable for a new body again.
Sourcepub fn collider_mut(&mut self, index: usize) -> &mut C
pub fn collider_mut(&mut self, index: usize) -> &mut C
Get the collider at the sepcified index as mutable.
Sourcepub fn body_mut(&mut self, index: usize) -> &mut Body<C>
pub fn body_mut(&mut self, index: usize) -> &mut Body<C>
Get the body at the sepcified index as mutable.
Sourcepub fn find_static_collision(&self, collider: &C) -> Option<S>
pub fn find_static_collision(&self, collider: &C) -> Option<S>
Checks for a static collision with collider and returns the index.
Sourcepub fn find_dynamic_collision(&self, collider: &C) -> Option<D>
pub fn find_dynamic_collision(&self, collider: &C) -> Option<D>
Checks for a dynamic collision with collider and returns the index.
Sourcepub fn find_collision(&self, collider: &C) -> Option<ObjectIndex<S, D>>
pub fn find_collision(&self, collider: &C) -> Option<ObjectIndex<S, D>>
Checks for any collision with collider and returns the index.
Sourcepub fn compute_collisions(
&self,
) -> ArrayLinkedList<Vec<IndexedCollisionInfo<C::Vector, S, D>>>
pub fn compute_collisions( &self, ) -> ArrayLinkedList<Vec<IndexedCollisionInfo<C::Vector, S, D>>>
Computes the collisions between all colliders of a body with all other colliders. Returns a list for each, which can be indexed by the specified index.