[libgdx] Fixed physics when there is no translation.

This commit is contained in:
Nathan Sweet 2025-04-22 17:54:22 -04:00
parent 2a52efd437
commit 82ad1691c3

View File

@ -157,8 +157,7 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
z = Math.max(0, 1 - a / t); z = Math.max(0, 1 - a / t);
if (x) bone.worldX += (xOffset - xLag * z) * mix * data.x; if (x) bone.worldX += (xOffset - xLag * z) * mix * data.x;
if (y) bone.worldY += (yOffset - yLag * z) * mix * data.y; if (y) bone.worldY += (yOffset - yLag * z) * mix * data.y;
} else }
z = Math.max(0, 1 - a / t);
if (rotateOrShearX || scaleX) { if (rotateOrShearX || scaleX) {
float ca = atan2(bone.c, bone.a), c, s, mr = 0, dx = cx - bone.worldX, dy = cy - bone.worldY; float ca = atan2(bone.c, bone.a), c, s, mr = 0, dx = cx - bone.worldX, dy = cy - bone.worldY;
if (dx > qx) if (dx > qx)
@ -212,6 +211,7 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
rotateLag = rotateOffset - rs; rotateLag = rotateOffset - rs;
scaleLag = scaleOffset - ss; scaleLag = scaleOffset - ss;
} }
z = Math.max(0, 1 - a / t);
} }
remaining = a; remaining = a;
} }