[libgdx] Fixed skeleton wind and gravity.

This commit is contained in:
Nathan Sweet 2025-06-12 12:30:04 -04:00
parent 1702ff5139
commit 535a62051d

View File

@ -120,8 +120,8 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
ux = bx;
uy = by;
} else {
float a = remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1, m = 0, e = 0, qx = data.limit * delta,
qy = qx * Math.abs(skeleton.scaleY);
float a = remaining, i = p.inertia, f = skeleton.data.referenceScale, d = -1, m = 0, e = 0, ax = 0, ay = 0,
qx = data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
qx *= Math.abs(skeleton.scaleX);
if (x || y) {
if (x) {
@ -139,8 +139,9 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
d = (float)Math.pow(p.damping, 60 * t);
m = t * p.massInverse;
e = p.strength;
float w = f * p.wind * skeleton.scaleX, g = f * p.gravity * skeleton.scaleY,
ax = w * skeleton.windX + g * skeleton.gravityX, ay = w * skeleton.windY + g * skeleton.gravityY;
float w = f * p.wind, g = f * p.gravity;
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
do {
if (x) {
xVelocity += (ax - xOffset * e) * m;
@ -195,10 +196,11 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
d = (float)Math.pow(p.damping, 60 * t);
m = t * p.massInverse;
e = p.strength;
float w = f * p.wind, g = f * p.gravity;
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
}
float rs = rotateOffset, ss = scaleOffset, h = l / f,
ax = p.wind * skeleton.windX + p.gravity * skeleton.gravityX,
ay = p.wind * skeleton.windY + p.gravity * skeleton.gravityY;
float rs = rotateOffset, ss = scaleOffset, h = l / f;
while (true) {
a -= t;
if (scaleX) {