From 25b49803443a06215aa1794403746351dc3748f8 Mon Sep 17 00:00:00 2001 From: Stephan Schlosser Date: Fri, 21 May 2021 10:57:41 +0200 Subject: [PATCH] Reenabled new pathcaluclation after one year. To be tested! --- FS19_AutoDrive/scripts/Manager/GraphManager.lua | 12 ++++++------ FS19_AutoDrive/scripts/PathCalculation.lua | 12 ++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/FS19_AutoDrive/scripts/Manager/GraphManager.lua b/FS19_AutoDrive/scripts/Manager/GraphManager.lua index 80384f75..0125c776 100644 --- a/FS19_AutoDrive/scripts/Manager/GraphManager.lua +++ b/FS19_AutoDrive/scripts/Manager/GraphManager.lua @@ -153,8 +153,8 @@ function ADGraphManager:pathFromTo(startWaypointId, targetWaypointId) if startWaypointId == targetWaypointId then table.insert(wp, self.wayPoints[targetWaypointId]) else - -- wp = ADPathCalculator:GetPath(startWaypointId, targetWaypointId) - wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetWaypointId) + wp = ADPathCalculator:GetPath(startWaypointId, targetWaypointId) + --wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetWaypointId) end end return wp @@ -168,8 +168,8 @@ function ADGraphManager:pathFromToMarker(startWaypointId, markerId) table.insert(wp, 1, self.wayPoints[targetId]) return wp else - -- wp = ADPathCalculator:GetPath(startWaypointId, targetId) - wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetId) + wp = ADPathCalculator:GetPath(startWaypointId, targetId) + --wp = AutoDrive:dijkstraLiveShortestPath(startWaypointId, targetId) end end return wp @@ -200,8 +200,8 @@ function ADGraphManager:FastShortestPath(start, markerName, markerId) return wp end - -- wp = ADPathCalculator:GetPath(start_id, target_id) - wp = AutoDrive:dijkstraLiveShortestPath(start_id, target_id) + wp = ADPathCalculator:GetPath(start_id, target_id) + --wp = AutoDrive:dijkstraLiveShortestPath(start_id, target_id) return wp end diff --git a/FS19_AutoDrive/scripts/PathCalculation.lua b/FS19_AutoDrive/scripts/PathCalculation.lua index ba12a3a0..d5a45c64 100644 --- a/FS19_AutoDrive/scripts/PathCalculation.lua +++ b/FS19_AutoDrive/scripts/PathCalculation.lua @@ -4,9 +4,13 @@ function ADPathCalculator:GetPath(startID, targetID) local count = 0 if not ADGraphManager:areWayPointsPrepared() then + print("ADPathCalculator - preparing waypoints - 1") AutoDrive.checkWaypointsLinkedtothemselve(true) -- find WP linked to themselve, with parameter true issues will be fixed + print("ADPathCalculator - preparing waypoints - 2") AutoDrive.checkWaypointsMultipleSameOut(true) -- find WP with multiple same out ID, with parameter true issues will be fixed + print("ADPathCalculator - preparing waypoints - 3") ADGraphManager:prepareWayPoints() + print("ADPathCalculator - preparing waypoints - 4") end local network = ADGraphManager:getWayPoints() @@ -54,8 +58,8 @@ function ADPathCalculator:GetPath(startID, targetID) for _, outId in pairs(outMap) do local outPoint = network[outId] --- axel TODO implement automatic network check for such issue: waypoint linked to itself -> DONE with AutoDrive.checkWaypointsLinkedtothemselve(true) - if point.id ~= outPoint.id then + -- axel TODO implement automatic network check for such issue: waypoint linked to itself -> DONE with AutoDrive.checkWaypointsLinkedtothemselve(true) + --if point.id ~= outPoint.id then -- First check if this point needs to be added to the candidate list or if it has already been tested local toBeAdded = true if results[outId] ~= nil then @@ -69,7 +73,7 @@ function ADPathCalculator:GetPath(startID, targetID) toBeAdded = false end end - if toBeAdded or (#point.incoming > 1) then + if toBeAdded then --or (#point.incoming > 1) candidates:enqueue({p=outPoint, distance=(distance + distanceFunc(outPoint.x - point.x, outPoint.z - point.z) + (addedWeights[outPoint.id] or 0)), pre=point.id}) end @@ -80,7 +84,7 @@ function ADPathCalculator:GetPath(startID, targetID) results[point.id][outId] = {distance=distance, pre=previousPoint} end end - end + --end end point = nil else