mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix Generic6DOFJoint3D not respecting angular limits
A 6DOF constraint that constrains all rotation axis in combination with a body that has some of its rotation axis locked would not constrain the rotation in the unlocked axis.
Fixes #109018
(cherry picked from commit 9bb8d12c1b
)
This commit is contained in:
parent
0234028f7c
commit
a3b924766d
1 changed files with 15 additions and 2 deletions
|
@ -143,9 +143,22 @@ public:
|
||||||
mInvI2 = inBody2.IsDynamic()? inBody2.GetMotionProperties()->GetInverseInertiaForRotation(inRotation2) : Mat44::sZero();
|
mInvI2 = inBody2.IsDynamic()? inBody2.GetMotionProperties()->GetInverseInertiaForRotation(inRotation2) : Mat44::sZero();
|
||||||
|
|
||||||
// Calculate effective mass: K^-1 = (J M^-1 J^T)^-1
|
// Calculate effective mass: K^-1 = (J M^-1 J^T)^-1
|
||||||
if (!mEffectiveMass.SetInversed3x3(mInvI1 + mInvI2))
|
Mat44 inertia_sum = mInvI1 + mInvI2;
|
||||||
|
if (!mEffectiveMass.SetInversed3x3(inertia_sum))
|
||||||
|
{
|
||||||
|
// If a column is zero, the axis is locked and we set the column to identity.
|
||||||
|
// This does not matter because any impulse will always be multiplied with mInvI1 or mInvI2 which will result in zero for the locked coordinate.
|
||||||
|
Vec4 zero = Vec4::sZero();
|
||||||
|
if (inertia_sum.GetColumn4(0) == zero)
|
||||||
|
inertia_sum.SetColumn4(0, Vec4(1, 0, 0, 0));
|
||||||
|
if (inertia_sum.GetColumn4(1) == zero)
|
||||||
|
inertia_sum.SetColumn4(1, Vec4(0, 1, 0, 0));
|
||||||
|
if (inertia_sum.GetColumn4(2) == zero)
|
||||||
|
inertia_sum.SetColumn4(2, Vec4(0, 0, 1, 0));
|
||||||
|
if (!mEffectiveMass.SetInversed3x3(inertia_sum))
|
||||||
Deactivate();
|
Deactivate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Deactivate this constraint
|
/// Deactivate this constraint
|
||||||
inline void Deactivate()
|
inline void Deactivate()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue