From 2169b4db39b4124ff13662fc9970f2410f85a132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 20 Jun 2020 18:19:33 +0200 Subject: [PATCH] Fix render simple --- raycastlib.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/raycastlib.h b/raycastlib.h index fdfc021..3ca6fe9 100644 --- a/raycastlib.h +++ b/raycastlib.h @@ -26,7 +26,7 @@ author: Miloslav "drummyfish" Ciz license: CC0 1.0 - version: 0.904 + version: 0.905 */ #include @@ -1526,16 +1526,18 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount, int16_t wallHeightWorld = _RCL_floorFunction(hit.square.x,hit.square.y); - wallHeightScreen = RCL_perspectiveScaleVertical((wallHeightWorld * - _RCL_camera.resolution.y) / RCL_UNITS_PER_SQUARE,dist); + RCL_Unit worldPointTop = wallHeightWorld - _RCL_camera.height; + RCL_Unit worldPointBottom = -1 * _RCL_camera.height; - int16_t RCL_normalizedWallHeight = wallHeightWorld != 0 ? - ((RCL_UNITS_PER_SQUARE * wallHeightScreen) / wallHeightWorld) : 0; + wallStart = _RCL_middleRow - + (RCL_perspectiveScaleVertical(worldPointTop,dist) + * _RCL_camera.resolution.y) / RCL_UNITS_PER_SQUARE; - heightOffset = RCL_perspectiveScaleVertical(_RCL_cameraHeightScreen,dist); + int16_t wallEnd = _RCL_middleRow - + (RCL_perspectiveScaleVertical(worldPointBottom,dist) + * _RCL_camera.resolution.y) / RCL_UNITS_PER_SQUARE; - wallStart = _RCL_middleRow - wallHeightScreen + heightOffset + - RCL_normalizedWallHeight; + wallHeightScreen = wallEnd - wallStart; } } else @@ -2036,3 +2038,4 @@ void RCL_initRayConstraints(RCL_RayConstraints *constraints) } #endif +