diff --git a/src/DotRecast.Core/DemoMath.cs b/src/DotRecast.Core/DemoMath.cs
deleted file mode 100644
index b803863..0000000
--- a/src/DotRecast.Core/DemoMath.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
-recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
-DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-3. This notice may not be removed or altered from any source distribution.
-*/
-
-using System;
-
-namespace DotRecast.Core
-{
- public class DemoMath
- {
- public static float vDistSqr(float[] v1, float[] v2, int i)
- {
- float dx = v2[i] - v1[0];
- float dy = v2[i + 1] - v1[1];
- float dz = v2[i + 2] - v1[2];
- return dx * dx + dy * dy + dz * dz;
- }
-
- public static float[] vCross(float[] v1, float[] v2)
- {
- float[] dest = new float[3];
- dest[0] = v1[1] * v2[2] - v1[2] * v2[1];
- dest[1] = v1[2] * v2[0] - v1[0] * v2[2];
- dest[2] = v1[0] * v2[1] - v1[1] * v2[0];
- return dest;
- }
-
- public static float vDot(float[] v1, float[] v2)
- {
- return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
- }
-
- public static float sqr(float f)
- {
- return f * f;
- }
-
- public static float getPathLen(float[] path, int npath)
- {
- float totd = 0;
- for (int i = 0; i < npath - 1; ++i)
- {
- totd += (float)Math.Sqrt(vDistSqr(path, i * 3, (i + 1) * 3));
- }
-
- return totd;
- }
-
- public static float vDistSqr(float[] v, int i, int j)
- {
- float dx = v[i] - v[j];
- float dy = v[i + 1] - v[j + 1];
- float dz = v[i + 2] - v[j + 2];
- return dx * dx + dy * dy + dz * dz;
- }
-
- public static float step(float threshold, float v)
- {
- return v < threshold ? 0.0f : 1.0f;
- }
-
- public static int clamp(int v, int min, int max)
- {
- return Math.Max(Math.Min(v, max), min);
- }
-
- public static float clamp(float v, float min, float max)
- {
- return Math.Max(Math.Min(v, max), min);
- }
-
- public static float lerp(float f, float g, float u)
- {
- return u * g + (1f - u) * f;
- }
- }
-}
\ No newline at end of file
diff --git a/src/DotRecast.Core/DotRecast.Core.csproj b/src/DotRecast.Core/DotRecast.Core.csproj
index 12c0675..65342d3 100644
--- a/src/DotRecast.Core/DotRecast.Core.csproj
+++ b/src/DotRecast.Core/DotRecast.Core.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/src/DotRecast.Detour/DetourCommon.cs b/src/DotRecast.Core/RecastMath.cs
similarity index 93%
rename from src/DotRecast.Detour/DetourCommon.cs
rename to src/DotRecast.Core/RecastMath.cs
index 7c7de91..7e4f6d1 100644
--- a/src/DotRecast.Detour/DetourCommon.cs
+++ b/src/DotRecast.Core/RecastMath.cs
@@ -20,11 +20,79 @@ freely, subject to the following restrictions:
using System;
-namespace DotRecast.Detour
+namespace DotRecast.Core
{
- public static class DetourCommon
+ public static class RecastMath
{
public const float EPS = 1e-4f;
+ private static readonly float EQUAL_THRESHOLD = sqr(1.0f / 16384.0f);
+
+ public static float vDistSqr(float[] v1, float[] v2, int i)
+ {
+ float dx = v2[i] - v1[0];
+ float dy = v2[i + 1] - v1[1];
+ float dz = v2[i + 2] - v1[2];
+ return dx * dx + dy * dy + dz * dz;
+ }
+
+ public static float[] vCross(float[] v1, float[] v2)
+ {
+ float[] dest = new float[3];
+ dest[0] = v1[1] * v2[2] - v1[2] * v2[1];
+ dest[1] = v1[2] * v2[0] - v1[0] * v2[2];
+ dest[2] = v1[0] * v2[1] - v1[1] * v2[0];
+ return dest;
+ }
+
+ public static float vDot(float[] v1, float[] v2)
+ {
+ return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
+ }
+
+ public static float sqr(float f)
+ {
+ return f * f;
+ }
+
+ public static float getPathLen(float[] path, int npath)
+ {
+ float totd = 0;
+ for (int i = 0; i < npath - 1; ++i)
+ {
+ totd += (float)Math.Sqrt(vDistSqr(path, i * 3, (i + 1) * 3));
+ }
+
+ return totd;
+ }
+
+ public static float vDistSqr(float[] v, int i, int j)
+ {
+ float dx = v[i] - v[j];
+ float dy = v[i + 1] - v[j + 1];
+ float dz = v[i + 2] - v[j + 2];
+ return dx * dx + dy * dy + dz * dz;
+ }
+
+ public static float step(float threshold, float v)
+ {
+ return v < threshold ? 0.0f : 1.0f;
+ }
+
+ public static float clamp(float v, float min, float max)
+ {
+ return Math.Max(Math.Min(v, max), min);
+ }
+
+ public static int clamp(int v, int min, int max)
+ {
+ return Math.Max(Math.Min(v, max), min);
+ }
+
+ public static float lerp(float f, float g, float u)
+ {
+ return u * g + (1f - u) * f;
+ }
+
/// Performs a scaled vector addition. (@p v1 + (@p v2 * @p s))
/// @param[out] dest The result vector. [(x, y, z)]
@@ -159,11 +227,6 @@ namespace DotRecast.Detour
return dx * dx + dy * dy + dz * dz;
}
- public static float sqr(float a)
- {
- return a * a;
- }
-
/// Derives the square of the scalar length of the vector. (len * len)
/// @param[in] v The vector. [(x, y, z)]
/// @return The square of the scalar length of the vector.
@@ -185,15 +248,6 @@ namespace DotRecast.Detour
return (float)Math.Sqrt(dx * dx + dy * dy + dz * dz);
}
- public static float clamp(float v, float min, float max)
- {
- return Math.Max(Math.Min(v, max), min);
- }
-
- public static int clamp(int v, int min, int max)
- {
- return Math.Max(Math.Min(v, max), min);
- }
/// Derives the distance between the specified points on the xz-plane.
/// @param[in] v1 A point. [(x, y, z)]
@@ -236,7 +290,6 @@ namespace DotRecast.Detour
}
}
- private static readonly float EQUAL_THRESHOLD = sqr(1.0f / 16384.0f);
/// Performs a 'sloppy' colocation check of the specified points.
/// @param[in] p0 A point. [(x, y, z)]
diff --git a/src/DotRecast.Detour/VectorPtr.cs b/src/DotRecast.Core/VectorPtr.cs
similarity index 92%
rename from src/DotRecast.Detour/VectorPtr.cs
rename to src/DotRecast.Core/VectorPtr.cs
index 6644e1f..833ddf0 100644
--- a/src/DotRecast.Detour/VectorPtr.cs
+++ b/src/DotRecast.Core/VectorPtr.cs
@@ -18,12 +18,12 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-namespace DotRecast.Detour
+namespace DotRecast.Core
{
/**
- * Wrapper for 3-element pieces (3D vectors) of a bigger float array.
- *
- */
+ * Wrapper for 3-element pieces (3D vectors) of a bigger float array.
+ *
+ */
public class VectorPtr
{
private readonly float[] array;
diff --git a/src/DotRecast.Detour.Crowd/Crowd.cs b/src/DotRecast.Detour.Crowd/Crowd.cs
index 739bf1d..a105f55 100644
--- a/src/DotRecast.Detour.Crowd/Crowd.cs
+++ b/src/DotRecast.Detour.Crowd/Crowd.cs
@@ -27,7 +27,7 @@ using DotRecast.Detour.Crowd.Tracking;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
/**
* Members in this module implement local steering and dynamic avoidance features.
diff --git a/src/DotRecast.Detour.Crowd/CrowdAgent.cs b/src/DotRecast.Detour.Crowd/CrowdAgent.cs
index fa8f770..df9cf36 100644
--- a/src/DotRecast.Detour.Crowd/CrowdAgent.cs
+++ b/src/DotRecast.Detour.Crowd/CrowdAgent.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
/// Represents an agent managed by a #dtCrowd object.
/// @ingroup crowd
diff --git a/src/DotRecast.Detour.Crowd/LocalBoundary.cs b/src/DotRecast.Detour.Crowd/LocalBoundary.cs
index 22519f5..228ed35 100644
--- a/src/DotRecast.Detour.Crowd/LocalBoundary.cs
+++ b/src/DotRecast.Detour.Crowd/LocalBoundary.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class LocalBoundary
{
diff --git a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs
index 0a7d89c..14c111a 100644
--- a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs
+++ b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs
@@ -23,7 +23,7 @@ using DotRecast.Detour.Crowd.Tracking;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class ObstacleAvoidanceQuery
{
diff --git a/src/DotRecast.Detour.Crowd/PathCorridor.cs b/src/DotRecast.Detour.Crowd/PathCorridor.cs
index fb3e5dc..ff8fc35 100644
--- a/src/DotRecast.Detour.Crowd/PathCorridor.cs
+++ b/src/DotRecast.Detour.Crowd/PathCorridor.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
/**
* Represents a dynamic polygon corridor used to plan agent movement.
diff --git a/src/DotRecast.Detour.Crowd/PathQueue.cs b/src/DotRecast.Detour.Crowd/PathQueue.cs
index 9d8717a..9b3c6ed 100644
--- a/src/DotRecast.Detour.Crowd/PathQueue.cs
+++ b/src/DotRecast.Detour.Crowd/PathQueue.cs
@@ -22,7 +22,7 @@ using System.Collections.Generic;
namespace DotRecast.Detour.Crowd
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class PathQueue
{
diff --git a/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs b/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs
index 2882099..a6790c8 100644
--- a/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs
+++ b/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs
@@ -22,7 +22,7 @@ using System;
namespace DotRecast.Detour.Crowd.Tracking
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class ObstacleAvoidanceDebugData
{
diff --git a/src/DotRecast.Detour.Dynamic/DynamicTileCheckpoint.cs b/src/DotRecast.Detour.Dynamic/DynamicTileCheckpoint.cs
index c3846d7..32e812d 100644
--- a/src/DotRecast.Detour.Dynamic/DynamicTileCheckpoint.cs
+++ b/src/DotRecast.Detour.Dynamic/DynamicTileCheckpoint.cs
@@ -18,7 +18,7 @@ freely, subject to the following restrictions:
using System.Collections.Generic;
using DotRecast.Recast;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Dynamic
{
diff --git a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs
index 4743105..62defa2 100644
--- a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs
+++ b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs
@@ -16,7 +16,7 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras
{
diff --git a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs
index dc29b28..0ef9da7 100644
--- a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs
+++ b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs
@@ -1,6 +1,6 @@
using System;
using DotRecast.Recast;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras.Jumplink
{
diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs
index 6b0679a..260f619 100644
--- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs
+++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs
@@ -1,5 +1,5 @@
using System.Collections.Generic;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras.Jumplink
{
diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs
index db453e7..711522f 100644
--- a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs
+++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using DotRecast.Core;
using DotRecast.Recast;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras.Jumplink
{
diff --git a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs
index a8b2a6d..4833bd5 100644
--- a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs
+++ b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs
@@ -1,6 +1,6 @@
using System;
using DotRecast.Recast;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Extras.Jumplink
{
diff --git a/src/DotRecast.Detour.TileCache/TileCache.cs b/src/DotRecast.Detour.TileCache/TileCache.cs
index a180217..6af7550 100644
--- a/src/DotRecast.Detour.TileCache/TileCache.cs
+++ b/src/DotRecast.Detour.TileCache/TileCache.cs
@@ -22,7 +22,7 @@ using System;
using System.Collections.Generic;
using DotRecast.Core;
using DotRecast.Detour.TileCache.Io;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.TileCache
{
diff --git a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs
index 11de14b..6f0a1f4 100644
--- a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs
+++ b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs
@@ -24,7 +24,7 @@ using System.IO;
using DotRecast.Core;
using DotRecast.Detour.TileCache.Io;
using DotRecast.Detour.TileCache.Io.Compress;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.TileCache
{
diff --git a/src/DotRecast.Detour/ConvexConvexIntersection.cs b/src/DotRecast.Detour/ConvexConvexIntersection.cs
index b65ba48..f6a4bee 100644
--- a/src/DotRecast.Detour/ConvexConvexIntersection.cs
+++ b/src/DotRecast.Detour/ConvexConvexIntersection.cs
@@ -20,7 +20,7 @@ using System;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
/**
* Convex-convex intersection based on "Computational Geometry in C" by Joseph O'Rourke
diff --git a/src/DotRecast.Detour/DefaultQueryFilter.cs b/src/DotRecast.Detour/DefaultQueryFilter.cs
index 06f0221..bde3d2f 100644
--- a/src/DotRecast.Detour/DefaultQueryFilter.cs
+++ b/src/DotRecast.Detour/DefaultQueryFilter.cs
@@ -22,7 +22,7 @@ using System;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
/**
* The Default Implementation
diff --git a/src/DotRecast.Detour/DefaultQueryHeuristic.cs b/src/DotRecast.Detour/DefaultQueryHeuristic.cs
index e5dbb44..3d7ac48 100644
--- a/src/DotRecast.Detour/DefaultQueryHeuristic.cs
+++ b/src/DotRecast.Detour/DefaultQueryHeuristic.cs
@@ -15,10 +15,10 @@ freely, subject to the following restrictions:
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour
{
- using static DetourCommon;
public class DefaultQueryHeuristic : QueryHeuristic
{
diff --git a/src/DotRecast.Detour/DotRecast.Detour.csproj b/src/DotRecast.Detour/DotRecast.Detour.csproj
index 42dd189..4ee2241 100644
--- a/src/DotRecast.Detour/DotRecast.Detour.csproj
+++ b/src/DotRecast.Detour/DotRecast.Detour.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/src/DotRecast.Detour/FindNearestPolyQuery.cs b/src/DotRecast.Detour/FindNearestPolyQuery.cs
index 607531f..29e827e 100644
--- a/src/DotRecast.Detour/FindNearestPolyQuery.cs
+++ b/src/DotRecast.Detour/FindNearestPolyQuery.cs
@@ -2,7 +2,7 @@ using System;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class FindNearestPolyQuery : PolyQuery
{
diff --git a/src/DotRecast.Detour/Io/MeshSetReader.cs b/src/DotRecast.Detour/Io/MeshSetReader.cs
index 66769c2..5fdcb83 100644
--- a/src/DotRecast.Detour/Io/MeshSetReader.cs
+++ b/src/DotRecast.Detour/Io/MeshSetReader.cs
@@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class MeshSetReader
diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs
index a892cfb..8c65049 100644
--- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs
+++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs
@@ -18,10 +18,11 @@ freely, subject to the following restrictions:
using System;
using System.Collections.Generic;
+using DotRecast.Core;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class LegacyNavMeshQuery : NavMeshQuery
diff --git a/src/DotRecast.Detour/NavMesh.cs b/src/DotRecast.Detour/NavMesh.cs
index 060ec5b..45a080f 100644
--- a/src/DotRecast.Detour/NavMesh.cs
+++ b/src/DotRecast.Detour/NavMesh.cs
@@ -25,7 +25,7 @@ using DotRecast.Core;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class NavMesh
{
diff --git a/src/DotRecast.Detour/NavMeshBuilder.cs b/src/DotRecast.Detour/NavMeshBuilder.cs
index 2564fa8..f25bf04 100644
--- a/src/DotRecast.Detour/NavMeshBuilder.cs
+++ b/src/DotRecast.Detour/NavMeshBuilder.cs
@@ -20,10 +20,11 @@ freely, subject to the following restrictions:
using System;
using System.Collections.Generic;
+using DotRecast.Core;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public class NavMeshBuilder
{
diff --git a/src/DotRecast.Detour/NavMeshQuery.cs b/src/DotRecast.Detour/NavMeshQuery.cs
index c87f4d2..3e935ce 100644
--- a/src/DotRecast.Detour/NavMeshQuery.cs
+++ b/src/DotRecast.Detour/NavMeshQuery.cs
@@ -21,10 +21,11 @@ freely, subject to the following restrictions:
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using DotRecast.Core;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
using static Node;
public class NavMeshQuery
diff --git a/src/DotRecast.Detour/PolygonByCircleConstraint.cs b/src/DotRecast.Detour/PolygonByCircleConstraint.cs
index 8ed1280..828ebe8 100644
--- a/src/DotRecast.Detour/PolygonByCircleConstraint.cs
+++ b/src/DotRecast.Detour/PolygonByCircleConstraint.cs
@@ -20,7 +20,7 @@ using System;
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
public interface PolygonByCircleConstraint
{
diff --git a/src/DotRecast.Detour/StraightPathItem.cs b/src/DotRecast.Detour/StraightPathItem.cs
index e6b08fd..c414ac1 100644
--- a/src/DotRecast.Detour/StraightPathItem.cs
+++ b/src/DotRecast.Detour/StraightPathItem.cs
@@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour
{
- using static DetourCommon;
+ using static DotRecast.Core.RecastMath;
//TODO: (PP) Add comments
public class StraightPathItem
diff --git a/src/DotRecast.Recast.Demo/Builder/TileNavMeshBuilder.cs b/src/DotRecast.Recast.Demo/Builder/TileNavMeshBuilder.cs
index eaed959..e60fcd4 100644
--- a/src/DotRecast.Recast.Demo/Builder/TileNavMeshBuilder.cs
+++ b/src/DotRecast.Recast.Demo/Builder/TileNavMeshBuilder.cs
@@ -22,6 +22,7 @@ using System.Threading.Tasks;
using DotRecast.Core;
using DotRecast.Detour;
using DotRecast.Recast.Demo.Geom;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Recast.Demo.Builder;
@@ -99,7 +100,7 @@ public class TileNavMeshBuilder : AbstractNavMeshBuilder
int[] wh = Recast.calcGridSize(geom.getMeshBoundsMin(), geom.getMeshBoundsMax(), cellSize);
int tw = (wh[0] + tileSize - 1) / tileSize;
int th = (wh[1] + tileSize - 1) / tileSize;
- int tileBits = Math.Min(DetourCommon.ilog2(DetourCommon.nextPow2(tw * th)), 14);
+ int tileBits = Math.Min(ilog2(nextPow2(tw * th)), 14);
return tileBits;
}
diff --git a/src/DotRecast.Recast.Demo/Geom/Intersections.cs b/src/DotRecast.Recast.Demo/Geom/Intersections.cs
index 921d4a2..34adb1c 100644
--- a/src/DotRecast.Recast.Demo/Geom/Intersections.cs
+++ b/src/DotRecast.Recast.Demo/Geom/Intersections.cs
@@ -18,7 +18,7 @@ freely, subject to the following restrictions:
using System;
using DotRecast.Core;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Recast.Demo.Geom;
@@ -33,11 +33,11 @@ public class Intersections
// Compute triangle normal. Can be precalculated or cached if
// intersecting multiple segments against the same triangle
- float[] norm = DemoMath.vCross(ab, ac);
+ float[] norm = RecastMath.vCross(ab, ac);
// Compute denominator d. If d <= 0, segment is parallel to or points
// away from triangle, so exit early
- float d = DemoMath.vDot(qp, norm);
+ float d = RecastMath.vDot(qp, norm);
if (d <= 0.0f)
{
return null;
@@ -47,7 +47,7 @@ public class Intersections
// intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay
// dividing by d until intersection has been found to pierce triangle
float[] ap = vSub(sp, a);
- float t = DemoMath.vDot(ap, norm);
+ float t = RecastMath.vDot(ap, norm);
if (t < 0.0f)
{
return null;
@@ -59,14 +59,14 @@ public class Intersections
}
// Compute barycentric coordinate components and test if within bounds
- float[] e = DemoMath.vCross(qp, ap);
- v = DemoMath.vDot(ac, e);
+ float[] e = RecastMath.vCross(qp, ap);
+ v = RecastMath.vDot(ac, e);
if (v < 0.0f || v > d)
{
return null;
}
- w = -DemoMath.vDot(ab, e);
+ w = -RecastMath.vDot(ab, e);
if (w < 0.0f || v + w > d)
{
return null;
diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs
index edb0508..e3dfe8b 100644
--- a/src/DotRecast.Recast.Demo/RecastDemo.cs
+++ b/src/DotRecast.Recast.Demo/RecastDemo.cs
@@ -45,7 +45,7 @@ using DotRecast.Recast.Demo.Tools;
using DotRecast.Recast.Demo.UI;
using Silk.NET.SDL;
using Silk.NET.Windowing.Sdl;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using Color = System.Drawing.Color;
using Window = Silk.NET.Windowing.Window;
@@ -457,13 +457,13 @@ public class RecastDemo
var tempMoveDown = keyboard.IsKeyPressed(Key.E) || keyboard.IsKeyPressed(Key.PageDown) ? 1.0f : -1f;
var tempMoveAccel = keyboard.IsKeyPressed(Key.ShiftLeft) || keyboard.IsKeyPressed(Key.ShiftRight) ? 1.0f : -1f;
- _moveFront = DemoMath.clamp(_moveFront + tempMoveFront * dt * 4.0f, 0, 2.0f);
- _moveLeft = DemoMath.clamp(_moveLeft + tempMoveLeft * dt * 4.0f, 0, 2.0f);
- _moveBack = DemoMath.clamp(_moveBack + tempMoveBack * dt * 4.0f, 0, 2.0f);
- _moveRight = DemoMath.clamp(_moveRight + tempMoveRight * dt * 4.0f, 0, 2.0f);
- _moveUp = DemoMath.clamp(_moveUp + tempMoveUp * dt * 4.0f, 0, 2.0f);
- _moveDown = DemoMath.clamp(_moveDown + tempMoveDown * dt * 4.0f, 0, 2.0f);
- _moveAccel = DemoMath.clamp(_moveAccel + tempMoveAccel * dt * 4.0f, 0, 2.0f);
+ _moveFront = RecastMath.clamp(_moveFront + tempMoveFront * dt * 4.0f, 0, 2.0f);
+ _moveLeft = RecastMath.clamp(_moveLeft + tempMoveLeft * dt * 4.0f, 0, 2.0f);
+ _moveBack = RecastMath.clamp(_moveBack + tempMoveBack * dt * 4.0f, 0, 2.0f);
+ _moveRight = RecastMath.clamp(_moveRight + tempMoveRight * dt * 4.0f, 0, 2.0f);
+ _moveUp = RecastMath.clamp(_moveUp + tempMoveUp * dt * 4.0f, 0, 2.0f);
+ _moveDown = RecastMath.clamp(_moveDown + tempMoveDown * dt * 4.0f, 0, 2.0f);
+ _moveAccel = RecastMath.clamp(_moveAccel + tempMoveAccel * dt * 4.0f, 0, 2.0f);
}
}
@@ -708,7 +708,7 @@ public class RecastDemo
if (bmin != null && bmax != null)
{
camr = (float)(Math.Sqrt(
- DemoMath.sqr(bmax[0] - bmin[0]) + DemoMath.sqr(bmax[1] - bmin[1]) + DemoMath.sqr(bmax[2] - bmin[2]))
+ RecastMath.sqr(bmax[0] - bmin[0]) + RecastMath.sqr(bmax[1] - bmin[1]) + RecastMath.sqr(bmax[2] - bmin[2]))
/ 2);
cameraPos[0] = (bmax[0] + bmin[0]) / 2 + camr;
cameraPos[1] = (bmax[1] + bmin[1]) / 2 + camr;
diff --git a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs
index 65e36c2..deff4cd 100644
--- a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs
@@ -79,7 +79,7 @@ public class ConvexVolumeTool : Tool
// Create
// If clicked on that last pt, create the shape.
- if (pts.Count > 0 && DemoMath.vDistSqr(p,
+ if (pts.Count > 0 && RecastMath.vDistSqr(p,
new float[] { pts[pts.Count - 3], pts[pts.Count - 2], pts[pts.Count - 1] },
0) < 0.2f * 0.2f)
{
diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs
index e1293fc..62e774c 100644
--- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs
@@ -186,7 +186,7 @@ public class CrowdProfilingTool
bool valid = true;
foreach (FindRandomPointResult zone in zones)
{
- if (DemoMath.vDistSqr(zone.getRandomPt(), result.result.getRandomPt(), 0) < zoneSeparation)
+ if (RecastMath.vDistSqr(zone.getRandomPt(), result.result.getRandomPt(), 0) < zoneSeparation)
{
valid = false;
break;
@@ -310,7 +310,7 @@ public class CrowdProfilingTool
List potentialTargets = new();
foreach (FindRandomPointResult zone in zones)
{
- if (DemoMath.vDistSqr(zone.getRandomPt(), ag.npos, 0) > zoneRadius * zoneRadius)
+ if (RecastMath.vDistSqr(zone.getRandomPt(), ag.npos, 0) > zoneRadius * zoneRadius)
{
potentialTargets.Add(zone);
}
diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs
index 6e26e67..8eb0da4 100644
--- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs
@@ -30,6 +30,7 @@ using DotRecast.Recast.Demo.Geom;
using ImGuiNET;
using static DotRecast.Recast.Demo.Draw.DebugDraw;
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Recast.Demo.Tools;
@@ -323,10 +324,10 @@ public class CrowdTool : Tool
private float[] calcVel(float[] pos, float[] tgt, float speed)
{
- float[] vel = DetourCommon.vSub(tgt, pos);
+ float[] vel = vSub(tgt, pos);
vel[1] = 0.0f;
- DetourCommon.vNormalize(vel);
- return DetourCommon.vScale(vel, speed);
+ vNormalize(vel);
+ return vScale(vel, speed);
}
public override void handleRender(NavMeshRenderer renderer)
@@ -414,7 +415,7 @@ public class CrowdTool : Tool
dd.begin(LINES, 3.0f);
float[] prev = new float[3];
float preva = 1;
- DetourCommon.vCopy(prev, pos);
+ vCopy(prev, pos);
for (int j = 0; j < AGENT_MAX_TRAIL - 1; ++j)
{
int idx = (trail.htrail + AGENT_MAX_TRAIL - j) % AGENT_MAX_TRAIL;
@@ -423,7 +424,7 @@ public class CrowdTool : Tool
dd.vertex(prev[0], prev[1] + 0.1f, prev[2], duRGBA(0, 0, 0, (int)(128 * preva)));
dd.vertex(trail.trail[v], trail.trail[v + 1] + 0.1f, trail.trail[v + 2], duRGBA(0, 0, 0, (int)(128 * a)));
preva = a;
- DetourCommon.vCopy(prev, trail.trail, v);
+ vCopy(prev, trail.trail, v);
}
dd.end();
@@ -500,7 +501,7 @@ public class CrowdTool : Tool
float[] s = ag.boundary.getSegment(j);
float[] s0 = new float[] { s[0], s[1], s[2] };
float[] s3 = new float[] { s[3], s[4], s[5] };
- if (DetourCommon.triArea2D(pos, s0, s3) < 0.0f)
+ if (triArea2D(pos, s0, s3) < 0.0f)
col = duDarkenCol(col);
dd.appendArrow(s[0], s[1] + 0.2f, s[2], s[3], s[4] + 0.2f, s[5], 0.0f, 0.3f, col);
diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs
index 8c594d5..feb2ee2 100644
--- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs
@@ -33,7 +33,7 @@ using ImGuiNET;
using Silk.NET.Windowing;
using static DotRecast.Recast.Demo.Draw.DebugDraw;
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Recast.Demo.Tools;
@@ -252,7 +252,7 @@ public class DynamicUpdateTool : Tool
float[] baseUp = new float[] { 0, 1, 0 };
float[] forward = new float[] { (1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble()) };
vNormalize(forward);
- float[] side = DemoMath.vCross(forward, baseUp);
+ float[] side = RecastMath.vCross(forward, baseUp);
BoxCollider @base = new BoxCollider(baseCenter, BoxCollider.getHalfEdges(baseUp, forward, baseExtent),
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb);
float[] roofExtent = new float[] { 4.5f, 4.5f, 8f };
diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs
index 392c36e..0e81ab2 100644
--- a/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs
+++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs
@@ -1,6 +1,6 @@
using DotRecast.Recast.Demo.Draw;
using static DotRecast.Recast.RecastVectors;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs
index fb7d2f4..0c38615 100644
--- a/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs
+++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs
@@ -1,6 +1,6 @@
using DotRecast.Recast.Demo.Draw;
using static DotRecast.Recast.RecastVectors;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs
index 3aa60cb..2c041f0 100644
--- a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs
+++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs
@@ -1,6 +1,6 @@
using System;
using DotRecast.Recast.Demo.Draw;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Recast.Demo.Tools.Gizmos;
diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs
index b17f43e..1c898f1 100644
--- a/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs
+++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs
@@ -1,5 +1,5 @@
using DotRecast.Recast.Demo.Draw;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.Demo.Tools.Gizmos.GizmoHelper;
diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs
index 2779885..efcbf38 100644
--- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs
@@ -23,7 +23,7 @@ using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.Geom;
using ImGuiNET;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.Demo.Draw.DebugDraw;
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
diff --git a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs
index d748c90..c46a5c6 100644
--- a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs
@@ -56,7 +56,7 @@ public class OffMeshConnectionTool : Tool
DemoOffMeshConnection nearestConnection = null;
foreach (DemoOffMeshConnection offMeshCon in geom.getOffMeshConnections())
{
- float d = Math.Min(DemoMath.vDistSqr(p, offMeshCon.verts, 0), DemoMath.vDistSqr(p, offMeshCon.verts, 3));
+ float d = Math.Min(RecastMath.vDistSqr(p, offMeshCon.verts, 0), RecastMath.vDistSqr(p, offMeshCon.verts, 3));
if (d < nearestDist && Math.Sqrt(d) < sample.getSettingsUI().getAgentRadius())
{
nearestDist = d;
diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs
index 83f79f5..884cc28 100644
--- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs
+++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs
@@ -6,7 +6,7 @@ using DotRecast.Detour;
using DotRecast.Recast.Demo.Builder;
using DotRecast.Recast.Demo.Draw;
using ImGuiNET;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.Demo.Draw.DebugDraw;
using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
@@ -257,7 +257,7 @@ public class TestNavmeshTool : Tool
// Find movement delta.
float[] delta = vSub(steerTarget.steerPos, iterPos);
- float len = (float)Math.Sqrt(DemoMath.vDot(delta, delta));
+ float len = (float)Math.Sqrt(RecastMath.vDot(delta, delta));
// If the steer target is end of path or off-mesh link, do not move past the location.
if ((endOfPath || offMeshConnection) && len < STEP_SIZE)
{
@@ -882,8 +882,8 @@ public class TestNavmeshTool : Tool
float[] s = wallSegments.getSegmentVerts()[j];
float[] s3 = new float[] { s[3], s[4], s[5] };
// Skip too distant segments.
- Tuple distSqr = DetourCommon.distancePtSegSqr2D(m_spos, s, 0, 3);
- if (distSqr.Item1 > DemoMath.sqr(m_neighbourhoodRadius))
+ Tuple distSqr = distancePtSegSqr2D(m_spos, s, 0, 3);
+ if (distSqr.Item1 > RecastMath.sqr(m_neighbourhoodRadius))
{
continue;
}
@@ -903,7 +903,7 @@ public class TestNavmeshTool : Tool
else
{
int col = duRGBA(192, 32, 16, 192);
- if (DetourCommon.triArea2D(m_spos, s, s3) < 0.0f)
+ if (triArea2D(m_spos, s, s3) < 0.0f)
{
col = duRGBA(96, 32, 16, 192);
}
@@ -1026,7 +1026,7 @@ public class TestNavmeshTool : Tool
{
// In case of partial path, make sure the end point is clamped to the last polygon.
float[] epos = new float[3];
- DetourCommon.vCopy(epos, m_epos);
+ vCopy(epos, m_epos);
if (m_polys[m_polys.Count - 1] != m_endRef)
{
Result result = m_navQuery
diff --git a/src/DotRecast.Recast/RecastCommon.cs b/src/DotRecast.Recast/RecastCommon.cs
index c659fd7..47cf374 100644
--- a/src/DotRecast.Recast/RecastCommon.cs
+++ b/src/DotRecast.Recast/RecastCommon.cs
@@ -22,7 +22,7 @@ using System;
namespace DotRecast.Recast
{
- public class RecastCommon
+ public static class RecastCommon
{
/// Gets neighbor connection data for the specified direction.
/// @param[in] s The span to check.
@@ -75,10 +75,5 @@ namespace DotRecast.Recast
int con = s.con;
s.con = (con & ~(0x3f << shift)) | ((i & 0x3f) << shift);
}
-
- public static int clamp(int v, int min, int max)
- {
- return Math.Max(Math.Min(max, v), min);
- }
}
}
\ No newline at end of file
diff --git a/src/DotRecast.Recast/RecastCompact.cs b/src/DotRecast.Recast/RecastCompact.cs
index 9edda28..275041d 100644
--- a/src/DotRecast.Recast/RecastCompact.cs
+++ b/src/DotRecast.Recast/RecastCompact.cs
@@ -18,11 +18,12 @@ freely, subject to the following restrictions:
using System;
+using static DotRecast.Core.RecastMath;
+using static DotRecast.Recast.RecastConstants;
+using static DotRecast.Recast.RecastVectors;
+
namespace DotRecast.Recast
{
- using static RecastConstants;
- using static RecastVectors;
-
public class RecastCompact
{
private const int MAX_LAYERS = RC_NOT_CONNECTED - 1;
@@ -92,8 +93,8 @@ namespace DotRecast.Recast
{
int bot = s.smax;
int top = s.next != null ? (int)s.next.smin : MAX_HEIGHT;
- chf.spans[idx].y = RecastCommon.clamp(bot, 0, MAX_HEIGHT);
- chf.spans[idx].h = RecastCommon.clamp(top - bot, 0, MAX_HEIGHT);
+ chf.spans[idx].y = clamp(bot, 0, MAX_HEIGHT);
+ chf.spans[idx].h = clamp(top - bot, 0, MAX_HEIGHT);
chf.areas[idx] = s.area;
idx++;
c.count++;
diff --git a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs
index 2e17f8a..ae8540b 100644
--- a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs
+++ b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs
@@ -19,12 +19,12 @@ freely, subject to the following restrictions:
using System;
using DotRecast.Core;
+using static DotRecast.Core.RecastMath;
+using static DotRecast.Recast.RecastConstants;
+using static DotRecast.Recast.RecastVectors;
+
namespace DotRecast.Recast
{
- using static RecastConstants;
- using static RecastVectors;
- using static RecastCommon;
-
public class RecastFilledVolumeRasterization
{
private const float EPSILON = 0.00001f;
@@ -230,8 +230,8 @@ namespace DotRecast.Recast
int smax = (int)Math.Ceiling((h[1] - hf.bmin[1]) * ich);
if (smin != smax)
{
- int ismin = RecastCommon.clamp(smin, 0, SPAN_MAX_HEIGHT);
- int ismax = RecastCommon.clamp(smax, ismin + 1, SPAN_MAX_HEIGHT);
+ int ismin = clamp(smin, 0, SPAN_MAX_HEIGHT);
+ int ismax = clamp(smax, ismin + 1, SPAN_MAX_HEIGHT);
RecastRasterization.addSpan(hf, x, z, ismin, ismax, area, flagMergeThr);
}
}
@@ -786,11 +786,6 @@ namespace DotRecast.Recast
return dx * dx + dy * dy + dz * dz;
}
- public static float clamp(float v, float min, float max)
- {
- return Math.Max(Math.Min(max, v), min);
- }
-
private static bool overlapBounds(float[] amin, float[] amax, float[] bounds)
{
bool overlap = true;
diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs
index 63c2da4..a0d8098 100644
--- a/src/DotRecast.Recast/RecastMeshDetail.cs
+++ b/src/DotRecast.Recast/RecastMeshDetail.cs
@@ -21,11 +21,12 @@ freely, subject to the following restrictions:
using System;
using System.Collections.Generic;
using DotRecast.Core;
+using static DotRecast.Core.RecastMath;
+using static DotRecast.Recast.RecastCommon;
+using static DotRecast.Recast.RecastConstants;
namespace DotRecast.Recast
{
- using static RecastCommon;
- using static RecastConstants;
public class RecastMeshDetail
{
@@ -273,8 +274,8 @@ namespace DotRecast.Recast
{
int ix = (int)Math.Floor(fx * ics + 0.01f);
int iz = (int)Math.Floor(fz * ics + 0.01f);
- ix = RecastCommon.clamp(ix - hp.xmin, 0, hp.width - 1);
- iz = RecastCommon.clamp(iz - hp.ymin, 0, hp.height - 1);
+ ix = clamp(ix - hp.xmin, 0, hp.width - 1);
+ iz = clamp(iz - hp.ymin, 0, hp.height - 1);
int h = hp.data[ix + iz * hp.width];
if (h == RC_UNSET_HEIGHT)
{
diff --git a/src/DotRecast.Recast/RecastRasterization.cs b/src/DotRecast.Recast/RecastRasterization.cs
index 8959524..3ba9fbe 100644
--- a/src/DotRecast.Recast/RecastRasterization.cs
+++ b/src/DotRecast.Recast/RecastRasterization.cs
@@ -19,10 +19,11 @@ freely, subject to the following restrictions:
*/
using System;
+using static DotRecast.Core.RecastMath;
+using static DotRecast.Recast.RecastConstants;
namespace DotRecast.Recast
{
- using static RecastConstants;
public class RecastRasterization
{
@@ -269,8 +270,8 @@ namespace DotRecast.Recast
int w = hf.width;
int h = hf.height;
// use -1 rather than 0 to cut the polygon properly at the start of the tile
- z0 = RecastCommon.clamp(z0, -1, h - 1);
- z1 = RecastCommon.clamp(z1, 0, h - 1);
+ z0 = clamp(z0, -1, h - 1);
+ z1 = clamp(z1, 0, h - 1);
// Clip the triangle into all grid cells it touches.
float[] buf = new float[7 * 3 * 4];
@@ -320,8 +321,8 @@ namespace DotRecast.Recast
continue;
}
- x0 = RecastCommon.clamp(x0, -1, w - 1);
- x1 = RecastCommon.clamp(x1, 0, w - 1);
+ x0 = clamp(x0, -1, w - 1);
+ x1 = clamp(x1, 0, w - 1);
int nv, nv2 = nvRow;
for (int x = x0; x <= x1; ++x)
@@ -366,8 +367,8 @@ namespace DotRecast.Recast
spanMax = by;
// Snap the span to the heightfield height grid.
- int spanMinCellIndex = RecastCommon.clamp((int)Math.Floor(spanMin * inverseCellHeight), 0, SPAN_MAX_HEIGHT);
- int spanMaxCellIndex = RecastCommon.clamp((int)Math.Ceiling(spanMax * inverseCellHeight), spanMinCellIndex + 1, SPAN_MAX_HEIGHT);
+ int spanMinCellIndex = clamp((int)Math.Floor(spanMin * inverseCellHeight), 0, SPAN_MAX_HEIGHT);
+ int spanMaxCellIndex = clamp((int)Math.Ceiling(spanMax * inverseCellHeight), spanMinCellIndex + 1, SPAN_MAX_HEIGHT);
addSpan(hf, x, z, spanMinCellIndex, spanMaxCellIndex, area, flagMergeThreshold);
}
diff --git a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs
index 68b0369..e3261be 100644
--- a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs
+++ b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs
@@ -24,7 +24,7 @@ using NUnit.Framework;
namespace DotRecast.Detour.Crowd.Test;
-using static DetourCommon;
+using static DotRecast.Core.RecastMath;
public class AbstractCrowdTest
{
diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs
index 16a04b5..74151c2 100644
--- a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs
+++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs
@@ -23,7 +23,7 @@ using DotRecast.Detour.Io;
using DotRecast.Recast;
using DotRecast.Recast.Geom;
using NUnit.Framework;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Test.Io;
diff --git a/test/DotRecast.Detour.Test/RandomPointTest.cs b/test/DotRecast.Detour.Test/RandomPointTest.cs
index b7bea0e..57813fd 100644
--- a/test/DotRecast.Detour.Test/RandomPointTest.cs
+++ b/test/DotRecast.Detour.Test/RandomPointTest.cs
@@ -19,7 +19,7 @@ freely, subject to the following restrictions:
using System;
using System.Diagnostics;
using NUnit.Framework;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.Test;
diff --git a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs
index a4f470e..a86affc 100644
--- a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs
+++ b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs
@@ -21,7 +21,7 @@ freely, subject to the following restrictions:
using DotRecast.Core;
using DotRecast.Detour.TileCache.Io.Compress;
using DotRecast.Recast.Geom;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
using static DotRecast.Recast.RecastVectors;
namespace DotRecast.Detour.TileCache.Test;
diff --git a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs
index 02b9b93..c2af279 100644
--- a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs
+++ b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs
@@ -22,7 +22,7 @@ using System.Collections.Generic;
using DotRecast.Core;
using DotRecast.Recast;
using DotRecast.Recast.Geom;
-using static DotRecast.Detour.DetourCommon;
+using static DotRecast.Core.RecastMath;
namespace DotRecast.Detour.TileCache.Test;