Skip to content

Commit

Permalink
fix sprin joint to use correct axis
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Jul 10, 2024
1 parent cda3862 commit c1b7de1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/joints/rapier_damped_spring_joint_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl RapierDampedSpringJoint2D {
let invalid_joint = Self {
rest_length: 0.0,
stiffness: 20.0,
damping: 1.5,
damping: 1.0,
base: RapierJointBase::default(),
};
let body_a_rid = body_a.get_base().get_rid();
Expand All @@ -54,14 +54,14 @@ impl RapierDampedSpringJoint2D {
vector_to_rapier(rapier_anchor_a),
vector_to_rapier(rapier_anchor_b),
20.0,
1.5,
1.0,
rest_length,
true,
);
Self {
rest_length,
stiffness: 20.0,
damping: 1.5,
damping: 1.0,
base: RapierJointBase::new(space_handle, space_rid, handle),
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/rapier_wrapper/joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ impl PhysicsEngine {
let mut joint = RevoluteJointBuilder::new()
.local_anchor1(Point { coords: anchor_1 })
.local_anchor2(Point { coords: anchor_2 })
.motor_model(MotorModel::ForceBased)
.contacts_enabled(!disable_collision);
if angular_limit_enabled {
joint = joint.limits([angular_limit_lower, angular_limit_upper]);
Expand Down Expand Up @@ -128,7 +127,10 @@ impl PhysicsEngine {
{
joint
.data
.set_motor_position(JointAxis::AngX, rest_length, stiffness, damping);
.set_motor_position(JointAxis::LinX, rest_length, stiffness, damping);
joint
.data
.set_motor_model(JointAxis::LinX, MotorModel::AccelerationBased);
}
}

Expand Down

0 comments on commit c1b7de1

Please sign in to comment.