diff --git a/config/VehicleConfigurations.xml b/config/VehicleConfigurations.xml index 2d1e7c037..4f8e3cfa5 100644 --- a/config/VehicleConfigurations.xml +++ b/config/VehicleConfigurations.xml @@ -485,9 +485,13 @@ You can define the following custom settings: turnRadius = "10" /> + diff --git a/scripts/ai/controllers/ShovelController.lua b/scripts/ai/controllers/ShovelController.lua index 7c40c3e6d..2b336d34d 100644 --- a/scripts/ai/controllers/ShovelController.lua +++ b/scripts/ai/controllers/ShovelController.lua @@ -189,7 +189,7 @@ function ShovelController:calculateMinimalUnloadingHeight(triggerNode) local maxHeightObjectHit = 0 for i=self.MIN_TRIGGER_HEIGHT, self.MAX_TRIGGER_HEIGHT, 0.1 do self.objectWasHit = false - raycastAll(sx, terrainHeight + i, sz, dx, 0, dz, length + raycastAll(sx, terrainHeight + i, sz, dx, 0, dz, length, "calculateMinimalUnloadingHeightRaycastCallback", self, self.TRIGGER_HEIGHT_RAYCAST_COLLISION_MASK) if self.objectWasHit then diff --git a/scripts/gui/CoursePlot.lua b/scripts/gui/CoursePlot.lua index 5c2a1953e..8fd08ad64 100644 --- a/scripts/gui/CoursePlot.lua +++ b/scripts/gui/CoursePlot.lua @@ -23,7 +23,7 @@ CoursePlot = CpObject() -- x = 0, y = 0 is the bottom left corner of the screen, terrainSize is in meters function CoursePlot:init() self.lineThickness = 2 / g_screenHeight -- 2 pixels - self.arrowThickness = 3 / g_screenHeight -- 3 pixels + self.arrowThickness = 10 / g_screenHeight -- 10 pixels -- the normal FS22 blue self.color = {CpGuiUtil.getNormalizedRgb(42, 193, 237)} -- a lighter shade of the same color @@ -173,7 +173,7 @@ end ---@param a number|nil ---@param isHudMap boolean|nil function CoursePlot:drawArrow(map, x, z, rotation, r, g, b, a, isHudMap) - local zoom = isHudMap and map.layout:getIconZoom() or map.fullScreenLayout:getIconZoom() + local zoom = map.layout:getIconZoom() * map.layout:getIconZoom() if isHudMap and map.state == IngameMap.STATE_MAP then --- When the hud is completely open, then the signs need to be scaled down. zoom = zoom * 0.5 @@ -226,7 +226,7 @@ function CoursePlot:draw(map, isHudMap) -- render the start and stop signs local signSizeMeters = 0.02 - local zoom = isHudMap and map.layout:getIconZoom() or map.fullScreenLayout:getIconZoom() + local zoom = map.layout:getIconZoom() if isHudMap and map.state == IngameMap.STATE_MAP then --- When the hud is completely open, then the signs need to be scaled down. zoom = zoom * 0.5 diff --git a/scripts/specializations/CpShovelPositions.lua b/scripts/specializations/CpShovelPositions.lua index 6de630f9f..170776c7c 100644 --- a/scripts/specializations/CpShovelPositions.lua +++ b/scripts/specializations/CpShovelPositions.lua @@ -417,7 +417,7 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height sy = yMin + 0.01 ey = yMin + 0.01 end - local hasIntersection, i1z, i1y, i2z, i2y = MathUtil.getCircleLineIntersection( + local hasIntersection, i1z, i1y, i2z, i2y = CpMathUtil.getCircleLineIntersection( az, ay, radiusArmToolToShovelTool, sz, sy, ez, ey) @@ -500,9 +500,10 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height name = "shovelY", value = shovelY}) table.insert(debugData, { name = "dirRot", value = math.deg(oldRotRelativeArmRot) }) - table.insert(debugData, { - name = "distAlpha", value = MathUtil.vector2Length(i1z - tz, i1y - ty) }) - + if i1z ~= nil and i1y ~= nil then + table.insert(debugData, { + name = "distAlpha", value = MathUtil.vector2Length(i1z - tz, i1y - ty) }) + end table.insert(debugData, { value = "", name = "", diff --git a/scripts/util/CpMathUtil.lua b/scripts/util/CpMathUtil.lua index 7183bc410..ba1dc341f 100644 --- a/scripts/util/CpMathUtil.lua +++ b/scripts/util/CpMathUtil.lua @@ -319,4 +319,28 @@ end --- Divide a by b, but instead of throwing an error when b is 0, return math.huge function CpMathUtil.divide(a, b) return b == 0 and math.huge or a / b -end \ No newline at end of file +end + +--- Legancy function form LS22 +function CpMathUtil.getCircleLineIntersection(circleX, circleZ, radius, lineStartX, lineStartZ, lineEndX, lineEndZ) + local p3x = lineStartX - circleX + local p3z = lineStartZ - circleZ + local p4x = lineEndX - circleX + local p4z = lineEndZ - circleZ + local m = (p4z - p3z) / (p4x - p3x) + local b = p3z - m * p3x + local dis = math.pow(radius, 2) * math.pow(m, 2) + math.pow(radius, 2) - math.pow(b, 2) + + if dis < 0 then + return false + else + local t1 = (-m * b + math.sqrt(dis)) / (math.pow(m, 2) + 1) + local t2 = (-m * b - math.sqrt(dis)) / (math.pow(m, 2) + 1) + local intersect1X = t1 + circleX + local intersect1Z = m * t1 + b + circleZ + local intersect2X = t2 + circleX + local intersect2Z = m * t2 + b + circleZ + + return true, intersect1X, intersect1Z, intersect2X, intersect2Z + end +end