diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index cf68fe5..2d7cdea 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -277,15 +277,10 @@ public class TestNavmeshTool : IRcTool { if (m_sposSet && m_startRef != 0 && m_eposSet) { - float dx = m_epos.x - m_spos.x; - float dz = m_epos.z - m_spos.z; - float dist = (float)Math.Sqrt(dx * dx + dz * dz); - List refs = new(); List parentRefs = new(); - List costs = new(); - var status = m_navQuery.FindPolysAroundCircle(m_startRef, m_spos, dist, m_filter, ref refs, ref parentRefs, ref costs); + var status = _impl.FindPolysAroundCircle(m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs); if (status.Succeeded()) { m_polys = refs; @@ -798,7 +793,6 @@ public class TestNavmeshTool : IRcTool } - public void HandleUpdate(float dt) { // TODO Auto-generated method stub diff --git a/src/DotRecast.Recast.DemoTool/Tools/TestNavmeshToolImpl.cs b/src/DotRecast.Recast.DemoTool/Tools/TestNavmeshToolImpl.cs index 0c22204..c670ba1 100644 --- a/src/DotRecast.Recast.DemoTool/Tools/TestNavmeshToolImpl.cs +++ b/src/DotRecast.Recast.DemoTool/Tools/TestNavmeshToolImpl.cs @@ -252,28 +252,40 @@ namespace DotRecast.Recast.DemoTool.Tools return status; } - public DtStatus FindPolysAroundShape(long startRef, RcVec3f m_spos, RcVec3f m_epos, IDtQueryFilter filter, ref List resultRef, ref List resultParent, out RcVec3f[] queryPoly) + public DtStatus FindPolysAroundCircle(long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List resultRef, ref List resultParent) { - float nx = (m_epos.z - m_spos.z) * 0.25f; - float nz = -(m_epos.x - m_spos.x) * 0.25f; + float dx = epos.x - spos.x; + float dz = epos.z - spos.z; + float dist = (float)Math.Sqrt(dx * dx + dz * dz); + + List costs = new List(); + var navQuery = _sample.GetNavMeshQuery(); + + return navQuery.FindPolysAroundCircle(startRef, spos, dist, filter, ref resultRef, ref resultParent, ref costs); + } + + public DtStatus FindPolysAroundShape(long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List resultRef, ref List resultParent, out RcVec3f[] queryPoly) + { + float nx = (epos.z - spos.z) * 0.25f; + float nz = -(epos.x - spos.x) * 0.25f; float agentHeight = GetSample() != null ? GetSample().GetSettings().agentHeight : 0; queryPoly = new RcVec3f[4]; - queryPoly[0].x = m_spos.x + nx * 1.2f; - queryPoly[0].y = m_spos.y + agentHeight / 2; - queryPoly[0].z = m_spos.z + nz * 1.2f; + queryPoly[0].x = spos.x + nx * 1.2f; + queryPoly[0].y = spos.y + agentHeight / 2; + queryPoly[0].z = spos.z + nz * 1.2f; - queryPoly[1].x = m_spos.x - nx * 1.3f; - queryPoly[1].y = m_spos.y + agentHeight / 2; - queryPoly[1].z = m_spos.z - nz * 1.3f; + queryPoly[1].x = spos.x - nx * 1.3f; + queryPoly[1].y = spos.y + agentHeight / 2; + queryPoly[1].z = spos.z - nz * 1.3f; - queryPoly[2].x = m_epos.x - nx * 0.8f; - queryPoly[2].y = m_epos.y + agentHeight / 2; - queryPoly[2].z = m_epos.z - nz * 0.8f; + queryPoly[2].x = epos.x - nx * 0.8f; + queryPoly[2].y = epos.y + agentHeight / 2; + queryPoly[2].z = epos.z - nz * 0.8f; - queryPoly[3].x = m_epos.x + nx; - queryPoly[3].y = m_epos.y + agentHeight / 2; - queryPoly[3].z = m_epos.z + nz; + queryPoly[3].x = epos.x + nx; + queryPoly[3].y = epos.y + agentHeight / 2; + queryPoly[3].z = epos.z + nz; var costs = new List(); var navQuery = _sample.GetNavMeshQuery();