forked from bit/DotRecastNetSim
refactor: PATHFIND_STRAIGHT
This commit is contained in:
parent
ace37833e5
commit
ac0ee0f734
|
@ -664,23 +664,8 @@ public class TestNavmeshSampleTool : ISampleTool
|
||||||
}
|
}
|
||||||
else if (_mode == RcTestNavmeshToolMode.PATHFIND_STRAIGHT)
|
else if (_mode == RcTestNavmeshToolMode.PATHFIND_STRAIGHT)
|
||||||
{
|
{
|
||||||
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
|
_tool.FindStraightPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast,
|
||||||
{
|
ref m_polys, ref m_straightPath, _straightPathOption);
|
||||||
var polys = new List<long>();
|
|
||||||
var straightPath = new List<StraightPathItem>();
|
|
||||||
var status = _tool.FindStraightPath(navQuery, m_startRef, m_endRef, m_spos, m_epos, m_filter, _enableRaycast,
|
|
||||||
ref polys, ref straightPath, _straightPathOption);
|
|
||||||
|
|
||||||
if (status.Succeeded())
|
|
||||||
{
|
|
||||||
m_polys = polys;
|
|
||||||
m_straightPath = straightPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_straightPath = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
|
else if (_mode == RcTestNavmeshToolMode.PATHFIND_SLICED)
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,8 +165,19 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
public DtStatus FindStraightPath(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPt, RcVec3f endPt, IDtQueryFilter filter, bool enableRaycast,
|
public DtStatus FindStraightPath(DtNavMeshQuery navQuery, long startRef, long endRef, RcVec3f startPt, RcVec3f endPt, IDtQueryFilter filter, bool enableRaycast,
|
||||||
ref List<long> polys, ref List<StraightPathItem> straightPath, int straightPathOptions)
|
ref List<long> polys, ref List<StraightPathItem> straightPath, int straightPathOptions)
|
||||||
{
|
{
|
||||||
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));
|
{
|
||||||
|
return DtStatus.DT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
polys ??= new List<long>();
|
||||||
|
straightPath ??= new List<StraightPathItem>();
|
||||||
|
|
||||||
|
polys.Clear();
|
||||||
|
straightPath.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;
|
||||||
|
|
Loading…
Reference in New Issue