diff options
author | Silc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com> | 2023-05-17 07:03:45 +0900 |
---|---|---|
committer | Silc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com> | 2023-05-17 07:03:45 +0900 |
commit | e09c3d81260a0549549aaa3ec3696110490ebf00 (patch) | |
tree | e828e5430c5309b0585d13c9ca085eb127a89ed1 | |
parent | 9f12e7b52d944281a39b7d3a33de6700c76cc23a (diff) | |
download | redot-engine-e09c3d81260a0549549aaa3ec3696110490ebf00.tar.gz |
Optimize Tween calculations by caching some divisions
-rw-r--r-- | scene/animation/easing_equations.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/scene/animation/easing_equations.h b/scene/animation/easing_equations.h index a5af7dea54..1b9c378b4f 100644 --- a/scene/animation/easing_equations.h +++ b/scene/animation/easing_equations.h @@ -78,7 +78,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace sine @@ -104,7 +105,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace quint @@ -130,7 +132,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace quart @@ -157,7 +160,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace quad @@ -197,7 +201,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace expo @@ -264,7 +269,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace elastic @@ -293,7 +299,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace cubic @@ -322,7 +329,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace circ @@ -356,14 +364,16 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return in(t * 2, b, c / 2, d); } - return out(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return out(t * 2 - d, b + h, h, d); } static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace bounce @@ -398,7 +408,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { if (t < d / 2) { return out(t * 2, b, c / 2, d); } - return in(t * 2 - d, b + c / 2, c / 2, d); + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); } }; // namespace back |