diff --git a/src/DotRecast.Core/Intersections.cs b/src/DotRecast.Core/Intersections.cs index 8ec2ab7..27536a8 100644 --- a/src/DotRecast.Core/Intersections.cs +++ b/src/DotRecast.Core/Intersections.cs @@ -1,4 +1,5 @@ /* +Copyright (c) 2009-2010 Mikko Mononen memon@inside.org recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com diff --git a/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs b/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs index 67e8267..060003e 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs @@ -76,7 +76,7 @@ namespace DotRecast.Detour.Crowd public DtCrowdAgentParams option; /// The local path corridor corners for the agent. - public List corners = new List(); + public List corners = new List(); public DtMoveRequestState targetState; diff --git a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs index d77ace4..3816862 100644 --- a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs +++ b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs @@ -114,14 +114,14 @@ namespace DotRecast.Detour.Crowd * @param[in] navquery The query object used to build the corridor. * @return Corners */ - public int FindCorners(ref List corners, int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter) + public int FindCorners(ref List corners, int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter) { var result = navquery.FindStraightPath(m_pos, m_target, m_path, ref corners, maxCorners, 0); if (result.Succeeded()) { // Prune points in the beginning of the path which are too close. int start = 0; - foreach (StraightPathItem spi in corners) + foreach (DtStraightPath spi in corners) { if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0 || RcVec3f.Dist2DSqr(spi.pos, m_pos) > MIN_TARGET_DIST) @@ -136,7 +136,7 @@ namespace DotRecast.Detour.Crowd // Prune points after an off-mesh connection. for (int i = start; i < corners.Count; i++) { - StraightPathItem spi = corners[i]; + DtStraightPath spi = corners[i]; if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { end = i + 1; diff --git a/src/DotRecast.Detour/InFlag.cs b/src/DotRecast.Detour/DtConvexConvexInFlag.cs similarity index 69% rename from src/DotRecast.Detour/InFlag.cs rename to src/DotRecast.Detour/DtConvexConvexInFlag.cs index bdf29d3..cbfe2ea 100644 --- a/src/DotRecast.Detour/InFlag.cs +++ b/src/DotRecast.Detour/DtConvexConvexInFlag.cs @@ -1,6 +1,6 @@ namespace DotRecast.Detour { - public enum InFlag + public enum DtConvexConvexInFlag { Pin, Qin, diff --git a/src/DotRecast.Detour/Intersection.cs b/src/DotRecast.Detour/DtConvexConvexIntersection.cs similarity index 67% rename from src/DotRecast.Detour/Intersection.cs rename to src/DotRecast.Detour/DtConvexConvexIntersection.cs index 319288e..a53f8ac 100644 --- a/src/DotRecast.Detour/Intersection.cs +++ b/src/DotRecast.Detour/DtConvexConvexIntersection.cs @@ -1,6 +1,6 @@ namespace DotRecast.Detour { - public enum Intersection + public enum DtConvexConvexIntersection { None, Single, diff --git a/src/DotRecast.Detour/ConvexConvexIntersection.cs b/src/DotRecast.Detour/DtConvexConvexIntersections.cs similarity index 78% rename from src/DotRecast.Detour/ConvexConvexIntersection.cs rename to src/DotRecast.Detour/DtConvexConvexIntersections.cs index 2561ada..56df886 100644 --- a/src/DotRecast.Detour/ConvexConvexIntersection.cs +++ b/src/DotRecast.Detour/DtConvexConvexIntersections.cs @@ -25,7 +25,7 @@ namespace DotRecast.Detour /** * Convex-convex intersection based on "Computational Geometry in C" by Joseph O'Rourke */ - public static class ConvexConvexIntersection + public static class DtConvexConvexIntersections { private static readonly float EPSILON = 0.0001f; @@ -46,8 +46,8 @@ namespace DotRecast.Detour int ai = 0; int bi = 0; - InFlag f = InFlag.Unknown; - bool FirstPoint = true; + DtConvexConvexInFlag f = DtConvexConvexInFlag.Unknown; + bool firstPoint = true; RcVec3f ip = new RcVec3f(); RcVec3f iq = new RcVec3f(); @@ -70,13 +70,13 @@ namespace DotRecast.Detour } bool parallel = cross == 0f; - Intersection code = parallel ? ParallelInt(a1, a, b1, b, ref ip, ref iq) : SegSegInt(a1, a, b1, b, ref ip, ref iq); + DtConvexConvexIntersection code = parallel ? ParallelInt(a1, a, b1, b, ref ip, ref iq) : SegSegInt(a1, a, b1, b, ref ip, ref iq); - if (code == Intersection.Single) + if (code == DtConvexConvexIntersection.Single) { - if (FirstPoint) + if (firstPoint) { - FirstPoint = false; + firstPoint = false; aa = ba = 0; } @@ -87,7 +87,7 @@ namespace DotRecast.Detour /*-----Advance rules-----*/ /* Special case: A & B overlap and oppositely oriented. */ - if (code == Intersection.Overlap && A.Dot2D(B) < 0) + if (code == DtConvexConvexIntersection.Overlap && A.Dot2D(B) < 0) { ii = AddVertex(inters, ii, ip); ii = AddVertex(inters, ii, iq); @@ -103,7 +103,7 @@ namespace DotRecast.Detour else if (parallel && Math.Abs(aHB) < EPSILON && Math.Abs(bHA) < EPSILON) { /* Advance but do not output point. */ - if (f == InFlag.Pin) + if (f == DtConvexConvexInFlag.Pin) { ba++; bi++; @@ -119,7 +119,7 @@ namespace DotRecast.Detour { if (bHA > 0) { - if (f == InFlag.Pin) + if (f == DtConvexConvexInFlag.Pin) { ii = AddVertex(inters, ii, a); } @@ -129,7 +129,7 @@ namespace DotRecast.Detour } else { - if (f == InFlag.Qin) + if (f == DtConvexConvexInFlag.Qin) { ii = AddVertex(inters, ii, b); } @@ -142,7 +142,7 @@ namespace DotRecast.Detour { if (aHB > 0) { - if (f == InFlag.Qin) + if (f == DtConvexConvexInFlag.Qin) { ii = AddVertex(inters, ii, b); } @@ -152,7 +152,7 @@ namespace DotRecast.Detour } else { - if (f == InFlag.Pin) + if (f == DtConvexConvexInFlag.Pin) { ii = AddVertex(inters, ii, a); } @@ -165,7 +165,7 @@ namespace DotRecast.Detour } while ((aa < n || ba < m) && aa < 2 * n && ba < 2 * m); /* Deal with special cases: not implemented. */ - if (f == InFlag.Unknown) + if (f == DtConvexConvexInFlag.Unknown) { return null; } @@ -175,27 +175,6 @@ namespace DotRecast.Detour return copied; } - private static int AddVertex(float[] inters, int ii, float[] p) - { - if (ii > 0) - { - if (inters[ii - 3] == p[0] && inters[ii - 2] == p[1] && inters[ii - 1] == p[2]) - { - return ii; - } - - if (inters[0] == p[0] && inters[1] == p[1] && inters[2] == p[2]) - { - return ii; - } - } - - inters[ii] = p[0]; - inters[ii + 1] = p[1]; - inters[ii + 2] = p[2]; - return ii + 3; - } - private static int AddVertex(float[] inters, int ii, RcVec3f p) { if (ii > 0) @@ -218,21 +197,21 @@ namespace DotRecast.Detour } - private static InFlag InOut(InFlag inflag, float aHB, float bHA) + private static DtConvexConvexInFlag InOut(DtConvexConvexInFlag inflag, float aHB, float bHA) { if (aHB > 0) { - return InFlag.Pin; + return DtConvexConvexInFlag.Pin; } else if (bHA > 0) { - return InFlag.Qin; + return DtConvexConvexInFlag.Qin; } return inflag; } - private static Intersection SegSegInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) + private static DtConvexConvexIntersection SegSegInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) { if (DtUtils.IntersectSegSeg2D(a, b, c, d, out var s, out var t)) { @@ -241,58 +220,58 @@ namespace DotRecast.Detour p.x = a.x + (b.x - a.x) * s; p.y = a.y + (b.y - a.y) * s; p.z = a.z + (b.z - a.z) * s; - return Intersection.Single; + return DtConvexConvexIntersection.Single; } } - return Intersection.None; + return DtConvexConvexIntersection.None; } - private static Intersection ParallelInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) + private static DtConvexConvexIntersection ParallelInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) { if (Between(a, b, c) && Between(a, b, d)) { p = c; q = d; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } if (Between(c, d, a) && Between(c, d, b)) { p = a; q = b; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } if (Between(a, b, c) && Between(c, d, b)) { p = c; q = b; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } if (Between(a, b, c) && Between(c, d, a)) { p = c; q = a; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } if (Between(a, b, d) && Between(c, d, b)) { p = d; q = b; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } if (Between(a, b, d) && Between(c, d, a)) { p = d; q = a; - return Intersection.Overlap; + return DtConvexConvexIntersection.Overlap; } - return Intersection.None; + return DtConvexConvexIntersection.None; } private static bool Between(RcVec3f a, RcVec3f b, RcVec3f c) diff --git a/src/DotRecast.Detour/DefaultQueryHeuristic.cs b/src/DotRecast.Detour/DtDefaultQueryHeuristic.cs similarity index 85% rename from src/DotRecast.Detour/DefaultQueryHeuristic.cs rename to src/DotRecast.Detour/DtDefaultQueryHeuristic.cs index 21c2f87..9e5a222 100644 --- a/src/DotRecast.Detour/DefaultQueryHeuristic.cs +++ b/src/DotRecast.Detour/DtDefaultQueryHeuristic.cs @@ -22,14 +22,14 @@ using DotRecast.Core; namespace DotRecast.Detour { - public class DefaultQueryHeuristic : IQueryHeuristic + public class DtDefaultQueryHeuristic : IDtQueryHeuristic { public const float H_SCALE = 0.999f; // Search heuristic scale. - public static readonly DefaultQueryHeuristic Default = new DefaultQueryHeuristic(H_SCALE); + public static readonly DtDefaultQueryHeuristic Default = new DtDefaultQueryHeuristic(H_SCALE); private readonly float scale; - public DefaultQueryHeuristic(float scale) + public DtDefaultQueryHeuristic(float scale) { this.scale = scale; } diff --git a/src/DotRecast.Detour/DtFindPathOption.cs b/src/DotRecast.Detour/DtFindPathOption.cs index bc130b1..7c119d9 100644 --- a/src/DotRecast.Detour/DtFindPathOption.cs +++ b/src/DotRecast.Detour/DtFindPathOption.cs @@ -2,16 +2,16 @@ { public readonly struct DtFindPathOption { - public static readonly DtFindPathOption NoOption = new DtFindPathOption(DefaultQueryHeuristic.Default, 0, 0); + public static readonly DtFindPathOption NoOption = new DtFindPathOption(DtDefaultQueryHeuristic.Default, 0, 0); - public static readonly DtFindPathOption AnyAngle = new DtFindPathOption(DefaultQueryHeuristic.Default, DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue); - public static readonly DtFindPathOption ZeroScale = new DtFindPathOption(new DefaultQueryHeuristic(0.0f), 0, 0); + public static readonly DtFindPathOption AnyAngle = new DtFindPathOption(DtDefaultQueryHeuristic.Default, DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE, float.MaxValue); + public static readonly DtFindPathOption ZeroScale = new DtFindPathOption(new DtDefaultQueryHeuristic(0.0f), 0, 0); - public readonly IQueryHeuristic heuristic; + public readonly IDtQueryHeuristic heuristic; public readonly int options; public readonly float raycastLimit; - public DtFindPathOption(IQueryHeuristic heuristic, int options, float raycastLimit) + public DtFindPathOption(IDtQueryHeuristic heuristic, int options, float raycastLimit) { this.heuristic = heuristic; this.options = options; @@ -19,7 +19,7 @@ } public DtFindPathOption(int options, float raycastLimit) - : this(DefaultQueryHeuristic.Default, options, raycastLimit) + : this(DtDefaultQueryHeuristic.Default, options, raycastLimit) { } } diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 4827a6e..d19ec32 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -1024,15 +1024,15 @@ namespace DotRecast.Detour */ public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options) { - return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DefaultQueryHeuristic.Default, -1.0f); + return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DtDefaultQueryHeuristic.Default, -1.0f); } public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options, float raycastLimit) { - return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DefaultQueryHeuristic.Default, raycastLimit); + return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DtDefaultQueryHeuristic.Default, raycastLimit); } - public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options, IQueryHeuristic heuristic, float raycastLimit) + public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options, IDtQueryHeuristic heuristic, float raycastLimit) { // Init path state. m_query = new DtQueryData(); @@ -1431,20 +1431,20 @@ namespace DotRecast.Detour return DtStatus.DT_SUCCSESS | details; } - protected DtStatus AppendVertex(RcVec3f pos, int flags, long refs, ref List straightPath, + protected DtStatus AppendVertex(RcVec3f pos, int flags, long refs, ref List straightPath, int maxStraightPath) { if (straightPath.Count > 0 && DtUtils.VEqual(straightPath[straightPath.Count - 1].pos, pos)) { // The vertices are equal, update flags and poly. - straightPath[straightPath.Count - 1] = new StraightPathItem(straightPath[straightPath.Count - 1].pos, flags, refs); + straightPath[straightPath.Count - 1] = new DtStraightPath(straightPath[straightPath.Count - 1].pos, flags, refs); } else { if (straightPath.Count < maxStraightPath) { // Append new vertex. - straightPath.Add(new StraightPathItem(pos, flags, refs)); + straightPath.Add(new DtStraightPath(pos, flags, refs)); } // If reached end of path or there is no space to append more vertices, return. @@ -1458,7 +1458,7 @@ namespace DotRecast.Detour } protected DtStatus AppendPortals(int startIdx, int endIdx, RcVec3f endPos, List path, - ref List straightPath, int maxStraightPath, int options) + ref List straightPath, int maxStraightPath, int options) { var startPos = straightPath[straightPath.Count - 1].pos; // Append or update last vertex @@ -1537,7 +1537,7 @@ namespace DotRecast.Detour /// @param[in] options Query options. (see: #dtStraightPathOptions) /// @returns The status flags for the query. public virtual DtStatus FindStraightPath(RcVec3f startPos, RcVec3f endPos, List path, - ref List straightPath, + ref List straightPath, int maxStraightPath, int options) { if (!RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == straightPath diff --git a/src/DotRecast.Detour/DtQueryData.cs b/src/DotRecast.Detour/DtQueryData.cs index 8a872bf..ea925c2 100644 --- a/src/DotRecast.Detour/DtQueryData.cs +++ b/src/DotRecast.Detour/DtQueryData.cs @@ -34,6 +34,6 @@ namespace DotRecast.Detour public IDtQueryFilter filter; public int options; public float raycastLimitSqr; - public IQueryHeuristic heuristic; + public IDtQueryHeuristic heuristic; } } \ No newline at end of file diff --git a/src/DotRecast.Detour/StraightPathItem.cs b/src/DotRecast.Detour/DtStraightPath.cs similarity index 92% rename from src/DotRecast.Detour/StraightPathItem.cs rename to src/DotRecast.Detour/DtStraightPath.cs index d675bf4..a04d740 100644 --- a/src/DotRecast.Detour/StraightPathItem.cs +++ b/src/DotRecast.Detour/DtStraightPath.cs @@ -23,13 +23,13 @@ using DotRecast.Core; namespace DotRecast.Detour { //TODO: (PP) Add comments - public readonly struct StraightPathItem + public readonly struct DtStraightPath { public readonly RcVec3f pos; public readonly int flags; public readonly long refs; - public StraightPathItem(RcVec3f pos, int flags, long refs) + public DtStraightPath(RcVec3f pos, int flags, long refs) { this.pos = pos; this.flags = flags; diff --git a/src/DotRecast.Detour/DtStrictDtPolygonByCircleConstraint.cs b/src/DotRecast.Detour/DtStrictDtPolygonByCircleConstraint.cs index d2e7c64..1278b58 100644 --- a/src/DotRecast.Detour/DtStrictDtPolygonByCircleConstraint.cs +++ b/src/DotRecast.Detour/DtStrictDtPolygonByCircleConstraint.cs @@ -51,7 +51,7 @@ namespace DotRecast.Detour } float[] qCircle = Circle(center, radius); - float[] intersection = ConvexConvexIntersection.Intersect(verts, qCircle); + float[] intersection = DtConvexConvexIntersections.Intersect(verts, qCircle); if (intersection == null && DtUtils.PointInPolygon(center, verts, verts.Length / 3)) { // circle inside polygon diff --git a/src/DotRecast.Detour/IQueryHeuristic.cs b/src/DotRecast.Detour/IDtQueryHeuristic.cs similarity index 96% rename from src/DotRecast.Detour/IQueryHeuristic.cs rename to src/DotRecast.Detour/IDtQueryHeuristic.cs index 8b60e48..8a5c051 100644 --- a/src/DotRecast.Detour/IQueryHeuristic.cs +++ b/src/DotRecast.Detour/IDtQueryHeuristic.cs @@ -21,7 +21,7 @@ using DotRecast.Core; namespace DotRecast.Detour { - public interface IQueryHeuristic + public interface IDtQueryHeuristic { float GetCost(RcVec3f neighbourPos, RcVec3f endPos); } diff --git a/src/DotRecast.Detour/PathUtils.cs b/src/DotRecast.Detour/PathUtils.cs index c46989f..c819947 100644 --- a/src/DotRecast.Detour/PathUtils.cs +++ b/src/DotRecast.Detour/PathUtils.cs @@ -38,7 +38,7 @@ namespace DotRecast.Detour steerPosRef = 0; // Find steer target. - var straightPath = new List(MAX_STEER_POINTS); + var straightPath = new List(MAX_STEER_POINTS); var result = navQuery.FindStraightPath(startPos, endPos, path, ref straightPath, MAX_STEER_POINTS, 0); if (result.Failed()) { diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs index adde6e0..826680b 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs @@ -56,7 +56,7 @@ public class TestNavmeshSampleTool : ISampleTool private bool m_hitResult; private float m_distanceToWall; - private List m_straightPath; + private List m_straightPath; private List m_polys; private List m_parent; private float m_neighbourhoodRadius; @@ -285,8 +285,8 @@ public class TestNavmeshSampleTool : ISampleTool dd.Begin(LINES, 2.0f); for (int i = 0; i < m_straightPath.Count - 1; ++i) { - StraightPathItem straightPathItem = m_straightPath[i]; - StraightPathItem straightPathItem2 = m_straightPath[i + 1]; + DtStraightPath straightPathItem = m_straightPath[i]; + DtStraightPath straightPathItem2 = m_straightPath[i + 1]; int col; if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { @@ -305,7 +305,7 @@ public class TestNavmeshSampleTool : ISampleTool dd.Begin(POINTS, 6.0f); for (int i = 0; i < m_straightPath.Count; ++i) { - StraightPathItem straightPathItem = m_straightPath[i]; + DtStraightPath straightPathItem = m_straightPath[i]; int col; if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0) { @@ -350,8 +350,8 @@ public class TestNavmeshSampleTool : ISampleTool dd.Begin(LINES, 2.0f); for (int i = 0; i < m_straightPath.Count - 1; ++i) { - StraightPathItem straightPathItem = m_straightPath[i]; - StraightPathItem straightPathItem2 = m_straightPath[i + 1]; + DtStraightPath straightPathItem = m_straightPath[i]; + DtStraightPath straightPathItem2 = m_straightPath[i + 1]; dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, straightPathItem.pos.z, spathCol); dd.Vertex(straightPathItem2.pos.x, straightPathItem2.pos.y + 0.4f, straightPathItem2.pos.z, spathCol); } @@ -360,7 +360,7 @@ public class TestNavmeshSampleTool : ISampleTool dd.Begin(POINTS, 4.0f); for (int i = 0; i < m_straightPath.Count; ++i) { - StraightPathItem straightPathItem = m_straightPath[i]; + DtStraightPath straightPathItem = m_straightPath[i]; dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, straightPathItem.pos.z, spathCol); } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs index 35bab9c..2131e66 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs @@ -163,7 +163,7 @@ namespace DotRecast.Recast.Toolset.Tools } public DtStatus FindStraightPath(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPt, RcVec3f endPt, IDtQueryFilter filter, bool enableRaycast, - ref List polys, ref List straightPath, int straightPathOptions) + ref List polys, ref List straightPath, int straightPathOptions) { if (startRef == 0 || endRef == 0) { @@ -171,7 +171,7 @@ namespace DotRecast.Recast.Toolset.Tools } polys ??= new List(); - straightPath ??= new List(); + straightPath ??= new List(); polys.Clear(); straightPath.Clear(); @@ -212,7 +212,7 @@ namespace DotRecast.Recast.Toolset.Tools } public DtStatus UpdateSlicedFindPath(DtNavMeshQuery navQuery, int maxIter, long endRef, RcVec3f startPos, RcVec3f endPos, - ref List path, ref List straightPath) + ref List path, ref List straightPath) { var status = navQuery.UpdateSlicedFindPath(maxIter, out _); @@ -237,7 +237,7 @@ namespace DotRecast.Recast.Toolset.Tools } } - straightPath = new List(MAX_POLYS); + straightPath = new List(MAX_POLYS); navQuery.FindStraightPath(startPos, epos, path, ref straightPath, MAX_POLYS, DtNavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS); } @@ -246,7 +246,7 @@ namespace DotRecast.Recast.Toolset.Tools public DtStatus Raycast(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, - ref List polys, ref List straightPath, ref RcVec3f hitPos, ref RcVec3f hitNormal, ref bool hitResult) + ref List polys, ref List straightPath, ref RcVec3f hitPos, ref RcVec3f hitNormal, ref bool hitResult) { if (startRef == 0 || endRef == 0) { @@ -289,10 +289,10 @@ namespace DotRecast.Recast.Toolset.Tools } } - straightPath ??= new List(); + straightPath ??= new List(); straightPath.Clear(); - straightPath.Add(new StraightPathItem(startPos, 0, 0)); - straightPath.Add(new StraightPathItem(hitPos, 0, 0)); + straightPath.Add(new DtStraightPath(startPos, 0, 0)); + straightPath.Add(new DtStraightPath(hitPos, 0, 0)); return status; } diff --git a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs index cd8fcb3..55ffded 100644 --- a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs @@ -40,28 +40,28 @@ public class PathCorridorTest [Test] public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned() { - List straightPath = new(); - straightPath.Add(new StraightPathItem(RcVec3f.Of(11, 20, 30.00001f), 0, 0)); - straightPath.Add(new StraightPathItem(RcVec3f.Of(12, 20, 30.00002f), 0, 0)); - straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); - straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); + List straightPath = new(); + straightPath.Add(new DtStraightPath(RcVec3f.Of(11, 20, 30.00001f), 0, 0)); + straightPath.Add(new DtStraightPath(RcVec3f.Of(12, 20, 30.00002f), 0, 0)); + straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), 0, 0)); + straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), 0, 0)); var mockQuery = new Mock(It.IsAny()); mockQuery.Setup(q => q.FindStraightPath( It.IsAny(), It.IsAny(), It.IsAny>(), - ref It.Ref>.IsAny, + ref It.Ref>.IsAny, It.IsAny(), It.IsAny()) ) .Callback((RcVec3f startPos, RcVec3f endPos, List path, - ref List refStraightPath, int maxStraightPath, int options) => + ref List refStraightPath, int maxStraightPath, int options) => { refStraightPath = straightPath; }) .Returns(() => DtStatus.DT_SUCCSESS); - var path = new List(); + var path = new List(); corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter); Assert.That(path.Count, Is.EqualTo(4)); Assert.That(path, Is.EqualTo(straightPath)); @@ -70,31 +70,31 @@ public class PathCorridorTest [Test] public void ShouldPrunePathInFindCorners() { - List straightPath = new(); - straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00001f), 0, 0)); // too close - straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close - straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); - straightPath.Add(new StraightPathItem(RcVec3f.Of(12f, 22, 33f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh - straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh + List straightPath = new(); + straightPath.Add(new DtStraightPath(RcVec3f.Of(10, 20, 30.00001f), 0, 0)); // too close + straightPath.Add(new DtStraightPath(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close + straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), 0, 0)); + straightPath.Add(new DtStraightPath(RcVec3f.Of(12f, 22, 33f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh + straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh var mockQuery = new Mock(It.IsAny()); mockQuery.Setup(q => q.FindStraightPath( It.IsAny(), It.IsAny(), It.IsAny>(), - ref It.Ref>.IsAny, + ref It.Ref>.IsAny, It.IsAny(), It.IsAny()) ).Callback((RcVec3f startPos, RcVec3f endPos, List path, - ref List refStraightPath, int maxStraightPath, int options) => + ref List refStraightPath, int maxStraightPath, int options) => { refStraightPath = straightPath; }) .Returns(() => DtStatus.DT_SUCCSESS); - var path = new List(); + var path = new List(); corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter); Assert.That(path.Count, Is.EqualTo(2)); - Assert.That(path, Is.EqualTo(new List { straightPath[2], straightPath[3] })); + Assert.That(path, Is.EqualTo(new List { straightPath[2], straightPath[3] })); } } \ No newline at end of file diff --git a/test/DotRecast.Detour.Test/ConvexConvexIntersectionTest.cs b/test/DotRecast.Detour.Test/ConvexConvexIntersectionTest.cs index 80cef40..02f1814 100644 --- a/test/DotRecast.Detour.Test/ConvexConvexIntersectionTest.cs +++ b/test/DotRecast.Detour.Test/ConvexConvexIntersectionTest.cs @@ -29,7 +29,7 @@ public class ConvexConvexIntersectionTest { float[] p = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; float[] q = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; - float[] intersection = ConvexConvexIntersection.Intersect(p, q); + float[] intersection = DtConvexConvexIntersections.Intersect(p, q); Assert.That(intersection.Length, Is.EqualTo(5 * 3)); Assert.That(intersection, Is.EqualTo(p)); } @@ -39,7 +39,7 @@ public class ConvexConvexIntersectionTest { float[] p = { -5, 0, -5, -5, 0, 4, 1, 0, 4, 1, 0, -5 }; float[] q = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; - float[] intersection = ConvexConvexIntersection.Intersect(p, q); + float[] intersection = DtConvexConvexIntersections.Intersect(p, q); Assert.That(intersection.Length, Is.EqualTo(5 * 3)); Assert.That(intersection, Is.EqualTo(new[] { 1, 0, 3, 1, 0, -3.4f, -2, 0, -4, -4, 0, 0, -3, 0, 3 })); } diff --git a/test/DotRecast.Detour.Test/FindPathTest.cs b/test/DotRecast.Detour.Test/FindPathTest.cs index 331ab76..14c4fca 100644 --- a/test/DotRecast.Detour.Test/FindPathTest.cs +++ b/test/DotRecast.Detour.Test/FindPathTest.cs @@ -71,63 +71,63 @@ public class FindPathTest : AbstractDetourTest } }; - private static readonly StraightPathItem[][] STRAIGHT_PATHS = + private static readonly DtStraightPath[][] STRAIGHT_PATHS = { new[] { - new StraightPathItem(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L), - new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L), - new StraightPathItem(RcVec3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L), - new StraightPathItem(RcVec3f.Of(6.457663f, 10.197294f, -18.334061f), 2, 0L) + new DtStraightPath(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L), + new DtStraightPath(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L), + new DtStraightPath(RcVec3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L), + new DtStraightPath(RcVec3f.Of(6.457663f, 10.197294f, -18.334061f), 2, 0L) }, new[] { - new StraightPathItem(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L), - new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L), - new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L), - new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L), - new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L), - new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L), - new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L), - new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L), - new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L), - new StraightPathItem(RcVec3f.Of(-11.815216f, 0.197294f, 3.008419f), 2, 0L) + new DtStraightPath(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L), + new DtStraightPath(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L), + new DtStraightPath(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L), + new DtStraightPath(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L), + new DtStraightPath(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L), + new DtStraightPath(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L), + new DtStraightPath(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L), + new DtStraightPath(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L), + new DtStraightPath(RcVec3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L), + new DtStraightPath(RcVec3f.Of(-11.815216f, 0.197294f, 3.008419f), 2, 0L) }, new[] { - new StraightPathItem(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L), - new StraightPathItem(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L), - new StraightPathItem(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L), - new StraightPathItem(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L), - new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), - new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), - new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L), - new StraightPathItem(RcVec3f.Of(38.423977f, 10.197294f, -0.116067f), 2, 0L) + new DtStraightPath(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L), + new DtStraightPath(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L), + new DtStraightPath(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L), + new DtStraightPath(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L), + new DtStraightPath(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), + new DtStraightPath(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), + new DtStraightPath(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L), + new DtStraightPath(RcVec3f.Of(38.423977f, 10.197294f, -0.116067f), 2, 0L) }, new[] { - new StraightPathItem(RcVec3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L), - new StraightPathItem(RcVec3f.Of(0.863553f, 10.197294f, -10.310320f), 2, 0L) + new DtStraightPath(RcVec3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L), + new DtStraightPath(RcVec3f.Of(0.863553f, 10.197294f, -10.310320f), 2, 0L) }, new[] { - new StraightPathItem(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L), - new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L), - new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L), - new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L), - new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L), - new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), - new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), - new StraightPathItem(RcVec3f.Of(18.784092f, 10.197294f, 3.054368f), 2, 0L) + new DtStraightPath(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L), + new DtStraightPath(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L), + new DtStraightPath(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L), + new DtStraightPath(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L), + new DtStraightPath(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L), + new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), + new DtStraightPath(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), + new DtStraightPath(RcVec3f.Of(18.784092f, 10.197294f, 3.054368f), 2, 0L) } }; @@ -193,7 +193,7 @@ public class FindPathTest : AbstractDetourTest var startPos = startPoss[i]; var endPos = endPoss[i]; var status = query.FindPath(startRef, endRef, startPos, endPos, filter, ref path, DtFindPathOption.NoOption); - var straightPath = new List(); + var straightPath = new List(); query.FindStraightPath(startPos, endPos, path, ref straightPath, int.MaxValue, 0); Assert.That(straightPath.Count, Is.EqualTo(STRAIGHT_PATHS[i].Length)); for (int j = 0; j < STRAIGHT_PATHS[i].Length; j++) diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs index f99da57..b40e971 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs @@ -58,7 +58,7 @@ public class TileCacheFindPathTest : AbstractTileCacheTest int maxStraightPath = 256; int options = 0; - var pathStr = new List(); + var pathStr = new List(); query.FindStraightPath(startPos, endPos, path, ref pathStr, maxStraightPath, options); Assert.That(pathStr.Count, Is.EqualTo(8)); }