Skip to content

Commit 1d6317b

Browse files
authored
Merge pull request #725 from Courseplay/609-cp-worker-leaving-path
fix: stay on field turn maneuver
2 parents 439f743 + e82edc7 commit 1d6317b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/ai/turns/TurnManeuver.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,15 @@ function TurnManeuver:adjustCourseToFitField(course, dBack, ixBeforeEndingTurnSe
302302
-- reversingOffset may be even behind the back marker, especially for vehicles which have a AIToolReverserDirectionNode
303303
-- which is then used as the PPC controlled node, and thus it must be far enough that we reach the lowering
304304
-- point before the controlled node reaches the end of the course
305+
local from = dFromTurnEnd + self.steeringLength - 1
306+
local to = math.min(dFromTurnEnd, self.turnContext.backMarkerDistance, -reversingOffset)
307+
-- if the reverse section is shorter than 1 m (or, even negative, meaning to > from), make sure we still
308+
-- have a short, 1 m reversing section.
309+
if from - to < 1 then
310+
to = from - 1
311+
end
305312
local reverseAfterTurn = Course.createFromNode(self.vehicle, self.turnContext.vehicleAtTurnEndNode,
306-
0, dFromTurnEnd + self.steeringLength - 1,
307-
math.min(dFromTurnEnd, self.turnContext.backMarkerDistance, -reversingOffset), -0.8, true)
313+
0, from, to, -0.8, true)
308314
courseWithReversing:append(reverseAfterTurn)
309315
endingTurnLength = reverseAfterTurn:getLength()
310316
elseif self.turnContext.turnEndForwardOffset <= 0 and dFromTurnEnd >= 0 then

0 commit comments

Comments
 (0)