diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-02-10 11:56:51 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-02-11 15:58:46 +0100 |
| commit | 5b80c4efbf93ad1294c9d3d390d8c8f090681b0e (patch) | |
| tree | d82cef06b68a078dc23230e4e596021f7071b9b7 /src/dynamics/joint/joint.rs | |
| parent | 3be866920657f7a13a49486795e06f14d92f4969 (diff) | |
| download | rapier-5b80c4efbf93ad1294c9d3d390d8c8f090681b0e.tar.gz rapier-5b80c4efbf93ad1294c9d3d390d8c8f090681b0e.tar.bz2 rapier-5b80c4efbf93ad1294c9d3d390d8c8f090681b0e.zip | |
Start experimenting with a generic joint implementation for joint drives.
Diffstat (limited to 'src/dynamics/joint/joint.rs')
| -rw-r--r-- | src/dynamics/joint/joint.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/dynamics/joint/joint.rs b/src/dynamics/joint/joint.rs index 9fe6488..31c5e0a 100644 --- a/src/dynamics/joint/joint.rs +++ b/src/dynamics/joint/joint.rs @@ -1,6 +1,8 @@ #[cfg(feature = "dim3")] use crate::dynamics::RevoluteJoint; -use crate::dynamics::{BallJoint, FixedJoint, JointHandle, PrismaticJoint, RigidBodyHandle}; +use crate::dynamics::{ + BallJoint, FixedJoint, GenericJoint, JointHandle, PrismaticJoint, RigidBodyHandle, +}; #[derive(Copy, Clone)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] @@ -17,6 +19,7 @@ pub enum JointParams { /// A revolute joint that removes all degrees of degrees of freedom between the affected /// bodies except for the translation along one axis. RevoluteJoint(RevoluteJoint), + GenericJoint(GenericJoint), } impl JointParams { @@ -26,8 +29,9 @@ impl JointParams { JointParams::BallJoint(_) => 0, JointParams::FixedJoint(_) => 1, JointParams::PrismaticJoint(_) => 2, + JointParams::GenericJoint(_) => 3, #[cfg(feature = "dim3")] - JointParams::RevoluteJoint(_) => 3, + JointParams::RevoluteJoint(_) => 4, } } @@ -49,6 +53,15 @@ impl JointParams { } } + /// Gets a reference to the underlying generic joint, if `self` is one. + pub fn as_generic_joint(&self) -> Option<&GenericJoint> { + if let JointParams::GenericJoint(j) = self { + Some(j) + } else { + None + } + } + /// Gets a reference to the underlying prismatic joint, if `self` is one. pub fn as_prismatic_joint(&self) -> Option<&PrismaticJoint> { if let JointParams::PrismaticJoint(j) = self { @@ -81,6 +94,12 @@ impl From<FixedJoint> for JointParams { } } +impl From<GenericJoint> for JointParams { + fn from(j: GenericJoint) -> Self { + JointParams::GenericJoint(j) + } +} + #[cfg(feature = "dim3")] impl From<RevoluteJoint> for JointParams { fn from(j: RevoluteJoint) -> Self { |
