summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-09-24 13:21:55 +0200
committerGitHub <noreply@github.com>2021-09-24 13:21:55 +0200
commit5e4a71200e25811d8e570d87f08f0878dabb8bb9 (patch)
treec3271d3a6ec7b6647d97fcddc408f676718b21d7
parent32ab77ef8f537b2f2d0e4c6c0e6127ea9c2a20f4 (diff)
parent5c1195e456a168486c251340275ad8e9193873e9 (diff)
Merge pull request #53003 from KoBeWi/tween_0()
-rw-r--r--doc/classes/Tween.xml1
-rw-r--r--thirdparty/misc/easing_equations.cpp4
2 files changed, 5 insertions, 0 deletions
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index ede6e2fdd5..f94018c96b 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -86,6 +86,7 @@
[code]initial_value[/code] is the starting value of the interpolation.
[code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code].
[code]duration[/code] is the total time of the interpolation.
+ [b]Note:[/b] If [code]duration[/code] is equal to [code]0[/code], the method will always return the final value, regardless of [code]elapsed_time[/code] provided.
</description>
</method>
<method name="is_running">
diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp
index ce32c1a362..d164e3d560 100644
--- a/thirdparty/misc/easing_equations.cpp
+++ b/thirdparty/misc/easing_equations.cpp
@@ -312,6 +312,10 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
};
real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) {
+ if (d == 0) {
+ // Special case to avoid dividing by 0 in equations.
+ return b + c;
+ }
interpolater cb = interpolaters[p_trans_type][p_ease_type];
ERR_FAIL_COND_V(cb == NULL, b);