From 2d42625184cd70e954fe6ef8dc6c95a23e13b9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 25 Aug 2020 12:58:40 +0200 Subject: [PATCH] Revert "bug with Tween.is_active, fixes #39760" This reverts commit 8ef40b930641baa0206528ed7461334c5227758a. --- scene/animation/tween.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 965239819653..795accd8507f 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -689,7 +689,7 @@ void Tween::_tween_process(float p_delta) { } // Are all of the tweens complete? - int any_unfinished = 0; + bool all_finished = true; // For each tween we wish to interpolate... for (List::Element *E = interpolates.front(); E; E = E->next()) { @@ -697,13 +697,13 @@ void Tween::_tween_process(float p_delta) { // Get the data from it InterpolateData &data = E->get(); + // Track if we hit one that isn't finished yet + all_finished = all_finished && data.finish; + // Is the data not active or already finished? No need to go any further if (!data.active || data.finish) continue; - // Track if we hit one that isn't finished yet - any_unfinished++; - // Get the target object for this interpolation Object *object = ObjectDB::get_instance(data.id); if (object == NULL) @@ -787,17 +787,18 @@ void Tween::_tween_process(float p_delta) { emit_signal("tween_completed", object, NodePath(Vector(), data.key, false)); // If we are not repeating the tween, remove it - if (!repeat) { + if (!repeat) call_deferred("_remove_by_uid", data.uid); - any_unfinished--; - } + } else if (!repeat) { + // Check whether all tweens are finished + all_finished = all_finished && data.finish; } } // One less update left to go pending_update--; // If all tweens are completed, we no longer need to be active - if (any_unfinished == 0) { + if (all_finished) { set_active(false); emit_signal("tween_all_completed"); }