Compare commits

..

No commits in common. "7de4b511350337275e4a7404893462110b695e26" and "2cf9d9de188990c748ecf16452034e820ae78066" have entirely different histories.

2 changed files with 7 additions and 21 deletions

View File

@ -23,7 +23,6 @@ using System.Collections.Generic;
using DotRecast.Core;
using DotRecast.Core.Buffers;
using DotRecast.Core.Numerics;
using CollectionExtensions = DotRecast.Core.Collections.CollectionExtensions;
namespace DotRecast.Detour
{
@ -34,8 +33,6 @@ namespace DotRecast.Detour
/// @ingroup detour
public class DtNavMeshQuery
{
public const int MAX_PATH_LENGTH = 256;
protected readonly DtNavMesh m_nav; //< Pointer to navmesh data.
protected DtQueryData m_query; //< Sliced query state.
@ -885,8 +882,7 @@ namespace DotRecast.Detour
float lastBestNodeCost = startNode.total;
DtRaycastHit rayHit = new DtRaycastHit();
using var pathRent = RcRentedArray.Rent<long>(MAX_PATH_LENGTH);
rayHit.path = pathRent.AsArray();
rayHit.path = new List<long>();
while (!m_openList.IsEmpty())
{
// Remove node from open list and put it in closed list.
@ -1175,8 +1171,7 @@ namespace DotRecast.Detour
}
var rayHit = new DtRaycastHit();
using var pathRent = RcRentedArray.Rent<long>(MAX_PATH_LENGTH);
rayHit.path = pathRent.AsArray();
rayHit.path = new List<long>();
int iter = 0;
while (iter < maxIter && !m_openList.IsEmpty())
@ -2268,15 +2263,13 @@ namespace DotRecast.Detour
out float t, out RcVec3f hitNormal, ref List<long> path)
{
DtRaycastHit hit = new DtRaycastHit();
using var pathRent = RcRentedArray.Rent<long>(MAX_PATH_LENGTH);
hit.path = pathRent.AsArray();
hit.path = path;
DtStatus status = Raycast(startRef, startPos, endPos, filter, 0, ref hit, 0);
t = hit.t;
hitNormal = hit.hitNormal;
path.Clear();
CollectionExtensions.AddRange(path, new Span<long>(hit.path, 0, hit.pathCount));
path = hit.path;
return status;
}
@ -2342,7 +2335,7 @@ namespace DotRecast.Detour
}
hit.t = 0;
hit.pathCount = 0;
hit.path.Clear();
hit.pathCost = 0;
Span<RcVec3f> verts = stackalloc RcVec3f[m_nav.GetMaxVertsPerPoly() + 1];
@ -2395,7 +2388,7 @@ namespace DotRecast.Detour
}
// Store visited polygons.
hit.AddPathNode(curRef);
hit.path.Add(curRef);
// Ray end is completely inside the polygon.
if (segMax == -1)

View File

@ -38,16 +38,9 @@ namespace DotRecast.Detour
public int hitEdgeIndex;
/// Pointer to an array of reference ids of the visited polygons. [opt]
public long[] path;
public int pathCount;
public List<long> path;
/// The cost of the path until hit.
public float pathCost;
public void AddPathNode(long nodeRef)
{
path[pathCount++] = nodeRef;
}
}
}