[libgdx] PhysicsConstraint clean up.

This commit is contained in:
Nathan Sweet 2024-03-03 20:29:11 -04:00
parent 30d92e1a14
commit ad71a986ad

View File

@ -150,7 +150,7 @@ public class PhysicsConstraint implements Updatable {
ux = bx; ux = bx;
uy = by; uy = by;
} else { } else {
float a = this.remaining, i = inertia, t = data.step, f = skeleton.data.referenceScale; float a = remaining, i = inertia, t = data.step, f = skeleton.data.referenceScale, d = -1;
if (x || y) { if (x || y) {
if (x) { if (x) {
xOffset += (ux - bx) * i; xOffset += (ux - bx) * i;
@ -161,8 +161,8 @@ public class PhysicsConstraint implements Updatable {
uy = by; uy = by;
} }
if (a >= t) { if (a >= t) {
d = (float)Math.pow(damping, 60 * t);
float m = massInverse * t, e = strength, w = wind * f, g = gravity * f; float m = massInverse * t, e = strength, w = wind * f, g = gravity * f;
float d = (float)Math.pow(damping, 60 * t);
do { do {
if (x) { if (x) {
xVelocity += (w - xOffset * e) * m; xVelocity += (w - xOffset * e) * m;
@ -199,10 +199,10 @@ public class PhysicsConstraint implements Updatable {
float r = l * bone.getWorldScaleX(); float r = l * bone.getWorldScaleX();
if (r > 0) scaleOffset += ((cx - bone.worldX) * c + (cy - bone.worldY) * s) * i / r; if (r > 0) scaleOffset += ((cx - bone.worldX) * c + (cy - bone.worldY) * s) * i / r;
} }
a = this.remaining; a = remaining;
if (a >= t) { if (a >= t) {
float m = massInverse * t, e = strength, w = wind, g = gravity; if (d == -1) d = (float)Math.pow(damping, 60 * t);
float d = (float)Math.pow(damping, 60 * t), h = l / f; float m = massInverse * t, e = strength, w = wind, g = gravity, h = l / f;
while (true) { while (true) {
a -= t; a -= t;
if (scaleX) { if (scaleX) {
@ -223,7 +223,7 @@ public class PhysicsConstraint implements Updatable {
} }
} }
} }
this.remaining = a; remaining = a;
} }
cx = bone.worldX; cx = bone.worldX;
cy = bone.worldY; cy = bone.worldY;