Skip to content

Commit

Permalink
Release 1.0.3.8
Browse files Browse the repository at this point in the history
Fixes error in the path finder where it would still collide with trees
Limited drawing of lines to 1000
  • Loading branch information
Stephan-S committed Aug 2, 2019
1 parent 07b1d0d commit b2bb1a3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion FS19_AutoDrive/modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Créer, ajouter, modifier, supprimer vos routes ou points de destination à l'ai
]]>
</ru>
</description>
<version>1.0.3.7</version>
<version>1.0.3.8</version>
<multiplayer supported="true"/>
<iconFilename>store.dds</iconFilename>
<extraSourceFiles>
Expand Down
2 changes: 1 addition & 1 deletion FS19_AutoDrive/scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {};
AutoDrive.Version = "1.0.3.7";
AutoDrive.Version = "1.0.3.8";
AutoDrive.config_changed = false;

AutoDrive.directory = g_currentModDirectory;
Expand Down
8 changes: 5 additions & 3 deletions FS19_AutoDrive/scripts/AutoDriveLineDraw.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AutoDrive.LineDraw = {};
AutoDrive.LineDraw.initLines = 20;
AutoDrive.LineDraw.maxLines = 1000;
AutoDrive.LineDraw.initColorR = 1;
AutoDrive.LineDraw.initColorG = 0;
AutoDrive.LineDraw.initColorB = 1;
Expand Down Expand Up @@ -49,14 +50,15 @@ function AutoDrive:drawLine(startPoint, targetPoint, r, g, b, a)
end;
local color = AutoDrive:newColor(r, g, b, a);
AutoDrive.LineDraw.jobCounter = AutoDrive.LineDraw.jobCounter + 1;
while AutoDrive.LineDraw.jobCounter > AutoDrive.LineDraw.lineCounter do
AutoDrive.LineDraw.lines[AutoDrive.LineDraw.lineCounter+1] = AutoDrive:createLineObject();
while AutoDrive.LineDraw.jobCounter > AutoDrive.LineDraw.lineCounter and AutoDrive.LineDraw.lineCounter < AutoDrive.LineDraw.maxLines do
AutoDrive.LineDraw.lines[AutoDrive.LineDraw.lineCounter+1] = AutoDrive:createLineObject();
end;

local job = {};
job["startPoint"] = startPoint;
job["targetPoint"] = targetPoint;
job["color"] = color;
AutoDrive.LineDraw.jobs[AutoDrive.LineDraw.jobCounter] = job;
AutoDrive.LineDraw.jobs[AutoDrive.LineDraw.jobCounter] = job;
end;

function AutoDrive:createLineObject()
Expand Down
8 changes: 4 additions & 4 deletions FS19_AutoDrive/scripts/AutoDrivePathFinder.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AutoDrive.MAX_PATHFINDER_STEPS_PER_FRAME = 20;
AutoDrive.MAX_PATHFINDER_STEPS_TOTAL = 400;
AutoDrive.PATHFINDER_TARGET_DISTANCE = 25;
AutoDrive.PATHFINDER_START_DISTANCE = 5;
AutoDrive.PATHFINDER_START_DISTANCE = 15;
AutoDrive.PP_UP = 0;
AutoDrive.PP_UP_RIGHT = 1;
AutoDrive.PP_RIGHT = 2;
Expand Down Expand Up @@ -452,7 +452,7 @@ function AutoDrivePathFinder:checkGridCell(pf, cell)

local angleRad = math.atan2(pf.targetVector.z, pf.targetVector.x);
local y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, worldPos.x, 1, worldPos.z)
local shapes = overlapBox(worldPos.x,y+3,worldPos.z, 0,angleRad,0, AutoDrive.PP_CELL_X/2,2.5,AutoDrive.PP_CELL_Z/2, "collisionTestCallbackIgnore", nil, AIVehicleUtil.COLLISION_MASK, true, true, true)
local shapes = overlapBox(worldPos.x,y+3,worldPos.z, 0,angleRad,0, AutoDrive.PP_CELL_X/2,2.7,AutoDrive.PP_CELL_Z/2, "collisionTestCallbackIgnore", nil, AIVehicleUtil.COLLISION_MASK, true, true, true)
cell.hasCollision = (shapes > 0);

local previousCell = cell.incoming
Expand Down Expand Up @@ -718,9 +718,9 @@ function AutoDrivePathFinder:smoothResultingPPPath_Refined(pf)
local corner4Z = nodeAhead.z + math.sin(rightAngle) * sideLength;

local y = worldPos.y;
local shapes = overlapBox(worldPos.x,y,worldPos.z, 0,angleRad,0, AutoDrive.PP_CELL_X,5,length, "collisionTestCallbackIgnore", nil, AIVehicleUtil.COLLISION_MASK, true, true, true)
local shapes = overlapBox(worldPos.x + vectorX/2,y,worldPos.z + vectorZ/2, 0,angleRad,0, AutoDrive.PP_CELL_X,2.7,length, "collisionTestCallbackIgnore", nil, AIVehicleUtil.COLLISION_MASK, true, true, true)
hasCollision = hasCollision or (shapes > 0);
shapes = overlapBox(worldPos.x,y,worldPos.z, 0,angleRad,0, AutoDrive.PP_CELL_X,5,length, "collisionTestCallbackIgnore", nil, Player.COLLISIONMASK_TRIGGER, true, true, true)
shapes = overlapBox(worldPos.x + vectorX/2,y,worldPos.z + vectorZ/2, 0,angleRad,0, AutoDrive.PP_CELL_X,2.7,length, "collisionTestCallbackIgnore", nil, Player.COLLISIONMASK_TRIGGER, true, true, true)
hasCollision = hasCollision or (shapes > 0);

if (index > 1) then
Expand Down
Binary file added releases/1.0.3.8/FS19_AutoDrive.zip
Binary file not shown.

0 comments on commit b2bb1a3

Please sign in to comment.