1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/raycastlib.git synced 2024-11-24 20:59:58 +01:00
This commit is contained in:
Miloslav Číž 2018-09-12 13:45:08 +02:00
parent 1436b17c30
commit 2c77b6d728

View file

@ -787,14 +787,17 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
int_maybe32_t z1Screen = _middleRow - perspectiveScale( int_maybe32_t z1Screen = _middleRow - perspectiveScale(
(worldZPrev * _camera.resolution.y) / UNITS_PER_SQUARE,dist); (worldZPrev * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
int_maybe32_t z2Screen = _middleRow - perspectiveScale(
(worldZ2 * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
int8_t skipFloorWall = ((z1Screen < 0 && z2Screen < 0) ||
(z1Screen > _camResYLimit && z2Screen > _camResYLimit));
int_maybe32_t z1ScreenNoClamp = z1Screen; int_maybe32_t z1ScreenNoClamp = z1Screen;
z1Screen = clamp(z1Screen,0,_camResYLimit); z1Screen = clamp(z1Screen,0,_camResYLimit);
z1Screen = z1Screen > y2 ? z1Screen : y2; z1Screen = z1Screen > y2 ? z1Screen : y2;
int_maybe32_t z2Screen = _middleRow - perspectiveScale(
(worldZ2 * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
int_maybe32_t wallScreenHeightNoClamp = z1ScreenNoClamp - z2Screen + 1; int_maybe32_t wallScreenHeightNoClamp = z1ScreenNoClamp - z2Screen + 1;
wallScreenHeightNoClamp = wallScreenHeightNoClamp == 0 ? 1 : wallScreenHeightNoClamp = wallScreenHeightNoClamp == 0 ? 1 :
wallScreenHeightNoClamp; wallScreenHeightNoClamp;
@ -802,6 +805,8 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
z2Screen = clamp(z2Screen,0,_camResYLimit); z2Screen = clamp(z2Screen,0,_camResYLimit);
z2Screen = z2Screen > y2 ? z2Screen : y2; z2Screen = z2Screen > y2 ? z2Screen : y2;
int_maybe32_t zTop = z1Screen < z2Screen ? z1Screen : z2Screen;
// make the same variables for ceiling // make the same variables for ceiling
Unit wallHeightCeil = 0; Unit wallHeightCeil = 0;
@ -809,6 +814,9 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
int_maybe32_t z1ScreenCeil = 0; int_maybe32_t z1ScreenCeil = 0;
int_maybe32_t z1ScreenCeilNoClamp = 0; int_maybe32_t z1ScreenCeilNoClamp = 0;
int_maybe32_t z2ScreenCeil = 0; int_maybe32_t z2ScreenCeil = 0;
int_maybe32_t wallScreenHeightCeilNoClamp = 0;
int_maybe32_t zBottomCeil;
int8_t skipCeilingWall = 1;
if (_ceilFunction != 0) if (_ceilFunction != 0)
{ {
@ -820,16 +828,18 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
z1ScreenCeil = _middleRow - perspectiveScale( z1ScreenCeil = _middleRow - perspectiveScale(
(worldZPrevCeil * _camera.resolution.y) / UNITS_PER_SQUARE,dist); (worldZPrevCeil * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
z2ScreenCeil = _middleRow - perspectiveScale(
(worldZ2Ceil * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
skipCeilingWall = ((z1ScreenCeil < 0 && z2ScreenCeil < 0) ||
(z1ScreenCeil > _camResYLimit && z2ScreenCeil > _camResYLimit));
z1ScreenCeilNoClamp = z1ScreenCeil; z1ScreenCeilNoClamp = z1ScreenCeil;
z1ScreenCeil = clamp(z1ScreenCeil,0,_camResYLimit); z1ScreenCeil = clamp(z1ScreenCeil,0,_camResYLimit);
z1ScreenCeil = z1ScreenCeil < y ? z1ScreenCeil : y; z1ScreenCeil = z1ScreenCeil < y ? z1ScreenCeil : y;
z2ScreenCeil = _middleRow - perspectiveScale( wallScreenHeightCeilNoClamp =
(worldZ2Ceil * _camera.resolution.y) / UNITS_PER_SQUARE,dist);
}
int_maybe32_t wallScreenHeightCeilNoClamp =
z2ScreenCeil - z1ScreenCeilNoClamp; z2ScreenCeil - z1ScreenCeilNoClamp;
wallScreenHeightCeilNoClamp = wallScreenHeightCeilNoClamp != 0 ? wallScreenHeightCeilNoClamp = wallScreenHeightCeilNoClamp != 0 ?
@ -838,17 +848,13 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
z2ScreenCeil = clamp(z2ScreenCeil,0,_camResYLimit); z2ScreenCeil = clamp(z2ScreenCeil,0,_camResYLimit);
z2ScreenCeil = z2ScreenCeil < y ? z2ScreenCeil : y; z2ScreenCeil = z2ScreenCeil < y ? z2ScreenCeil : y;
int_maybe32_t zTop = z1Screen < z2Screen ? z1Screen : z2Screen; zBottomCeil = z1ScreenCeil > z2ScreenCeil ?
int_maybe32_t zBottomCeil = z1ScreenCeil > z2ScreenCeil ?
z1ScreenCeil : z2ScreenCeil; z1ScreenCeil : z2ScreenCeil;
}
if (zTop <= zBottomCeil) if (zTop <= zBottomCeil)
zBottomCeil = zTop; // walls on ceiling and floor met zBottomCeil = zTop; // walls on ceiling and floor met
if (z1Screen == 0) // TMP: nasty shear bug workaround
z1Screen = -1;
// draw floor until wall // draw floor until wall
p.isWall = 0; p.isWall = 0;
@ -892,7 +898,11 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
p.depth = dist; p.depth = dist;
p.isFloor = 1; p.isFloor = 1;
int_maybe32_t iTo = y2 < zTop ? zTop : y2; int_maybe32_t iTo;
if (!skipFloorWall)
{
iTo = y2 < zTop ? zTop : y2;
for (int_maybe32_t i = z1Screen < y ? z1Screen : y; i >= iTo; --i) for (int_maybe32_t i = z1Screen < y ? z1Screen : y; i >= iTo; --i)
{ {
@ -905,12 +915,13 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
_pixelFunction(&p); _pixelFunction(&p);
} }
}
// draw ceiling wall // draw ceiling wall
p.isFloor = 0; p.isFloor = 0;
if (_ceilFunction != 0) if (!skipCeilingWall)
{ {
iTo = y > zBottomCeil ? zBottomCeil : y; iTo = y > zBottomCeil ? zBottomCeil : y;