1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/raycastlib.git synced 2024-11-20 20:19:57 +01:00

Horizontal -> vertical

This commit is contained in:
Miloslav Číž 2019-09-27 03:57:12 +02:00
parent 00919b8c23
commit c737137402

View file

@ -26,7 +26,7 @@
author: Miloslav "drummyfish" Ciz author: Miloslav "drummyfish" Ciz
license: CC0 1.0 license: CC0 1.0
version: 0.81 version: 0.82
*/ */
#include <stdint.h> #include <stdint.h>
@ -472,6 +472,8 @@ void RCL_initRayConstraints(RCL_RayConstraints *constraints);
//============================================================================= //=============================================================================
// privates // privates
#define _RCL_UNUSED(what) (void)(what);
// global helper variables, for precomputing stuff etc. // global helper variables, for precomputing stuff etc.
RCL_Camera _RCL_camera; RCL_Camera _RCL_camera;
RCL_Unit _RCL_horizontalDepthStep = 0; RCL_Unit _RCL_horizontalDepthStep = 0;
@ -1042,7 +1044,7 @@ RCL_Unit RCL_adjustDistance(RCL_Unit distance, RCL_Camera *camera,
} }
/// Helper for drawing floor or ceiling. Returns the last drawn pixel position. /// Helper for drawing floor or ceiling. Returns the last drawn pixel position.
static inline int16_t _RCL_drawHorizontal( static inline int16_t _RCL_drawVertical(
RCL_Unit yCurrent, RCL_Unit yCurrent,
RCL_Unit yTo, RCL_Unit yTo,
RCL_Unit limit1, // TODO: int16_t? RCL_Unit limit1, // TODO: int16_t?
@ -1056,6 +1058,8 @@ static inline int16_t _RCL_drawHorizontal(
RCL_PixelInfo *pixelInfo RCL_PixelInfo *pixelInfo
) )
{ {
_RCL_UNUSED(ray);
RCL_Unit depthIncrement; RCL_Unit depthIncrement;
RCL_Unit dx; RCL_Unit dx;
RCL_Unit dy; RCL_Unit dy;
@ -1132,6 +1136,8 @@ static inline int16_t _RCL_drawWall(
RCL_PixelInfo *pixelInfo RCL_PixelInfo *pixelInfo
) )
{ {
_RCL_UNUSED(height)
pixelInfo->isWall = 1; pixelInfo->isWall = 1;
RCL_Unit limit = RCL_clamp(yTo,limit1,limit2); RCL_Unit limit = RCL_clamp(yTo,limit1,limit2);
@ -1295,7 +1301,7 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
p.depth = 0; p.depth = 0;
#endif #endif
limit = _RCL_drawHorizontal(fPosY,fZ1Screen,cPosY + 1, limit = _RCL_drawVertical(fPosY,fZ1Screen,cPosY + 1,
_RCL_camera.resolution.y,fZ1World,-1,RCL_COMPUTE_FLOOR_DEPTH, _RCL_camera.resolution.y,fZ1World,-1,RCL_COMPUTE_FLOOR_DEPTH,
// ^ purposfully allow outside screen bounds // ^ purposfully allow outside screen bounds
RCL_COMPUTE_FLOOR_TEXCOORDS && p.height == RCL_FLOOR_TEXCOORDS_HEIGHT, RCL_COMPUTE_FLOOR_TEXCOORDS && p.height == RCL_FLOOR_TEXCOORDS_HEIGHT,
@ -1315,7 +1321,7 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
_RCL_horizontalDepthStep; _RCL_horizontalDepthStep;
#endif #endif
limit = _RCL_drawHorizontal(cPosY,cZ1Screen, limit = _RCL_drawVertical(cPosY,cZ1Screen,
-1,fPosY - 1,cZ1World,1,RCL_COMPUTE_CEILING_DEPTH,0,1,&ray,&p); -1,fPosY - 1,cZ1World,1,RCL_COMPUTE_CEILING_DEPTH,0,1,&ray,&p);
// ^ purposfully allow outside screen bounds here // ^ purposfully allow outside screen bounds here
@ -1476,7 +1482,7 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount,
p.depth = 1; p.depth = 1;
p.height = RCL_UNITS_PER_SQUARE; p.height = RCL_UNITS_PER_SQUARE;
y = _RCL_drawHorizontal(-1,wallStart,-1,_RCL_middleRow,_RCL_camera.height,1, y = _RCL_drawVertical(-1,wallStart,-1,_RCL_middleRow,_RCL_camera.height,1,
RCL_COMPUTE_CEILING_DEPTH,0,1,&ray,&p); RCL_COMPUTE_CEILING_DEPTH,0,1,&ray,&p);
// draw wall // draw wall
@ -1507,7 +1513,7 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount,
p.depth = (_RCL_camera.resolution.y - y) * _RCL_horizontalDepthStep + 1; p.depth = (_RCL_camera.resolution.y - y) * _RCL_horizontalDepthStep + 1;
#endif #endif
_RCL_drawHorizontal(y,_RCL_camResYLimit,-1,_RCL_camResYLimit, _RCL_drawVertical(y,_RCL_camResYLimit,-1,_RCL_camResYLimit,
_RCL_camera.height,1,RCL_COMPUTE_FLOOR_DEPTH,RCL_COMPUTE_FLOOR_TEXCOORDS, _RCL_camera.height,1,RCL_COMPUTE_FLOOR_DEPTH,RCL_COMPUTE_FLOOR_TEXCOORDS,
-1,&ray,&p); -1,&ray,&p);
} }