From 6af978871bb6a339b767ee87e493c5927f40ea19 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 28 Nov 2016 18:10:44 +0100 Subject: [PATCH] [libgdx] Better way to reset rotation direction on first frame. --- .../com/esotericsoftware/spine/AnimationState.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index ca6cabe8a..8673595ae 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -239,6 +239,9 @@ public class AnimationState { private void applyRotateTimeline (Timeline timeline, Skeleton skeleton, float time, float alpha, boolean setupPose, float[] timelinesRotation, int i, boolean firstFrame) { + + if (firstFrame) timelinesRotation[i] = 0; + if (alpha == 1) { timeline.apply(skeleton, 0, time, null, 1, setupPose, false); return; @@ -272,13 +275,9 @@ public class AnimationState { // Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. float r1 = setupPose ? bone.data.rotation : bone.rotation; float total, diff = r2 - r1; - if (diff == 0) { - if (firstFrame) { - timelinesRotation[i] = 0; - total = 0; - } else - total = timelinesRotation[i]; - } else { + if (diff == 0) + total = timelinesRotation[i]; + else { diff -= (16384 - (int)(16384.499999999996 - diff / 360)) * 360; float lastTotal, lastDiff; if (firstFrame) {