Remove fast_f2nat

FossilOrigin-Name: 51fb59fc934df4829a82f7992f10435519dc8deb7098c3be1b17642fc6c05a44
This commit is contained in:
Jonathan Schleifer 2025-03-23 17:45:28 +00:00
parent 6320094293
commit e995b95a84
5 changed files with 17 additions and 23 deletions

View file

@ -198,7 +198,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D *v)
float y = ly;
int i = 0;
for (;;) {
struct sqr *s = S(fast_f2nat(x), fast_f2nat(y));
struct sqr *s = S((int)x, (int)y);
if (SOLID(s))
break;
float floor = s->floor;

View file

@ -100,10 +100,10 @@ collide(DynamicEntity *d, bool spawn, float drop, float rise)
const float fy1 = d.origin.y - d.radius;
const float fx2 = d.origin.x + d.radius;
const float fy2 = d.origin.y + d.radius;
const int x1 = fast_f2nat(fx1);
const int y1 = fast_f2nat(fy1);
const int x2 = fast_f2nat(fx2);
const int y2 = fast_f2nat(fy2);
const int x1 = fx1;
const int y1 = fy1;
const int x2 = fx2;
const int y2 = fy2;
float hi = 127, lo = -128;
// big monsters are afraid of heights, unless angry :)
float minfloor =

View file

@ -36,8 +36,6 @@
# define __cdecl
#endif
#define fast_f2nat(val) ((int)(val))
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -31,9 +31,8 @@ lightray(float bx, float by, Entity *light)
int l = light.attr2 << PRECBITS;
int stepx = (int)(dx / (float)steps * PRECF);
int stepy = (int)(dy / (float)steps * PRECF);
int stepl =
fast_f2nat(l / (float)steps); // incorrect: light will fade quicker
// if near edge of the world
// incorrect: light will fade quicker if near edge of the world
int stepl = l / (float)steps;
if (hasoverbright) {
l /= lightscale;
@ -54,9 +53,9 @@ lightray(float bx, float by, Entity *light)
return;
int g = light.attr3 << PRECBITS;
int stepg = fast_f2nat(g / (float)steps);
int stepg = g / (float)steps;
int b = light.attr4 << PRECBITS;
int stepb = fast_f2nat(b / (float)steps);
int stepb = b / (float)steps;
g /= lightscale;
stepg /= lightscale;
b /= lightscale;

View file

@ -35,15 +35,12 @@ computeraytable(float vx, float vy)
for (int i = 0; i < NUMRAYS; i++) {
float angle = i * PI2 / NUMRAYS;
if ((apitch > 45 // must be bigger if fov>120
|| (angle < byaw && angle > syaw) ||
// try to avoid tracing ray if outside of frustrum
// apitch must be bigger if fov > 120
if ((apitch > 45 || (angle < byaw && angle > syaw) ||
(angle < byaw - PI2 && angle > syaw - PI2) ||
(angle < byaw + PI2 && angle > syaw + PI2)) &&
!OUTBORD(vx, vy) &&
!SOLID(S(fast_f2nat(vx),
fast_f2nat(vy)))) // try to avoid tracing ray if outside
// of frustrum
{
!OUTBORD(vx, vy) && !SOLID(S((int)vx, (int)vy))) {
float ray = i * 8 / (float)NUMRAYS;
float dx, dy;
if (ray > 1 && ray < 3) {
@ -66,7 +63,7 @@ computeraytable(float vx, float vy)
sy += dy;
// 90% of time spend in this function is on this
// line
if (SOLID(S(fast_f2nat(sx), fast_f2nat(sy)))) {
if (SOLID(S((int)sx, (int)sy))) {
rdist[i] = (float)(fabs(sx - vx) +
fabs(sy - vy));
break;
@ -183,9 +180,9 @@ isoccluded(float vx, float vy, float cx, float cy,
l = ca(cx - vx, cy + csize - vy);
} // H
}
int si = fast_f2nat(h * (NUMRAYS / 8)) +
NUMRAYS; // get indexes into occlusion map from angles
int ei = fast_f2nat(l * (NUMRAYS / 8)) + NUMRAYS + 1;
// get indexes into occlusion map from angles
int si = h * (NUMRAYS / 8) + NUMRAYS;
int ei = l * (NUMRAYS / 8) + NUMRAYS + 1;
if (ei <= si)
ei += NUMRAYS;