From e0f46c2b38b3cde73cd6e480b176581c2960cb1a Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 17 Sep 2021 00:50:07 +0200 Subject: [PATCH] Add a special case for 0-time interpolations (cherry picked from commit 5c1195e456a168486c251340275ad8e9193873e9) --- thirdparty/misc/easing_equations.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp index af48aaf079b..52b31d1763a 100644 --- a/thirdparty/misc/easing_equations.cpp +++ b/thirdparty/misc/easing_equations.cpp @@ -312,6 +312,10 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] }; 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);