Explorar o código

[libgdx] PhysicsConstraint clean up.

Nathan Sweet hai 1 ano
pai
achega
ad71a986ad

+ 6 - 6
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PhysicsConstraint.java

@@ -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;
-						float d = (float)Math.pow(damping, 60 * t), h = l / f;
+						if (d == -1) d = (float)Math.pow(damping, 60 * t);
+						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;