From 19e358bdfc2d0dc7410ff278a7921725132e7c83 Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 7 May 2024 23:56:15 +0900 Subject: [PATCH] m_npath instead of m_path.Count --- src/DotRecast.Detour.Crowd/DtPathCorridor.cs | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs index c4be0a6..e7d56e8 100644 --- a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs +++ b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs @@ -238,7 +238,7 @@ namespace DotRecast.Detour.Crowd /// @param[in] filter The filter to apply to the operation. public bool OptimizePathTopology(DtNavMeshQuery navquery, IDtQueryFilter filter, int maxIterations) { - if (m_path.Count < 3) + if (m_npath < 3) { return false; } @@ -262,21 +262,21 @@ namespace DotRecast.Detour.Crowd // Advance the path up to and over the off-mesh connection. long prevRef = 0, polyRef = m_path[0]; int npos = 0; - while (npos < m_path.Count && polyRef != offMeshConRef) + while (npos < m_npath && polyRef != offMeshConRef) { prevRef = polyRef; polyRef = m_path[npos]; npos++; } - if (npos == m_path.Count) + if (npos == m_npath) { // Could not find offMeshConRef return false; } // Prune path - m_path = m_path.GetRange(npos, m_path.Count - npos); + m_path = m_path.GetRange(npos, m_npath - npos); m_npath -= npos; refs[0] = prevRef; @@ -398,7 +398,7 @@ namespace DotRecast.Detour.Crowd public void FixPathStart(long safeRef, RcVec3f safePos) { m_pos = safePos; - if (m_path.Count < 3 && m_path.Count > 0) + if (m_npath < 3 && m_npath > 0) { long p = m_path[m_npath - 1]; m_path.Clear(); @@ -420,12 +420,12 @@ namespace DotRecast.Detour.Crowd { // Keep valid path as far as possible. int n = 0; - while (n < m_path.Count && navquery.IsValidPolyRef(m_path[n], filter)) + while (n < m_npath && navquery.IsValidPolyRef(m_path[n], filter)) { n++; } - if (m_path.Count == n) + if (m_npath == n) { // All valid, no need to fix. return true; @@ -438,7 +438,7 @@ namespace DotRecast.Detour.Crowd m_path.Add(safeRef); m_npath = 1; } - else if (n < m_path.Count) + else if (n < m_npath) { // The path is partially usable. m_path = m_path.GetRange(0, n); @@ -446,7 +446,7 @@ namespace DotRecast.Detour.Crowd } // Clamp target pos to last poly - navquery.ClosestPointOnPolyBoundary(m_path[m_path.Count - 1], m_target, out m_target); + navquery.ClosestPointOnPolyBoundary(m_path[m_npath - 1], m_target, out m_target); return true; } @@ -462,7 +462,7 @@ namespace DotRecast.Detour.Crowd public bool IsValid(int maxLookAhead, DtNavMeshQuery navquery, IDtQueryFilter filter) { // Check that all polygons still pass query filter. - int n = Math.Min(m_path.Count, maxLookAhead); + int n = Math.Min(m_npath, maxLookAhead); for (int i = 0; i < n; ++i) { if (!navquery.IsValidPolyRef(m_path[i], filter)) @@ -492,14 +492,14 @@ namespace DotRecast.Detour.Crowd /// @return The polygon reference id of the first polygon in the corridor. (Or zero if there is no path.) public long GetFirstPoly() { - return 0 == m_path.Count ? 0 : m_path[0]; + return 0 == m_npath ? 0 : m_path[0]; } /// The polygon reference id of the last polygon in the corridor, the polygon containing the target. /// @return The polygon reference id of the last polygon in the corridor. (Or zero if there is no path.) public long GetLastPoly() { - return 0 == m_path.Count ? 0 : m_path[m_path.Count - 1]; + return 0 == m_npath ? 0 : m_path[m_npath - 1]; } /// The corridor's path. @@ -513,7 +513,7 @@ namespace DotRecast.Detour.Crowd /// @return The number of polygons in the current corridor path. public int GetPathCount() { - return m_path.Count; + return m_npath; } } } \ No newline at end of file