forked from mirror/DotRecast
Compare commits
3 Commits
db0717a77e
...
ff930712ee
Author | SHA1 | Date |
---|---|---|
wrenge | ff930712ee | |
wrenge | 6fe6844efd | |
wrenge | c8104cec4d |
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
@ -43,6 +43,11 @@ namespace DotRecast.Core.Buffers
|
|||
return _array;
|
||||
}
|
||||
|
||||
public Span<T> AsSpan()
|
||||
{
|
||||
return new Span<T>(_array, 0, Length);
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1365,6 +1365,11 @@ namespace DotRecast.Detour
|
|||
}
|
||||
|
||||
public int GetTilesAt(int x, int y, DtMeshTile[] tiles, int maxTiles)
|
||||
{
|
||||
return GetTilesAt(x, y, (Span<DtMeshTile>)tiles, maxTiles);
|
||||
}
|
||||
|
||||
public int GetTilesAt(int x, int y, Span<DtMeshTile> tiles, int maxTiles)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
|
|
|
@ -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 = polysRent.AsSpan();
|
||||
int n = 0;
|
||||
|
||||
if (tile.data.bvTree != null)
|
||||
|
@ -786,7 +788,8 @@ namespace DotRecast.Detour
|
|||
m_nav.CalcTileLoc(bmax, out var maxx, out var maxy);
|
||||
|
||||
const int MAX_NEIS = 32;
|
||||
DtMeshTile[] neis = new DtMeshTile[MAX_NEIS];
|
||||
using RcRentedArray<DtMeshTile> neisRent = RcRentedArray.Rent<DtMeshTile>(MAX_NEIS);
|
||||
Span<DtMeshTile> neis = neisRent.AsSpan();
|
||||
|
||||
for (int y = miny; y <= maxy; ++y)
|
||||
{
|
||||
|
|
|
@ -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