diff --git a/src/DotRecast.Detour/DtCallbackPolyQuery.cs b/src/DotRecast.Detour/DtCallbackPolyQuery.cs index 77f626f..e0b8cfb 100644 --- a/src/DotRecast.Detour/DtCallbackPolyQuery.cs +++ b/src/DotRecast.Detour/DtCallbackPolyQuery.cs @@ -11,7 +11,7 @@ namespace DotRecast.Detour _callback = callback; } - public void Process(DtMeshTile tile, DtPoly[] poly, Span refs, int count) + public void Process(DtMeshTile tile, Span poly, Span refs, int count) { for (int i = 0; i < count; ++i) { diff --git a/src/DotRecast.Detour/DtCollectPolysQuery.cs b/src/DotRecast.Detour/DtCollectPolysQuery.cs index e98daa7..29710d4 100644 --- a/src/DotRecast.Detour/DtCollectPolysQuery.cs +++ b/src/DotRecast.Detour/DtCollectPolysQuery.cs @@ -26,7 +26,7 @@ namespace DotRecast.Detour return m_overflow; } - public void Process(DtMeshTile tile, DtPoly[] poly, Span refs, int count) + public void Process(DtMeshTile tile, Span poly, Span refs, int count) { int numLeft = m_maxPolys - m_numCollected; int toCopy = count; diff --git a/src/DotRecast.Detour/DtFindNearestPolyQuery.cs b/src/DotRecast.Detour/DtFindNearestPolyQuery.cs index b0c4cf1..1ffa22b 100644 --- a/src/DotRecast.Detour/DtFindNearestPolyQuery.cs +++ b/src/DotRecast.Detour/DtFindNearestPolyQuery.cs @@ -20,7 +20,7 @@ namespace DotRecast.Detour _nearestPoint = center; } - public void Process(DtMeshTile tile, DtPoly[] poly, Span refs, int count) + public void Process(DtMeshTile tile, Span poly, Span refs, int count) { for (int i = 0; i < count; ++i) { diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 9defb66..faeb460 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -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 polyRefs = stackalloc long[batchSize]; - DtPoly[] polys = new DtPoly[batchSize]; + using RcRentedArray polysRent = RcRentedArray.Rent(batchSize); + Span polys = new Span(polysRent.AsArray(), 0, batchSize); int n = 0; if (tile.data.bvTree != null) diff --git a/src/DotRecast.Detour/IDtPolyQuery.cs b/src/DotRecast.Detour/IDtPolyQuery.cs index 890d171..5a6db49 100644 --- a/src/DotRecast.Detour/IDtPolyQuery.cs +++ b/src/DotRecast.Detour/IDtPolyQuery.cs @@ -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 refs, int count); + void Process(DtMeshTile tile, Span poly, Span refs, int count); } } \ No newline at end of file