aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/joint/generic_joint.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-06-23 16:23:39 +0200
committerSébastien Crozet <developer@crozet.re>2022-07-03 13:55:41 +0200
commit5063f3bb4fec2716f78a208552ee260f22428840 (patch)
treeb5665abb9c97469354c8c4dfd1a3fca21057ce16 /src/dynamics/joint/generic_joint.rs
parentcd0be8c076c69b88bb1848de72228225eeccb52d (diff)
downloadrapier-5063f3bb4fec2716f78a208552ee260f22428840.tar.gz
rapier-5063f3bb4fec2716f78a208552ee260f22428840.tar.bz2
rapier-5063f3bb4fec2716f78a208552ee260f22428840.zip
Add the ability to disable contacts between two rigid-bodies attached by joints
Diffstat (limited to 'src/dynamics/joint/generic_joint.rs')
-rw-r--r--src/dynamics/joint/generic_joint.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/dynamics/joint/generic_joint.rs b/src/dynamics/joint/generic_joint.rs
index b3277e9..1cf96cb 100644
--- a/src/dynamics/joint/generic_joint.rs
+++ b/src/dynamics/joint/generic_joint.rs
@@ -206,6 +206,8 @@ pub struct GenericJoint {
///
/// Note that the mostor must also be explicitly enabled by the `motors` bitmask.
pub motors: [JointMotor; SPATIAL_DIM],
+ /// Are contacts between the attached rigid-bodies enabled?
+ pub contacts_enabled: bool,
}
impl Default for GenericJoint {
@@ -219,6 +221,7 @@ impl Default for GenericJoint {
coupled_axes: JointAxesMask::empty(),
limits: [JointLimits::default(); SPATIAL_DIM],
motors: [JointMotor::default(); SPATIAL_DIM],
+ contacts_enabled: true,
}
}
}
@@ -275,6 +278,17 @@ impl GenericJoint {
self
}
+ /// Are contacts between the attached rigid-bodies enabled?
+ pub fn contacts_enabled(&self) -> bool {
+ self.contacts_enabled
+ }
+
+ /// Sets whether contacts between the attached rigid-bodies are enabled.
+ pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
+ self.contacts_enabled = enabled;
+ self
+ }
+
/// The principal (local X) axis of this joint, expressed in the first rigid-body’s local-space.
#[must_use]
pub fn local_axis1(&self) -> UnitVector<Real> {
@@ -481,8 +495,9 @@ impl GenericJoint {
}
/// Create generic joints using the builder pattern.
-#[derive(Copy, Clone, Debug)]
-pub struct GenericJointBuilder(GenericJoint);
+#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
+#[derive(Copy, Clone, Debug, PartialEq)]
+pub struct GenericJointBuilder(pub GenericJoint);
impl GenericJointBuilder {
/// Creates a new generic joint builder.
@@ -498,6 +513,13 @@ impl GenericJointBuilder {
self
}
+ /// Sets whether contacts between the attached rigid-bodies are enabled.
+ #[must_use]
+ pub fn contacts_enabled(mut self, enabled: bool) -> Self {
+ self.0.contacts_enabled = enabled;
+ self
+ }
+
/// Sets the joint’s frame, expressed in the first rigid-body’s local-space.
#[must_use]
pub fn local_frame1(mut self, local_frame: Isometry<Real>) -> Self {