use glam::Vec2;
use rapier2d::{
dynamics::GenericJoint as RGenericJoint,
prelude::{JointAxis, JointEnabled, JointLimits, JointMotor, MotorModel, Real, UnitVector},
};
pub use rapier2d::dynamics::JointAxesMask;
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct GenericJoint {
pub data: RGenericJoint,
}
impl GenericJoint {
#[must_use]
pub fn new(locked_axes: JointAxesMask) -> Self {
Self {
data: RGenericJoint::new(locked_axes),
}
}
pub fn is_enabled(&self) -> bool {
self.data.enabled == JointEnabled::Enabled
}
pub fn set_enabled(&mut self, enabled: bool) {
self.data.set_enabled(enabled);
}
pub fn lock_axes(&mut self, axes: JointAxesMask) -> &mut Self {
self.data = *self.data.lock_axes(axes);
self
}
pub fn set_local_frame1(&mut self, local_frame: (Vec2, f32)) -> &mut Self {
self.data.set_local_frame1(local_frame.into());
self
}
pub fn set_local_frame2(&mut self, local_frame: (Vec2, f32)) -> &mut Self {
self.data.set_local_frame2(local_frame.into());
self
}
#[must_use]
pub fn local_axis1(&self) -> Vec2 {
self.data.local_axis1().into()
}
pub fn set_local_axis1(&mut self, local_axis: Vec2) -> &mut Self {
self.data
.set_local_axis1(UnitVector::new_normalize(local_axis.into()));
self
}
#[must_use]
pub fn local_axis2(&self) -> Vec2 {
self.data.local_axis2().into()
}
pub fn set_local_axis2(&mut self, local_axis: Vec2) -> &mut Self {
self.data
.set_local_axis2(UnitVector::new_normalize(local_axis.into()));
self
}
#[must_use]
pub fn local_anchor1(&self) -> Vec2 {
self.data.local_anchor1().into()
}
pub fn set_local_anchor1(&mut self, anchor1: Vec2) -> &mut Self {
self.data.set_local_anchor1(anchor1.into());
self
}
#[must_use]
pub fn local_anchor2(&self) -> Vec2 {
self.data.local_anchor2().into()
}
pub fn set_local_anchor2(&mut self, anchor2: Vec2) -> &mut Self {
self.data.set_local_anchor2(anchor2.into());
self
}
pub fn contacts_enabled(&self) -> bool {
self.data.contacts_enabled()
}
pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
self.data.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn limits(&self, axis: JointAxis) -> Option<&JointLimits<Real>> {
self.data.limits(axis)
}
pub fn set_limits(&mut self, axis: JointAxis, limits: [Real; 2]) -> &mut Self {
self.data.set_limits(axis, limits);
self
}
#[must_use]
pub fn motor_model(&self, axis: JointAxis) -> Option<MotorModel> {
self.data.motor_model(axis)
}
pub fn set_motor_model(&mut self, axis: JointAxis, model: MotorModel) -> &mut Self {
self.data.set_motor_model(axis, model);
self
}
pub fn set_motor_velocity(
&mut self,
axis: JointAxis,
target_vel: Real,
factor: Real,
) -> &mut Self {
self.set_motor(
axis,
self.data.motors[axis as usize].target_pos,
target_vel,
0.0,
factor,
)
}
pub fn set_motor_position(
&mut self,
axis: JointAxis,
target_pos: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.set_motor(axis, target_pos, 0.0, stiffness, damping)
}
pub fn set_motor_max_force(&mut self, axis: JointAxis, max_force: Real) -> &mut Self {
self.data.motors[axis as usize].max_force = max_force;
self
}
#[must_use]
pub fn motor(&self, axis: JointAxis) -> Option<&JointMotor> {
self.data.motor(axis)
}
pub fn set_motor(
&mut self,
axis: JointAxis,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor(axis, target_pos, target_vel, stiffness, damping);
self
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct GenericJointBuilder(pub GenericJoint);
impl GenericJointBuilder {
#[must_use]
pub fn new(locked_axes: JointAxesMask) -> Self {
Self(GenericJoint::new(locked_axes))
}
#[must_use]
pub fn locked_axes(mut self, axes: JointAxesMask) -> Self {
self.0.data.locked_axes = axes;
self
}
#[must_use]
pub fn contacts_enabled(mut self, enabled: bool) -> Self {
self.0.data.contacts_enabled = enabled;
self
}
#[must_use]
pub fn local_frame1(mut self, local_frame: (Vec2, f32)) -> Self {
self.0.set_local_frame1(local_frame);
self
}
#[must_use]
pub fn local_frame2(mut self, local_frame: (Vec2, f32)) -> Self {
self.0.set_local_frame2(local_frame);
self
}
#[must_use]
pub fn local_axis1(mut self, local_axis: Vec2) -> Self {
self.0.set_local_axis1(local_axis);
self
}
#[must_use]
pub fn local_axis2(mut self, local_axis: Vec2) -> Self {
self.0.set_local_axis2(local_axis);
self
}
#[must_use]
pub fn local_anchor1(mut self, anchor1: Vec2) -> Self {
self.0.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(mut self, anchor2: Vec2) -> Self {
self.0.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn limits(mut self, axis: JointAxis, limits: [Real; 2]) -> Self {
self.0.set_limits(axis, limits);
self
}
#[must_use]
pub fn coupled_axes(mut self, axes: JointAxesMask) -> Self {
self.0.data.coupled_axes = axes;
self
}
#[must_use]
pub fn motor_model(mut self, axis: JointAxis, model: MotorModel) -> Self {
self.0.set_motor_model(axis, model);
self
}
#[must_use]
pub fn motor_velocity(mut self, axis: JointAxis, target_vel: Real, factor: Real) -> Self {
self.0.set_motor_velocity(axis, target_vel, factor);
self
}
#[must_use]
pub fn motor_position(
mut self,
axis: JointAxis,
target_pos: Real,
stiffness: Real,
damping: Real,
) -> Self {
self.0
.set_motor_position(axis, target_pos, stiffness, damping);
self
}
#[must_use]
pub fn set_motor(
mut self,
axis: JointAxis,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> Self {
self.0
.set_motor(axis, target_pos, target_vel, stiffness, damping);
self
}
#[must_use]
pub fn motor_max_force(mut self, axis: JointAxis, max_force: Real) -> Self {
self.0.set_motor_max_force(axis, max_force);
self
}
#[must_use]
pub fn build(self) -> GenericJoint {
self.0
}
}
impl From<GenericJointBuilder> for GenericJoint {
fn from(val: GenericJointBuilder) -> Self {
val.0
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(transparent)]
pub struct FixedJoint {
pub data: GenericJoint,
}
impl Default for FixedJoint {
fn default() -> Self {
FixedJoint::new()
}
}
impl FixedJoint {
#[must_use]
pub fn new() -> Self {
let data = GenericJointBuilder::new(JointAxesMask::LOCKED_FIXED_AXES).build();
Self { data }
}
pub fn contacts_enabled(&self) -> bool {
self.data.data.contacts_enabled
}
pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
self.data.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_frame1(&self) -> (Vec2, f32) {
self.data.data.local_frame1.into()
}
pub fn set_local_frame1(&mut self, local_frame: (Vec2, f32)) -> &mut Self {
self.data.set_local_frame1(local_frame);
self
}
#[must_use]
pub fn local_frame2(&self) -> (Vec2, f32) {
self.data.data.local_frame2.into()
}
pub fn set_local_frame2(&mut self, local_frame: (Vec2, f32)) -> &mut Self {
self.data.set_local_frame2(local_frame);
self
}
#[must_use]
pub fn local_anchor1(&self) -> Vec2 {
self.data.local_anchor1()
}
pub fn set_local_anchor1(&mut self, anchor1: Vec2) -> &mut Self {
self.data.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(&self) -> Vec2 {
self.data.local_anchor2()
}
pub fn set_local_anchor2(&mut self, anchor2: Vec2) -> &mut Self {
self.data.set_local_anchor2(anchor2);
self
}
}
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct FixedJointBuilder(pub FixedJoint);
impl FixedJointBuilder {
pub fn new() -> Self {
Self(FixedJoint::new())
}
#[must_use]
pub fn contacts_enabled(mut self, enabled: bool) -> Self {
self.0.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_frame1(mut self, local_frame: (Vec2, f32)) -> Self {
self.0.set_local_frame1(local_frame);
self
}
#[must_use]
pub fn local_frame2(mut self, local_frame: (Vec2, f32)) -> Self {
self.0.set_local_frame2(local_frame);
self
}
#[must_use]
pub fn local_anchor1(mut self, anchor1: Vec2) -> Self {
self.0.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(mut self, anchor2: Vec2) -> Self {
self.0.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn build(self) -> FixedJoint {
self.0
}
}
impl From<FixedJointBuilder> for GenericJoint {
fn from(val: FixedJointBuilder) -> Self {
val.0.data
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(transparent)]
pub struct PrismaticJoint {
pub data: GenericJoint,
}
impl PrismaticJoint {
pub fn new(axis: Vec2) -> Self {
let data = GenericJointBuilder::new(JointAxesMask::LOCKED_PRISMATIC_AXES)
.local_axis1(axis)
.local_axis2(axis)
.build();
Self { data }
}
pub fn data(&self) -> &GenericJoint {
&self.data
}
pub fn contacts_enabled(&self) -> bool {
self.data.contacts_enabled()
}
pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
self.data.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(&self) -> Vec2 {
self.data.local_anchor1()
}
pub fn set_local_anchor1(&mut self, anchor1: Vec2) -> &mut Self {
self.data.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(&self) -> Vec2 {
self.data.local_anchor2()
}
pub fn set_local_anchor2(&mut self, anchor2: Vec2) -> &mut Self {
self.data.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn local_axis1(&self) -> Vec2 {
self.data.local_axis1()
}
pub fn set_local_axis1(&mut self, axis1: Vec2) -> &mut Self {
self.data.set_local_axis1(axis1);
self
}
#[must_use]
pub fn local_axis2(&self) -> Vec2 {
self.data.local_axis2()
}
pub fn set_local_axis2(&mut self, axis2: Vec2) -> &mut Self {
self.data.set_local_axis2(axis2);
self
}
#[must_use]
pub fn motor(&self) -> Option<&JointMotor> {
self.data.motor(JointAxis::X)
}
pub fn set_motor_model(&mut self, model: MotorModel) -> &mut Self {
self.data.set_motor_model(JointAxis::X, model);
self
}
pub fn set_motor_velocity(&mut self, target_vel: Real, factor: Real) -> &mut Self {
self.data
.set_motor_velocity(JointAxis::X, target_vel, factor);
self
}
pub fn set_motor_position(
&mut self,
target_pos: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor_position(JointAxis::X, target_pos, stiffness, damping);
self
}
pub fn set_motor(
&mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor(JointAxis::X, target_pos, target_vel, stiffness, damping);
self
}
pub fn set_motor_max_force(&mut self, max_force: Real) -> &mut Self {
self.data.set_motor_max_force(JointAxis::X, max_force);
self
}
#[must_use]
pub fn limits(&self) -> Option<&JointLimits<Real>> {
self.data.limits(JointAxis::X)
}
pub fn set_limits(&mut self, limits: [Real; 2]) -> &mut Self {
self.data.set_limits(JointAxis::X, limits);
self
}
}
impl From<PrismaticJoint> for GenericJoint {
fn from(val: PrismaticJoint) -> Self {
val.data
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct PrismaticJointBuilder(pub PrismaticJoint);
impl PrismaticJointBuilder {
pub fn new(axis: Vec2) -> Self {
Self(PrismaticJoint::new(axis))
}
#[must_use]
pub fn contacts_enabled(mut self, enabled: bool) -> Self {
self.0.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(mut self, anchor1: Vec2) -> Self {
self.0.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(mut self, anchor2: Vec2) -> Self {
self.0.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn local_axis1(mut self, axis1: Vec2) -> Self {
self.0.set_local_axis1(axis1);
self
}
#[must_use]
pub fn local_axis2(mut self, axis2: Vec2) -> Self {
self.0.set_local_axis2(axis2);
self
}
#[must_use]
pub fn motor_model(mut self, model: MotorModel) -> Self {
self.0.set_motor_model(model);
self
}
#[must_use]
pub fn motor_velocity(mut self, target_vel: Real, factor: Real) -> Self {
self.0.set_motor_velocity(target_vel, factor);
self
}
#[must_use]
pub fn motor_position(mut self, target_pos: Real, stiffness: Real, damping: Real) -> Self {
self.0.set_motor_position(target_pos, stiffness, damping);
self
}
#[must_use]
pub fn set_motor(
mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> Self {
self.0.set_motor(target_pos, target_vel, stiffness, damping);
self
}
#[must_use]
pub fn motor_max_force(mut self, max_force: Real) -> Self {
self.0.set_motor_max_force(max_force);
self
}
#[must_use]
pub fn limits(mut self, limits: [Real; 2]) -> Self {
self.0.set_limits(limits);
self
}
#[must_use]
pub fn build(self) -> PrismaticJoint {
self.0
}
}
impl From<PrismaticJointBuilder> for GenericJoint {
fn from(val: PrismaticJointBuilder) -> Self {
val.0.into()
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(transparent)]
pub struct RevoluteJoint {
pub data: GenericJoint,
}
impl RevoluteJoint {
pub fn new() -> Self {
let data = GenericJointBuilder::new(JointAxesMask::LOCKED_REVOLUTE_AXES);
Self { data: data.build() }
}
pub fn data(&self) -> &GenericJoint {
&self.data
}
pub fn contacts_enabled(&self) -> bool {
self.data.contacts_enabled()
}
pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
self.data.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(&self) -> Vec2 {
self.data.local_anchor1()
}
pub fn set_local_anchor1(&mut self, anchor1: Vec2) -> &mut Self {
self.data.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(&self) -> Vec2 {
self.data.local_anchor2()
}
pub fn set_local_anchor2(&mut self, anchor2: Vec2) -> &mut Self {
self.data.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn motor(&self) -> Option<&JointMotor> {
self.data.motor(JointAxis::AngX)
}
pub fn set_motor_model(&mut self, model: MotorModel) -> &mut Self {
self.data.set_motor_model(JointAxis::AngX, model);
self
}
pub fn set_motor_velocity(&mut self, target_vel: Real, factor: Real) -> &mut Self {
self.data
.set_motor_velocity(JointAxis::AngX, target_vel, factor);
self
}
pub fn set_motor_position(
&mut self,
target_pos: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor_position(JointAxis::AngX, target_pos, stiffness, damping);
self
}
pub fn set_motor(
&mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor(JointAxis::AngX, target_pos, target_vel, stiffness, damping);
self
}
pub fn set_motor_max_force(&mut self, max_force: Real) -> &mut Self {
self.data.set_motor_max_force(JointAxis::AngX, max_force);
self
}
#[must_use]
pub fn limits(&self) -> Option<&JointLimits<Real>> {
self.data.limits(JointAxis::AngX)
}
pub fn set_limits(&mut self, limits: [Real; 2]) -> &mut Self {
self.data.set_limits(JointAxis::AngX, limits);
self
}
}
impl Default for RevoluteJoint {
fn default() -> Self {
Self::new()
}
}
impl From<RevoluteJoint> for GenericJoint {
fn from(val: RevoluteJoint) -> Self {
val.data
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct RevoluteJointBuilder(pub RevoluteJoint);
impl RevoluteJointBuilder {
pub fn new() -> Self {
Self(RevoluteJoint::new())
}
#[must_use]
pub fn contacts_enabled(mut self, enabled: bool) -> Self {
self.0.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(mut self, anchor1: Vec2) -> Self {
self.0.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(mut self, anchor2: Vec2) -> Self {
self.0.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn motor_model(mut self, model: MotorModel) -> Self {
self.0.set_motor_model(model);
self
}
#[must_use]
pub fn motor_velocity(mut self, target_vel: Real, factor: Real) -> Self {
self.0.set_motor_velocity(target_vel, factor);
self
}
#[must_use]
pub fn motor_position(mut self, target_pos: Real, stiffness: Real, damping: Real) -> Self {
self.0.set_motor_position(target_pos, stiffness, damping);
self
}
#[must_use]
pub fn motor(
mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> Self {
self.0.set_motor(target_pos, target_vel, stiffness, damping);
self
}
#[must_use]
pub fn motor_max_force(mut self, max_force: Real) -> Self {
self.0.set_motor_max_force(max_force);
self
}
#[must_use]
pub fn limits(mut self, limits: [Real; 2]) -> Self {
self.0.set_limits(limits);
self
}
#[must_use]
pub fn build(self) -> RevoluteJoint {
self.0
}
}
impl Default for RevoluteJointBuilder {
fn default() -> Self {
Self::new()
}
}
impl From<RevoluteJointBuilder> for GenericJoint {
fn from(val: RevoluteJointBuilder) -> Self {
val.0.into()
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(transparent)]
pub struct RopeJoint {
pub data: GenericJoint,
}
impl RopeJoint {
pub fn new() -> Self {
let data = GenericJointBuilder::new(JointAxesMask::FREE_FIXED_AXES)
.coupled_axes(JointAxesMask::LIN_AXES)
.build();
Self { data }
}
pub fn data(&self) -> &GenericJoint {
&self.data
}
pub fn contacts_enabled(&self) -> bool {
self.data.contacts_enabled()
}
pub fn set_contacts_enabled(&mut self, enabled: bool) -> &mut Self {
self.data.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(&self) -> Vec2 {
self.data.local_anchor1()
}
pub fn set_local_anchor1(&mut self, anchor1: Vec2) -> &mut Self {
self.data.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(&self) -> Vec2 {
self.data.local_anchor2()
}
pub fn set_local_anchor2(&mut self, anchor2: Vec2) -> &mut Self {
self.data.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn local_axis1(&self) -> Vec2 {
self.data.local_axis1()
}
pub fn set_local_axis1(&mut self, axis1: Vec2) -> &mut Self {
self.data.set_local_axis1(axis1);
self
}
#[must_use]
pub fn local_axis2(&self) -> Vec2 {
self.data.local_axis2()
}
pub fn set_local_axis2(&mut self, axis2: Vec2) -> &mut Self {
self.data.set_local_axis2(axis2);
self
}
#[must_use]
pub fn motor(&self, axis: JointAxis) -> Option<&JointMotor> {
self.data.motor(axis)
}
pub fn set_motor_model(&mut self, model: MotorModel) -> &mut Self {
self.data.set_motor_model(JointAxis::X, model);
self.data.set_motor_model(JointAxis::Y, model);
self
}
pub fn set_motor_velocity(&mut self, target_vel: Real, factor: Real) -> &mut Self {
self.data
.set_motor_velocity(JointAxis::X, target_vel, factor);
self.data
.set_motor_velocity(JointAxis::Y, target_vel, factor);
self
}
pub fn set_motor_position(
&mut self,
target_pos: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor_position(JointAxis::X, target_pos, stiffness, damping);
self.data
.set_motor_position(JointAxis::Y, target_pos, stiffness, damping);
self
}
pub fn set_motor(
&mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> &mut Self {
self.data
.set_motor(JointAxis::X, target_pos, target_vel, stiffness, damping);
self.data
.set_motor(JointAxis::Y, target_pos, target_vel, stiffness, damping);
self
}
pub fn set_motor_max_force(&mut self, max_force: Real) -> &mut Self {
self.data.set_motor_max_force(JointAxis::X, max_force);
self.data.set_motor_max_force(JointAxis::Y, max_force);
self
}
#[must_use]
pub fn limits(&self, axis: JointAxis) -> Option<&JointLimits<Real>> {
self.data.limits(axis)
}
pub fn set_limits(&mut self, limits: [Real; 2]) -> &mut Self {
self.data.set_limits(JointAxis::X, limits);
self.data.set_limits(JointAxis::Y, limits);
self
}
}
impl Default for RopeJoint {
fn default() -> Self {
Self::new()
}
}
impl From<RopeJoint> for GenericJoint {
fn from(val: RopeJoint) -> Self {
val.data
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct RopeJointBuilder(pub RopeJoint);
impl RopeJointBuilder {
pub fn new() -> Self {
Self(RopeJoint::new())
}
#[must_use]
pub fn contacts_enabled(mut self, enabled: bool) -> Self {
self.0.set_contacts_enabled(enabled);
self
}
#[must_use]
pub fn local_anchor1(mut self, anchor1: Vec2) -> Self {
self.0.set_local_anchor1(anchor1);
self
}
#[must_use]
pub fn local_anchor2(mut self, anchor2: Vec2) -> Self {
self.0.set_local_anchor2(anchor2);
self
}
#[must_use]
pub fn local_axis1(mut self, axis1: Vec2) -> Self {
self.0.set_local_axis1(axis1);
self
}
#[must_use]
pub fn local_axis2(mut self, axis2: Vec2) -> Self {
self.0.set_local_axis2(axis2);
self
}
#[must_use]
pub fn motor_model(mut self, model: MotorModel) -> Self {
self.0.set_motor_model(model);
self
}
#[must_use]
pub fn motor_velocity(mut self, target_vel: Real, factor: Real) -> Self {
self.0.set_motor_velocity(target_vel, factor);
self
}
#[must_use]
pub fn motor_position(mut self, target_pos: Real, stiffness: Real, damping: Real) -> Self {
self.0.set_motor_position(target_pos, stiffness, damping);
self
}
#[must_use]
pub fn set_motor(
mut self,
target_pos: Real,
target_vel: Real,
stiffness: Real,
damping: Real,
) -> Self {
self.0.set_motor(target_pos, target_vel, stiffness, damping);
self
}
#[must_use]
pub fn motor_max_force(mut self, max_force: Real) -> Self {
self.0.set_motor_max_force(max_force);
self
}
#[must_use]
pub fn limits(mut self, limits: [Real; 2]) -> Self {
self.0.set_limits(limits);
self
}
#[must_use]
pub fn build(self) -> RopeJoint {
self.0
}
}
impl From<RopeJointBuilder> for GenericJoint {
fn from(val: RopeJointBuilder) -> Self {
val.0.into()
}
}
impl Default for RopeJointBuilder {
fn default() -> Self {
Self::new()
}
}