diff --git a/scripts/CpUtil.lua b/scripts/CpUtil.lua index 2dc678578..1fbfacec6 100644 --- a/scripts/CpUtil.lua +++ b/scripts/CpUtil.lua @@ -484,5 +484,6 @@ end function CpUtil.getDefaultCollisionFlags() return CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + - CollisionFlag.VEHICLE + CollisionFlag.BUILDING + CollisionFlag.PLACEMENT_BLOCKING + CollisionFlag.VEHICLE + CollisionFlag.BUILDING + CollisionFlag.STATIC_OBJECT + + CollisionFlag.WATER end \ No newline at end of file diff --git a/scripts/dev/DevHelper.lua b/scripts/dev/DevHelper.lua index 2f9d8ec67..ff7c52000 100644 --- a/scripts/dev/DevHelper.lua +++ b/scripts/dev/DevHelper.lua @@ -25,6 +25,10 @@ along with this program. If not, see . --- Also showing field/fruit/collision information when walking around DevHelper = CpObject() +DevHelper.overlapBoxWidth = 3 +DevHelper.overlapBoxHeight = 3 +DevHelper.overlapBoxLength = 5 + function DevHelper:init() self.data = {} self.isEnabled = false @@ -85,7 +89,9 @@ function DevHelper:update() local collisionMask = CpUtil.getDefaultCollisionFlags() + CollisionFlag.TERRAIN_DELTA self.data.collidingShapes = '' - overlapBox(self.data.x, self.data.y + 0.2, self.data.z, 0, self.yRot, 0, 1.6, 1, 8, "overlapBoxCallback", self, collisionMask, true, true, true) + overlapBox(self.data.x, self.data.y + 0.2, self.data.z, 0, self.yRot, 0, + DevHelper.overlapBoxWidth / 2, DevHelper.overlapBoxHeight / 2, DevHelper.overlapBoxLength / 2, + "overlapBoxCallback", self, collisionMask, true, true, true) end @@ -94,7 +100,7 @@ function DevHelper:overlapBoxCallback(transformId) local text if collidingObject then if collidingObject.getRootVehicle then - text = 'vehicle' .. collidingObject:getName() + text = 'vehicle ' .. collidingObject:getName() else if collidingObject:isa(Bale) then text = 'Bale ' .. tostring(collidingObject.id) .. ' ' .. tostring(collidingObject.nodeId) @@ -206,8 +212,9 @@ function DevHelper:draw() --local x, y, z = localToWorld(self.node, 0, -1, -3) --drawDebugLine(x, y, z, 1, 1, 1, x + nx, y + ny, z + nz, 1, 1, 1) - --local xRot, yRot, zRot = getWorldRotation(self.tNode) - --DebugUtil.drawOverlapBox(self.data.x, self.data.y, self.data.z, xRot, yRot, zRot, 4, 1, 4, 0, 100, 0) + DebugUtil.drawOverlapBox(self.data.x, self.data.y, self.data.z, 0, self.yRot, 0, + DevHelper.overlapBoxWidth / 2, DevHelper.overlapBoxHeight / 2, DevHelper.overlapBoxLength / 2, + 0, 100, 0) PathfinderUtil.showOverlapBoxes() g_fieldScanner:draw() end diff --git a/scripts/pathfinder/PathfinderUtil.lua b/scripts/pathfinder/PathfinderUtil.lua index 2751011d2..7d4488c89 100644 --- a/scripts/pathfinder/PathfinderUtil.lua +++ b/scripts/pathfinder/PathfinderUtil.lua @@ -263,7 +263,7 @@ function PathfinderUtil.CollisionDetector.removeNodeToIgnore(node) end function PathfinderUtil.CollisionDetector:overlapBoxCallback(transformId) - if PathfinderUtil.CollisionDetector.NODES_TO_IGNORE[transformId] then + if PathfinderUtil.CollisionDetector.NODES_TO_IGNORE[transformId] then --- Global node, that needs to be ignored return end @@ -273,8 +273,8 @@ function PathfinderUtil.CollisionDetector:overlapBoxCallback(transformId) -- an object we want to ignore return end + local rootVehicle if collidingObject then - local rootVehicle if collidingObject.getRootVehicle then rootVehicle = collidingObject:getRootVehicle() elseif collidingObject:isa(Bale) and collidingObject.mountObject then @@ -663,7 +663,7 @@ end function PathfinderUtil.getWaypointAsState3D(waypoint, xOffset, zOffset) local result = State3D(waypoint.x, -waypoint.z, CpMathUtil.angleFromGameDeg(waypoint.angle)) if waypoint:getIsReverse() then - --- If it's a reverse driven waypoint, then the target heading needs to be inverted. + --- If it's a reverse driven waypoint, then the target heading needs to be inverted. result:reverseHeading() end local offset = Vector(zOffset, -xOffset)