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

Fix ceiling bug

This commit is contained in:
Miloslav Číž 2018-09-03 10:04:10 +02:00
parent c61589d82b
commit 03064d6440

View file

@ -222,7 +222,7 @@ inline Unit absVal(Unit value)
/// Performs division, rounding down, NOT towards zero. /// Performs division, rounding down, NOT towards zero.
inline Unit divRoundDown(Unit value, Unit divisor) inline Unit divRoundDown(Unit value, Unit divisor)
{ {
return value / divisor - (value < 0 ? 1 : 0); return value / divisor - ( (value < 0) ? 1 : 0);
} }
// Bhaskara's cosine approximation formula // Bhaskara's cosine approximation formula
@ -540,8 +540,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
int_maybe32_t y2 = 0; // screen y (for ceil), will only fo down int_maybe32_t y2 = 0; // screen y (for ceil), will only fo down
Unit worldZPrev = _startHeight; Unit worldZPrev = _startHeight;
Unit worldZPrevCeil = UNITS_PER_SQUARE * 5 - _startHeight - 2 * _camera.height;
Unit worldZPrevCeil = UNITS_PER_SQUARE * 5 + _startHeight;
PixelInfo p; PixelInfo p;
p.position.x = x; p.position.x = x;