summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-20 22:23:43 +0200
committerGitHub <noreply@github.com>2020-07-20 22:23:43 +0200
commit80a8a36ca19f9d2bc9fad83f671d732ea339a93f (patch)
tree4c4ab26cfec7123304b7946ec97bfb35b3f340ac /scene
parent0a1dd5b6e40a628892d8dc95bd05f1dc72d8b4ab (diff)
parentd60617de101dbcde31ac67c34022a2153910d065 (diff)
Merge pull request #39801 from ChristopheLY/tween-bool-state
bug with Tween.is_active, fixes #39760
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/tween.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 854db5fee2..bd4396d680 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -701,21 +701,21 @@ void Tween::_tween_process(float p_delta) {
}
// Are all of the tweens complete?
- bool all_finished = true;
+ int any_unfinished = 0;
// For each tween we wish to interpolate...
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
// 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 == nullptr) {
@@ -802,17 +802,15 @@ void Tween::_tween_process(float p_delta) {
// If we are not repeating the tween, remove it
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 (all_finished) {
+ if (any_unfinished == 0) {
set_active(false);
emit_signal("tween_all_completed");
}