Skip to content

Commit 3afefd9

Browse files
authored
Merge pull request #22 from Courseplay/Gui-Additions
Shovel position debug fix and arrow size increased
2 parents 2f93029 + f96988e commit 3afefd9

5 files changed

Lines changed: 41 additions & 12 deletions

File tree

config/VehicleConfigurations.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,13 @@ You can define the following custom settings:
485485
turnRadius = "10"
486486
/>
487487
<Vehicle name="lm845.xml"
488-
turnRadius = "10"
489-
fixWheelLoaderDirectionNodeByMovingToolIx = "1"
490-
articulatedAxisReverseNodeInverted = "true"
488+
articulatedAxisReverseNodeInverted = "true"
489+
turnRadius = "10"
490+
fixWheelLoaderDirectionNodeByMovingToolIx = "1"
491+
/>
492+
<Vehicle name="wheelLoader435S.xml"
493+
fixWheelLoaderDirectionNodeByMovingToolIx = "1"
494+
turnRadius = "10"
491495
/>
492496

493497
<!--Vermeer-->

scripts/ai/controllers/ShovelController.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function ShovelController:calculateMinimalUnloadingHeight(triggerNode)
189189
local maxHeightObjectHit = 0
190190
for i=self.MIN_TRIGGER_HEIGHT, self.MAX_TRIGGER_HEIGHT, 0.1 do
191191
self.objectWasHit = false
192-
raycastAll(sx, terrainHeight + i, sz, dx, 0, dz, length
192+
raycastAll(sx, terrainHeight + i, sz, dx, 0, dz, length,
193193
"calculateMinimalUnloadingHeightRaycastCallback", self,
194194
self.TRIGGER_HEIGHT_RAYCAST_COLLISION_MASK)
195195
if self.objectWasHit then

scripts/gui/CoursePlot.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CoursePlot = CpObject()
2323
-- x = 0, y = 0 is the bottom left corner of the screen, terrainSize is in meters
2424
function CoursePlot:init()
2525
self.lineThickness = 2 / g_screenHeight -- 2 pixels
26-
self.arrowThickness = 3 / g_screenHeight -- 3 pixels
26+
self.arrowThickness = 10 / g_screenHeight -- 10 pixels
2727
-- the normal FS22 blue
2828
self.color = {CpGuiUtil.getNormalizedRgb(42, 193, 237)}
2929
-- a lighter shade of the same color
@@ -173,7 +173,7 @@ end
173173
---@param a number|nil
174174
---@param isHudMap boolean|nil
175175
function CoursePlot:drawArrow(map, x, z, rotation, r, g, b, a, isHudMap)
176-
local zoom = isHudMap and map.layout:getIconZoom() or map.fullScreenLayout:getIconZoom()
176+
local zoom = map.layout:getIconZoom() * map.layout:getIconZoom()
177177
if isHudMap and map.state == IngameMap.STATE_MAP then
178178
--- When the hud is completely open, then the signs need to be scaled down.
179179
zoom = zoom * 0.5
@@ -226,7 +226,7 @@ function CoursePlot:draw(map, isHudMap)
226226
-- render the start and stop signs
227227

228228
local signSizeMeters = 0.02
229-
local zoom = isHudMap and map.layout:getIconZoom() or map.fullScreenLayout:getIconZoom()
229+
local zoom = map.layout:getIconZoom()
230230
if isHudMap and map.state == IngameMap.STATE_MAP then
231231
--- When the hud is completely open, then the signs need to be scaled down.
232232
zoom = zoom * 0.5

scripts/specializations/CpShovelPositions.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height
417417
sy = yMin + 0.01
418418
ey = yMin + 0.01
419419
end
420-
local hasIntersection, i1z, i1y, i2z, i2y = MathUtil.getCircleLineIntersection(
420+
local hasIntersection, i1z, i1y, i2z, i2y = CpMathUtil.getCircleLineIntersection(
421421
az, ay, radiusArmToolToShovelTool,
422422
sz, sy, ez, ey)
423423

@@ -500,9 +500,10 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height
500500
name = "shovelY", value = shovelY})
501501
table.insert(debugData, {
502502
name = "dirRot", value = math.deg(oldRotRelativeArmRot) })
503-
table.insert(debugData, {
504-
name = "distAlpha", value = MathUtil.vector2Length(i1z - tz, i1y - ty) })
505-
503+
if i1z ~= nil and i1y ~= nil then
504+
table.insert(debugData, {
505+
name = "distAlpha", value = MathUtil.vector2Length(i1z - tz, i1y - ty) })
506+
end
506507
table.insert(debugData, {
507508
value = "",
508509
name = "",

scripts/util/CpMathUtil.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,28 @@ end
319319
--- Divide a by b, but instead of throwing an error when b is 0, return math.huge
320320
function CpMathUtil.divide(a, b)
321321
return b == 0 and math.huge or a / b
322-
end
322+
end
323+
324+
--- Legancy function form LS22
325+
function CpMathUtil.getCircleLineIntersection(circleX, circleZ, radius, lineStartX, lineStartZ, lineEndX, lineEndZ)
326+
local p3x = lineStartX - circleX
327+
local p3z = lineStartZ - circleZ
328+
local p4x = lineEndX - circleX
329+
local p4z = lineEndZ - circleZ
330+
local m = (p4z - p3z) / (p4x - p3x)
331+
local b = p3z - m * p3x
332+
local dis = math.pow(radius, 2) * math.pow(m, 2) + math.pow(radius, 2) - math.pow(b, 2)
333+
334+
if dis < 0 then
335+
return false
336+
else
337+
local t1 = (-m * b + math.sqrt(dis)) / (math.pow(m, 2) + 1)
338+
local t2 = (-m * b - math.sqrt(dis)) / (math.pow(m, 2) + 1)
339+
local intersect1X = t1 + circleX
340+
local intersect1Z = m * t1 + b + circleZ
341+
local intersect2X = t2 + circleX
342+
local intersect2Z = m * t2 + b + circleZ
343+
344+
return true, intersect1X, intersect1Z, intersect2X, intersect2Z
345+
end
346+
end

0 commit comments

Comments
 (0)