From 11052643058fdb16a7e56624f398295974a27578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Mon, 10 Sep 2018 14:36:09 +0200 Subject: [PATCH] Fix horizon bug --- raycastlib.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/raycastlib.h b/raycastlib.h index 1b1e9b2..b7b7da0 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -883,6 +883,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY; Unit horizon = (y2 < _middleRow || _ceilFunction == 0) ? _middleRow : y2; + horizon = clamp(horizon,0,_camera.resolution.y); for (int_maybe32_t i = y; i >= horizon + (horizon > y2 ? 0 : 1); --i) { @@ -900,6 +901,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) absVal(worldZPrevCeil) * VERTICAL_DEPTH_MULTIPLY : UNITS_PER_SQUARE; horizon = y > _middleRow ? _middleRow : y; + horizon = clamp(horizon,0,_camera.resolution.y); for (int_maybe32_t i = y2; i < horizon; ++i) {