[−][src]Trait oxygengine_physics_2d::prelude::BodySet
Trait implemented by sets of bodies.
A set of bodies maps a body handle to a body instance. In addition, it must maintain a set of
body handle of bodies that have been removed (see the pop_removal_event
method for details).
Associated Types
type Handle: BodyHandle
Type of a body handle identifying a body in this set.
Required methods
fn get(&self, handle: Self::Handle) -> Option<&(dyn Body<N> + 'static)>
Gets a reference to the body identified by handle
.
fn get_mut(
&mut self,
handle: Self::Handle
) -> Option<&mut (dyn Body<N> + 'static)>
&mut self,
handle: Self::Handle
) -> Option<&mut (dyn Body<N> + 'static)>
Gets a mutable reference to the body identified by handle
.
fn contains(&self, handle: Self::Handle) -> bool
Check if this set contains a body identified by handle
.
fn foreach(&self, f: &mut dyn FnMut(Self::Handle, &(dyn Body<N> + 'static)))
Iterate through all the bodies on this set, applying the closure f
on them.
fn foreach_mut(
&mut self,
f: &mut dyn FnMut(Self::Handle, &mut (dyn Body<N> + 'static))
)
&mut self,
f: &mut dyn FnMut(Self::Handle, &mut (dyn Body<N> + 'static))
)
Mutable iterate through all the bodies on this set, applying the closure f
on them.
fn pop_removal_event(&mut self) -> Option<Self::Handle>
Gets the handle of one body that has been removed.
A body set must keep track (using typically a stack or a queue) of every body that has been removed from it. This is used by nphysics to perform some internal cleanup actions, or physical actions like waking bodies touching one that has been removed.
This method should return a removed body handle only once.
Provided methods
fn get_pair(
&self,
handle1: Self::Handle,
handle2: Self::Handle
) -> (Option<&(dyn Body<N> + 'static)>, Option<&(dyn Body<N> + 'static)>)
&self,
handle1: Self::Handle,
handle2: Self::Handle
) -> (Option<&(dyn Body<N> + 'static)>, Option<&(dyn Body<N> + 'static)>)
Gets a reference to the two bodies identified by handle1
and handle2
.
Both handles are allowed to be equal.
Implementors
impl<N> BodySet<N> for DefaultBodySet<N> where
N: RealField,
[src]
N: RealField,
type Handle = Index
fn get(
&self,
handle: <DefaultBodySet<N> as BodySet<N>>::Handle
) -> Option<&(dyn Body<N> + 'static)>
[src]
&self,
handle: <DefaultBodySet<N> as BodySet<N>>::Handle
) -> Option<&(dyn Body<N> + 'static)>
fn get_mut(
&mut self,
handle: <DefaultBodySet<N> as BodySet<N>>::Handle
) -> Option<&mut (dyn Body<N> + 'static)>
[src]
&mut self,
handle: <DefaultBodySet<N> as BodySet<N>>::Handle
) -> Option<&mut (dyn Body<N> + 'static)>
fn contains(&self, handle: <DefaultBodySet<N> as BodySet<N>>::Handle) -> bool
[src]
fn foreach(
&self,
f: &mut dyn FnMut(<DefaultBodySet<N> as BodySet<N>>::Handle, &(dyn Body<N> + 'static))
)
[src]
&self,
f: &mut dyn FnMut(<DefaultBodySet<N> as BodySet<N>>::Handle, &(dyn Body<N> + 'static))
)
fn foreach_mut(
&mut self,
f: &mut dyn FnMut(<DefaultBodySet<N> as BodySet<N>>::Handle, &mut (dyn Body<N> + 'static))
)
[src]
&mut self,
f: &mut dyn FnMut(<DefaultBodySet<N> as BodySet<N>>::Handle, &mut (dyn Body<N> + 'static))
)
fn pop_removal_event(
&mut self
) -> Option<<DefaultBodySet<N> as BodySet<N>>::Handle>
[src]
&mut self
) -> Option<<DefaultBodySet<N> as BodySet<N>>::Handle>