diff --git a/src/dynamics/fixed_joint.rs b/src/dynamics/fixed_joint.rs index 3bfe9346..ebc46d8f 100644 --- a/src/dynamics/fixed_joint.rs +++ b/src/dynamics/fixed_joint.rs @@ -81,6 +81,11 @@ impl FixedJoint { self.data.set_local_anchor2(anchor2); self } + + /// Returns the locked axes that are set for the fixed joint. + pub fn locked_axes(&self) -> JointAxesMask { + self.data.locked_axes() + } } impl From for GenericJoint { diff --git a/src/dynamics/mod.rs b/src/dynamics/mod.rs index 1e112d96..def0974e 100644 --- a/src/dynamics/mod.rs +++ b/src/dynamics/mod.rs @@ -9,6 +9,7 @@ pub use self::rope_joint::*; use bevy::reflect::Reflect; use rapier::dynamics::CoefficientCombineRule as RapierCoefficientCombineRule; +pub use rapier::dynamics::{JointAxesMask, JointAxis}; #[cfg(feature = "dim3")] pub use self::spherical_joint::*; diff --git a/src/dynamics/prismatic_joint.rs b/src/dynamics/prismatic_joint.rs index 5d3f35e4..a551587e 100644 --- a/src/dynamics/prismatic_joint.rs +++ b/src/dynamics/prismatic_joint.rs @@ -86,6 +86,21 @@ impl PrismaticJoint { self } + /// Returns the locked axes that are set for the prismatic joint. + pub fn locked_axes(&self) -> JointAxesMask { + self.data.locked_axes() + } + + /// Allows you to set the locked axes for the prismatic joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_PRISMATIC_AXES`, then they won't have an effect. + pub fn set_locked_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_PRISMATIC_AXES, false); + self.data.lock_axes(filtered_axes); + self + } + /// The motor affecting the joint’s translational degree of freedom. #[must_use] pub fn motor(&self) -> Option<&JointMotor> { @@ -198,6 +213,16 @@ impl PrismaticJointBuilder { self } + /// Allows you to set the locked axes for the prismatic joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_PRISMATIC_AXES`, then they won't have an effect. + pub fn lock_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_PRISMATIC_AXES, false); + self.0.data.lock_axes(filtered_axes); + self + } + /// Set the spring-like model used by the motor to reach the desired target velocity and position. #[must_use] pub fn motor_model(mut self, model: MotorModel) -> Self { diff --git a/src/dynamics/revolute_joint.rs b/src/dynamics/revolute_joint.rs index 590c033c..8602b38f 100644 --- a/src/dynamics/revolute_joint.rs +++ b/src/dynamics/revolute_joint.rs @@ -77,6 +77,21 @@ impl RevoluteJoint { self } + /// Returns the locked axes that are set for the revolute joint. + pub fn locked_axes(&self) -> JointAxesMask { + self.data.locked_axes() + } + + /// Allows you to set the locked axes for the revolute joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_REVOLUTE_AXES`, then they won't have an effect. + pub fn set_locked_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_REVOLUTE_AXES, false); + self.data.lock_axes(filtered_axes); + self + } + /// The motor affecting the joint’s rotational degree of freedom. #[must_use] pub fn motor(&self) -> Option<&JointMotor> { @@ -189,6 +204,16 @@ impl RevoluteJointBuilder { self } + /// Allows you to set the locked axes for the revolute joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_REVOLUTE_AXES`, then they won't have an effect. + pub fn lock_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_REVOLUTE_AXES, false); + self.0.data.lock_axes(filtered_axes); + self + } + /// Set the spring-like model used by the motor to reach the desired target velocity and position. #[must_use] pub fn motor_model(mut self, model: MotorModel) -> Self { diff --git a/src/dynamics/rope_joint.rs b/src/dynamics/rope_joint.rs index cac1cb65..2bf254ef 100644 --- a/src/dynamics/rope_joint.rs +++ b/src/dynamics/rope_joint.rs @@ -83,6 +83,21 @@ impl RopeJoint { self } + /// Returns the locked axes that are set for the rope joint. + pub fn locked_axes(&self) -> JointAxesMask { + self.data.locked_axes() + } + + /// Allows you to set the locked axes for the rope joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_FIXED_AXES`, then they won't have an effect. + pub fn set_locked_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_FIXED_AXES, false); + self.data.lock_axes(filtered_axes); + self + } + /// The motor affecting the joint’s translational degree of freedom. #[must_use] pub fn motor(&self, axis: JointAxis) -> Option<&JointMotor> { @@ -225,6 +240,16 @@ impl RopeJointBuilder { self } + /// Allows you to set the locked axes for the rope joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_FIXED_AXES`, then they won't have an effect. + pub fn lock_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_FIXED_AXES, false); + self.0.data.lock_axes(filtered_axes); + self + } + /// Set the spring-like model used by the motor to reach the desired target velocity and position. #[must_use] pub fn motor_model(mut self, model: MotorModel) -> Self { diff --git a/src/dynamics/spherical_joint.rs b/src/dynamics/spherical_joint.rs index a8619d53..a7150f55 100644 --- a/src/dynamics/spherical_joint.rs +++ b/src/dynamics/spherical_joint.rs @@ -63,6 +63,21 @@ impl SphericalJoint { self } + /// Returns the locked axes that are set for the spherical joint. + pub fn locked_axes(&self) -> JointAxesMask { + self.data.locked_axes() + } + + /// Allows you to set the locked axes for the spherical joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_SPHERICAL_AXES`, then they won't have an effect. + pub fn set_locked_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_SPHERICAL_AXES, false); + self.data.lock_axes(filtered_axes); + self + } + /// The motor affecting the joint’s rotational degree of freedom along the specified axis. #[must_use] pub fn motor(&self, axis: JointAxis) -> Option<&JointMotor> { @@ -169,6 +184,16 @@ impl SphericalJointBuilder { self } + /// Allows you to set the locked axes for the spherical joint + /// If the inputed axes enable any of the axes that are included in + /// `JointAxesMask::LOCKED_SPHERICAL_AXES`, then they won't have an effect. + pub fn lock_axes(mut self, axes: JointAxesMask) -> Self { + let mut filtered_axes = axes; + filtered_axes.set(JointAxesMask::LOCKED_SPHERICAL_AXES, false); + self.0.data.lock_axes(filtered_axes); + self + } + /// Set the spring-like model used by the motor to reach the desired target velocity and position. #[must_use] pub fn motor_model(mut self, axis: JointAxis, model: MotorModel) -> Self {