| 1 |
diff --git a/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h b/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h |
| 2 |
index ec84776a46..387c0d9737 100644 |
| 3 |
--- a/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h |
| 4 |
+++ b/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h |
| 5 |
@@ -143,8 +143,21 @@ public: |
| 6 |
mInvI2 = inBody2.IsDynamic()? inBody2.GetMotionProperties()->GetInverseInertiaForRotation(inRotation2) : Mat44::sZero(); |
| 7 |
|
| 8 |
// Calculate effective mass: K^-1 = (J M^-1 J^T)^-1 |
| 9 |
- if (!mEffectiveMass.SetInversed3x3(mInvI1 + mInvI2)) |
| 10 |
- Deactivate(); |
| 11 |
+ Mat44 inertia_sum = mInvI1 + mInvI2; |
| 12 |
+ if (!mEffectiveMass.SetInversed3x3(inertia_sum)) |
| 13 |
+ { |
| 14 |
+ // If a column is zero, the axis is locked and we set the column to identity. |
| 15 |
+ // This does not matter because any impulse will always be multiplied with mInvI1 or mInvI2 which will result in zero for the locked coordinate. |
| 16 |
+ Vec4 zero = Vec4::sZero(); |
| 17 |
+ if (inertia_sum.GetColumn4(0) == zero) |
| 18 |
+ inertia_sum.SetColumn4(0, Vec4(1, 0, 0, 0)); |
| 19 |
+ if (inertia_sum.GetColumn4(1) == zero) |
| 20 |
+ inertia_sum.SetColumn4(1, Vec4(0, 1, 0, 0)); |
| 21 |
+ if (inertia_sum.GetColumn4(2) == zero) |
| 22 |
+ inertia_sum.SetColumn4(2, Vec4(0, 0, 1, 0)); |
| 23 |
+ if (!mEffectiveMass.SetInversed3x3(inertia_sum)) |
| 24 |
+ Deactivate(); |
| 25 |
+ } |
| 26 |
} |
| 27 |
|
| 28 |
/// Deactivate this constraint |