mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-21 20:29:59 +01:00
Start rewriting floor
This commit is contained in:
parent
b682f37048
commit
7afd833980
1 changed files with 23 additions and 6 deletions
29
raycastlib.h
29
raycastlib.h
|
@ -996,6 +996,7 @@ static inline int16_t _RCL_drawHorizontal(
|
|||
RCL_Unit verticalOffset,
|
||||
int16_t increment,
|
||||
int8_t computeDepth,
|
||||
int16_t depthIncrementMultiplier,
|
||||
RCL_PixelInfo *pixelInfo
|
||||
)
|
||||
{
|
||||
|
@ -1008,12 +1009,15 @@ static inline int16_t _RCL_drawHorizontal(
|
|||
pixelInfo->depth += RCL_absVal(verticalOffset) *
|
||||
RCL_VERTICAL_DEPTH_MULTIPLY;
|
||||
|
||||
RCL_Unit depthIncrement = depthIncrementMultiplier *
|
||||
_RCL_horizontalDepthStep;
|
||||
|
||||
for (int16_t i = yCurrent + increment;
|
||||
increment == -1 ? i >= limit : i <= limit; // TODO: is efficient?
|
||||
i += increment)
|
||||
{
|
||||
pixelInfo->position.y = i;
|
||||
pixelInfo->depth += _RCL_horizontalDepthStep;
|
||||
pixelInfo->depth += depthIncrement;
|
||||
RCL_PIXEL_FUNCTION(pixelInfo);
|
||||
}
|
||||
}
|
||||
|
@ -1188,7 +1192,7 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
#endif
|
||||
|
||||
limit = _RCL_drawHorizontal(fPosY,fZ1Screen,cPosY + 1,
|
||||
_RCL_camera.resolution.y,fZ1World,-1,RCL_COMPUTE_FLOOR_DEPTH,&p);
|
||||
_RCL_camera.resolution.y,fZ1World,-1,RCL_COMPUTE_FLOOR_DEPTH,1,&p);
|
||||
// ^ purposfully allow outside screen bounds
|
||||
|
||||
if (fPosY > limit)
|
||||
|
@ -1205,7 +1209,7 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
#endif
|
||||
|
||||
limit = _RCL_drawHorizontal(cPosY,cZ1Screen,
|
||||
-1,fPosY - 1,cZ1World,1,RCL_COMPUTE_CEILING_DEPTH,&p);
|
||||
-1,fPosY - 1,cZ1World,1,RCL_COMPUTE_CEILING_DEPTH,1,&p);
|
||||
// ^ purposfully allow outside screen bounds here
|
||||
|
||||
if (cPosY < limit)
|
||||
|
@ -1362,7 +1366,7 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
// ^ in case there is no wall
|
||||
|
||||
y = _RCL_drawHorizontal(-1,wallStart,-1,_RCL_middleRow,_RCL_camera.height,1,
|
||||
RCL_COMPUTE_CEILING_DEPTH,&p);
|
||||
RCL_COMPUTE_CEILING_DEPTH,1,&p);
|
||||
|
||||
// draw wall
|
||||
|
||||
|
@ -1377,9 +1381,11 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
p.texCoords.x = p.hit.textureCoord;
|
||||
|
||||
limit = _RCL_drawWall(y,wallStart,wallStart + wallHeightScreen - 1,-1,
|
||||
_RCL_camera.resolution.y,p.hit.arrayValue,1,&p);
|
||||
_RCL_camera.resolution.y,p.hit.arrayValue,1,&p);
|
||||
|
||||
y = RCL_max(y,limit) + 1; // take max, in case no wall was drawn
|
||||
// y = RCL_max(y,limit) + 1; // take max, in case no wall was drawn
|
||||
|
||||
y = RCL_max(y,limit); // take max, in case no wall was drawn
|
||||
|
||||
// draw floor
|
||||
|
||||
|
@ -1389,6 +1395,15 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
p.depth = (_RCL_camera.resolution.y - y) * _RCL_horizontalDepthStep + 1;
|
||||
#endif
|
||||
|
||||
_RCL_drawHorizontal(y,_RCL_camResYLimit,-1,
|
||||
_RCL_camResYLimit,_RCL_camera.height,1,
|
||||
RCL_COMPUTE_FLOOR_DEPTH,-1,&p);
|
||||
|
||||
/*
|
||||
#if RCL_COMPUTE_FLOOR_DEPTH == 1
|
||||
p.depth = (_RCL_camera.resolution.y - y) * _RCL_horizontalDepthStep + 1;
|
||||
#endif
|
||||
|
||||
#if RCL_COMPUTE_FLOOR_TEXCOORDS == 1
|
||||
RCL_Unit dx = p.hit.position.x - _RCL_camera.position.x;
|
||||
RCL_Unit dy = p.hit.position.y - _RCL_camera.position.y;
|
||||
|
@ -1425,6 +1440,8 @@ void _RCL_columnFunctionSimple(RCL_HitResult *hits, uint16_t hitCount, uint16_t
|
|||
if (p.depth < 0) // just in case
|
||||
p.depth = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void RCL_renderComplex(RCL_Camera cam, RCL_ArrayFunction floorHeightFunc,
|
||||
|
|
Loading…
Reference in a new issue