Replace Lerp functions.
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Voile.Extensions
|
||||
{
|
||||
public static Vector2 Lerp(this Vector2 a, Vector2 b, double t)
|
||||
{
|
||||
return new Vector2(MathUtils.Lerp(a.X, b.X, t), MathUtils.Lerp(a.Y, b.Y, t));
|
||||
return new Vector2((float)MathUtils.Lerp(a.X, b.X, t), (float)MathUtils.Lerp(a.Y, b.Y, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Voile
|
||||
{
|
||||
public static class MathUtils
|
||||
{
|
||||
public static float Lerp(float a, float b, double t) => a + (b - a) * (float)t;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double LerpUnclamped(double a, double b, double t) => (a * (1d - t)) + (b * t);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float LerpUnclamped(float a, float b, float t) => (a * (1f - t)) + (b * t);
|
||||
|
||||
public static Color LerpColor(Color colorA, Color colorB, double t)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static double Lerp(double a, double b, double t) => t <= 0d ? a : t >= 1d ? b : LerpUnclamped(a, b, t);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static float Lerp(float a, float b, float t) => t <= 0f ? a : t >= 1f ? b : LerpUnclamped(a, b, t);
|
||||
|
||||
public static Color LerpColor(Color colorA, Color colorB, float t)
|
||||
{
|
||||
var r = Lerp(colorA.R, colorB.R, t);
|
||||
var g = Lerp(colorA.G, colorB.G, t);
|
||||
|
||||
Reference in New Issue
Block a user