forked from mirror/DotRecast
long[] -> Span<long>
This commit is contained in:
parent
c9a54d4b4e
commit
ec9ebe28b9
|
@ -55,19 +55,15 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
RcAtomicBoolean found = new RcAtomicBoolean();
|
||||
RcAtomicFloat minHeight = new RcAtomicFloat(pt.Y);
|
||||
|
||||
navMeshQuery.QueryPolygons(pt, halfExtents, DtQueryNoOpFilter.Shared, new DtCallbackPolyQuery((tile, poly, refs, count) =>
|
||||
navMeshQuery.QueryPolygons(pt, halfExtents, DtQueryNoOpFilter.Shared, new DtCallbackPolyQuery((tile, poly, refs) =>
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var status = navMeshQuery.GetPolyHeight(refs[i], pt, out var h);
|
||||
var status = navMeshQuery.GetPolyHeight(refs, pt, out var h);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
if (h > minHeight.Get() && h < maxHeight)
|
||||
{
|
||||
minHeight.Exchange(h);
|
||||
found.Set(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -4,16 +4,19 @@ namespace DotRecast.Detour
|
|||
{
|
||||
public class DtCallbackPolyQuery : IDtPolyQuery
|
||||
{
|
||||
private readonly Action<DtMeshTile, DtPoly[], long[], int> _callback;
|
||||
private readonly Action<DtMeshTile, DtPoly, long> _callback;
|
||||
|
||||
public DtCallbackPolyQuery(Action<DtMeshTile, DtPoly[], long[], int> callback)
|
||||
public DtCallbackPolyQuery(Action<DtMeshTile, DtPoly, long> callback)
|
||||
{
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, long[] refs, int count)
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count)
|
||||
{
|
||||
_callback?.Invoke(tile, poly, refs, count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
_callback?.Invoke(tile, poly[i], refs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using DotRecast.Core;
|
||||
using System;
|
||||
using DotRecast.Core;
|
||||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ namespace DotRecast.Detour
|
|||
return m_overflow;
|
||||
}
|
||||
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, long[] refs, int count)
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count)
|
||||
{
|
||||
int numLeft = m_maxPolys - m_numCollected;
|
||||
int toCopy = count;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace DotRecast.Detour
|
|||
_nearestPoint = center;
|
||||
}
|
||||
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, long[] refs, int count)
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
|
|
@ -580,7 +580,7 @@ namespace DotRecast.Detour
|
|||
protected void QueryPolygonsInTile(DtMeshTile tile, RcVec3f qmin, RcVec3f qmax, IDtQueryFilter filter, IDtPolyQuery query)
|
||||
{
|
||||
const int batchSize = 32;
|
||||
long[] polyRefs = new long[batchSize];
|
||||
Span<long> polyRefs = stackalloc long[batchSize];
|
||||
DtPoly[] polys = new DtPoly[batchSize];
|
||||
int n = 0;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
/// Provides custom polygon query behavior.
|
||||
|
@ -7,6 +9,6 @@ namespace DotRecast.Detour
|
|||
{
|
||||
/// Called for each batch of unique polygons touched by the search area in dtNavMeshQuery::queryPolygons.
|
||||
/// This can be called multiple times for a single query.
|
||||
void Process(DtMeshTile tile, DtPoly[] poly, long[] refs, int count);
|
||||
void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue