diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-01-27 14:20:14 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-01-27 14:20:14 +0100 |
| commit | 8ff2bcc3ec666805aceedaa477bde89f2a577d1c (patch) | |
| tree | 5cb00c1003e75924b7ac9ad6dbbd509052a3def2 /src/geometry | |
| parent | a3324f85131215613b7a8acb60d9ee9517cc803d (diff) | |
| download | rapier-8ff2bcc3ec666805aceedaa477bde89f2a577d1c.tar.gz rapier-8ff2bcc3ec666805aceedaa477bde89f2a577d1c.tar.bz2 rapier-8ff2bcc3ec666805aceedaa477bde89f2a577d1c.zip | |
Add all the missing docs.
Diffstat (limited to 'src/geometry')
| -rw-r--r-- | src/geometry/collider.rs | 18 | ||||
| -rw-r--r-- | src/geometry/collider_set.rs | 2 | ||||
| -rw-r--r-- | src/geometry/contact_pair.rs | 16 | ||||
| -rw-r--r-- | src/geometry/mod.rs | 2 |
4 files changed, 38 insertions, 0 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index 8924a3d..fa2da68 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -191,6 +191,7 @@ impl ColliderBuilder { self.density.unwrap_or(default_density) } + /// Initialize a new collider builder with a compound shape. pub fn compound(shapes: Vec<(Isometry<Real>, SharedShape)>) -> Self { Self::new(SharedShape::compound(shapes)) } @@ -357,29 +358,46 @@ impl ColliderBuilder { )) } + /// Initializes a new collider builder with a 2D convex polygon or 3D convex polyhedron + /// obtained after computing the convex-hull of the given points. pub fn convex_hull(points: &[Point<Real>]) -> Option<Self> { SharedShape::convex_hull(points).map(|cp| Self::new(cp)) } + /// Initializes a new collider builder with a round 2D convex polygon or 3D convex polyhedron + /// obtained after computing the convex-hull of the given points. The shape is dilated + /// by a sphere of radius `border_radius`. pub fn round_convex_hull(points: &[Point<Real>], border_radius: Real) -> Option<Self> { SharedShape::round_convex_hull(points, border_radius).map(|cp| Self::new(cp)) } + /// Creates a new collider builder that is a convex polygon formed by the + /// given polyline assumed to be convex (no convex-hull will be automatically + /// computed). #[cfg(feature = "dim2")] pub fn convex_polyline(points: Vec<Point<Real>>) -> Option<Self> { SharedShape::convex_polyline(points).map(|cp| Self::new(cp)) } + /// Creates a new collider builder that is a round convex polygon formed by the + /// given polyline assumed to be convex (no convex-hull will be automatically + /// computed). The polygon shape is dilated by a sphere of radius `border_radius`. #[cfg(feature = "dim2")] pub fn round_convex_polyline(points: Vec<Point<Real>>, border_radius: Real) -> Option<Self> { SharedShape::round_convex_polyline(points, border_radius).map(|cp| Self::new(cp)) } + /// Creates a new collider builder that is a convex polyhedron formed by the + /// given triangle-mesh assumed to be convex (no convex-hull will be automatically + /// computed). #[cfg(feature = "dim3")] pub fn convex_mesh(points: Vec<Point<Real>>, indices: &[[u32; 3]]) -> Option<Self> { SharedShape::convex_mesh(points, indices).map(|cp| Self::new(cp)) } + /// Creates a new collider builder that is a round convex polyhedron formed by the + /// given triangle-mesh assumed to be convex (no convex-hull will be automatically + /// computed). The triangle mesh shape is dilated by a sphere of radius `border_radius`. #[cfg(feature = "dim3")] pub fn round_convex_mesh( points: Vec<Point<Real>>, diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs index b40c7f3..3ceb297 100644 --- a/src/geometry/collider_set.rs +++ b/src/geometry/collider_set.rs @@ -12,10 +12,12 @@ use std::ops::{Index, IndexMut}; pub struct ColliderHandle(pub(crate) crate::data::arena::Index); impl ColliderHandle { + /// Converts this handle into its (index, generation) components. pub fn into_raw_parts(self) -> (usize, u64) { self.0.into_raw_parts() } + /// Reconstructs an handle from its (index, generation) components. pub fn from_raw_parts(id: usize, generation: u64) -> Self { Self(crate::data::arena::Index::from_raw_parts(id, generation)) } diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs index cbb012a..f6c4989 100644 --- a/src/geometry/contact_pair.rs +++ b/src/geometry/contact_pair.rs @@ -62,6 +62,7 @@ pub struct ContactPair { /// /// All contact manifold contain themselves contact points between the colliders. pub manifolds: Vec<ContactManifold>, + /// Is there any active contact in this contact pair? pub has_any_active_contact: bool, pub(crate) workspace: Option<ContactManifoldsWorkspace>, } @@ -95,18 +96,31 @@ pub struct ContactManifoldData { // contact preparation method. /// Flags used to control some aspects of the constraints solver for this contact manifold. pub solver_flags: SolverFlags, + /// The world-space contact normal shared by all the contact in this contact manifold. pub normal: Vector<Real>, + /// The contacts that will be seen by the constraints solver for computing forces. pub solver_contacts: Vec<SolverContact>, } +/// A contact seen by the constraints solver for computing forces. #[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct SolverContact { + /// The world-space contact point. pub point: Point<Real>, + /// The distance between the two original contacts points along the contact normal. + /// If negative, this is measures the penetration depth. pub dist: Real, + /// The effective friction coefficient at this contact point. pub friction: Real, + /// The effective restitution coefficient at this contact point. pub restitution: Real, + /// The artificially add relative velocity at the contact point. + /// This is set to zero by default. Set to a non-zero value to + /// simulate, e.g., conveyor belts. pub surface_velocity: Vector<Real>, + /// Associated contact data used to warm-start the constraints + /// solver. pub data: ContactData, } @@ -132,6 +146,8 @@ impl ContactManifoldData { } } + /// Number of actives contacts, i.e., contacts that will be seen by + /// the constraints solver. #[inline] pub fn num_active_contacts(&self) -> usize { self.solver_contacts.len() diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index d1c4161..861763e 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -14,7 +14,9 @@ pub use self::pair_filter::{ContactPairFilter, IntersectionPairFilter, PairFilte pub use parry::query::TrackedContact; +/// A contact between two colliders. pub type Contact = parry::query::TrackedContact<ContactData>; +/// A contact manifold between two colliders. pub type ContactManifold = parry::query::ContactManifold<ContactManifoldData, ContactData>; /// A segment shape. pub type Segment = parry::shape::Segment; |
