From c6eb85b3674c36cfc426486d866a78dfc5452ae0 Mon Sep 17 00:00:00 2001 From: jussi Date: Sat, 20 Jul 2024 15:29:50 +0300 Subject: GetRayBoxCells also returns exit point. --- examples/ray_box_cells/main.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'examples/ray_box_cells/main.lua') diff --git a/examples/ray_box_cells/main.lua b/examples/ray_box_cells/main.lua index 9c7e54f..77aa058 100644 --- a/examples/ray_box_cells/main.lua +++ b/examples/ray_box_cells/main.lua @@ -16,6 +16,7 @@ local drawCellSize = cellSize:clone() local ray = nil local rayCol = nil local cells = {} +local exitPoint = {} local guiMouseHover = false local spinnerEdit = { @@ -64,7 +65,7 @@ function RL.update( delta ) ray = RL.GetMouseRay( RL.GetMousePosition(), camera.camera ) rayCol = box:getRayCollision( ray ) - cells = RL.GetRayBoxCells( ray, box:maxToPos(), cellSize ) + cells, exitPoint = RL.GetRayBoxCells( ray, box:maxToPos(), cellSize ) drawCellSize:setV( cellSize ) end end @@ -95,11 +96,12 @@ function RL.draw() RL.DrawRay( ray, RL.BLUE ) RL.DrawSphere( ray[1], 0.1, RL.GREEN ) end - 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 ) + end if cells then for _, cell in ipairs( cells ) do RL.DrawCubeWires( box.min + Vector3:tempT( cell ) * drawCellSize + drawCellSize:scale( 0.5 ), drawCellSize, RL.RED ) -- cgit v1.2.3