refactor: PATHFIND_FOLLOW

This commit is contained in:
ikpil 2023-09-10 13:53:31 +09:00
parent 539a028f58
commit ace37833e5
2 changed files with 18 additions and 22 deletions

View File

@ -659,25 +659,8 @@ public class TestNavmeshSampleTool : ISampleTool
if (_mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
{
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
{
var polys = new List<long>();
var smoothPath = new List<RcVec3f>();
var status = _tool.FindFollowPath(navMesh, navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast,
ref polys, ref smoothPath);
if (status.Succeeded())
{
m_polys = polys;
m_smoothPath = smoothPath;
}
}
else
{
m_polys = null;
m_smoothPath = null;
}
_tool.FindFollowPath(navMesh, navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast,
ref m_polys, ref m_smoothPath);
}
else if (_mode == RcTestNavmeshToolMode.PATHFIND_STRAIGHT)
{

View File

@ -23,9 +23,22 @@ namespace DotRecast.Recast.Toolset.Tools
public DtStatus FindFollowPath(DtNavMesh navMesh, DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPt, RcVec3f endPt, IDtQueryFilter filter, bool enableRaycast,
ref List<long> polys, ref List<RcVec3f> smoothPath)
{
navQuery.FindPath(startRef, endRef, startPt, endPt, filter, ref polys,
new DtFindPathOption(enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue));
if (startRef == 0 || endRef == 0)
{
polys?.Clear();
smoothPath?.Clear();
return DtStatus.DT_FAILURE;
}
polys ??= new List<long>();
smoothPath ??= new List<RcVec3f>();
polys.Clear();
smoothPath.Clear();
var opt = new DtFindPathOption(enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue);
navQuery.FindPath(startRef, endRef, startPt, endPt, filter, ref polys, opt);
if (0 >= polys.Count)
return DtStatus.DT_FAILURE;
@ -229,7 +242,7 @@ namespace DotRecast.Recast.Toolset.Tools
{
return status;
}
// results ...
polys = rayHit.path;