From b45ea725d72ace84196571e760feafe33cbc7bd7 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Wed, 12 Aug 2020 21:09:44 +0200 Subject: [PATCH] Remove CannyFastMath. --- Robust.Client/Debugging/DebugDrawing.cs | 3 +- .../GameStates/ClientGameStateManager.cs | 2 -- .../Placement/Modes/AlignSnapgridBorder.cs | 2 -- .../UserInterface/Controls/BoxContainer.cs | 2 -- .../UserInterface/Controls/SplitContainer.cs | 4 +-- .../UserInterface/Controls/TabContainer.cs | 2 -- Robust.Shared.Maths/Angle.cs | 2 -- Robust.Shared.Maths/Box2.cs | 4 +-- Robust.Shared.Maths/Box2Rotated.cs | 2 -- Robust.Shared.Maths/Circle.cs | 2 -- Robust.Shared.Maths/Color.cs | 2 -- Robust.Shared.Maths/Direction.cs | 2 -- Robust.Shared.Maths/FloatMath.cs | 30 +++++-------------- Robust.Shared.Maths/MathHelper.cs | 2 -- Robust.Shared.Maths/Matrix3.cs | 2 -- Robust.Shared.Maths/Matrix4.cs | 2 -- Robust.Shared.Maths/Quaternion.cs | 2 -- .../Robust.Shared.Maths.csproj | 1 - Robust.Shared.Maths/UIBox2.cs | 2 -- Robust.Shared.Maths/UIBox2i.cs | 2 -- Robust.Shared.Maths/Vector2.cs | 6 ++-- Robust.Shared.Maths/Vector2d.cs | 2 -- Robust.Shared.Maths/Vector2i.cs | 2 -- Robust.Shared.Maths/Vector2u.cs | 2 -- Robust.Shared.Maths/Vector3.cs | 26 ++++++++-------- Robust.Shared.Maths/Vector3d.cs | 2 -- Robust.Shared.Maths/Vector4.cs | 26 ++++++++-------- Robust.Shared.Maths/Vector4d.cs | 2 -- .../Systems/SharedPhysicsSystem.cs | 4 +-- Robust.Shared/Noise/FastNoise.cs | 10 +++---- Robust.Shared/Noise/NoiseGenerator.cs | 4 +-- Robust.Shared/Physics/CollisionSolver.cs | 19 ++++++------ Robust.Shared/Physics/DynamicTree.cs | 2 -- Robust.Shared/Physics/Ray.cs | 2 -- 34 files changed, 54 insertions(+), 127 deletions(-) diff --git a/Robust.Client/Debugging/DebugDrawing.cs b/Robust.Client/Debugging/DebugDrawing.cs index 9b20a383b..d403af89f 100644 --- a/Robust.Client/Debugging/DebugDrawing.cs +++ b/Robust.Client/Debugging/DebugDrawing.cs @@ -16,7 +16,6 @@ using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Prototypes; -using MathF = CannyFastMath.MathF; namespace Robust.Client.Debugging { @@ -218,7 +217,7 @@ namespace Robust.Client.Debugging public override Color CalcWakeColor(Color color, float wakePercent) { - var percent = MathF.Clamp(wakePercent, 0, 1); + var percent = FloatMath.Clamp(wakePercent, 0, 1); var r = 1 - (percent * (1 - color.R)); var g = 1 - (percent * (1 - color.G)); diff --git a/Robust.Client/GameStates/ClientGameStateManager.cs b/Robust.Client/GameStates/ClientGameStateManager.cs index 2cc53ae0d..dd75308c1 100644 --- a/Robust.Client/GameStates/ClientGameStateManager.cs +++ b/Robust.Client/GameStates/ClientGameStateManager.cs @@ -21,8 +21,6 @@ using Robust.Shared.Interfaces.Timing; using Robust.Shared.Log; using Robust.Shared.Timing; using Robust.Shared.Utility; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Client.GameStates { diff --git a/Robust.Client/Placement/Modes/AlignSnapgridBorder.cs b/Robust.Client/Placement/Modes/AlignSnapgridBorder.cs index 51fe4e9b7..639084969 100644 --- a/Robust.Client/Placement/Modes/AlignSnapgridBorder.cs +++ b/Robust.Client/Placement/Modes/AlignSnapgridBorder.cs @@ -4,8 +4,6 @@ using Robust.Client.Graphics.Drawing; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Utility; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Client.Placement.Modes { diff --git a/Robust.Client/UserInterface/Controls/BoxContainer.cs b/Robust.Client/UserInterface/Controls/BoxContainer.cs index f6c00f880..67304c772 100644 --- a/Robust.Client/UserInterface/Controls/BoxContainer.cs +++ b/Robust.Client/UserInterface/Controls/BoxContainer.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using Robust.Shared.Maths; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Client.UserInterface.Controls { diff --git a/Robust.Client/UserInterface/Controls/SplitContainer.cs b/Robust.Client/UserInterface/Controls/SplitContainer.cs index 1ac399649..b569097ce 100644 --- a/Robust.Client/UserInterface/Controls/SplitContainer.cs +++ b/Robust.Client/UserInterface/Controls/SplitContainer.cs @@ -117,7 +117,7 @@ namespace Robust.Client.UserInterface.Controls /// private float ClampSplitCenter(float splitCenter, float? firstMinSize = null, float? secondMinSize = null) { - splitCenter = Math.Clamp(splitCenter, SplitMin, SplitMax); + splitCenter = FloatMath.Clamp(splitCenter, SplitMin, SplitMax); if (ResizeMode == SplitResizeMode.RespectChildrenMinSize && ChildCount == 2) { @@ -128,7 +128,7 @@ namespace Robust.Client.UserInterface.Controls secondMinSize ??= (Vertical ? second.CombinedMinimumSize.Y : second.CombinedMinimumSize.X); var size = Vertical ? Height : Width; - splitCenter = Math.Clamp(splitCenter, firstMinSize.Value, size - (secondMinSize.Value + SplitWidth)); + splitCenter = FloatMath.Clamp(splitCenter, firstMinSize.Value, size - (secondMinSize.Value + SplitWidth)); } return splitCenter; diff --git a/Robust.Client/UserInterface/Controls/TabContainer.cs b/Robust.Client/UserInterface/Controls/TabContainer.cs index b8fb2fd3e..fa0434d02 100644 --- a/Robust.Client/UserInterface/Controls/TabContainer.cs +++ b/Robust.Client/UserInterface/Controls/TabContainer.cs @@ -5,8 +5,6 @@ using Robust.Client.Graphics.Drawing; using Robust.Shared.Input; using Robust.Shared.Localization; using Robust.Shared.Maths; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Client.UserInterface.Controls { diff --git a/Robust.Shared.Maths/Angle.cs b/Robust.Shared.Maths/Angle.cs index dfa60bc55..cd827eb93 100644 --- a/Robust.Shared.Maths/Angle.cs +++ b/Robust.Shared.Maths/Angle.cs @@ -1,7 +1,5 @@ using System; using JetBrains.Annotations; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Box2.cs b/Robust.Shared.Maths/Box2.cs index 1d18cad17..f8fecff4d 100644 --- a/Robust.Shared.Maths/Box2.cs +++ b/Robust.Shared.Maths/Box2.cs @@ -326,8 +326,8 @@ namespace Robust.Shared.Maths public Vector2 ClosestPoint(in Vector2 position) { // clamp the point to the border of the box - var cx = Math.Clamp(position.X, Left, Right); - var cy = Math.Clamp(position.Y, Bottom, Top); + var cx = FloatMath.Clamp(position.X, Left, Right); + var cy = FloatMath.Clamp(position.Y, Bottom, Top); return new Vector2(cx, cy); } diff --git a/Robust.Shared.Maths/Box2Rotated.cs b/Robust.Shared.Maths/Box2Rotated.cs index e01f5b963..cf96311a6 100644 --- a/Robust.Shared.Maths/Box2Rotated.cs +++ b/Robust.Shared.Maths/Box2Rotated.cs @@ -1,6 +1,4 @@ using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Circle.cs b/Robust.Shared.Maths/Circle.cs index f15ac3408..1f760ec63 100644 --- a/Robust.Shared.Maths/Circle.cs +++ b/Robust.Shared.Maths/Circle.cs @@ -1,6 +1,4 @@ using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Color.cs b/Robust.Shared.Maths/Color.cs index 9a3f4c511..0ec50c0e1 100644 --- a/Robust.Shared.Maths/Color.cs +++ b/Robust.Shared.Maths/Color.cs @@ -36,8 +36,6 @@ using SysVector4 = System.Numerics.Vector4; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; #endif -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Direction.cs b/Robust.Shared.Maths/Direction.cs index edf547c86..d2aded231 100644 --- a/Robust.Shared.Maths/Direction.cs +++ b/Robust.Shared.Maths/Direction.cs @@ -1,6 +1,4 @@ using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/FloatMath.cs b/Robust.Shared.Maths/FloatMath.cs index 24539ec6d..5cb7474dd 100644 --- a/Robust.Shared.Maths/FloatMath.cs +++ b/Robust.Shared.Maths/FloatMath.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.CompilerServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { @@ -33,13 +31,13 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Clamp(this float val, float min, float max) { - return MathF.Clamp(val, min, max); + return Math.Max(Math.Min(val, max), min); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Clamp(this double val, double min, double max) { - return Math.Clamp(val, min, max); + return Math.Max(Math.Min(val, max), min); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -84,8 +82,7 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Lerp(double a, double b, double blend) { - //return a + (b - a) * blend; - return Math.Interpolate(a, b, blend); + return a + (b - a) * blend; } /// @@ -94,39 +91,26 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Lerp(float a, float b, float blend) { - //return a + (b - a) * blend; - return MathF.Interpolate(a, b, blend); + return a + (b - a) * blend; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float InterpolateCubic(float preA, float a, float b, float postB, float t) { - //return a + 0.5f * t * (b - preA + t * (2.0f * preA - 5.0f * a + 4.0f * b - postB + t * (3.0f * (a - b) + postB - preA))); - return MathF.CubicInterpolate(preA,a, b, postB, t); + return a + 0.5f * t * (b - preA + t * (2.0f * preA - 5.0f * a + 4.0f * b - postB + t * (3.0f * (a - b) + postB - preA))); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double InterpolateCubic(double preA, double a, double b, double postB, double t) { - //return a + 0.5 * t * (b - preA + t * (2.0 * preA - 5.0 * a + 4.0 * b - postB + t * (3.0 * (a - b) + postB - preA))); - return Math.CubicInterpolate(preA,a, b, postB, t); + return a + 0.5 * t * (b - preA + t * (2.0 * preA - 5.0 * a + 4.0 * b - postB + t * (3.0 * (a - b) + postB - preA))); } // Clamps value between 0 and 1 and returns value [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Clamp01(float value) { - /* - if (value < 0F) - return 0F; - - if (value > 1F) - return 1F; - - return value; - */ - - return MathF.Clamp(value, 0, 1); + return FloatMath.Clamp(value, 0, 1); } // Loops the value t, so that it is never larger than length and never smaller than 0. diff --git a/Robust.Shared.Maths/MathHelper.cs b/Robust.Shared.Maths/MathHelper.cs index 4589c1d8b..1e40b548c 100644 --- a/Robust.Shared.Maths/MathHelper.cs +++ b/Robust.Shared.Maths/MathHelper.cs @@ -13,8 +13,6 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Matrix3.cs b/Robust.Shared.Maths/Matrix3.cs index 0d40c57ab..ad7243c15 100644 --- a/Robust.Shared.Maths/Matrix3.cs +++ b/Robust.Shared.Maths/Matrix3.cs @@ -27,8 +27,6 @@ SOFTWARE. using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Matrix4.cs b/Robust.Shared.Maths/Matrix4.cs index 3bf23dea3..4e01ae20b 100644 --- a/Robust.Shared.Maths/Matrix4.cs +++ b/Robust.Shared.Maths/Matrix4.cs @@ -28,8 +28,6 @@ SOFTWARE. using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Quaternion.cs b/Robust.Shared.Maths/Quaternion.cs index 1b850f5cf..163e5fe97 100644 --- a/Robust.Shared.Maths/Quaternion.cs +++ b/Robust.Shared.Maths/Quaternion.cs @@ -29,8 +29,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Xml.Serialization; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Robust.Shared.Maths.csproj b/Robust.Shared.Maths/Robust.Shared.Maths.csproj index a264799a5..d174d99cc 100644 --- a/Robust.Shared.Maths/Robust.Shared.Maths.csproj +++ b/Robust.Shared.Maths/Robust.Shared.Maths.csproj @@ -16,6 +16,5 @@ - diff --git a/Robust.Shared.Maths/UIBox2.cs b/Robust.Shared.Maths/UIBox2.cs index 1ca51ea6d..bf817dbae 100644 --- a/Robust.Shared.Maths/UIBox2.cs +++ b/Robust.Shared.Maths/UIBox2.cs @@ -1,6 +1,4 @@ using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/UIBox2i.cs b/Robust.Shared.Maths/UIBox2i.cs index 542b20e4e..12c12ba9d 100644 --- a/Robust.Shared.Maths/UIBox2i.cs +++ b/Robust.Shared.Maths/UIBox2i.cs @@ -1,6 +1,4 @@ using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Vector2.cs b/Robust.Shared.Maths/Vector2.cs index 5b54be591..e569becaf 100644 --- a/Robust.Shared.Maths/Vector2.cs +++ b/Robust.Shared.Maths/Vector2.cs @@ -1,8 +1,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { @@ -261,9 +259,9 @@ namespace Robust.Shared.Maths { return new Vector2( //factor * (b.X - a.X) + a.X, - MathF.Interpolate(a.X, b.X, factor), + FloatMath.Lerp(a.X, b.X, factor), //factor * (b.Y - a.Y) + a.Y - MathF.Interpolate(a.Y, b.Y, factor) + FloatMath.Lerp(a.Y, b.Y, factor) ); } diff --git a/Robust.Shared.Maths/Vector2d.cs b/Robust.Shared.Maths/Vector2d.cs index cb72e64b8..ccda884b4 100644 --- a/Robust.Shared.Maths/Vector2d.cs +++ b/Robust.Shared.Maths/Vector2d.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Vector2i.cs b/Robust.Shared.Maths/Vector2i.cs index 32e97c09d..0fba3e3da 100644 --- a/Robust.Shared.Maths/Vector2i.cs +++ b/Robust.Shared.Maths/Vector2i.cs @@ -1,8 +1,6 @@ using System; using System.Runtime.InteropServices; using Newtonsoft.Json; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Vector2u.cs b/Robust.Shared.Maths/Vector2u.cs index 97d9520b5..8079b4bb0 100644 --- a/Robust.Shared.Maths/Vector2u.cs +++ b/Robust.Shared.Maths/Vector2u.cs @@ -1,8 +1,6 @@ using System; using System.Runtime.InteropServices; using Newtonsoft.Json; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Vector3.cs b/Robust.Shared.Maths/Vector3.cs index 9e4707e30..82a4a1ca7 100644 --- a/Robust.Shared.Maths/Vector3.cs +++ b/Robust.Shared.Maths/Vector3.cs @@ -29,8 +29,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Xml.Serialization; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { @@ -502,9 +500,9 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector3 Clamp(Vector3 vec, Vector3 min, Vector3 max) { - vec.X = MathF.Clamp(vec.X, min.X, max.X); - vec.Y = MathF.Clamp(vec.Y, min.Y, max.Y); - vec.Z = MathF.Clamp(vec.Z, min.Z, max.Z); + vec.X = FloatMath.Clamp(vec.X, min.X, max.X); + vec.Y = FloatMath.Clamp(vec.Y, min.Y, max.Y); + vec.Z = FloatMath.Clamp(vec.Z, min.Z, max.Z); return vec; } @@ -518,9 +516,9 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(ref Vector3 vec, ref Vector3 min, ref Vector3 max, out Vector3 result) { - result.X = MathF.Clamp(vec.X, min.X, max.X); - result.Y = MathF.Clamp(vec.Y, min.Y, max.Y); - result.Z = MathF.Clamp(vec.Z, min.Z, max.Z); + result.X = FloatMath.Clamp(vec.X, min.X, max.X); + result.Y = FloatMath.Clamp(vec.Y, min.Y, max.Y); + result.Z = FloatMath.Clamp(vec.Z, min.Z, max.Z); } #endregion @@ -630,9 +628,9 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector3 Lerp(Vector3 a, Vector3 b, float blend) { - a.X = MathF.Interpolate(a.X, b.X, blend); - a.Y = MathF.Interpolate(a.Y, b.Y, blend); - a.Z = MathF.Interpolate(a.Z, b.Z, blend); + a.X = FloatMath.Lerp(a.X, b.X, blend); + a.Y = FloatMath.Lerp(a.Y, b.Y, blend); + a.Z = FloatMath.Lerp(a.Z, b.Z, blend); return a; } @@ -646,9 +644,9 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Lerp(ref Vector3 a, ref Vector3 b, float blend, out Vector3 result) { - result.X = MathF.Interpolate(a.X, b.X, blend); - result.Y = MathF.Interpolate(a.Y, b.Y, blend); - result.Z = MathF.Interpolate(a.Z, b.Z, blend); + result.X = FloatMath.Lerp(a.X, b.X, blend); + result.Y = FloatMath.Lerp(a.Y, b.Y, blend); + result.Z = FloatMath.Lerp(a.Z, b.Z, blend); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Robust.Shared.Maths/Vector3d.cs b/Robust.Shared.Maths/Vector3d.cs index 91b7affe9..2a580cc40 100644 --- a/Robust.Shared.Maths/Vector3d.cs +++ b/Robust.Shared.Maths/Vector3d.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared.Maths/Vector4.cs b/Robust.Shared.Maths/Vector4.cs index 0326e9d3e..07082003b 100644 --- a/Robust.Shared.Maths/Vector4.cs +++ b/Robust.Shared.Maths/Vector4.cs @@ -28,8 +28,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Xml.Serialization; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { @@ -509,10 +507,10 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Clamp(Vector4 vec, Vector4 min, Vector4 max) { - vec.X = MathF.Clamp( vec.X, min.X, max.X ); - vec.Y = MathF.Clamp( vec.Y, min.Y, max.Y ); - vec.Z = MathF.Clamp( vec.Z, min.Z, max.Z ); - vec.W = MathF.Clamp( vec.W, min.W, max.W ); + vec.X = FloatMath.Clamp( vec.X, min.X, max.X ); + vec.Y = FloatMath.Clamp( vec.Y, min.Y, max.Y ); + vec.Z = FloatMath.Clamp( vec.Z, min.Z, max.Z ); + vec.W = FloatMath.Clamp( vec.W, min.W, max.W ); return vec; } @@ -526,10 +524,10 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Clamp(ref Vector4 vec, ref Vector4 min, ref Vector4 max, out Vector4 result) { - result.X = MathF.Clamp( vec.X, min.X, max.X ); - result.Y = MathF.Clamp( vec.Y, min.Y, max.Y ); - result.Z = MathF.Clamp( vec.Z, min.Z, max.Z ); - result.W = MathF.Clamp( vec.W, min.W, max.W ); + result.X = FloatMath.Clamp( vec.X, min.X, max.X ); + result.Y = FloatMath.Clamp( vec.Y, min.Y, max.Y ); + result.Z = FloatMath.Clamp( vec.Z, min.Z, max.Z ); + result.W = FloatMath.Clamp( vec.W, min.W, max.W ); } #endregion Clamp @@ -625,10 +623,10 @@ namespace Robust.Shared.Maths [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Lerp(ref Vector4 a, ref Vector4 b, float blend, out Vector4 result) { - result.X = MathF.Interpolate(a.X, b.X, blend); - result.Y = MathF.Interpolate(a.Y, b.Y, blend); - result.Z = MathF.Interpolate(a.Z, b.Z, blend); - result.W = MathF.Interpolate(a.W, b.W, blend); + result.X = FloatMath.Lerp(a.X, b.X, blend); + result.Y = FloatMath.Lerp(a.Y, b.Y, blend); + result.Z = FloatMath.Lerp(a.Z, b.Z, blend); + result.W = FloatMath.Lerp(a.W, b.W, blend); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Robust.Shared.Maths/Vector4d.cs b/Robust.Shared.Maths/Vector4d.cs index 198b222c9..f278fd672 100644 --- a/Robust.Shared.Maths/Vector4d.cs +++ b/Robust.Shared.Maths/Vector4d.cs @@ -1,7 +1,5 @@ using System; using System.Runtime.InteropServices; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths { diff --git a/Robust.Shared/GameObjects/Systems/SharedPhysicsSystem.cs b/Robust.Shared/GameObjects/Systems/SharedPhysicsSystem.cs index 7a7e78cdc..1bd19b87c 100644 --- a/Robust.Shared/GameObjects/Systems/SharedPhysicsSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedPhysicsSystem.cs @@ -101,7 +101,7 @@ namespace Robust.Shared.GameObjects.Systems var multiplier = deltaTime / (1f / 60); - var divisions = Math.Clamp( + var divisions = FloatMath.Clamp( MathF.Round(solveIterationsAt60 * multiplier, MidpointRounding.AwayFromZero), 1, 20 @@ -303,7 +303,7 @@ namespace Robust.Shared.GameObjects.Systems private bool FixClipping(List collisions, float divisions) { const float allowance = 1 / 128f; - var percent = Math.Clamp(1f / divisions, 0.01f, 1f); + var percent = FloatMath.Clamp(1f / divisions, 0.01f, 1f); var done = true; foreach (var collision in collisions) { diff --git a/Robust.Shared/Noise/FastNoise.cs b/Robust.Shared/Noise/FastNoise.cs index 69ac7864e..fc334cb71 100644 --- a/Robust.Shared/Noise/FastNoise.cs +++ b/Robust.Shared/Noise/FastNoise.cs @@ -38,8 +38,6 @@ using FN_DECIMAL = System.Single; #endif using System; using System.Runtime.CompilerServices; -using MathI = CannyFastMath.Math; -using Math = CannyFastMath.MathF; namespace Robust.Shared.Noise { @@ -220,11 +218,11 @@ namespace Robust.Shared.Noise // Both indicies must be >= 0, index1 must be < 4 public void SetCellularDistance2Indicies(int cellularDistanceIndex0, int cellularDistanceIndex1) { - m_cellularDistanceIndex0 = MathI.Min(cellularDistanceIndex0, cellularDistanceIndex1); - m_cellularDistanceIndex1 = MathI.Max(cellularDistanceIndex0, cellularDistanceIndex1); + m_cellularDistanceIndex0 = Math.Min(cellularDistanceIndex0, cellularDistanceIndex1); + m_cellularDistanceIndex1 = Math.Max(cellularDistanceIndex0, cellularDistanceIndex1); - m_cellularDistanceIndex0 = MathI.Min(MathI.Max(m_cellularDistanceIndex0, 0), FN_CELLULAR_INDEX_MAX); - m_cellularDistanceIndex1 = MathI.Min(MathI.Max(m_cellularDistanceIndex1, 0), FN_CELLULAR_INDEX_MAX); + m_cellularDistanceIndex0 = Math.Min(Math.Max(m_cellularDistanceIndex0, 0), FN_CELLULAR_INDEX_MAX); + m_cellularDistanceIndex1 = Math.Min(Math.Max(m_cellularDistanceIndex1, 0), FN_CELLULAR_INDEX_MAX); } // Sets the maximum distance a cellular point can move from it's grid position diff --git a/Robust.Shared/Noise/NoiseGenerator.cs b/Robust.Shared/Noise/NoiseGenerator.cs index 273a84b7d..8abae66d1 100644 --- a/Robust.Shared/Noise/NoiseGenerator.cs +++ b/Robust.Shared/Noise/NoiseGenerator.cs @@ -1,8 +1,6 @@ using System; using JetBrains.Annotations; using Robust.Shared.Maths; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Noise { @@ -93,7 +91,7 @@ namespace Robust.Shared.Noise const float dx = x2 - x1; const float dy = y2 - y1; - const float tau = (float) Math.TAU; //(float)Math.PI * 2; + const float tau = (float)Math.PI * 2; const float dxTau = dx / tau; const float dyTau = dy / tau; diff --git a/Robust.Shared/Physics/CollisionSolver.cs b/Robust.Shared/Physics/CollisionSolver.cs index eac9eb64d..b69140880 100644 --- a/Robust.Shared/Physics/CollisionSolver.cs +++ b/Robust.Shared/Physics/CollisionSolver.cs @@ -2,7 +2,6 @@ using Robust.Shared.Interfaces.Physics; using Robust.Shared.Map; using Robust.Shared.Maths; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Physics { @@ -109,7 +108,7 @@ namespace Robust.Shared.Physics { var aRad = a.Radius; var aPos = manifold.A.Entity.Transform.WorldPosition; - + var bRect = new AlignedRectangle(manifold.B.Entity.Transform.WorldPosition, b.LocalBounds.Size / 2); CalculateCollisionFeatures(bRect, new Circle(aPos, aRad), (float) flip * -1, out features); @@ -167,7 +166,7 @@ namespace Robust.Shared.Physics // generate collision normal var normal = dist.Normalized; - // half of the total + // half of the total var penetraction = (radiiSum - dist.Length) * 0.5f; var contacts = new Vector2[1]; @@ -267,7 +266,7 @@ namespace Robust.Shared.Physics // Calculate overlap on x axis float x_overlap = a_extent_x + b_extent_x - MathF.Abs(n.X); - + // SAT test on x axis if (!(x_overlap > 0)) { @@ -385,7 +384,7 @@ namespace Robust.Shared.Physics /// Half of the total width and height of the rectangle. /// public readonly Vector2 HalfExtents; - + /// /// A 1x1 unit rectangle with the origin centered on the world origin. /// @@ -419,7 +418,7 @@ namespace Robust.Shared.Physics HalfExtents = new Vector2(halfWidth, halfHeight); Center = new Vector2(box.Left + halfWidth, box.Height + halfHeight); } - + public AlignedRectangle(Vector2 halfExtents) { Center = default; @@ -438,8 +437,8 @@ namespace Robust.Shared.Physics public Vector2 ClosestPoint(in Vector2 position) { // clamp the point to the border of the box - var cx = MathF.Clamp(position.X, Left, Right); - var cy = MathF.Clamp(position.Y, Bottom, Top); + var cx = FloatMath.Clamp(position.X, Left, Right); + var cy = FloatMath.Clamp(position.Y, Bottom, Top); return new Vector2(cx, cy); } @@ -612,8 +611,8 @@ namespace Robust.Shared.Physics var yMax = HalfExtents.Y; // clamp the point to the border of the box - var cx = MathF.Clamp(localPoint.X, xMin, xMax); - var cy = MathF.Clamp(localPoint.Y, yMin, yMax); + var cx = FloatMath.Clamp(localPoint.X, xMin, xMax); + var cy = FloatMath.Clamp(localPoint.Y, yMin, yMax); return TransformPoint(new Vector2(cx, cy)); } diff --git a/Robust.Shared/Physics/DynamicTree.cs b/Robust.Shared/Physics/DynamicTree.cs index a82041245..8cf293a60 100644 --- a/Robust.Shared/Physics/DynamicTree.cs +++ b/Robust.Shared/Physics/DynamicTree.cs @@ -26,8 +26,6 @@ using System.Runtime.CompilerServices; using JetBrains.Annotations; using Robust.Shared.Maths; using Robust.Shared.Utility; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Physics { diff --git a/Robust.Shared/Physics/Ray.cs b/Robust.Shared/Physics/Ray.cs index 517b49b03..6cb4d99e0 100644 --- a/Robust.Shared/Physics/Ray.cs +++ b/Robust.Shared/Physics/Ray.cs @@ -1,8 +1,6 @@ using Robust.Shared.Map; using Robust.Shared.Utility; using System; -using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Robust.Shared.Maths {