Expose ColliderSet::{take_modified, take_removed} (#887)

These are practically necessary when working without a PhysicsPipeline
This commit is contained in:
Benjamin Saunders
2025-11-02 09:35:53 -08:00
committed by GitHub
parent 57c4e912a6
commit a68d0c600b
4 changed files with 29 additions and 8 deletions

View File

@@ -5,7 +5,8 @@ use crate::geometry::{Collider, ColliderChanges, ColliderHandle, ColliderParent}
use crate::math::Isometry;
use std::ops::{Index, IndexMut};
pub(crate) type ModifiedColliders = ModifiedObjects<ColliderHandle, Collider>;
/// A set of modified colliders
pub type ModifiedColliders = ModifiedObjects<ColliderHandle, Collider>;
impl HasModifiedFlag for Collider {
#[inline]
@@ -71,7 +72,16 @@ impl ColliderSet {
}
}
pub(crate) fn take_modified(&mut self) -> ModifiedColliders {
/// Fetch the set of colliders modified since the last call to
/// `take_modified`
///
/// Provides a value that can be passed to the `modified_colliders` argument
/// of [`BroadPhaseBvh::update`](crate::geometry::BroadPhaseBvh::update).
///
/// Should not be used if this [`ColliderSet`] will be used with a
/// [`PhysicsPipeline`](crate::pipeline::PhysicsPipeline), which handles
/// broadphase updates automatically.
pub fn take_modified(&mut self) -> ModifiedColliders {
std::mem::take(&mut self.modified_colliders)
}
@@ -79,7 +89,15 @@ impl ColliderSet {
self.modified_colliders = modified;
}
pub(crate) fn take_removed(&mut self) -> Vec<ColliderHandle> {
/// Fetch the set of colliders removed since the last call to `take_removed`
///
/// Provides a value that can be passed to the `removed_colliders` argument
/// of [`BroadPhaseBvh::update`](crate::geometry::BroadPhaseBvh::update).
///
/// Should not be used if this [`ColliderSet`] will be used with a
/// [`PhysicsPipeline`](crate::pipeline::PhysicsPipeline), which handles
/// broadphase updates automatically.
pub fn take_removed(&mut self) -> Vec<ColliderHandle> {
std::mem::take(&mut self.removed_colliders)
}

View File

@@ -4,7 +4,7 @@ pub use self::broad_phase_bvh::{BroadPhaseBvh, BvhOptimizationStrategy};
pub use self::broad_phase_pair_event::{BroadPhasePairEvent, ColliderPair};
pub use self::collider::{Collider, ColliderBuilder};
pub use self::collider_components::*;
pub use self::collider_set::ColliderSet;
pub use self::collider_set::{ColliderSet, ModifiedColliders};
pub use self::contact_pair::{
ContactData, ContactManifoldData, ContactPair, IntersectionPair, SimdSolverContact,
SolverContact, SolverFlags,
@@ -211,7 +211,6 @@ impl ContactForceEvent {
}
}
pub(crate) use self::collider_set::ModifiedColliders;
pub(crate) use self::narrow_phase::ContactManifoldIndex;
pub use parry::shape::*;