1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-17 14:11:06 +00:00

Added smoothstep built-in function

(cherry picked from commit 514a3fb96a)
This commit is contained in:
Chaosus
2019-03-19 14:39:43 +03:00
committed by Hein-Pieter van Braam-Stewart
parent 340bf6e80c
commit 6ab01490f5
10 changed files with 91 additions and 1 deletions

View File

@@ -261,6 +261,16 @@ namespace Godot
return (real_t)Math.Sinh(s);
}
public static real_t SmoothStep(real_t from, real_t to, real_t weight)
{
if (IsEqualApprox(from, to))
{
return from;
}
real_t x = Clamp((weight - from) / (to - from), (real_t)0.0, (real_t)1.0);
return x * x * (3 - 2 * x);
}
public static real_t Sqrt(real_t s)
{
return (real_t)Math.Sqrt(s);