fix(Core/Travel): Loosen chained-probe non-progress threshold

This commit is contained in:
bash 2026-05-18 00:50:32 +02:00
parent 26d260d3a9
commit 720d3f91e1

View File

@ -852,14 +852,17 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
PathGenerator path(pathUnit); PathGenerator path(pathUnit);
// Non-progress detection: track best distance-to-target across // Non-progress detection: track best distance-to-target seen so
// iterations. If two consecutive steps fail to improve it, the // far. Bail only after many consecutive iterations with no
// chained probe is oscillating between polygons in a local navmesh // meaningful improvement — the chained probe can legitimately
// pocket — bail to avoid accumulating 40 iterations of useless // zigzag (especially on dense vertical-stacked polys like spiral
// waypoints that leave the bot stranded mid-terrain. // ramps) so we want a generous threshold to avoid false positives.
// Trigger fires only when stuck for ~10 iterations in a navmesh
// pocket where no step gets us 1y closer to the target.
float bestDistToTarget = std::numeric_limits<float>::max(); float bestDistToTarget = std::numeric_limits<float>::max();
uint32 noProgress = 0; uint32 iterSinceImprovement = 0;
constexpr uint32 MAX_NO_PROGRESS = 2; constexpr uint32 MAX_ITER_NO_IMPROVEMENT = 10;
constexpr float MIN_IMPROVEMENT = 1.0f;
// Limit the pathfinding attempts // Limit the pathfinding attempts
for (uint32 i = 0; i < maxAttempt; i++) for (uint32 i = 0; i < maxAttempt; i++)
@ -881,15 +884,14 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
break; break;
float distNow = this->distance(&subPath.back()); float distNow = this->distance(&subPath.back());
if (distNow + 0.5f >= bestDistToTarget) if (distNow < bestDistToTarget - MIN_IMPROVEMENT)
{
if (++noProgress >= MAX_NO_PROGRESS)
break;
}
else
{ {
bestDistToTarget = distNow; bestDistToTarget = distNow;
noProgress = 0; iterSinceImprovement = 0;
}
else if (++iterSinceImprovement >= MAX_ITER_NO_IMPROVEMENT)
{
break;
} }
currentPos = subPath.back(); currentPos = subPath.back();