mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:45:41 +00:00
Inline float arithmetic, don't cast
This commit is contained in:
parent
778d8c6cf1
commit
37c7b74379
@ -16,7 +16,9 @@
|
||||
/// </returns>
|
||||
public static float Lerp(float value, float target, float alpha)
|
||||
{
|
||||
return (float)Lerp(value * 1.0, target, alpha);
|
||||
// rookie mistake: a + t * (b - a)
|
||||
// "precise" method: (1 - t) * a + t * b
|
||||
return ((1.0f - alpha) * value) + (alpha * target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -121,6 +121,6 @@ public static class SingleExtensions
|
||||
/// <returns><paramref name="value" /> rounded to the nearest multiple of <paramref name="nearest" />.</returns>
|
||||
public static float Round(this float value, float nearest)
|
||||
{
|
||||
return (float)((double)value).Round(nearest);
|
||||
return MathF.Round(value / nearest) * nearest;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user