Struct CollisionManager

Source
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>

Source

pub fn new() -> Self

Creates a new collision manager.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new collision manager with the capacity of expected bodies specified.

Source

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.

Source

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.

Source

pub fn replace_collider(&mut self, index: usize, collider: C)

Replaces the existing collider at the specified index by a new collider.

Source

pub fn replace_body(&mut self, index: usize, body: Body<C>)

Replaces the existing body at the specified index by a new body.

Source

pub fn remove_collider(&mut self, index: usize)

Removes an existing collider, so the index is usable for a new collect again.

Source

pub fn remove_body(&mut self, index: usize)

Removes an existing body, so the index is usable for a new body again.

Source

pub fn collider(&self, index: usize) -> &C

Get the collider at the sepcified index.

Source

pub fn collider_mut(&mut self, index: usize) -> &mut C

Get the collider at the sepcified index as mutable.

Source

pub fn body(&self, index: usize) -> &Body<C>

Get the body at the sepcified index.

Source

pub fn body_mut(&mut self, index: usize) -> &mut Body<C>

Get the body at the sepcified index as mutable.

Source

pub fn find_static_collision(&self, collider: &C) -> Option<S>

Checks for a static collision with collider and returns the index.

Source

pub fn find_dynamic_collision(&self, collider: &C) -> Option<D>

Checks for a dynamic collision with collider and returns the index.

Source

pub fn find_collision(&self, collider: &C) -> Option<ObjectIndex<S, D>>

Checks for any collision with collider and returns the index.

Source

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.

Auto Trait Implementations§

§

impl<C, S, D> Freeze for CollisionManager<C, S, D>

§

impl<C, S, D> RefUnwindSafe for CollisionManager<C, S, D>

§

impl<C, S, D> Send for CollisionManager<C, S, D>
where D: Send, C: Send, S: Send,

§

impl<C, S, D> Sync for CollisionManager<C, S, D>
where D: Sync, C: Sync, S: Sync,

§

impl<C, S, D> Unpin for CollisionManager<C, S, D>
where D: Unpin, C: Unpin, S: Unpin,

§

impl<C, S, D> UnwindSafe for CollisionManager<C, S, D>
where D: UnwindSafe, C: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.