forked from mirror/DotRecast
Replaced arrays with spans in query. Replaced array allocation with buffer rent in query.
This commit is contained in:
parent
db0717a77e
commit
c8104cec4d
|
@ -11,7 +11,7 @@ namespace DotRecast.Detour
|
|||
_callback = callback;
|
||||
}
|
||||
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count)
|
||||
public void Process(DtMeshTile tile, Span<DtPoly> poly, Span<long> refs, int count)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace DotRecast.Detour
|
|||
return m_overflow;
|
||||
}
|
||||
|
||||
public void Process(DtMeshTile tile, DtPoly[] poly, Span<long> refs, int count)
|
||||
public void Process(DtMeshTile tile, Span<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, Span<long> refs, int count)
|
||||
public void Process(DtMeshTile tile, Span<DtPoly> poly, Span<long> refs, int count)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ freely, subject to the following restrictions:
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Core.Buffers;
|
||||
using DotRecast.Core.Numerics;
|
||||
|
||||
namespace DotRecast.Detour
|
||||
|
@ -597,7 +598,8 @@ namespace DotRecast.Detour
|
|||
{
|
||||
const int batchSize = 32;
|
||||
Span<long> polyRefs = stackalloc long[batchSize];
|
||||
DtPoly[] polys = new DtPoly[batchSize];
|
||||
using RcRentedArray<DtPoly> polysRent = RcRentedArray.Rent<DtPoly>(batchSize);
|
||||
Span<DtPoly> polys = new Span<DtPoly>(polysRent.AsArray(), 0, batchSize);
|
||||
int n = 0;
|
||||
|
||||
if (tile.data.bvTree != null)
|
||||
|
|
|
@ -9,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, Span<long> refs, int count);
|
||||
void Process(DtMeshTile tile, Span<DtPoly> poly, Span<long> refs, int count);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue