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