forked from mirror/DotRecast
add `int nvisited` in DtPathUtils.functions
This commit is contained in:
parent
deb02778cc
commit
59849e1dac
|
@ -218,7 +218,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
{
|
{
|
||||||
if (res.Count > 1 && t > 0.99f)
|
if (res.Count > 1 && t > 0.99f)
|
||||||
{
|
{
|
||||||
m_npath = DtPathUtils.MergeCorridorStartShortcut(ref m_path, m_npath, m_maxPath, res);
|
m_npath = DtPathUtils.MergeCorridorStartShortcut(ref m_path, m_npath, m_maxPath, res, res.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
|
|
||||||
if (status.Succeeded() && res.Count > 0)
|
if (status.Succeeded() && res.Count > 0)
|
||||||
{
|
{
|
||||||
m_npath = DtPathUtils.MergeCorridorStartShortcut(ref m_path, m_npath, m_maxPath, res);
|
m_npath = DtPathUtils.MergeCorridorStartShortcut(ref m_path, m_npath, m_maxPath, res, res.Count);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
var status = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter, out var result, ref visited);
|
var status = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter, out var result, ref visited);
|
||||||
if (status.Succeeded())
|
if (status.Succeeded())
|
||||||
{
|
{
|
||||||
m_npath = DtPathUtils.MergeCorridorStartMoved(ref m_path, m_npath, m_maxPath, visited);
|
m_npath = DtPathUtils.MergeCorridorStartMoved(ref m_path, m_npath, m_maxPath, visited, visited.Count);
|
||||||
|
|
||||||
// Adjust the position to stay on top of the navmesh.
|
// Adjust the position to stay on top of the navmesh.
|
||||||
m_pos = result;
|
m_pos = result;
|
||||||
|
@ -363,7 +363,7 @@ namespace DotRecast.Detour.Crowd
|
||||||
var status = navquery.MoveAlongSurface(m_path[^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())
|
if (status.Succeeded())
|
||||||
{
|
{
|
||||||
m_npath = DtPathUtils.MergeCorridorEndMoved(ref m_path, m_npath, m_maxPath, visited);
|
m_npath = DtPathUtils.MergeCorridorEndMoved(ref m_path, m_npath, m_maxPath, visited, visited.Count);
|
||||||
|
|
||||||
// TODO: should we do that?
|
// TODO: should we do that?
|
||||||
// Adjust the position to stay on top of the navmesh.
|
// Adjust the position to stay on top of the navmesh.
|
||||||
|
|
|
@ -20,7 +20,6 @@ freely, subject to the following restrictions:
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using DotRecast.Core.Numerics;
|
using DotRecast.Core.Numerics;
|
||||||
|
|
||||||
namespace DotRecast.Detour
|
namespace DotRecast.Detour
|
||||||
|
@ -147,7 +146,7 @@ namespace DotRecast.Detour
|
||||||
return npath;
|
return npath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MergeCorridorStartMoved(ref List<long> path, int npath, int maxPath, List<long> visited)
|
public static int MergeCorridorStartMoved(ref List<long> path, int npath, int maxPath, List<long> visited, int nvisited)
|
||||||
{
|
{
|
||||||
int furthestPath = -1;
|
int furthestPath = -1;
|
||||||
int furthestVisited = -1;
|
int furthestVisited = -1;
|
||||||
|
@ -156,7 +155,7 @@ namespace DotRecast.Detour
|
||||||
for (int i = npath - 1; i >= 0; --i)
|
for (int i = npath - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int j = visited.Count - 1; j >= 0; --j)
|
for (int j = nvisited - 1; j >= 0; --j)
|
||||||
{
|
{
|
||||||
if (path[i] == visited[j])
|
if (path[i] == visited[j])
|
||||||
{
|
{
|
||||||
|
@ -183,7 +182,7 @@ namespace DotRecast.Detour
|
||||||
// Adjust beginning of the buffer to include the visited.
|
// Adjust beginning of the buffer to include the visited.
|
||||||
List<long> result = new List<long>();
|
List<long> result = new List<long>();
|
||||||
// Store visited
|
// Store visited
|
||||||
for (int i = visited.Count - 1; i > furthestVisited; --i)
|
for (int i = nvisited - 1; i > furthestVisited; --i)
|
||||||
{
|
{
|
||||||
result.Add(visited[i]);
|
result.Add(visited[i]);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +193,7 @@ namespace DotRecast.Detour
|
||||||
return result.Count;
|
return result.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MergeCorridorEndMoved(ref List<long> path, int npath, int maxPath, List<long> visited)
|
public static int MergeCorridorEndMoved(ref List<long> path, int npath, int maxPath, List<long> visited, int nvisited)
|
||||||
{
|
{
|
||||||
int furthestPath = -1;
|
int furthestPath = -1;
|
||||||
int furthestVisited = -1;
|
int furthestVisited = -1;
|
||||||
|
@ -203,7 +202,7 @@ namespace DotRecast.Detour
|
||||||
for (int i = 0; i < npath; ++i)
|
for (int i = 0; i < npath; ++i)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int j = visited.Count - 1; j >= 0; --j)
|
for (int j = nvisited - 1; j >= 0; --j)
|
||||||
{
|
{
|
||||||
if (path[i] == visited[j])
|
if (path[i] == visited[j])
|
||||||
{
|
{
|
||||||
|
@ -227,13 +226,13 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// Concatenate paths.
|
// Concatenate paths.
|
||||||
List<long> result = path.GetRange(0, furthestPath);
|
List<long> result = path.GetRange(0, furthestPath);
|
||||||
result.AddRange(visited.GetRange(furthestVisited, visited.Count - furthestVisited));
|
result.AddRange(visited.GetRange(furthestVisited, nvisited - furthestVisited));
|
||||||
|
|
||||||
path = result;
|
path = result;
|
||||||
return result.Count;
|
return result.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MergeCorridorStartShortcut(ref List<long> path, int npath, int maxPath, List<long> visited)
|
public static int MergeCorridorStartShortcut(ref List<long> path, int npath, int maxPath, List<long> visited, int nvisited)
|
||||||
{
|
{
|
||||||
int furthestPath = -1;
|
int furthestPath = -1;
|
||||||
int furthestVisited = -1;
|
int furthestVisited = -1;
|
||||||
|
@ -242,7 +241,7 @@ namespace DotRecast.Detour
|
||||||
for (int i = npath - 1; i >= 0; --i)
|
for (int i = npath - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int j = visited.Count - 1; j >= 0; --j)
|
for (int j = nvisited - 1; j >= 0; --j)
|
||||||
{
|
{
|
||||||
if (path[i] == visited[j])
|
if (path[i] == visited[j])
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
||||||
|
|
||||||
iterPos = result;
|
iterPos = result;
|
||||||
|
|
||||||
pathIterPolyCount = DtPathUtils.MergeCorridorStartMoved(ref pathIterPolys, pathIterPolyCount, MAX_POLYS, visited);
|
pathIterPolyCount = DtPathUtils.MergeCorridorStartMoved(ref pathIterPolys, pathIterPolyCount, MAX_POLYS, visited, visited.Count);
|
||||||
pathIterPolyCount = DtPathUtils.FixupShortcuts(ref pathIterPolys, pathIterPolyCount, navQuery);
|
pathIterPolyCount = DtPathUtils.FixupShortcuts(ref pathIterPolys, pathIterPolyCount, navQuery);
|
||||||
|
|
||||||
var status = navQuery.GetPolyHeight(pathIterPolys[0], result, out var h);
|
var status = navQuery.GetPolyHeight(pathIterPolys[0], result, out var h);
|
||||||
|
|
Loading…
Reference in New Issue