From df8b84a0d5883fef771063a799272193ca1968d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Fri, 7 Sep 2018 18:35:55 +0200 Subject: [PATCH] Fix drawing bug --- raycastlib.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raycastlib.h b/raycastlib.h index 045df40..e964f3c 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -676,6 +676,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) int_maybe32_t z1ScreenNoClamp = z1Screen; z1Screen = clamp(z1Screen,0,_camResYLimit); + z1Screen = z1Screen > y2 ? z1Screen : y2; int_maybe32_t z1ScreenCeil = _middleRow - perspectiveScale( (worldZPrevCeil * _camera.resolution.y) / UNITS_PER_SQUARE,dist); @@ -683,6 +684,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) int_maybe32_t z1ScreenCeilNoClamp = z1ScreenCeil; z1ScreenCeil = clamp(z1ScreenCeil,0,_camResYLimit); + z1ScreenCeil = z1ScreenCeil < y ? z1ScreenCeil : y; int_maybe32_t z2Screen = _middleRow - perspectiveScale( (worldZ2 * _camera.resolution.y) / UNITS_PER_SQUARE,dist); @@ -693,6 +695,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) wallScreenHeightNoClamp : 1; z2Screen = clamp(z2Screen,0,_camResYLimit); + z2Screen = z2Screen > y2 ? z2Screen : y2; int_maybe32_t z2ScreenCeil = _middleRow - perspectiveScale( (worldZ2Ceil * _camera.resolution.y) / UNITS_PER_SQUARE,dist); @@ -704,6 +707,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray) wallScreenHeightCeilNoClamp : 1; z2ScreenCeil = clamp(z2ScreenCeil,0,_camResYLimit); + z2ScreenCeil = z2ScreenCeil < y ? z2ScreenCeil : y; int_maybe32_t zTop = z1Screen < z2Screen ? z1Screen : z2Screen;