From a064d7683244cfc7289bad42bd5d91e153ad690c Mon Sep 17 00:00:00 2001 From: badlogic Date: Tue, 30 Oct 2018 16:51:29 +0100 Subject: [PATCH] [csharp] Ported new fix for 0 timeScale not returning to setup pose. See #1194. --- spine-csharp/src/AnimationState.cs | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 8e77c41a58..ea6b47a27f 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -98,11 +98,11 @@ public void Update (float delta) { float nextTime = current.trackLast - next.delay; if (nextTime >= 0) { next.delay = 0; - next.trackTime = nextTime + (delta * next.timeScale); + next.trackTime = (nextTime / current.timeScale + delta) * next.timeScale; current.trackTime += currentDelta; SetCurrent(i, next, true); while (next.mixingFrom != null) { - next.mixTime += currentDelta; + next.mixTime += delta; next = next.mixingFrom; } continue; @@ -153,15 +153,8 @@ private bool UpdateMixingFrom (TrackEntry to, float delta) { return finished; } - // If to has 0 timeScale and is not the first entry, remove the mix and apply it one more time to return to the setup pose. - if (to.timeScale == 0 && to.mixingTo != null) { - to.timeScale = 1; - to.mixTime = 0; - to.mixDuration = 0; - } - from.trackTime += delta * from.timeScale; - to.mixTime += delta * to.timeScale; + to.mixTime += delta; return false; } @@ -514,8 +507,10 @@ public TrackEntry AddAnimation (int trackIndex, string animationName, bool loop, /// for a track. If the track is empty, it is equivalent to calling . /// /// delay Seconds to begin this animation after the start of the previous animation. If <= 0, uses the duration of the - /// previous track entry minus any mix duration plus the specifieddelay.If the previous entry is - /// looping, its next loop completion is used instead of the duration. + /// previous track entry minus any mix duration (from the ) plus the + /// specifieddelay (ie the mix ends at (delay = 0) or before (delay < 0) the previous + /// track entry duration). If the previous entry is looping, its next loop completion is used + /// instead of the duration. /// /// A track entry to allow further customization of animation playback. References to the track entry must not be kept /// after @@ -782,7 +777,7 @@ public void Reset () { /// /// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing /// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the - /// track entry will become the current track entry. + /// track entry will become the current track entry. affects the delay. public float Delay { get { return delay; } set { delay = value; } } /// @@ -842,8 +837,15 @@ public float AnimationTime { } /// - /// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or + /// Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower or /// faster. Defaults to 1. + /// + /// is not affected by track entry time scale, so may need to + // be adjusted to match the animation speed. + /// + /// When using with a delay <= 0, note the + /// { is set using the mix duration from the , assuming time scale to be 1. If + /// the time scale is not 1, the delay may need to be adjusted. /// public float TimeScale { get { return timeScale; } set { timeScale = value; } } @@ -897,7 +899,8 @@ public bool IsComplete { /// In that case, the mixDuration must be set before is next called. /// /// When using with a - /// delay less than or equal to 0, note the is set using the mix duration from the + /// delay less than or equal to 0, note the is set using the mix duration from the , + /// not a mix duration set afterward. /// /// ///