From 754b279b1ae0f51c6fd4dfb1c063103ad70ff9f0 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 7 Sep 2025 14:00:45 +0300 Subject: [PATCH] Optimize math::smootherstep somewhat --- libs/math/include/psemek/math/math.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/math/include/psemek/math/math.hpp b/libs/math/include/psemek/math/math.hpp index 8438e6c7..a19ef28d 100644 --- a/libs/math/include/psemek/math/math.hpp +++ b/libs/math/include/psemek/math/math.hpp @@ -225,7 +225,8 @@ namespace psemek::math template T smootherstep(T x) { - return x * x * x * (T{10} - x * (T{15} - T{6} * x)); + auto x2 = x * x; + return x * x2 * (T{10} - x * T{15} + x2 * T{6}); } template