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

Fix division by zero

This commit is contained in:
Miloslav Číž 2018-09-29 13:09:41 +02:00
parent 74bb0ac18a
commit a5fa09de35

View file

@ -1125,10 +1125,11 @@ static inline int16_t _RCL_drawHorizontal(
if (doCoords) /*constant condition - compiler should optimize it out*/\ if (doCoords) /*constant condition - compiler should optimize it out*/\
{\ {\
RCL_Unit d = _RCL_floorPixelDistances[i];\ RCL_Unit d = _RCL_floorPixelDistances[i];\
RCL_Unit d2 = RCL_nonZero(pixelInfo->hit.distance);\
pixelInfo->texCoords.x =\ pixelInfo->texCoords.x =\
_RCL_camera.position.x + ((d * dx) / (pixelInfo->hit.distance));\ _RCL_camera.position.x + ((d * dx) / d2);\
pixelInfo->texCoords.y =\ pixelInfo->texCoords.y =\
_RCL_camera.position.y + ((d * dy) / (pixelInfo->hit.distance));\ _RCL_camera.position.y + ((d * dy) / d2);\
}\ }\
RCL_PIXEL_FUNCTION(pixelInfo);\ RCL_PIXEL_FUNCTION(pixelInfo);\
}\ }\
@ -1284,6 +1285,7 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
{ {
hit = hits[j]; hit = hits[j];
distance = hit.distance; distance = hit.distance;
p.hit = hit;
fWallHeight = _RCL_floorFunction(hit.square.x,hit.square.y); fWallHeight = _RCL_floorFunction(hit.square.x,hit.square.y);
fZ2World = fWallHeight - _RCL_camera.height; fZ2World = fWallHeight - _RCL_camera.height;
@ -1328,8 +1330,6 @@ void _RCL_columnFunctionComplex(RCL_HitResult *hits, uint16_t hitCount, uint16_t
p.depth = 0; p.depth = 0;
#endif #endif
p.hit = hit;
limit = _RCL_drawHorizontal(fPosY,fZ1Screen,cPosY + 1, limit = _RCL_drawHorizontal(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