added npath in MergeCorridor functions

This commit is contained in:
ikpil 2024-02-23 01:02:23 +09:00
parent 7836b78bb4
commit 3c4723c907
3 changed files with 10 additions and 10 deletions

View File

@ -215,7 +215,7 @@ namespace DotRecast.Detour.Crowd
{
if (res.Count > 1 && t > 0.99f)
{
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, m_maxPath, res);
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, m_path.Count, m_maxPath, res);
}
}
}
@ -241,13 +241,13 @@ namespace DotRecast.Detour.Crowd
}
var res = new List<long>();
navquery.InitSlicedFindPath(m_path[0], m_path[m_path.Count - 1], m_pos, m_target, filter, 0);
navquery.InitSlicedFindPath(m_path[0], m_path[^1], m_pos, m_target, filter, 0);
navquery.UpdateSlicedFindPath(maxIterations, out var _);
var status = navquery.FinalizeSlicedFindPathPartial(m_path, ref res);
if (status.Succeeded() && res.Count > 0)
{
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, m_maxPath, res);
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, m_path.Count, m_maxPath, res);
return true;
}
@ -316,7 +316,7 @@ namespace DotRecast.Detour.Crowd
var status = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter, out var result, ref visited);
if (status.Succeeded())
{
m_path = DtPathUtils.MergeCorridorStartMoved(m_path, m_maxPath, visited);
m_path = DtPathUtils.MergeCorridorStartMoved(m_path, m_path.Count, m_maxPath, visited);
// Adjust the position to stay on top of the navmesh.
m_pos = result;
@ -355,10 +355,10 @@ namespace DotRecast.Detour.Crowd
{
// Move along navmesh and update new position.
var visited = new List<long>();
var status = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter, out var result, ref visited);
var status = navquery.MoveAlongSurface(m_path[^1], m_target, npos, filter, out var result, ref visited);
if (status.Succeeded())
{
m_path = DtPathUtils.MergeCorridorEndMoved(m_path, m_maxPath, visited);
m_path = DtPathUtils.MergeCorridorEndMoved(m_path, m_path.Count, m_maxPath, visited);
// TODO: should we do that?
// Adjust the position to stay on top of the navmesh.
/*

View File

@ -141,7 +141,7 @@ namespace DotRecast.Detour
return path;
}
public static List<long> MergeCorridorStartMoved(List<long> path, int maxPath, List<long> visited)
public static List<long> MergeCorridorStartMoved(List<long> path, int npath, int maxPath, List<long> visited)
{
int furthestPath = -1;
int furthestVisited = -1;
@ -186,7 +186,7 @@ namespace DotRecast.Detour
return result;
}
public static List<long> MergeCorridorEndMoved(List<long> path, int maxPath, List<long> visited)
public static List<long> MergeCorridorEndMoved(List<long> path, int npath, int maxPath, List<long> visited)
{
int furthestPath = -1;
int furthestVisited = -1;
@ -223,7 +223,7 @@ namespace DotRecast.Detour
return result;
}
public static List<long> MergeCorridorStartShortcut(List<long> path, int maxPath, List<long> visited)
public static List<long> MergeCorridorStartShortcut(List<long> path, int npath, int maxPath, List<long> visited)
{
int furthestPath = -1;
int furthestVisited = -1;

View File

@ -92,7 +92,7 @@ namespace DotRecast.Recast.Toolset.Tools
iterPos = result;
pathIterPolys = DtPathUtils.MergeCorridorStartMoved(pathIterPolys, MAX_POLYS, visited);
pathIterPolys = DtPathUtils.MergeCorridorStartMoved(pathIterPolys, pathIterPolys.Count, MAX_POLYS, visited);
pathIterPolys = DtPathUtils.FixupShortcuts(pathIterPolys, navQuery);
var status = navQuery.GetPolyHeight(pathIterPolys[0], result, out var h);