From cd88d5a92d186180f6765056a6a15cea4a4f460e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 9 Mar 2020 16:21:10 +0100 Subject: [PATCH] Fix collision checking --- raycastlib.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/raycastlib.h b/raycastlib.h index 625d665..8c51e79 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -1755,12 +1755,17 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset, RCL_Unit bottomLimit = -1 * RCL_INFINITY; RCL_Unit topLimit = RCL_INFINITY; + RCL_Unit currCeilHeight = RCL_INFINITY; + if (computeHeight) { bottomLimit = camera->height - RCL_CAMERA_COLL_HEIGHT_BELOW + RCL_CAMERA_COLL_STEP_HEIGHT; topLimit = camera->height + RCL_CAMERA_COLL_HEIGHT_ABOVE; + + if (ceilingHeightFunc != 0) + currCeilHeight = ceilingHeightFunc(xSquare,ySquare); } // checks a single square for collision against the camera @@ -1768,7 +1773,9 @@ void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset, if (computeHeight)\ {\ RCL_Unit height = floorHeightFunc(s1,s2);\ - if (height > bottomLimit)\ + if (height > bottomLimit || \ + currCeilHeight - height < \ + RCL_CAMERA_COLL_HEIGHT_BELOW + RCL_CAMERA_COLL_HEIGHT_ABOVE)\ dir##Collides = 1;\ else if (ceilingHeightFunc != 0)\ {\