From 8d058fb4f4479a041fce1ff3379ba794856c9a3c Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Fri, 6 Dec 2024 12:43:55 -1000 Subject: [PATCH] [libgdx] Improved AnimationState behavior when paused. Ie, when time scale is 0 or `update(0)` is used. * Better check for whether the from entry has been applied at least once. * Discard the from entry if both the from and to entries haven't advanced. Ie, the mix hasn't started for the from entry. --- .../spine/AnimationState.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 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 e415c8496..4adcb55aa 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -180,16 +180,18 @@ public class AnimationState { from.animationLast = from.nextAnimationLast; from.trackLast = from.nextTrackLast; - // Require mixTime > 0 to ensure the mixing from entry was applied at least once. - if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { - // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). - 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); + 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; } - return finished; } from.trackTime += delta * from.timeScale;