Allow disabling colliders, rigid-bodies and impulse joints
This commit is contained in:
@@ -41,6 +41,14 @@ impl ColliderSet {
|
||||
self.colliders.iter().map(|(h, c)| (ColliderHandle(h), c))
|
||||
}
|
||||
|
||||
/// Iterate through all the enabled colliders on this set.
|
||||
pub fn iter_enabled(&self) -> impl Iterator<Item = (ColliderHandle, &Collider)> {
|
||||
self.colliders
|
||||
.iter()
|
||||
.map(|(h, c)| (ColliderHandle(h), c))
|
||||
.filter(|(_, c)| c.is_enabled())
|
||||
}
|
||||
|
||||
/// Iterates mutably through all the colliders on this set.
|
||||
#[cfg(not(feature = "dev-remove-slow-accessors"))]
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = (ColliderHandle, &mut Collider)> {
|
||||
@@ -52,6 +60,12 @@ impl ColliderSet {
|
||||
})
|
||||
}
|
||||
|
||||
/// Iterates mutably through all the enabled colliders on this set.
|
||||
#[cfg(not(feature = "dev-remove-slow-accessors"))]
|
||||
pub fn iter_enabled_mut(&mut self) -> impl Iterator<Item = (ColliderHandle, &mut Collider)> {
|
||||
self.iter_mut().filter(|(_, c)| c.is_enabled())
|
||||
}
|
||||
|
||||
/// The number of colliders on this set.
|
||||
pub fn len(&self) -> usize {
|
||||
self.colliders.len()
|
||||
@@ -268,6 +282,17 @@ impl ColliderSet {
|
||||
pub(crate) fn get_mut_internal(&mut self, handle: ColliderHandle) -> Option<&mut Collider> {
|
||||
self.colliders.get_mut(handle.0)
|
||||
}
|
||||
|
||||
// Just a very long name instead of `.get_mut` to make sure
|
||||
// this is really the method we wanted to use instead of `get_mut_internal`.
|
||||
pub(crate) fn get_mut_internal_with_modification_tracking(
|
||||
&mut self,
|
||||
handle: ColliderHandle,
|
||||
) -> Option<&mut Collider> {
|
||||
let result = self.colliders.get_mut(handle.0)?;
|
||||
Self::mark_as_modified(handle, result, &mut self.modified_colliders);
|
||||
Some(result)
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<crate::data::Index> for ColliderSet {
|
||||
|
||||
Reference in New Issue
Block a user