forked from mirror/DotRecast
refactor: PATHFIND_FOLLOW
This commit is contained in:
parent
539a028f58
commit
ace37833e5
|
@ -659,25 +659,8 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
|
|
||||||
if (_mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
if (_mode == RcTestNavmeshToolMode.PATHFIND_FOLLOW)
|
||||||
{
|
{
|
||||||
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
|
_tool.FindFollowPath(navMesh, navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast,
|
||||||
{
|
ref m_polys, ref m_smoothPath);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (_mode == RcTestNavmeshToolMode.PATHFIND_STRAIGHT)
|
else if (_mode == RcTestNavmeshToolMode.PATHFIND_STRAIGHT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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,
|
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)
|
ref List<long> polys, ref List<RcVec3f> smoothPath)
|
||||||
{
|
{
|
||||||
navQuery.FindPath(startRef, endRef, startPt, endPt, filter, ref polys,
|
if (startRef == 0 || endRef == 0)
|
||||||
new DtFindPathOption(enableRaycast ? DtNavMeshQuery.DT_FINDPATH_ANY_ANGLE : 0, float.MaxValue));
|
{
|
||||||
|
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)
|
if (0 >= polys.Count)
|
||||||
return DtStatus.DT_FAILURE;
|
return DtStatus.DT_FAILURE;
|
||||||
|
|
||||||
|
@ -229,7 +242,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// results ...
|
// results ...
|
||||||
polys = rayHit.path;
|
polys = rayHit.path;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue