refactor PATHFIND_SLICED

This commit is contained in:
ikpil 2023-09-10 14:37:02 +09:00
parent 013a53fbc9
commit ab05f845ca
2 changed files with 8 additions and 8 deletions

View File

@ -669,14 +669,10 @@ public class TestNavmeshSampleTool : ISampleTool
} }
else if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED) else if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
{ {
m_polys = null; m_polys?.Clear();
m_straightPath = null; m_straightPath?.Clear();
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_pathFindStatus = _tool.InitSlicedFindPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast);
} }
}
else if (_mode == RcTestNavmeshToolMode.RAYCAST) else if (_mode == RcTestNavmeshToolMode.RAYCAST)
{ {
_tool.Raycast(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _tool.Raycast(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter,
@ -708,7 +704,6 @@ public class TestNavmeshSampleTool : ISampleTool
public void HandleUpdate(float dt) public void HandleUpdate(float dt)
{ {
// TODO Auto-generated method stub
if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED) if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
{ {
DtNavMeshQuery navQuery = _sample.GetNavMeshQuery(); DtNavMeshQuery navQuery = _sample.GetNavMeshQuery();

View File

@ -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) 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, return navQuery.InitSlicedFindPath(startRef, endRef, startPos, endPos, filter,
enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0,
float.MaxValue float.MaxValue