Optimize math::smootherstep somewhat

This commit is contained in:
Nikita Lisitsa 2025-09-07 14:00:45 +03:00
parent 08f62bdaf7
commit 754b279b1a

View file

@ -225,7 +225,8 @@ namespace psemek::math
template <typename T> template <typename T>
T smootherstep(T x) 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 <typename T> template <typename T>