From 5aa677563d00e06b8274c6fc43aa1ba8e73deb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Wed, 5 Sep 2018 18:38:53 +0200 Subject: [PATCH] Fix wall bug --- raycastlib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index 3c5abd1..f7ca961 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -722,7 +722,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) int_maybe32_t iTo = y2 < zTop ? zTop : y2; - for (int_maybe32_t i = z1Screen < y ? z1Screen : y; i > iTo; --i) + for (int_maybe32_t i = z1Screen < y ? z1Screen : y; i >= iTo; --i) { p.position.y = i; p.hit = hit; @@ -740,7 +740,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) { iTo = y > zBottomCeil ? zBottomCeil : y; - for (int_maybe32_t i = z1ScreenCeil > y2 ? z1ScreenCeil : y2; i < iTo; + for (int_maybe32_t i = z1ScreenCeil > y2 ? z1ScreenCeil : y2; i <= iTo; ++i) { p.position.y = i; @@ -771,7 +771,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; - for (int_maybe32_t i = y; i >= horizon; --i) + for (int_maybe32_t i = y; i >= horizon + (horizon > y2 ? 0 : 1); --i) { p.position.y = i; p.depth = (_camera.resolution.y - i) * _floorDepthStep + floorCameraDiff;