diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index ce213da6a70..2b820070d66 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -276,10 +276,14 @@ namespace Godot /// Returns a normalized value considering the given range. /// This is the opposite of . /// - /// The interpolated value. + /// The start value for interpolation. /// The destination value for interpolation. - /// A value on the range of 0.0 to 1.0, representing the amount of interpolation. - /// The resulting value of the inverse interpolation. + /// The interpolated value. + /// + /// The resulting value of the inverse interpolation. + /// The returned value will be between 0.0 and 1.0 if is + /// between and (inclusive). + /// public static real_t InverseLerp(real_t from, real_t to, real_t weight) { return (weight - from) / (to - from); @@ -515,6 +519,21 @@ namespace Godot return rad * _rad2DegConst; } + /// + /// Maps a from [, ] + /// to [, ]. + /// + /// The value to map. + /// The start value for the input interpolation. + /// The destination value for the input interpolation. + /// The start value for the output interpolation. + /// The destination value for the output interpolation. + /// The resulting mapped value mapped. + public static real_t RangeLerp(real_t value, real_t inFrom, real_t inTo, real_t outFrom, real_t outTo) + { + return Lerp(outFrom, outTo, InverseLerp(inFrom, inTo, value)); + } + /// /// Rounds to the nearest whole number, /// with halfway cases rounded towards the nearest multiple of two.