From c695ef29b865b60631caa02f46d1bcdc1dbce059 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Thu, 18 Mar 2021 22:01:59 +0100 Subject: [PATCH] 3.2 - Fix Tween.is_active() always true after stop() and then start() Fix #39760 & #39801 These issues were resolved in master branch (and closed) but are still active in the 3.2 branch. --- scene/animation/tween.cpp | 15 +++++++++++++++ scene/animation/tween.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 1b927723fc..1829414144 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -855,8 +855,22 @@ bool Tween::start() { return true; } + pending_update++; + for (List::Element *E = interpolates.front(); E; E = E->next()) { + InterpolateData &data = E->get(); + data.active = true; + } + pending_update--; + // We want to be activated set_active(true); + + // Don't resume from current position if stop_all() function has been used + if (was_stopped) { + seek(0); + } + was_stopped = false; + return true; } @@ -925,6 +939,7 @@ bool Tween::stop(Object *p_object, StringName p_key) { bool Tween::stop_all() { // We no longer need to be active since all tweens have been stopped set_active(false); + was_stopped = true; // For each interpolation... pending_update++; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 2033faf6c0..fd1a6d7e98 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -115,7 +115,7 @@ private: float speed_scale; mutable int pending_update; int uid; - + bool was_stopped = false; List interpolates; struct PendingCommand {