Skip to content

Commit

Permalink
Fix 2D joint angle limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf committed Jun 16, 2023
1 parent db8eae5 commit 275217a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/constraints/joints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ pub trait Joint: Component + PositionConstraint + AngularConstraint {
let gradients = {
#[cfg(feature = "2d")]
{
let axis_vec2 = axis.truncate();
[axis_vec2, -axis_vec2]
// `axis.z` controls if the body should rotate counterclockwise or clockwise.
// The gradient has to be a 2D vector, so we use the y axis instead.
// This should work similarly, as `axis.x` and `axis.y` are normally 0 in 2D.
[Vector::Y * axis.z, Vector::NEG_Y * axis.z]
}
#[cfg(feature = "3d")]
{
Expand Down

0 comments on commit 275217a

Please sign in to comment.