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

Add horizon info

This commit is contained in:
Miloslav Číž 2018-09-10 13:35:39 +02:00
parent 303f5cee60
commit 615f142c3f

View file

@ -137,6 +137,7 @@ typedef struct
Vector2D position; ///< On-screen position. Vector2D position; ///< On-screen position.
int8_t isWall; ///< Whether the pixel is a wall or a floor/ceiling. int8_t isWall; ///< Whether the pixel is a wall or a floor/ceiling.
int8_t isFloor; ///< Whether the pixel is floor or ceiling. int8_t isFloor; ///< Whether the pixel is floor or ceiling.
int8_t isHorizon; ///< Whether the pixel is floor going towards horizon.
Unit depth; ///< Corrected depth. Unit depth; ///< Corrected depth.
HitResult hit; ///< Corresponding ray hit. HitResult hit; ///< Corresponding ray hit.
Unit textureCoordY; ///< Normalized (0 to UNITS_PER_SQUARE - 1) tex coord. Unit textureCoordY; ///< Normalized (0 to UNITS_PER_SQUARE - 1) tex coord.
@ -789,6 +790,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
p.isWall = 0; p.isWall = 0;
p.isFloor = 1; p.isFloor = 1;
p.isHorizon = 0;
Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY; Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY;
@ -877,6 +879,7 @@ void _columnFunction(HitResult *hits, uint16_t hitCount, uint16_t x, Ray ray)
p.isWall = 0; p.isWall = 0;
p.isFloor = 1; p.isFloor = 1;
p.isHorizon = 1;
Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY; Unit floorCameraDiff = absVal(worldZPrev) * VERTICAL_DEPTH_MULTIPLY;
Unit horizon = (y2 < _middleRow || _ceilFunction == 0) ? _middleRow : y2; Unit horizon = (y2 < _middleRow || _ceilFunction == 0) ? _middleRow : y2;