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

Fix fog bug

This commit is contained in:
Miloslav Číž 2018-09-03 09:39:46 +02:00
parent d1aa2658ee
commit 94bcb8e294

View file

@ -544,6 +544,8 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
PixelInfo p; PixelInfo p;
p.position.x = x; p.position.x = x;
#define VERTICAL_DEPTH_MULTIPLY 2
// we'll be simulatenously drawing the floor and the ceiling now // we'll be simulatenously drawing the floor and the ceiling now
for (uint_maybe32_t j = 0; j < hitCount; ++j) for (uint_maybe32_t j = 0; j < hitCount; ++j)
{ {
@ -598,7 +600,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
p.isWall = 0; p.isWall = 0;
Unit floorCameraDiff = absVal(worldZPrev) * 4; Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY;
for (int_maybe32_t i = y; i > z1Screen; --i) for (int_maybe32_t i = y; i > z1Screen; --i)
{ {
@ -609,7 +611,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
// draw ceiling until wall // draw ceiling until wall
Unit ceilCameraDiff = absVal(worldZPrevCeil) * 4; Unit ceilCameraDiff = absVal(worldZPrevCeil) * VERTICAL_DEPTH_MULTIPLY;
for (int_maybe32_t i = y2; i < z1ScreenCeil; ++i) for (int_maybe32_t i = y2; i < z1ScreenCeil; ++i)
{ {
@ -655,9 +657,8 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
p.isWall = 0; p.isWall = 0;
Unit floorCameraDiff = absVal(worldZPrev) * 4; Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY;
uint16_t horizon = y2 < _middleRow ? _middleRow : y2;
uint16_t horizon = y <= y2 ? y : _middleRow;
for (int_maybe32_t i = y; i >= horizon; --i) for (int_maybe32_t i = y; i >= horizon; --i)
{ {
@ -669,7 +670,8 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
// draw ceiling until horizon // draw ceiling until horizon
Unit ceilCameraDiff = absVal(worldZPrevCeil) * 4; Unit ceilCameraDiff = absVal(worldZPrevCeil) * VERTICAL_DEPTH_MULTIPLY;
horizon = y > _middleRow ? _middleRow : y;
for (int_maybe32_t i = y2; i < horizon; ++i) for (int_maybe32_t i = y2; i < horizon; ++i)
{ {
@ -679,6 +681,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
_pixelFunction(p); _pixelFunction(p);
} }
#undef VERTICAL_DEPTH_MULTIPLY
} }
void render(Camera cam, ArrayFunction arrayFunc, PixelFunction pixelFunc, void render(Camera cam, ArrayFunction arrayFunc, PixelFunction pixelFunc,