From 8af2379afa33cde124237c7e28039e21105c4346 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 22 Jan 2024 18:46:51 +0300 Subject: [PATCH] fix: Build Errors --- Game/Physics2D/PhysicsMath.cs | 22 +++++++++++----------- Game/Physics2D/Primitives/Line.cs | 2 +- Game/Physics2D/Primitives/Shape.cs | 10 +++++----- Game/Physics2D/Primitives/Triangle.cs | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Game/Physics2D/PhysicsMath.cs b/Game/Physics2D/PhysicsMath.cs index b22d844..a19f014 100644 --- a/Game/Physics2D/PhysicsMath.cs +++ b/Game/Physics2D/PhysicsMath.cs @@ -19,15 +19,15 @@ public static class PhysicsMath foreach (Vector2 point in vertices) { - minX = Math.Min(minX, point.X); - minY = Math.Min(minY, point.Y); - maxX = Math.Max(maxX, point.X); - maxY = Math.Max(maxY, point.Y); + minX = MathF.Min(minX, point.X); + minY = MathF.Min(minY, point.Y); + maxX = MathF.Max(maxX, point.X); + maxY = MathF.Max(maxY, point.Y); } float dx = maxX - minX; float dy = maxY - minY; - float deltaMax = Math.Max(dx, dy); + float deltaMax = MathF.Max(dx, dy); float midX = (minX + maxX) / 2; float midY = (minY + maxY) / 2; @@ -61,8 +61,8 @@ public static class PhysicsMath // point q lies on line segment 'pr' public static bool OnSegment(Vector2 p, Vector2 q, Vector2 r) { - if (q.X <= Math.Max(p.X, r.X) && q.X >= Math.Min(p.X, r.X) && - q.Y <= Math.Max(p.Y, r.Y) && q.Y >= Math.Min(p.Y, r.Y)) + if (q.X <= MathF.Max(p.X, r.X) && q.X >= MathF.Min(p.X, r.X) && + q.Y <= MathF.Max(p.Y, r.Y) && q.Y >= MathF.Min(p.Y, r.Y)) return true; return false; @@ -102,13 +102,13 @@ public static class PhysicsMath return true; const float floatNormal = (1 << 23) * float.Epsilon; - float absA = Math.Abs(a); - float absB = Math.Abs(b); - float diff = Math.Abs(a - b); + float absA = MathF.Abs(a); + float absB = MathF.Abs(b); + float diff = MathF.Abs(a - b); if (a == 0.0f || b == 0.0f || diff < floatNormal) return diff < (epsilon * floatNormal); - return diff / Math.Min(absA + absB, float.MaxValue) < epsilon; + return diff / MathF.Min(absA + absB, float.MaxValue) < epsilon; } } diff --git a/Game/Physics2D/Primitives/Line.cs b/Game/Physics2D/Primitives/Line.cs index 02cc06f..4b61625 100644 --- a/Game/Physics2D/Primitives/Line.cs +++ b/Game/Physics2D/Primitives/Line.cs @@ -99,7 +99,7 @@ public record Line(Vector2 From, Vector2 To) float t = (pointVector.X * edgeVector.X + pointVector.Y * edgeVector.Y) / (edgeVector.X * edgeVector.X + edgeVector.Y * edgeVector.Y); // Clamp t to the range [0, 1] to ensure the closest point is on the edge - t = Math.Max(0, Math.Min(1, t)); + t = MathF.Max(0, MathF.Min(1, t)); // Calculate the closest point on the edge float closestX = From.X + t * edgeVector.X; diff --git a/Game/Physics2D/Primitives/Shape.cs b/Game/Physics2D/Primitives/Shape.cs index bedc743..f5fa09b 100644 --- a/Game/Physics2D/Primitives/Shape.cs +++ b/Game/Physics2D/Primitives/Shape.cs @@ -16,15 +16,15 @@ public record Shape(IList Vertices) foreach (Vector2 point in Vertices) { - minX = Math.Min(minX, point.X); - minY = Math.Min(minY, point.Y); - maxX = Math.Max(maxX, point.X); - maxY = Math.Max(maxY, point.Y); + minX = MathF.Min(minX, point.X); + minY = MathF.Min(minY, point.Y); + maxX = MathF.Max(maxX, point.X); + maxY = MathF.Max(maxY, point.Y); } float dx = maxX - minX; float dy = maxY - minY; - float deltaMax = Math.Max(dx, dy); + float deltaMax = MathF.Max(dx, dy); float midX = (minX + maxX) / 2; float midY = (minY + maxY) / 2; diff --git a/Game/Physics2D/Primitives/Triangle.cs b/Game/Physics2D/Primitives/Triangle.cs index 6417951..7f01b8b 100644 --- a/Game/Physics2D/Primitives/Triangle.cs +++ b/Game/Physics2D/Primitives/Triangle.cs @@ -6,7 +6,7 @@ namespace Syntriax.Engine.Physics2D.Primitives; public record Triangle(Vector2 A, Vector2 B, Vector2 C) { - public float Area => Math.Abs(( + public float Area => MathF.Abs(( A.X * (B.Y - C.Y) + B.X * (C.Y - A.Y) + C.X * (A.Y - B.Y) @@ -23,7 +23,7 @@ public record Triangle(Vector2 A, Vector2 B, Vector2 C) float slopeBC = (C.Y - B.Y) / (C.X - B.X); Vector2 center; - if (Math.Abs(slopeAB - slopeBC) > float.Epsilon) + if (MathF.Abs(slopeAB - slopeBC) > float.Epsilon) { float x = (slopeAB * slopeBC * (A.Y - C.Y) + slopeBC * (A.X + B.X) - slopeAB * (B.X + C.X)) / (2 * (slopeBC - slopeAB)); float y = -(x - (A.X + B.X) / 2) / slopeAB + (A.Y + B.Y) / 2;