Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added locked_axes() and set_locked_axes() methods for (some) joints #416

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/dynamics/fixed_joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixedJoint> for GenericJoint {
Expand Down
1 change: 1 addition & 0 deletions src/dynamics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
25 changes: 25 additions & 0 deletions src/dynamics/prismatic_joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions src/dynamics/revolute_joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions src/dynamics/rope_joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions src/dynamics/spherical_joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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 {
Expand Down