summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-29 08:08:34 +0100
committerGitHub <noreply@github.com>2022-01-29 08:08:34 +0100
commitcb3d308f9695a2099fa109c6a29cc8a9e7e58422 (patch)
treeb3928d63c9e8a98a284cda447f27c0d3872cdde4 /scene
parent252ec22ff9fc2befd6b120fd40b0e008137a0392 (diff)
parent038977a985722036d4e2e7f90e0b477225955d80 (diff)
Merge pull request #57372 from KoBeWi/tween_freeze()
Better handle infinite Tween loops
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/tween.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 53ff3eeeae..a2fed718be 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -283,6 +283,10 @@ bool Tween::step(float p_delta) {
float step_delta = rem_delta;
step_active = false;
+#ifdef DEBUG_ENABLED
+ float prev_delta = rem_delta;
+#endif
+
for (Ref<Tweener> &tweener : tweeners.write[current_step]) {
// Modified inside Tweener.step().
float temp_delta = rem_delta;
@@ -312,6 +316,12 @@ bool Tween::step(float p_delta) {
start_tweeners();
}
}
+
+#ifdef DEBUG_ENABLED
+ if (Math::is_equal_approx(rem_delta, prev_delta) && running && loops <= 0) {
+ ERR_FAIL_V_MSG(false, "Infinite loop detected. Check set_loops() description for more info.");
+ }
+#endif
}
return true;