Skip to content

Commit

Permalink
test: fix draw fp2 utility
Browse files Browse the repository at this point in the history
  • Loading branch information
andywiecko committed Oct 9, 2024
1 parent 268137f commit 4b8a014
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,36 @@ public static JobHandle Schedule<T>(this Triangulator<T> triangulator, JobHandle
public static T[] DynamicCast<T>(this IEnumerable<float2> data) where T : unmanaged => default(T) switch
{
#if UNITY_MATHEMATICS_FIXEDPOINT
fp2 _ => data.Select(i => (T)(dynamic)i.ToFp2()).ToArray(),
fp2 => data.Select(i => (T)(dynamic)i.ToFp2()).ToArray(),
#endif
_ => data.Select(i => (T)(dynamic)i).ToArray()
};
public static IEnumerable<float2> Scale(this IEnumerable<float2> data, float s, bool predicate) => data.Select(i => (predicate ? s : 1f) * i);
public static T[] DynamicCast<T>(this IEnumerable<double2> data) where T : unmanaged => default(T) switch
{
// TODO: this extension can be removed entirely.
Vector2 _ => data.Select(i => (T)(dynamic)(float2)i).ToArray(),
Vector2 => data.Select(i => (T)(dynamic)(float2)i).ToArray(),
#if UNITY_MATHEMATICS_FIXEDPOINT
fp2 _ => data.Select(i => (T)(dynamic)((float2)i).ToFp2()).ToArray(),
fp2 => data.Select(i => (T)(dynamic)((float2)i).ToFp2()).ToArray(),
#endif
_ => data.Select(i => (T)(dynamic)i).ToArray()
};
public static IEqualityComparer<T> Comparer<T>(float epsilon = 0.0001f) => default(T) switch
{
float2 _ => Float2Comparer.With(epsilon) as IEqualityComparer<T>,
double2 _ => Double2Comparer.With(epsilon) as IEqualityComparer<T>,
float2 => Float2Comparer.With(epsilon) as IEqualityComparer<T>,
double2 => Double2Comparer.With(epsilon) as IEqualityComparer<T>,
#if UNITY_MATHEMATICS_FIXEDPOINT
fp2 _ => Fp2Comparer.With(epsilon) as IEqualityComparer<T>,
fp2 => Fp2Comparer.With(epsilon) as IEqualityComparer<T>,
#endif
Vector2 _ => new Vector2EqualityComparer(epsilon) as IEqualityComparer<T>,
Vector2 => new Vector2EqualityComparer(epsilon) as IEqualityComparer<T>,
_ => throw new NotImplementedException()
};
public static void Draw(this Triangulator triangulator, Color? color = null, float duration = 5f) => TestUtils.Draw(triangulator.Output.Positions.AsArray().Select(i => (float2)i).ToArray(), triangulator.Output.Triangles.AsArray().AsReadOnlySpan(), color ?? Color.red, duration);
public static void Draw<T>(this Triangulator<T> triangulator, Color? color = null, float duration = 5f) where T : unmanaged => TestUtils.Draw(
triangulator.Output.Positions.AsArray().Select(i => default(T) switch
{
#if UNITY_MATHEMATICS_FIXEDPOINT
fp2 v => math.float2((float)v.x, (float)v.y),
fp2 => math.float2((float)((dynamic)i).x, (float)((dynamic)i).y),
#endif
_ => (float2)(dynamic)i
}
Expand Down

0 comments on commit 4b8a014

Please sign in to comment.