[][src]Trait nphysics3d::object::ColliderSet

pub trait ColliderSet<N: RealField, Handle: BodyHandle>: CollisionObjectSet<N, CollisionObject = Collider<N, Handle>, CollisionObjectHandle = Self::Handle> {
    type Handle: ColliderHandle;
    fn get(&self, handle: Self::Handle) -> Option<&Collider<N, Handle>>;
fn get_mut(
        &mut self,
        handle: Self::Handle
    ) -> Option<&mut Collider<N, Handle>>;
fn contains(&self, handle: Self::Handle) -> bool;
fn foreach(&self, f: impl FnMut(Self::Handle, &Collider<N, Handle>));
fn foreach_mut(
        &mut self,
        f: impl FnMut(Self::Handle, &mut Collider<N, Handle>)
    );
fn pop_insertion_event(&mut self) -> Option<Self::Handle>;
fn pop_removal_event(
        &mut self
    ) -> Option<(Self::Handle, ColliderRemovalData<N, Handle>)>;
fn remove(
        &mut self,
        to_remove: Self::Handle
    ) -> Option<&mut ColliderRemovalData<N, Handle>>; fn get_pair(
        &self,
        handle1: Self::Handle,
        handle2: Self::Handle
    ) -> (Option<&Collider<N, Handle>>, Option<&Collider<N, Handle>>) { ... } }

Trait implemented by sets of colliders.

A set of colliders maps a collider handle to a collider instance. In addition, it must maintain a set of data related to colliders that have been inserted or removed (see the pop_insertion_event and pop_removal_event methods for details).

Associated Types

type Handle: ColliderHandle

Type of a collider handle identifying a collider in this set.

Loading content...

Required methods

fn get(&self, handle: Self::Handle) -> Option<&Collider<N, Handle>>

Gets a reference to the collider identified by handle.

fn get_mut(&mut self, handle: Self::Handle) -> Option<&mut Collider<N, Handle>>

Gets a mutable reference to the collider identified by handle.

fn contains(&self, handle: Self::Handle) -> bool

Check if this set contains a collider identified by handle.

fn foreach(&self, f: impl FnMut(Self::Handle, &Collider<N, Handle>))

Iterate through all the colliders on this set, applying the closure f on them.

fn foreach_mut(&mut self, f: impl FnMut(Self::Handle, &mut Collider<N, Handle>))

Mutable iterates through all the colliders on this set, applying the closure f on them.

fn pop_insertion_event(&mut self) -> Option<Self::Handle>

Gets the handle of one collider that has been inserted.

A collider set must keep track (using typically a stack or a queue) of every collider that has been inserted from it. This is used by nphysics to perform some internal setup actions, or physical actions like waking colliders touching one that has been inserted.

This method should return a removed collider handle only once.

fn pop_removal_event(
    &mut self
) -> Option<(Self::Handle, ColliderRemovalData<N, Handle>)>

Gets the handle and removal data of one collider that has been removed.

A collider set must keep track (using typically a stack or a queue) of every collider that has been removed from it. This is used by nphysics to perform some internal cleanup actions, or physical actions like waking colliders touching one that has been removed.

This method should return a removed collider handle and its associated ColliderRemovalData only once.

fn remove(
    &mut self,
    to_remove: Self::Handle
) -> Option<&mut ColliderRemovalData<N, Handle>>

Removes a collider from this set.

A collider can be removed automatically by nphysics when the collider it was attached too has been removed.

Loading content...

Provided methods

fn get_pair(
    &self,
    handle1: Self::Handle,
    handle2: Self::Handle
) -> (Option<&Collider<N, Handle>>, Option<&Collider<N, Handle>>)

Gets a reference to the two colliders identified by handle1 and handle2.

Both handles are allowed to be equal.

Loading content...

Implementors

impl<N: RealField, Handle: BodyHandle> ColliderSet<N, Handle> for DefaultColliderSet<N, Handle>[src]

type Handle = DefaultColliderHandle

Loading content...