mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-23 20:49:57 +01:00
Ugly hack fix
This commit is contained in:
parent
b542aeebea
commit
f09006066d
1 changed files with 22 additions and 5 deletions
25
raycastlib.h
25
raycastlib.h
|
@ -844,7 +844,7 @@ void RCL_castRayMultiHit(RCL_Ray ray, RCL_ArrayFunction arrayFunc,
|
|||
RCL_Unit diff = h.position.x - ray.start.x;
|
||||
|
||||
h.position.y = // avoid division by multiplying with reciprocal
|
||||
ray.start.y + ((ray.direction.y * diff) * rayDirXRecip) / RECIP_SCALE;
|
||||
ray.start.y + (ray.direction.y * diff * rayDirXRecip) / RECIP_SCALE;
|
||||
|
||||
#if RCL_RECTILINEAR
|
||||
/* Here we compute the fish eye corrected distance (perpendicular to
|
||||
|
@ -876,7 +876,7 @@ void RCL_castRayMultiHit(RCL_Ray ray, RCL_ArrayFunction arrayFunc,
|
|||
RCL_Unit diff = h.position.y - ray.start.y;
|
||||
|
||||
h.position.x =
|
||||
ray.start.x + ((ray.direction.x * diff) * rayDirYRecip) / RECIP_SCALE;
|
||||
ray.start.x + (ray.direction.x * diff * rayDirYRecip) / RECIP_SCALE;
|
||||
|
||||
#if RCL_RECTILINEAR
|
||||
h.distance =
|
||||
|
@ -1202,6 +1202,20 @@ static inline int16_t _RCL_drawWall(
|
|||
|
||||
RCL_Unit textureCoordScaled = pixelInfo->texCoords.y;
|
||||
|
||||
#if RCL_RECTILINEAR
|
||||
RCL_Unit tmp = pixelInfo->depth;
|
||||
pixelInfo->depth = (pixelInfo->depth * 23) / 32;
|
||||
|
||||
/* ^ UGLY HACK
|
||||
|
||||
For some reason the computed distance with rectilinear is larger, the
|
||||
correct distance is about 0.711 (~= 23/32) of the computed distance, so
|
||||
we correct it here in this ugly way.
|
||||
|
||||
TODO: investigate why, fix nicely
|
||||
*/
|
||||
#endif
|
||||
|
||||
for (RCL_Unit i = yCurrent + increment;
|
||||
increment == -1 ? i >= limit : i <= limit; // TODO: is efficient?
|
||||
i += increment)
|
||||
|
@ -1218,6 +1232,10 @@ static inline int16_t _RCL_drawWall(
|
|||
RCL_PIXEL_FUNCTION(pixelInfo);
|
||||
}
|
||||
|
||||
#if RCL_RECTILINEAR
|
||||
pixelInfo->depth = tmp;
|
||||
#endif
|
||||
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
@ -1680,8 +1698,7 @@ RCL_PixelInfo RCL_mapToScreen(RCL_Vector2D worldPosition, RCL_Unit height,
|
|||
middleColumn + (-1 * toPoint.y * middleColumn) / RCL_nonZero(result.depth);
|
||||
|
||||
result.position.y = camera.resolution.y / 2 -
|
||||
(((3 * camera.resolution.y) / 4 ) *
|
||||
// ((camera.resolution.y / 2) *
|
||||
(((3 * camera.resolution.y) / 4 ) *
|
||||
RCL_perspectiveScale(height - camera.height,result.depth))
|
||||
/ RCL_UNITS_PER_SQUARE + camera.shear;
|
||||
|
||||
|
|
Loading…
Reference in a new issue