mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[libgdx] PhysicsConstraint fixes, bone control.
This commit is contained in:
parent
23729f8eee
commit
9ed46c4ee1
@ -48,7 +48,7 @@ public class PhysicsConstraint implements Updatable {
|
||||
|
||||
boolean active;
|
||||
|
||||
private final Skeleton skeleton;
|
||||
final Skeleton skeleton;
|
||||
float remaining, lastTime;
|
||||
final Vector2 temp = new Vector2();
|
||||
|
||||
@ -133,15 +133,40 @@ public class PhysicsConstraint implements Updatable {
|
||||
Object[] springs = this.springs.items;
|
||||
int springCount = this.springs.size;
|
||||
|
||||
remaining += lastTime - skeleton.time;
|
||||
remaining += Math.max(skeleton.time - lastTime, 0);
|
||||
lastTime = skeleton.time;
|
||||
while (remaining > 0.016f) {
|
||||
while (remaining >= 0.016f) {
|
||||
remaining -= 0.016f;
|
||||
for (int i = 0; i < springCount; i++)
|
||||
((Spring)springs[i]).update();
|
||||
for (int i = 0; i < nodeCount; i++)
|
||||
((Node)nodes[i]).update(this);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nodeCount; i++) {
|
||||
Node node = (Node)nodes[i];
|
||||
Object[] bones = node.bones;
|
||||
int ii = 0, nn = bones.length;
|
||||
if (mix == 1) {
|
||||
for (; ii < nn; ii++) {
|
||||
Bone bone = (Bone)bones[ii];
|
||||
bone.worldX = node.x;
|
||||
bone.worldY = node.y;
|
||||
bone.worldToLocal(temp.set(bone.worldX, bone.worldY));
|
||||
bone.ax = temp.x;
|
||||
bone.ay = temp.y;
|
||||
}
|
||||
} else {
|
||||
for (; ii < nn; ii++) {
|
||||
Bone bone = (Bone)bones[ii];
|
||||
bone.worldX = bone.worldX + (node.x - bone.worldX) * mix;
|
||||
bone.worldY = bone.worldY + (node.y - bone.worldY) * mix;
|
||||
bone.worldToLocal(temp.set(bone.worldX, bone.worldY));
|
||||
bone.ax = temp.x;
|
||||
bone.ay = temp.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Array<Node> getNodes () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user