Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Aug 13, 2023
1 parent bdcd0bc commit a29842a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/ai/Markers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ local function setBackMarkerNode(vehicle, measuredBackDistance)
if AIUtil.hasImplementsOnTheBack(vehicle) then
local lastImplement
lastImplement, backMarkerOffset = AIUtil.getLastAttachedImplement(vehicle)
referenceNode = AIUtil.getDirectionNode(vehicle)
referenceNode = AIUtil.getDirectionNode(vehicle)
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, vehicle, 'Using the last implement\'s rear distance for the back marker node, %d m from root node', backMarkerOffset)
elseif measuredBackDistance then
referenceNode = AIUtil.getDirectionNode(vehicle)
referenceNode = AIUtil.getDirectionNode(vehicle)
backMarkerOffset = -measuredBackDistance
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, vehicle, 'back marker node on measured back distance %.1f', measuredBackDistance)
elseif reverserNode then
-- if there is a reverser node, use that, mainly because that most likely will turn with an implement
-- or with the back component of an articulated vehicle. Just need to find out the distance correctly
local dx, _, dz = localToLocal(reverserNode, AIUtil.getDirectionNode(vehicle), 0, 0, 0)
local dx, _, dz = localToLocal(reverserNode, AIUtil.getDirectionNode(vehicle), 0, 0, 0)
local dBetweenRootAndReverserNode = MathUtil.vector2Length(dx, dz)
backMarkerOffset = dBetweenRootAndReverserNode - vehicle.size.length / 2 - vehicle.size.lengthOffset
referenceNode = reverserNode
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, vehicle, 'Using the %s node for the back marker node %d m from root node (%d m between root and reverser)',
debugText, backMarkerOffset, dBetweenRootAndReverserNode)
else
referenceNode = AIUtil.getDirectionNode(vehicle)
referenceNode = AIUtil.getDirectionNode(vehicle)
backMarkerOffset = - vehicle.size.length / 2 + vehicle.size.lengthOffset
CpUtil.debugVehicle(CpDebug.DBG_IMPLEMENTS, vehicle, 'Using the vehicle\'s root node for the back marker node, %d m from root node', backMarkerOffset)
end
Expand Down

0 comments on commit a29842a

Please sign in to comment.