From 54e8835cb72c5f2f5e8f4d897c89c89a34769912 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sun, 10 Sep 2023 12:45:49 +0900 Subject: [PATCH] feat: add random point count --- src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs | 6 ++++-- src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs index 7995f56..53d0f2a 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs @@ -35,6 +35,7 @@ public class TestNavmeshSampleTool : ISampleTool private int _straightPathOption; // for random point in circle mode + private int _randomPointCount = 300; private bool _constrainByCircle; // @@ -126,6 +127,7 @@ public class TestNavmeshSampleTool : ISampleTool if (_mode == RcTestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE) { + ImGui.SliderInt("Random point count", ref _randomPointCount, 0, 10000); ImGui.Checkbox("Constrained", ref _constrainByCircle); } @@ -761,7 +763,7 @@ public class TestNavmeshSampleTool : ISampleTool var refs = new List(); var parentRefs = new List(); - var status = _tool.FindPolysAroundShape(navQuery, settings, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs, out var queryPoly); + var status = _tool.FindPolysAroundShape(navQuery, settings.agentHeight, m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs, out var queryPoly); if (status.Succeeded()) { m_queryPoly = queryPoly; @@ -791,7 +793,7 @@ public class TestNavmeshSampleTool : ISampleTool if (m_sposSet && m_startRef != 0 && m_eposSet) { var points = new List(); - _tool.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, _constrainByCircle, 500, ref points); + _tool.FindRandomPointAroundCircle(navQuery, m_startRef, m_spos, m_epos, m_filter, _constrainByCircle, _randomPointCount, ref points); randomPoints.AddRange(points); } } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs index 2a845ae..0485630 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs @@ -269,11 +269,10 @@ namespace DotRecast.Recast.Toolset.Tools return navQuery.FindPolysAroundCircle(startRef, spos, dist, filter, ref resultRef, ref resultParent, ref costs); } - public DtStatus FindPolysAroundShape(DtNavMeshQuery navQuery, RcNavMeshBuildSettings settings, long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List resultRef, ref List resultParent, out RcVec3f[] queryPoly) + public DtStatus FindPolysAroundShape(DtNavMeshQuery navQuery, float agentHeight, 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 = settings != null ? settings.agentHeight : 0; queryPoly = new RcVec3f[4]; queryPoly[0].x = spos.x + nx * 1.2f;