Skip to content

Commit

Permalink
fix: collision flags changed
Browse files Browse the repository at this point in the history
Removed PLACEMENT_BLOCKING which was added to avoid
the rice field pumps. Added STATIC_OBJECT instead,
and also WATER, hoping that rice fields won't
trigger it.
  • Loading branch information
Peter Vaiko committed Dec 25, 2024
1 parent b8e5bba commit 1fe3b2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scripts/CpUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions scripts/dev/DevHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
--- 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
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/pathfinder/PathfinderUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1fe3b2a

Please sign in to comment.