summaryrefslogtreecommitdiff
path: root/examples/ray_box_cells/main.lua
diff options
context:
space:
mode:
authorjussi2024-08-05 23:35:57 +0300
committerjussi2024-08-05 23:35:57 +0300
commitb011b2ca4e161fea2a742cb9b1673cd84cf0eba5 (patch)
treee8a46e45013cc0c2ad27a9f045349ae790cd0a07 /examples/ray_box_cells/main.lua
parentc6eb85b3674c36cfc426486d866a78dfc5452ae0 (diff)
downloadreilua-enhanced-b011b2ca4e161fea2a742cb9b1673cd84cf0eba5.tar.gz
reilua-enhanced-b011b2ca4e161fea2a742cb9b1673cd84cf0eba5.tar.bz2
reilua-enhanced-b011b2ca4e161fea2a742cb9b1673cd84cf0eba5.zip
GetRayBoxCells fix.
Diffstat (limited to 'examples/ray_box_cells/main.lua')
-rw-r--r--examples/ray_box_cells/main.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/ray_box_cells/main.lua b/examples/ray_box_cells/main.lua
index 77aa058..64e0db2 100644
--- a/examples/ray_box_cells/main.lua
+++ b/examples/ray_box_cells/main.lua
@@ -10,7 +10,8 @@ Cam3D = require( "camera3d" )
local monitor = 0
local camera = {}
-local box = BoundinBox:new( { -8, 0, -8 }, { 16, 16, 16 } )
+-- local box = BoundinBox:new( { -8, 0, -8 }, { 16, 16, 16 } )
+local box = BoundinBox:new( { -7, 1, -8 }, { 4, 1, 7 } )
local cellSize = Vector3:new( 1, 1, 1 )
local drawCellSize = cellSize:clone()
local ray = nil
@@ -60,10 +61,9 @@ function RL.update( delta )
-- Raycast.
- -- if not guiMouseHover then
if not guiMouseHover and RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT ) then
ray = RL.GetMouseRay( RL.GetMousePosition(), camera.camera )
- rayCol = box:getRayCollision( ray )
+ rayCol = box:getRayCollisionMAS( ray )
cells, exitPoint = RL.GetRayBoxCells( ray, box:maxToPos(), cellSize )
drawCellSize:setV( cellSize )
@@ -99,8 +99,8 @@ function RL.draw()
if rayCol and rayCol.hit then
RL.DrawSphere( rayCol.point, 0.1, RL.RED )
end
- if exitPoint.hit then
- RL.DrawSphere( exitPoint.point, 0.1, RL.RED )
+ if exitPoint and exitPoint.hit then
+ RL.DrawSphere( exitPoint.point, 0.1, RL.YELLOW )
end
if cells then
for _, cell in ipairs( cells ) do