From deca6bb92fe6ab84df6ba5f432998ae87373214e Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 23 Nov 2016 16:37:08 +0100 Subject: [PATCH 1/3] [libgdx] Reset to setup pose when trackEnd is reached. --- .../com/esotericsoftware/spine/AnimationState.java | 14 ++++++++------ .../com/esotericsoftware/spine/SkeletonViewer.java | 8 ++++++-- 2 files changed, 14 insertions(+), 8 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 924e3fdf5..c51f561f8 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -108,9 +108,7 @@ public class AnimationState { } continue; } - updateMixingFrom(current, delta); } else { - updateMixingFrom(current, delta); // Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { tracks.set(i, null); @@ -119,6 +117,7 @@ public class AnimationState { continue; } } + updateMixingFrom(current, delta); current.trackTime += currentDelta; } @@ -158,7 +157,10 @@ public class AnimationState { // Apply mixing from entries first. float mix = current.alpha; - if (current.mixingFrom != null) mix *= applyMixingFrom(current, skeleton); + if (current.mixingFrom != null) + mix *= applyMixingFrom(current, skeleton); + else if (current.trackTime >= current.trackEnd) // + mix = 0; // Set to setup pose the last time the entry will be applied. // Apply current entry. float animationLast = current.animationLast, animationTime = current.getAnimationTime(); @@ -750,10 +752,10 @@ public class AnimationState { /** The track time in seconds when this animation will be removed from the track. Defaults to the animation * {@link Animation#duration} for non-looping animations and the highest float possible for looping animations. If the track * end time is reached, no other animations are queued for playback, and mixing from any previous animations is complete, - * then the track is cleared, leaving skeletons in their previous pose. + * then the properties keyed by the animation are set to the setup pose and the track is cleared. *

- * It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} to mix the skeletons back to the - * setup pose, rather than leaving them in their previous pose. */ + * It may be desired to use {@link AnimationState#addEmptyAnimation(int, float, float)} to mix the properties back to the + * setup pose over time, rather than have it happen instantly. */ public float getTrackEnd () { return trackEnd; } diff --git a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java index 27d06409b..23d16c81e 100644 --- a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java +++ b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java @@ -227,10 +227,8 @@ public class SkeletonViewer extends ApplicationAdapter { state.setEmptyAnimation(track, 0); entry = state.addAnimation(track, ui.animationList.getSelected(), ui.loopCheckbox.isChecked(), 0); entry.setMixDuration(ui.mixSlider.getValue()); - entry.setTrackEnd(Integer.MAX_VALUE); } else { entry = state.setAnimation(track, ui.animationList.getSelected(), ui.loopCheckbox.isChecked()); - entry.setTrackEnd(Integer.MAX_VALUE); } entry.setAlpha(ui.alphaSlider.getValue()); } @@ -705,6 +703,12 @@ public class SkeletonViewer extends ApplicationAdapter { } void render () { + if (state.getCurrent(ui.trackButtons.getCheckedIndex()) == null) { + ui.animationList.getSelection().setProgrammaticChangeEvents(false); + ui.animationList.setSelected(null); + ui.animationList.getSelection().setProgrammaticChangeEvents(true); + } + statusLabel.pack(); if (minimizeButton.isChecked()) statusLabel.setPosition(10, 25, Align.bottom | Align.left); From 6d7217d44c998197db415a6e9a4a9fd2ba676c96 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 23 Nov 2016 16:52:17 +0100 Subject: [PATCH 2/3] [libgdx] Fixed AnimationStateTests. It now takes one extra frame for a track to be cleared when trackEnd is reached. --- .../src/com/esotericsoftware/spine/AnimationStateTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java index e0bb84c58..b66dccb41 100644 --- a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java +++ b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java @@ -650,8 +650,8 @@ public class AnimationStateTests { expect(0, "end", 0.8f, 0.9f), // expect(0, "dispose", 0.8f, 0.9f), // - expect(-1, "end", 0.1f, 0.9f), // - expect(-1, "dispose", 0.1f, 0.9f) // + expect(-1, "end", 0.2f, 1), // + expect(-1, "dispose", 0.2f, 1) // ); state.addAnimation(0, "events1", false, 0); run(0.1f, 10, new TestListener() { From 020f55700400fa3ecb07940147e14ff3bde46531 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 23 Nov 2016 16:58:53 +0100 Subject: [PATCH 3/3] [libgdx] Fixed losing mixingFrom when calling setAnimation twice. closes #761 --- .../src/com/esotericsoftware/spine/AnimationState.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 c51f561f8..734c6e38d 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -410,11 +410,11 @@ public class AnimationState { if (current != null) { if (current.nextTrackLast == -1) { // Don't mix from an entry that was never applied. - tracks.set(trackIndex, null); + tracks.set(trackIndex, current.mixingFrom); queue.interrupt(current); queue.end(current); disposeNext(current); - current = null; + current = current.mixingFrom; } else disposeNext(current); }