diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index d0454d1..685c722 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -2621,12 +2621,12 @@ namespace DotRecast.Detour /// @param[in] maxResult The maximum number of polygons the result arrays can hold. /// @returns The status flags for the query. public DtStatus FindPolysAroundShape(long startRef, float[] verts, IDtQueryFilter filter, - out List resultRef, out List resultParent, out List resultCost) + ref List resultRef, ref List resultParent, ref List resultCost) { - resultRef = new List(); - resultParent = new List(); - resultCost = new List(); - + resultRef.Clear(); + resultParent.Clear(); + resultCost.Clear(); + // Validate input int nverts = verts.Length / 3; if (!m_nav.IsValidPolyRef(startRef) || null == verts || nverts < 3 || null == filter) diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index 3603adb..b60760b 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -453,7 +453,11 @@ public class TestNavmeshTool : IRcTool m_queryPoly[10] = m_epos.y + agentHeight / 2; m_queryPoly[11] = m_epos.z + nz; - var status = m_navQuery.FindPolysAroundShape(m_startRef, m_queryPoly, m_filter, out var refs, out var parentRefs, out var costs); + var refs = new List(); + var parentRefs = new List(); + var costs = new List(); + + var status = m_navQuery.FindPolysAroundShape(m_startRef, m_queryPoly, m_filter, ref refs, ref parentRefs, ref costs); if (status.Succeeded()) { m_polys = refs; diff --git a/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs b/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs index 0834521..8935105 100644 --- a/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs +++ b/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs @@ -16,8 +16,8 @@ freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ +using System.Collections.Generic; using DotRecast.Core; - using NUnit.Framework; namespace DotRecast.Detour.Test; @@ -129,11 +129,16 @@ public class FindPolysAroundShapeTest : AbstractDetourTest public void TestFindPolysAroundShape() { IDtQueryFilter filter = new DtQueryDefaultFilter(); + var refs = new List(); + var parentRefs = new List(); + var costs = new List(); + for (int i = 0; i < startRefs.Length; i++) { long startRef = startRefs[i]; RcVec3f startPos = startPoss[i]; - query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter, out var refs, out var parentRefs, out var costs); + query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter, ref refs, ref parentRefs, ref costs); + Assert.That(refs.Count, Is.EqualTo(REFS[i].Length)); for (int v = 0; v < REFS[i].Length; v++) {