diff --git a/math/MathUtil.cs b/math/MathUtil.cs index 6c5723a6..6f00b591 100644 --- a/math/MathUtil.cs +++ b/math/MathUtil.cs @@ -371,12 +371,12 @@ public static float SmoothRise0To1(float fX, float yshift, float xZero, float sp } public static float WyvillRise01(float fX) { - float d = 1 - fX * fX; - return (d >= 0) ? 1 - (d * d * d) : 0; + float d = MathUtil.Clamp(1.0f - fX*fX, 0.0f, 1.0f); + return 1 - (d * d * d); } public static double WyvillRise01(double fX) { - double d = 1 - fX * fX; - return (d >= 0) ? 1 - (d * d * d) : 0; + double d = MathUtil.Clamp(1.0 - fX*fX, 0.0, 1.0); + return 1 - (d * d * d); } public static float WyvillFalloff01(float fX) {