Skip to content

Commit

Permalink
fix issue with units walking in circles near a move goal.
Browse files Browse the repository at this point in the history
  • Loading branch information
lostsquirrel1 committed Aug 12, 2024
1 parent 2f1e5b7 commit 1a5a352
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rts/Sim/Path/QTPFS/PathSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,9 +1595,13 @@ float3 QTPFS::PathSearch::FindNearestPointOnNodeToGoal(const QTPFS::SearchNode&
const float3 lastPoint({lastPoint2.x, 0.f, lastPoint2.y});
GetRectangleCollisionVolume(node, rv, rm);
bool collide = CCollisionHandler::IntersectBox(&rv, goalPos - rm, lastPoint - rm, &cq);
if (collide) {
// If the goalPos is inside the node, then the goalPos should be used.
return (cq.InsideHit()) ? goalPos : cq.GetHitPos() + rm;
}

// No collision means the nearest point was really the nearest point. We can't do better.
return (collide) ? cq.GetHitPos() + rm : lastPoint;
return lastPoint;
}

// #pragma GCC push_options
Expand Down

0 comments on commit 1a5a352

Please sign in to comment.