Skip to content

Commit

Permalink
Support fillArm on the fillTrigger (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnwop committed Feb 13, 2018
1 parent 636a7f8 commit d4676e3
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions specializations/HoseSystemFillTriggerInteractive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ function HoseSystemFillTriggerInteractive:update(dt)
return
end

if self.object.grabPoints ~= nil then
self.object.lastRaycastDistance = 0
self.object.lastRaycastObject = nil
self.object.lastRaycastDistance = 0
self.object.lastRaycastObject = nil

if self.object.grabPoints ~= nil then
for _, gp in pairs(self.object.grabPoints) do
if HoseSystem:getIsDetached(gp.state) then
local x, y, z = getWorldTranslation(gp.raycastNode)
Expand Down Expand Up @@ -99,21 +99,25 @@ function HoseSystemFillTriggerInteractive:update(dt)
-- end

if HoseSystem.debugRendering then
local xyz = { worldToLocal(gp.raycastNode, x, y, z) }
local color = { 1, 0 }
HoseSystemFillTriggerInteractive.debugRendering(self, gp.raycastNode, x, y, z)
end
end
end
end
end
end

xyz[3] = xyz[3] - HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE
xyz = { localToWorld(gp.raycastNode, xyz[1], xyz[2], xyz[3]) }
if self.object.fillArm ~= nil then
local x, y, z = getWorldTranslation(self.object.fillArm.node)

if self.object.lastRaycastDistance ~= 0 then
color = { 0, 1 }
end
raycast(x, y, z, self.object.fillArm.node, self, 1)

drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2], xyz[3], color[1], color[2], 0)
drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2] + HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE, xyz[3], color[1], color[2], 0)
drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2] - HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE, xyz[3], color[1], color[2], 0)
end
end
if self.object.lastRaycastDistance ~= 0 then
local isUnderFillplane, planeY = self.object.lastRaycastObject:checkPlaneY(y)

if isUnderFillplane and HoseSystemFillTriggerInteractive:allowFillTypeAffectDirtMask(self.object.lastRaycastObject.fillType) then
if HoseSystem.debugRendering then
HoseSystemFillTriggerInteractive.debugRendering(self, self.object.fillArm.node, x, y, z)
end
end
end
Expand All @@ -125,6 +129,26 @@ end
function HoseSystemFillTriggerInteractive:draw()
end

---
--
function HoseSystemFillTriggerInteractive.debugRendering(self, raycastNode, x, y, z)
if HoseSystem.debugRendering then
local xyz = { worldToLocal(raycastNode, x, y, z) }
local color = { 1, 0 }

xyz[3] = xyz[3] - HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE
xyz = { localToWorld(raycastNode, xyz[1], xyz[2], xyz[3]) }

if self.object.lastRaycastDistance ~= 0 then
color = { 0, 1 }
end

drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2], xyz[3], color[1], color[2], 0)
drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2] + HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE, xyz[3], color[1], color[2], 0)
drawDebugLine(x, y, z, color[1], color[2], 0, xyz[1], xyz[2] - HoseSystemFillTriggerInteractive.RAYCAST_DISTANCE, xyz[3], color[1], color[2], 0)
end
end

---
-- @param transformId
-- @param x
Expand Down

0 comments on commit d4676e3

Please sign in to comment.