@@ -540,6 +540,8 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
540540 m_pathPoints[i] = Vector3 (pathPoints[i * VERTEX_SIZE + 2 ], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1 ]);
541541 }
542542
543+ NormalizePath (pointCount);
544+
543545 // first point is always our current location - we need the next one
544546 setActualEndPosition (m_pathPoints[pointCount - 1 ]);
545547
@@ -977,17 +979,7 @@ void PathFinder::NormalizePath(uint32& size)
977979 m_sourceUnit->UpdateAllowedPositionZ (m_pathPoints[i].x , m_pathPoints[i].y , m_pathPoints[i].z );
978980 }
979981
980- // Check if the Z difference between each point is higher than SMOOTH_PATH_HEIGHT.
981- // Add another point if that's the case and keep adding new midpoints till the Z difference is low enough.
982- for (uint32 i = 1 ; i < m_pathPoints.size (); ++i)
983- {
984- if ((m_pathPoints[i - 1 ].z - m_pathPoints[i].z ) > SMOOTH_PATH_HEIGHT)
985- {
986- auto midPoint = m_pathPoints[i - 1 ] + (m_pathPoints[i] - m_pathPoints[i - 1 ]) / 2 .f ;
987- m_sourceUnit->UpdateAllowedPositionZ (midPoint.x , midPoint.y , midPoint.z );
988- m_pathPoints.insert (m_pathPoints.begin () + i, midPoint);
989- --i;
990- }
991- }
992- size = m_pathPoints.size ();
982+ // NOTE: A midpoint-insertion loop was here to smooth steep Z descents,
983+ // but it could loop infinitely when UpdateAllowedPositionZ returned terrain Z
984+ // values that prevented convergence (cliff faces, etc.). Removed.
993985}
0 commit comments