forked from bit/DotRecastNetSim
refactoring: prefix Dt
This commit is contained in:
parent
72a93f0e73
commit
e02e097577
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
||||||
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
|
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
|
||||||
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
|
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
public DtCrowdAgentParams option;
|
public DtCrowdAgentParams option;
|
||||||
|
|
||||||
/// The local path corridor corners for the agent.
|
/// The local path corridor corners for the agent.
|
||||||
public List<StraightPathItem> corners = new List<StraightPathItem>();
|
public List<DtStraightPath> corners = new List<DtStraightPath>();
|
||||||
|
|
||||||
public DtMoveRequestState targetState;
|
public DtMoveRequestState targetState;
|
||||||
|
|
||||||
|
|
|
@ -114,14 +114,14 @@ namespace DotRecast.Detour.Crowd
|
||||||
* @param[in] navquery The query object used to build the corridor.
|
* @param[in] navquery The query object used to build the corridor.
|
||||||
* @return Corners
|
* @return Corners
|
||||||
*/
|
*/
|
||||||
public int FindCorners(ref List<StraightPathItem> corners, int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter)
|
public int FindCorners(ref List<DtStraightPath> corners, int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter)
|
||||||
{
|
{
|
||||||
var result = navquery.FindStraightPath(m_pos, m_target, m_path, ref corners, maxCorners, 0);
|
var result = navquery.FindStraightPath(m_pos, m_target, m_path, ref corners, maxCorners, 0);
|
||||||
if (result.Succeeded())
|
if (result.Succeeded())
|
||||||
{
|
{
|
||||||
// Prune points in the beginning of the path which are too close.
|
// Prune points in the beginning of the path which are too close.
|
||||||
int start = 0;
|
int start = 0;
|
||||||
foreach (StraightPathItem spi in corners)
|
foreach (DtStraightPath spi in corners)
|
||||||
{
|
{
|
||||||
if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
|
if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0
|
||||||
|| RcVec3f.Dist2DSqr(spi.pos, m_pos) > MIN_TARGET_DIST)
|
|| RcVec3f.Dist2DSqr(spi.pos, m_pos) > MIN_TARGET_DIST)
|
||||||
|
@ -136,7 +136,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
// Prune points after an off-mesh connection.
|
// Prune points after an off-mesh connection.
|
||||||
for (int i = start; i < corners.Count; i++)
|
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)
|
if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
|
||||||
{
|
{
|
||||||
end = i + 1;
|
end = i + 1;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public enum InFlag
|
public enum DtConvexConvexInFlag
|
||||||
{
|
{
|
||||||
Pin,
|
Pin,
|
||||||
Qin,
|
Qin,
|
|
@ -1,6 +1,6 @@
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public enum Intersection
|
public enum DtConvexConvexIntersection
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Single,
|
Single,
|
|
@ -25,7 +25,7 @@ namespace DotRecast.Detour
|
||||||
/**
|
/**
|
||||||
* Convex-convex intersection based on "Computational Geometry in C" by Joseph O'Rourke
|
* 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;
|
private static readonly float EPSILON = 0.0001f;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ namespace DotRecast.Detour
|
||||||
int ai = 0;
|
int ai = 0;
|
||||||
int bi = 0;
|
int bi = 0;
|
||||||
|
|
||||||
InFlag f = InFlag.Unknown;
|
DtConvexConvexInFlag f = DtConvexConvexInFlag.Unknown;
|
||||||
bool FirstPoint = true;
|
bool firstPoint = true;
|
||||||
RcVec3f ip = new RcVec3f();
|
RcVec3f ip = new RcVec3f();
|
||||||
RcVec3f iq = new RcVec3f();
|
RcVec3f iq = new RcVec3f();
|
||||||
|
|
||||||
|
@ -70,13 +70,13 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parallel = cross == 0f;
|
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;
|
aa = ba = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace DotRecast.Detour
|
||||||
/*-----Advance rules-----*/
|
/*-----Advance rules-----*/
|
||||||
|
|
||||||
/* Special case: A & B overlap and oppositely oriented. */
|
/* 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, ip);
|
||||||
ii = AddVertex(inters, ii, iq);
|
ii = AddVertex(inters, ii, iq);
|
||||||
|
@ -103,7 +103,7 @@ namespace DotRecast.Detour
|
||||||
else if (parallel && Math.Abs(aHB) < EPSILON && Math.Abs(bHA) < EPSILON)
|
else if (parallel && Math.Abs(aHB) < EPSILON && Math.Abs(bHA) < EPSILON)
|
||||||
{
|
{
|
||||||
/* Advance but do not output point. */
|
/* Advance but do not output point. */
|
||||||
if (f == InFlag.Pin)
|
if (f == DtConvexConvexInFlag.Pin)
|
||||||
{
|
{
|
||||||
ba++;
|
ba++;
|
||||||
bi++;
|
bi++;
|
||||||
|
@ -119,7 +119,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
if (bHA > 0)
|
if (bHA > 0)
|
||||||
{
|
{
|
||||||
if (f == InFlag.Pin)
|
if (f == DtConvexConvexInFlag.Pin)
|
||||||
{
|
{
|
||||||
ii = AddVertex(inters, ii, a);
|
ii = AddVertex(inters, ii, a);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (f == InFlag.Qin)
|
if (f == DtConvexConvexInFlag.Qin)
|
||||||
{
|
{
|
||||||
ii = AddVertex(inters, ii, b);
|
ii = AddVertex(inters, ii, b);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
if (aHB > 0)
|
if (aHB > 0)
|
||||||
{
|
{
|
||||||
if (f == InFlag.Qin)
|
if (f == DtConvexConvexInFlag.Qin)
|
||||||
{
|
{
|
||||||
ii = AddVertex(inters, ii, b);
|
ii = AddVertex(inters, ii, b);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (f == InFlag.Pin)
|
if (f == DtConvexConvexInFlag.Pin)
|
||||||
{
|
{
|
||||||
ii = AddVertex(inters, ii, a);
|
ii = AddVertex(inters, ii, a);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ namespace DotRecast.Detour
|
||||||
} while ((aa < n || ba < m) && aa < 2 * n && ba < 2 * m);
|
} while ((aa < n || ba < m) && aa < 2 * n && ba < 2 * m);
|
||||||
|
|
||||||
/* Deal with special cases: not implemented. */
|
/* Deal with special cases: not implemented. */
|
||||||
if (f == InFlag.Unknown)
|
if (f == DtConvexConvexInFlag.Unknown)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -175,27 +175,6 @@ namespace DotRecast.Detour
|
||||||
return copied;
|
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)
|
private static int AddVertex(float[] inters, int ii, RcVec3f p)
|
||||||
{
|
{
|
||||||
if (ii > 0)
|
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)
|
if (aHB > 0)
|
||||||
{
|
{
|
||||||
return InFlag.Pin;
|
return DtConvexConvexInFlag.Pin;
|
||||||
}
|
}
|
||||||
else if (bHA > 0)
|
else if (bHA > 0)
|
||||||
{
|
{
|
||||||
return InFlag.Qin;
|
return DtConvexConvexInFlag.Qin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return inflag;
|
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))
|
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.x = a.x + (b.x - a.x) * s;
|
||||||
p.y = a.y + (b.y - a.y) * s;
|
p.y = a.y + (b.y - a.y) * s;
|
||||||
p.z = a.z + (b.z - a.z) * 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))
|
if (Between(a, b, c) && Between(a, b, d))
|
||||||
{
|
{
|
||||||
p = c;
|
p = c;
|
||||||
q = d;
|
q = d;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Between(c, d, a) && Between(c, d, b))
|
if (Between(c, d, a) && Between(c, d, b))
|
||||||
{
|
{
|
||||||
p = a;
|
p = a;
|
||||||
q = b;
|
q = b;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Between(a, b, c) && Between(c, d, b))
|
if (Between(a, b, c) && Between(c, d, b))
|
||||||
{
|
{
|
||||||
p = c;
|
p = c;
|
||||||
q = b;
|
q = b;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Between(a, b, c) && Between(c, d, a))
|
if (Between(a, b, c) && Between(c, d, a))
|
||||||
{
|
{
|
||||||
p = c;
|
p = c;
|
||||||
q = a;
|
q = a;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Between(a, b, d) && Between(c, d, b))
|
if (Between(a, b, d) && Between(c, d, b))
|
||||||
{
|
{
|
||||||
p = d;
|
p = d;
|
||||||
q = b;
|
q = b;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Between(a, b, d) && Between(c, d, a))
|
if (Between(a, b, d) && Between(c, d, a))
|
||||||
{
|
{
|
||||||
p = d;
|
p = d;
|
||||||
q = a;
|
q = a;
|
||||||
return Intersection.Overlap;
|
return DtConvexConvexIntersection.Overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Intersection.None;
|
return DtConvexConvexIntersection.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool Between(RcVec3f a, RcVec3f b, RcVec3f c)
|
private static bool Between(RcVec3f a, RcVec3f b, RcVec3f c)
|
|
@ -22,14 +22,14 @@ using DotRecast.Core;
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public class DefaultQueryHeuristic : IQueryHeuristic
|
public class DtDefaultQueryHeuristic : IDtQueryHeuristic
|
||||||
{
|
{
|
||||||
public const float H_SCALE = 0.999f; // Search heuristic scale.
|
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;
|
private readonly float scale;
|
||||||
|
|
||||||
public DefaultQueryHeuristic(float scale)
|
public DtDefaultQueryHeuristic(float scale)
|
||||||
{
|
{
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
}
|
}
|
|
@ -2,16 +2,16 @@
|
||||||
{
|
{
|
||||||
public readonly struct DtFindPathOption
|
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 AnyAngle = new DtFindPathOption(DtDefaultQueryHeuristic.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 ZeroScale = new DtFindPathOption(new DtDefaultQueryHeuristic(0.0f), 0, 0);
|
||||||
|
|
||||||
public readonly IQueryHeuristic heuristic;
|
public readonly IDtQueryHeuristic heuristic;
|
||||||
public readonly int options;
|
public readonly int options;
|
||||||
public readonly float raycastLimit;
|
public readonly float raycastLimit;
|
||||||
|
|
||||||
public DtFindPathOption(IQueryHeuristic heuristic, int options, float raycastLimit)
|
public DtFindPathOption(IDtQueryHeuristic heuristic, int options, float raycastLimit)
|
||||||
{
|
{
|
||||||
this.heuristic = heuristic;
|
this.heuristic = heuristic;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtFindPathOption(int options, float raycastLimit)
|
public DtFindPathOption(int options, float raycastLimit)
|
||||||
: this(DefaultQueryHeuristic.Default, options, raycastLimit)
|
: this(DtDefaultQueryHeuristic.Default, options, raycastLimit)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1024,15 +1024,15 @@ namespace DotRecast.Detour
|
||||||
*/
|
*/
|
||||||
public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options)
|
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)
|
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.
|
// Init path state.
|
||||||
m_query = new DtQueryData();
|
m_query = new DtQueryData();
|
||||||
|
@ -1431,20 +1431,20 @@ namespace DotRecast.Detour
|
||||||
return DtStatus.DT_SUCCSESS | details;
|
return DtStatus.DT_SUCCSESS | details;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DtStatus AppendVertex(RcVec3f pos, int flags, long refs, ref List<StraightPathItem> straightPath,
|
protected DtStatus AppendVertex(RcVec3f pos, int flags, long refs, ref List<DtStraightPath> straightPath,
|
||||||
int maxStraightPath)
|
int maxStraightPath)
|
||||||
{
|
{
|
||||||
if (straightPath.Count > 0 && DtUtils.VEqual(straightPath[straightPath.Count - 1].pos, pos))
|
if (straightPath.Count > 0 && DtUtils.VEqual(straightPath[straightPath.Count - 1].pos, pos))
|
||||||
{
|
{
|
||||||
// The vertices are equal, update flags and poly.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
if (straightPath.Count < maxStraightPath)
|
if (straightPath.Count < maxStraightPath)
|
||||||
{
|
{
|
||||||
// Append new vertex.
|
// 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.
|
// 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<long> path,
|
protected DtStatus AppendPortals(int startIdx, int endIdx, RcVec3f endPos, List<long> path,
|
||||||
ref List<StraightPathItem> straightPath, int maxStraightPath, int options)
|
ref List<DtStraightPath> straightPath, int maxStraightPath, int options)
|
||||||
{
|
{
|
||||||
var startPos = straightPath[straightPath.Count - 1].pos;
|
var startPos = straightPath[straightPath.Count - 1].pos;
|
||||||
// Append or update last vertex
|
// Append or update last vertex
|
||||||
|
@ -1537,7 +1537,7 @@ namespace DotRecast.Detour
|
||||||
/// @param[in] options Query options. (see: #dtStraightPathOptions)
|
/// @param[in] options Query options. (see: #dtStraightPathOptions)
|
||||||
/// @returns The status flags for the query.
|
/// @returns The status flags for the query.
|
||||||
public virtual DtStatus FindStraightPath(RcVec3f startPos, RcVec3f endPos, List<long> path,
|
public virtual DtStatus FindStraightPath(RcVec3f startPos, RcVec3f endPos, List<long> path,
|
||||||
ref List<StraightPathItem> straightPath,
|
ref List<DtStraightPath> straightPath,
|
||||||
int maxStraightPath, int options)
|
int maxStraightPath, int options)
|
||||||
{
|
{
|
||||||
if (!RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == straightPath
|
if (!RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == straightPath
|
||||||
|
|
|
@ -34,6 +34,6 @@ namespace DotRecast.Detour
|
||||||
public IDtQueryFilter filter;
|
public IDtQueryFilter filter;
|
||||||
public int options;
|
public int options;
|
||||||
public float raycastLimitSqr;
|
public float raycastLimitSqr;
|
||||||
public IQueryHeuristic heuristic;
|
public IDtQueryHeuristic heuristic;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,13 +23,13 @@ using DotRecast.Core;
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
//TODO: (PP) Add comments
|
//TODO: (PP) Add comments
|
||||||
public readonly struct StraightPathItem
|
public readonly struct DtStraightPath
|
||||||
{
|
{
|
||||||
public readonly RcVec3f pos;
|
public readonly RcVec3f pos;
|
||||||
public readonly int flags;
|
public readonly int flags;
|
||||||
public readonly long refs;
|
public readonly long refs;
|
||||||
|
|
||||||
public StraightPathItem(RcVec3f pos, int flags, long refs)
|
public DtStraightPath(RcVec3f pos, int flags, long refs)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
|
@ -51,7 +51,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] qCircle = Circle(center, radius);
|
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))
|
if (intersection == null && DtUtils.PointInPolygon(center, verts, verts.Length / 3))
|
||||||
{
|
{
|
||||||
// circle inside polygon
|
// circle inside polygon
|
||||||
|
|
|
@ -21,7 +21,7 @@ using DotRecast.Core;
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
public interface IQueryHeuristic
|
public interface IDtQueryHeuristic
|
||||||
{
|
{
|
||||||
float GetCost(RcVec3f neighbourPos, RcVec3f endPos);
|
float GetCost(RcVec3f neighbourPos, RcVec3f endPos);
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ namespace DotRecast.Detour
|
||||||
steerPosRef = 0;
|
steerPosRef = 0;
|
||||||
|
|
||||||
// Find steer target.
|
// Find steer target.
|
||||||
var straightPath = new List<StraightPathItem>(MAX_STEER_POINTS);
|
var straightPath = new List<DtStraightPath>(MAX_STEER_POINTS);
|
||||||
var result = navQuery.FindStraightPath(startPos, endPos, path, ref straightPath, MAX_STEER_POINTS, 0);
|
var result = navQuery.FindStraightPath(startPos, endPos, path, ref straightPath, MAX_STEER_POINTS, 0);
|
||||||
if (result.Failed())
|
if (result.Failed())
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
private bool m_hitResult;
|
private bool m_hitResult;
|
||||||
|
|
||||||
private float m_distanceToWall;
|
private float m_distanceToWall;
|
||||||
private List<StraightPathItem> m_straightPath;
|
private List<DtStraightPath> m_straightPath;
|
||||||
private List<long> m_polys;
|
private List<long> m_polys;
|
||||||
private List<long> m_parent;
|
private List<long> m_parent;
|
||||||
private float m_neighbourhoodRadius;
|
private float m_neighbourhoodRadius;
|
||||||
|
@ -285,8 +285,8 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
dd.Begin(LINES, 2.0f);
|
dd.Begin(LINES, 2.0f);
|
||||||
for (int i = 0; i < m_straightPath.Count - 1; ++i)
|
for (int i = 0; i < m_straightPath.Count - 1; ++i)
|
||||||
{
|
{
|
||||||
StraightPathItem straightPathItem = m_straightPath[i];
|
DtStraightPath straightPathItem = m_straightPath[i];
|
||||||
StraightPathItem straightPathItem2 = m_straightPath[i + 1];
|
DtStraightPath straightPathItem2 = m_straightPath[i + 1];
|
||||||
int col;
|
int col;
|
||||||
if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
|
if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
|
||||||
{
|
{
|
||||||
|
@ -305,7 +305,7 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
dd.Begin(POINTS, 6.0f);
|
dd.Begin(POINTS, 6.0f);
|
||||||
for (int i = 0; i < m_straightPath.Count; ++i)
|
for (int i = 0; i < m_straightPath.Count; ++i)
|
||||||
{
|
{
|
||||||
StraightPathItem straightPathItem = m_straightPath[i];
|
DtStraightPath straightPathItem = m_straightPath[i];
|
||||||
int col;
|
int col;
|
||||||
if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0)
|
if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0)
|
||||||
{
|
{
|
||||||
|
@ -350,8 +350,8 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
dd.Begin(LINES, 2.0f);
|
dd.Begin(LINES, 2.0f);
|
||||||
for (int i = 0; i < m_straightPath.Count - 1; ++i)
|
for (int i = 0; i < m_straightPath.Count - 1; ++i)
|
||||||
{
|
{
|
||||||
StraightPathItem straightPathItem = m_straightPath[i];
|
DtStraightPath straightPathItem = m_straightPath[i];
|
||||||
StraightPathItem straightPathItem2 = m_straightPath[i + 1];
|
DtStraightPath straightPathItem2 = m_straightPath[i + 1];
|
||||||
dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, straightPathItem.pos.z, spathCol);
|
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);
|
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);
|
dd.Begin(POINTS, 4.0f);
|
||||||
for (int i = 0; i < m_straightPath.Count; ++i)
|
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);
|
dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, straightPathItem.pos.z, spathCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
public DtStatus FindStraightPath(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPt, RcVec3f endPt, IDtQueryFilter filter, bool enableRaycast,
|
||||||
ref List<long> polys, ref List<StraightPathItem> straightPath, int straightPathOptions)
|
ref List<long> polys, ref List<DtStraightPath> straightPath, int straightPathOptions)
|
||||||
{
|
{
|
||||||
if (startRef == 0 || endRef == 0)
|
if (startRef == 0 || endRef == 0)
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
}
|
}
|
||||||
|
|
||||||
polys ??= new List<long>();
|
polys ??= new List<long>();
|
||||||
straightPath ??= new List<StraightPathItem>();
|
straightPath ??= new List<DtStraightPath>();
|
||||||
|
|
||||||
polys.Clear();
|
polys.Clear();
|
||||||
straightPath.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,
|
public DtStatus UpdateSlicedFindPath(DtNavMeshQuery navQuery, int maxIter, long endRef, RcVec3f startPos, RcVec3f endPos,
|
||||||
ref List<long> path, ref List<StraightPathItem> straightPath)
|
ref List<long> path, ref List<DtStraightPath> straightPath)
|
||||||
{
|
{
|
||||||
var status = navQuery.UpdateSlicedFindPath(maxIter, out _);
|
var status = navQuery.UpdateSlicedFindPath(maxIter, out _);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
straightPath = new List<StraightPathItem>(MAX_POLYS);
|
straightPath = new List<DtStraightPath>(MAX_POLYS);
|
||||||
navQuery.FindStraightPath(startPos, epos, path, ref straightPath, MAX_POLYS, DtNavMeshQuery.DT_STRAIGHTPATH_ALL_CROSSINGS);
|
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,
|
public DtStatus Raycast(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter,
|
||||||
ref List<long> polys, ref List<StraightPathItem> straightPath, ref RcVec3f hitPos, ref RcVec3f hitNormal, ref bool hitResult)
|
ref List<long> polys, ref List<DtStraightPath> straightPath, ref RcVec3f hitPos, ref RcVec3f hitNormal, ref bool hitResult)
|
||||||
{
|
{
|
||||||
if (startRef == 0 || endRef == 0)
|
if (startRef == 0 || endRef == 0)
|
||||||
{
|
{
|
||||||
|
@ -289,10 +289,10 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
straightPath ??= new List<StraightPathItem>();
|
straightPath ??= new List<DtStraightPath>();
|
||||||
straightPath.Clear();
|
straightPath.Clear();
|
||||||
straightPath.Add(new StraightPathItem(startPos, 0, 0));
|
straightPath.Add(new DtStraightPath(startPos, 0, 0));
|
||||||
straightPath.Add(new StraightPathItem(hitPos, 0, 0));
|
straightPath.Add(new DtStraightPath(hitPos, 0, 0));
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,28 +40,28 @@ public class PathCorridorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned()
|
public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned()
|
||||||
{
|
{
|
||||||
List<StraightPathItem> straightPath = new();
|
List<DtStraightPath> straightPath = new();
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(11, 20, 30.00001f), 0, 0));
|
straightPath.Add(new DtStraightPath(RcVec3f.Of(11, 20, 30.00001f), 0, 0));
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(12, 20, 30.00002f), 0, 0));
|
straightPath.Add(new DtStraightPath(RcVec3f.Of(12, 20, 30.00002f), 0, 0));
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
|
straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), 0, 0));
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
|
straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), 0, 0));
|
||||||
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
|
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
|
||||||
mockQuery.Setup(q => q.FindStraightPath(
|
mockQuery.Setup(q => q.FindStraightPath(
|
||||||
It.IsAny<RcVec3f>(),
|
It.IsAny<RcVec3f>(),
|
||||||
It.IsAny<RcVec3f>(),
|
It.IsAny<RcVec3f>(),
|
||||||
It.IsAny<List<long>>(),
|
It.IsAny<List<long>>(),
|
||||||
ref It.Ref<List<StraightPathItem>>.IsAny,
|
ref It.Ref<List<DtStraightPath>>.IsAny,
|
||||||
It.IsAny<int>(),
|
It.IsAny<int>(),
|
||||||
It.IsAny<int>())
|
It.IsAny<int>())
|
||||||
)
|
)
|
||||||
.Callback((RcVec3f startPos, RcVec3f endPos, List<long> path,
|
.Callback((RcVec3f startPos, RcVec3f endPos, List<long> path,
|
||||||
ref List<StraightPathItem> refStraightPath, int maxStraightPath, int options) =>
|
ref List<DtStraightPath> refStraightPath, int maxStraightPath, int options) =>
|
||||||
{
|
{
|
||||||
refStraightPath = straightPath;
|
refStraightPath = straightPath;
|
||||||
})
|
})
|
||||||
.Returns(() => DtStatus.DT_SUCCSESS);
|
.Returns(() => DtStatus.DT_SUCCSESS);
|
||||||
|
|
||||||
var path = new List<StraightPathItem>();
|
var path = new List<DtStraightPath>();
|
||||||
corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter);
|
corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter);
|
||||||
Assert.That(path.Count, Is.EqualTo(4));
|
Assert.That(path.Count, Is.EqualTo(4));
|
||||||
Assert.That(path, Is.EqualTo(straightPath));
|
Assert.That(path, Is.EqualTo(straightPath));
|
||||||
|
@ -70,31 +70,31 @@ public class PathCorridorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldPrunePathInFindCorners()
|
public void ShouldPrunePathInFindCorners()
|
||||||
{
|
{
|
||||||
List<StraightPathItem> straightPath = new();
|
List<DtStraightPath> straightPath = new();
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00001f), 0, 0)); // too close
|
straightPath.Add(new DtStraightPath(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 DtStraightPath(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close
|
||||||
straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
|
straightPath.Add(new DtStraightPath(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 DtStraightPath(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
|
straightPath.Add(new DtStraightPath(RcVec3f.Of(11f, 21, 32f), DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
|
||||||
|
|
||||||
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
|
var mockQuery = new Mock<DtNavMeshQuery>(It.IsAny<DtNavMesh>());
|
||||||
mockQuery.Setup(q => q.FindStraightPath(
|
mockQuery.Setup(q => q.FindStraightPath(
|
||||||
It.IsAny<RcVec3f>(),
|
It.IsAny<RcVec3f>(),
|
||||||
It.IsAny<RcVec3f>(),
|
It.IsAny<RcVec3f>(),
|
||||||
It.IsAny<List<long>>(),
|
It.IsAny<List<long>>(),
|
||||||
ref It.Ref<List<StraightPathItem>>.IsAny,
|
ref It.Ref<List<DtStraightPath>>.IsAny,
|
||||||
It.IsAny<int>(),
|
It.IsAny<int>(),
|
||||||
It.IsAny<int>())
|
It.IsAny<int>())
|
||||||
).Callback((RcVec3f startPos, RcVec3f endPos, List<long> path,
|
).Callback((RcVec3f startPos, RcVec3f endPos, List<long> path,
|
||||||
ref List<StraightPathItem> refStraightPath, int maxStraightPath, int options) =>
|
ref List<DtStraightPath> refStraightPath, int maxStraightPath, int options) =>
|
||||||
{
|
{
|
||||||
refStraightPath = straightPath;
|
refStraightPath = straightPath;
|
||||||
})
|
})
|
||||||
.Returns(() => DtStatus.DT_SUCCSESS);
|
.Returns(() => DtStatus.DT_SUCCSESS);
|
||||||
|
|
||||||
var path = new List<StraightPathItem>();
|
var path = new List<DtStraightPath>();
|
||||||
corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter);
|
corridor.FindCorners(ref path, int.MaxValue, mockQuery.Object, filter);
|
||||||
Assert.That(path.Count, Is.EqualTo(2));
|
Assert.That(path.Count, Is.EqualTo(2));
|
||||||
Assert.That(path, Is.EqualTo(new List<StraightPathItem> { straightPath[2], straightPath[3] }));
|
Assert.That(path, Is.EqualTo(new List<DtStraightPath> { straightPath[2], straightPath[3] }));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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[] 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[] 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.Length, Is.EqualTo(5 * 3));
|
||||||
Assert.That(intersection, Is.EqualTo(p));
|
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[] 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[] 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.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 }));
|
Assert.That(intersection, Is.EqualTo(new[] { 1, 0, 3, 1, 0, -3.4f, -2, 0, -4, -4, 0, 0, -3, 0, 3 }));
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,63 +71,63 @@ public class FindPathTest : AbstractDetourTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly StraightPathItem[][] STRAIGHT_PATHS =
|
private static readonly DtStraightPath[][] STRAIGHT_PATHS =
|
||||||
{
|
{
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new StraightPathItem(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L),
|
new DtStraightPath(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L),
|
||||||
new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
|
new DtStraightPath(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L),
|
||||||
new StraightPathItem(RcVec3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L),
|
new DtStraightPath(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(6.457663f, 10.197294f, -18.334061f), 2, 0L)
|
||||||
},
|
},
|
||||||
|
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new StraightPathItem(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L),
|
new DtStraightPath(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L),
|
||||||
new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L),
|
new DtStraightPath(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L),
|
||||||
new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L),
|
new DtStraightPath(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L),
|
||||||
new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L),
|
new DtStraightPath(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L),
|
||||||
new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L),
|
new DtStraightPath(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L),
|
||||||
new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L),
|
new DtStraightPath(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L),
|
||||||
new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L),
|
new DtStraightPath(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L),
|
||||||
new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L),
|
new DtStraightPath(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L),
|
||||||
new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L),
|
new DtStraightPath(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(-11.815216f, 0.197294f, 3.008419f), 2, 0L)
|
||||||
},
|
},
|
||||||
|
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new StraightPathItem(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L),
|
new DtStraightPath(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L),
|
||||||
new StraightPathItem(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L),
|
new DtStraightPath(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L),
|
||||||
new StraightPathItem(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L),
|
new DtStraightPath(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L),
|
||||||
new StraightPathItem(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L),
|
new DtStraightPath(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L),
|
||||||
new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
|
new DtStraightPath(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
|
||||||
new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L),
|
new DtStraightPath(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L),
|
||||||
new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L),
|
new DtStraightPath(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(38.423977f, 10.197294f, -0.116067f), 2, 0L)
|
||||||
},
|
},
|
||||||
|
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new StraightPathItem(RcVec3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L),
|
new DtStraightPath(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.863553f, 10.197294f, -10.310320f), 2, 0L)
|
||||||
},
|
},
|
||||||
|
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new StraightPathItem(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L),
|
new DtStraightPath(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L),
|
||||||
new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L),
|
new DtStraightPath(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L),
|
||||||
new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L),
|
new DtStraightPath(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L),
|
||||||
new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L),
|
new DtStraightPath(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L),
|
||||||
new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L),
|
new DtStraightPath(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L),
|
||||||
new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
|
new DtStraightPath(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
|
||||||
new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L),
|
new DtStraightPath(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(18.784092f, 10.197294f, 3.054368f), 2, 0L)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public class FindPathTest : AbstractDetourTest
|
||||||
var startPos = startPoss[i];
|
var startPos = startPoss[i];
|
||||||
var endPos = endPoss[i];
|
var endPos = endPoss[i];
|
||||||
var status = query.FindPath(startRef, endRef, startPos, endPos, filter, ref path, DtFindPathOption.NoOption);
|
var status = query.FindPath(startRef, endRef, startPos, endPos, filter, ref path, DtFindPathOption.NoOption);
|
||||||
var straightPath = new List<StraightPathItem>();
|
var straightPath = new List<DtStraightPath>();
|
||||||
query.FindStraightPath(startPos, endPos, path, ref straightPath, int.MaxValue, 0);
|
query.FindStraightPath(startPos, endPos, path, ref straightPath, int.MaxValue, 0);
|
||||||
Assert.That(straightPath.Count, Is.EqualTo(STRAIGHT_PATHS[i].Length));
|
Assert.That(straightPath.Count, Is.EqualTo(STRAIGHT_PATHS[i].Length));
|
||||||
for (int j = 0; j < STRAIGHT_PATHS[i].Length; j++)
|
for (int j = 0; j < STRAIGHT_PATHS[i].Length; j++)
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
|
||||||
int maxStraightPath = 256;
|
int maxStraightPath = 256;
|
||||||
int options = 0;
|
int options = 0;
|
||||||
|
|
||||||
var pathStr = new List<StraightPathItem>();
|
var pathStr = new List<DtStraightPath>();
|
||||||
query.FindStraightPath(startPos, endPos, path, ref pathStr, maxStraightPath, options);
|
query.FindStraightPath(startPos, endPos, path, ref pathStr, maxStraightPath, options);
|
||||||
Assert.That(pathStr.Count, Is.EqualTo(8));
|
Assert.That(pathStr.Count, Is.EqualTo(8));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue