From f1e0f0f728758a9b5b93ae99e96db8f50c18b083 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Thu, 13 Mar 2025 12:45:38 -0400 Subject: [PATCH] Fixed animation not being mixed out in some cases. Repro, with any animation playing: state.setAnimation(0, "shoot", true).setMixDuration(0.2f); state.apply(skeleton); Reverts 8d058fb4f4479a041fce1ff3379ba794856c9a3c. We can't know when it's safe to discard a queued animation. Users should avoid queuing animations they don't actually want. Prefer `to.nextTrackLast != -1` for "was applied", as `to.mixTime > 0` is user writable and not quite the same. --- .../spine/AnimationState.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 9cf287ffb..a9290ed94 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -180,18 +180,16 @@ public class AnimationState { from.animationLast = from.nextAnimationLast; from.trackLast = from.nextTrackLast; - if (to.nextTrackLast != -1) { // The from entry was applied at least once. - boolean discard = to.mixTime == 0 && from.mixTime == 0; // Discard the from entry when neither have advanced yet. - if (to.mixTime >= to.mixDuration || discard) { - // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. - if (from.totalAlpha == 0 || to.mixDuration == 0 || discard) { - to.mixingFrom = from.mixingFrom; - if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; - to.interruptAlpha = from.interruptAlpha; - queue.end(from); - } - return finished; + // The from entry was applied at least once and the mix is complete. + if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) { + // Mixing is complete for all entries before the from entry or the mix is instantaneous. + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; + to.interruptAlpha = from.interruptAlpha; + queue.end(from); } + return finished; } from.trackTime += delta * from.timeScale;