From 03064d64404f49dea139986ed276b71ed56e20ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 3 Sep 2018 10:04:10 +0200 Subject: [PATCH] Fix ceiling bug --- raycastlib.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 7f4057e..d2b78bf 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -222,7 +222,7 @@ inline Unit absVal(Unit value) /// Performs division, rounding down, NOT towards zero. inline Unit divRoundDown(Unit value, Unit divisor) { - return value / divisor - (value < 0 ? 1 : 0); + return value / divisor - ( (value < 0) ? 1 : 0); } // Bhaskara's cosine approximation formula @@ -540,8 +540,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) int_maybe32_t y2 = 0; // screen y (for ceil), will only fo down Unit worldZPrev = _startHeight; - - Unit worldZPrevCeil = UNITS_PER_SQUARE * 5 + _startHeight; + Unit worldZPrevCeil = UNITS_PER_SQUARE * 5 - _startHeight - 2 * _camera.height; PixelInfo p; p.position.x = x;