mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-23 20:49:57 +01:00
Adjust floor texturing
This commit is contained in:
parent
cc6e9c69f4
commit
a5b5d6d43e
1 changed files with 6 additions and 10 deletions
16
raycastlib.h
16
raycastlib.h
|
@ -1102,7 +1102,7 @@ static inline int16_t _RCL_drawHorizontal(
|
||||||
{\
|
{\
|
||||||
dx = pixelInfo->hit.position.x - _RCL_camera.position.x;\
|
dx = pixelInfo->hit.position.x - _RCL_camera.position.x;\
|
||||||
dy = pixelInfo->hit.position.y - _RCL_camera.position.y;\
|
dy = pixelInfo->hit.position.y - _RCL_camera.position.y;\
|
||||||
pixPos = yCurrent - _RCL_middleRow - 1;\
|
pixPos = yCurrent - _RCL_middleRow;\
|
||||||
rayCameraCos = RCL_vectorsAngleCos(\
|
rayCameraCos = RCL_vectorsAngleCos(\
|
||||||
RCL_angleToDirection(_RCL_camera.direction),ray->direction);\
|
RCL_angleToDirection(_RCL_camera.direction),ray->direction);\
|
||||||
}\
|
}\
|
||||||
|
@ -1589,16 +1589,11 @@ void RCL_renderSimple(RCL_Camera cam, RCL_ArrayFunction floorHeightFunc,
|
||||||
this will contain precomputed
|
this will contain precomputed
|
||||||
distance to the camera */
|
distance to the camera */
|
||||||
RCL_Unit camHeightScreenSize =
|
RCL_Unit camHeightScreenSize =
|
||||||
#ifdef RCL_RAYCAST_TINY
|
(cam.height * cam.resolution.y) / RCL_UNITS_PER_SQUARE;
|
||||||
(cam.height
|
|
||||||
#else
|
|
||||||
(((cam.height >> 6) << 6) // prevent weird floor movement with rounding
|
|
||||||
#endif
|
|
||||||
* cam.resolution.y) / RCL_UNITS_PER_SQUARE;
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < halfResY; ++i) // precompute the distances
|
for (uint16_t i = 0; i < halfResY; ++i) // precompute the distances
|
||||||
floorPixelDistances[i] =
|
floorPixelDistances[i] =
|
||||||
RCL_perspectiveScaleInverse(camHeightScreenSize,i);
|
RCL_perspectiveScaleInverse(camHeightScreenSize,i + 1);
|
||||||
|
|
||||||
// pass to _RCL_columnFunctionSimple
|
// pass to _RCL_columnFunctionSimple
|
||||||
_RCL_floorPixelDistances = floorPixelDistances;
|
_RCL_floorPixelDistances = floorPixelDistances;
|
||||||
|
@ -1700,9 +1695,10 @@ RCL_Unit RCL_perspectiveScaleInverse(RCL_Unit originalSize,
|
||||||
RCL_Unit scaledSize)
|
RCL_Unit scaledSize)
|
||||||
{
|
{
|
||||||
return scaledSize != 0 ?
|
return scaledSize != 0 ?
|
||||||
(originalSize * RCL_UNITS_PER_SQUARE) /
|
(originalSize * RCL_UNITS_PER_SQUARE + RCL_UNITS_PER_SQUARE / 2) /
|
||||||
|
// ^ take the middle
|
||||||
((RCL_VERTICAL_FOV * 2 * scaledSize) / RCL_UNITS_PER_SQUARE)
|
((RCL_VERTICAL_FOV * 2 * scaledSize) / RCL_UNITS_PER_SQUARE)
|
||||||
: 0;
|
: RCL_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset,
|
void RCL_moveCameraWithCollision(RCL_Camera *camera, RCL_Vector2D planeOffset,
|
||||||
|
|
Loading…
Reference in a new issue