mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-13 12:14:18 +01:00
Add NearEqual for vectors.
This commit is contained in:
parent
d10043a69a
commit
5cdcb9288e
2 changed files with 16 additions and 1 deletions
|
|
@ -75,7 +75,7 @@ public readonly struct ApplicationRules(
|
|||
{
|
||||
var modelValue = model.Parameters[flag];
|
||||
var gameValue = game.Parameters[flag];
|
||||
if ((modelValue.InternalQuadruple - gameValue.InternalQuadruple).LengthSquared() < 1e-9f)
|
||||
if (modelValue.NearEqual(gameValue))
|
||||
baseFlags &= ~flag;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,3 +48,18 @@ public readonly struct CustomizeParameterValue
|
|||
public override string ToString()
|
||||
=> _data.ToString();
|
||||
}
|
||||
|
||||
public static class VectorExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
public static bool NearEqual(this Vector3 lhs, Vector3 rhs, float eps = 1e-9f)
|
||||
=> (lhs - rhs).LengthSquared() < eps;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
public static bool NearEqual(this Vector4 lhs, Vector4 rhs, float eps = 1e-9f)
|
||||
=> (lhs - rhs).LengthSquared() < eps;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
public static bool NearEqual(this CustomizeParameterValue lhs, CustomizeParameterValue rhs, float eps = 1e-9f)
|
||||
=> NearEqual(lhs.InternalQuadruple, rhs.InternalQuadruple, eps);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue