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