Skip to content

Commit be9f6b4

Browse files
committed
Merge pull request #111087 from jrouwe/issue_109018
[JoltPhysics] Fix Generic6DOFJoint3D not respecting angular limits
2 parents ef496a4 + 9bb8d12 commit be9f6b4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,21 @@ class RotationEulerConstraintPart
143143
mInvI2 = inBody2.IsDynamic()? inBody2.GetMotionProperties()->GetInverseInertiaForRotation(inRotation2) : Mat44::sZero();
144144

145145
// Calculate effective mass: K^-1 = (J M^-1 J^T)^-1
146-
if (!mEffectiveMass.SetInversed3x3(mInvI1 + mInvI2))
147-
Deactivate();
146+
Mat44 inertia_sum = mInvI1 + mInvI2;
147+
if (!mEffectiveMass.SetInversed3x3(inertia_sum))
148+
{
149+
// If a column is zero, the axis is locked and we set the column to identity.
150+
// This does not matter because any impulse will always be multiplied with mInvI1 or mInvI2 which will result in zero for the locked coordinate.
151+
Vec4 zero = Vec4::sZero();
152+
if (inertia_sum.GetColumn4(0) == zero)
153+
inertia_sum.SetColumn4(0, Vec4(1, 0, 0, 0));
154+
if (inertia_sum.GetColumn4(1) == zero)
155+
inertia_sum.SetColumn4(1, Vec4(0, 1, 0, 0));
156+
if (inertia_sum.GetColumn4(2) == zero)
157+
inertia_sum.SetColumn4(2, Vec4(0, 0, 1, 0));
158+
if (!mEffectiveMass.SetInversed3x3(inertia_sum))
159+
Deactivate();
160+
}
148161
}
149162

150163
/// Deactivate this constraint

0 commit comments

Comments
 (0)