From ab05f845ca3e3f4fbbe042e3fe549f2b17f761ec Mon Sep 17 00:00:00 2001 From: ikpil Date: Sun, 10 Sep 2023 14:37:02 +0900 Subject: [PATCH] refactor PATHFIND_SLICED --- .../Tools/TestNavmeshSampleTool.cs | 11 +++-------- .../Tools/RcTestNavMeshTool.cs | 5 +++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs index a617d24..adde6e0 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshSampleTool.cs @@ -669,13 +669,9 @@ public class TestNavmeshSampleTool : ISampleTool } else if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED) { - m_polys = null; - m_straightPath = null; - - if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0) - { - m_pathFindStatus = _tool.InitSlicedFindPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast); - } + m_polys?.Clear(); + m_straightPath?.Clear(); + m_pathFindStatus = _tool.InitSlicedFindPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast); } else if (_mode == RcTestNavmeshToolMode.RAYCAST) { @@ -708,7 +704,6 @@ public class TestNavmeshSampleTool : ISampleTool public void HandleUpdate(float dt) { - // TODO Auto-generated method stub if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED) { DtNavMeshQuery navQuery = _sample.GetNavMeshQuery(); diff --git a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs index 6bbb5bb..35bab9c 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcTestNavMeshTool.cs @@ -200,6 +200,11 @@ namespace DotRecast.Recast.Toolset.Tools public DtStatus InitSlicedFindPath(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, bool enableRaycast) { + if (startRef == 0 || endRef == 0) + { + return DtStatus.DT_FAILURE; + } + return navQuery.InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue