diff --git a/src/data/mod.rs b/src/data/mod.rs index 1a89f1e..c460414 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -2,7 +2,7 @@ pub use self::arena::{Arena, Index}; pub use self::coarena::Coarena; -pub(crate) use self::modified_objects::{HasModifiedFlag, ModifiedObjects}; +pub use self::modified_objects::{HasModifiedFlag, ModifiedObjects}; pub mod arena; mod coarena; diff --git a/src/data/modified_objects.rs b/src/data/modified_objects.rs index 6ac85c6..3615f7d 100644 --- a/src/data/modified_objects.rs +++ b/src/data/modified_objects.rs @@ -9,7 +9,7 @@ use std::ops::Deref; /// be done for internal engine usage (like the physics pipeline). #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Clone, Debug)] -pub(crate) struct ModifiedObjects(Vec, PhantomData); +pub struct ModifiedObjects(Vec, PhantomData); impl Default for ModifiedObjects { fn default() -> Self { @@ -17,8 +17,11 @@ impl Default for ModifiedObjects { } } -pub(crate) trait HasModifiedFlag { +/// Objects that internally track a flag indicating whether they've been modified +pub trait HasModifiedFlag { + /// Whether the object has been modified fn has_modified_flag(&self) -> bool; + /// Mark object as modified fn set_modified_flag(&mut self); } @@ -30,6 +33,7 @@ impl Deref for ModifiedObjects { } impl ModifiedObjects { + /// Preallocate memory for `capacity` handles pub fn with_capacity(capacity: usize) -> Self { Self(Vec::with_capacity(capacity), PhantomData) } diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs index 31dc14a..3db5b4c 100644 --- a/src/geometry/collider_set.rs +++ b/src/geometry/collider_set.rs @@ -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; +/// A set of modified colliders +pub type ModifiedColliders = ModifiedObjects; 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 { + /// 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 { std::mem::take(&mut self.removed_colliders) } diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index 6547ad9..e7c97bb 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -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::*;