[libgdx] PhysicsConstraint, cannot reuse wind/gravity values for rotation.

This commit is contained in:
Nathan Sweet 2025-09-10 20:09:20 -06:00
parent 099c3ba096
commit abb436213c

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, ax = 0, ay = 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, qx = data.limit * delta,
qy = qx * Math.abs(skeleton.scaleY);
qx *= Math.abs(skeleton.scaleX);
if (x || y) {
if (x) {
@ -140,8 +140,8 @@ public class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
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 ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
float ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
do {
if (x) {
xVelocity += (ax - xOffset * e) * m;
@ -196,10 +196,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, g = f * p.gravity;
ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX;
ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY;
}
float ax = p.wind * skeleton.windX - p.gravity * skeleton.gravityX;
float ay = p.wind * skeleton.windY + p.gravity * skeleton.gravityY;
float rs = rotateOffset, ss = scaleOffset, h = l / f;
while (true) {
a -= t;