- cleaned up the remaining uses of the integer floorz/ceilingz variables.

This concerns two particularly ugly blocks of code in the move functions - these were fully redone with pure floating point math.
This commit is contained in:
Christoph Oelckers 2022-02-04 00:45:00 +01:00
parent 89c0e4234c
commit 4506b5cb08
4 changed files with 43 additions and 46 deletions

View file

@ -4810,7 +4810,7 @@ void getglobalz(DDukeActor* actor)
auto cc = actor->spr.cstat2; auto cc = actor->spr.cstat2;
actor->spr.cstat2 |= CSTAT2_SPRITE_NOFIND; // don't clip against self. getzrange cannot detect this because it only receives a coordinate. actor->spr.cstat2 |= CSTAT2_SPRITE_NOFIND; // don't clip against self. getzrange cannot detect this because it only receives a coordinate.
getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->__int_ceilingz, hz, &actor->__int_floorz, lz, zr, CLIPMASK0); getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
actor->spr.cstat2 = cc; actor->spr.cstat2 = cc;
actor->spr.cstat2 &= ~CSTAT2_SPRITE_NOSHADOW; actor->spr.cstat2 &= ~CSTAT2_SPRITE_NOSHADOW;
@ -4872,7 +4872,7 @@ void makeitfall(DDukeActor* actor)
if ((actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_STANDABLE)) if ((actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_STANDABLE))
{ {
Collision coll; Collision coll;
getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->__int_ceilingz, coll, &actor->__int_floorz, coll, 127, CLIPMASK0); getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 127, CLIPMASK0);
} }
else else
{ {

View file

@ -3494,7 +3494,6 @@ void moveeffectors_d(void) //STATNUM 3
void move_d(DDukeActor *actor, int playernum, int xvel) void move_d(DDukeActor *actor, int playernum, int xvel)
{ {
int l;
int goalang, angdif; int goalang, angdif;
int daxvel; int daxvel;
@ -3583,17 +3582,20 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{ {
if (actor->spr.picnum == COMMANDER) if (actor->spr.picnum == COMMANDER)
{ {
actor->__int_floorz = l = getflorzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double c, f;
if (actor->int_pos().Z > (l - (8 << 8))) getzsofslopeptr(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y, &c, &f);
actor->floorz = f;
actor->ceilingz = c;
if (actor->spr.pos.Z > f - 8)
{ {
if (actor->int_pos().Z > (l - (8 << 8))) actor->set_int_z(l - (8 << 8)); actor->spr.pos.Z = f - 8;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
actor->__int_ceilingz = l = getceilzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); if (actor->spr.pos.Z < c + 80)
if ((actor->int_pos().Z - l) < (80 << 8))
{ {
actor->set_int_z(l + (80 << 8)); actor->spr.pos.Z = c + 80;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
} }
@ -3601,16 +3603,18 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{ {
if (actor->spr.zvel > 0) if (actor->spr.zvel > 0)
{ {
actor->__int_floorz = l = getflorzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double f = getflorzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if (actor->int_pos().Z > (l - (30 << 8))) actor->floorz = f;
actor->set_int_z(l - (30 << 8)); if (actor->spr.pos.Z > f - 30)
actor->spr.pos.Z = f - 30;
} }
else else
{ {
actor->__int_ceilingz = l = getceilzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double c = getceilzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->int_pos().Z - l) < (50 << 8)) actor->ceilingz = c;
if (actor->spr.pos.Z < c + 50)
{ {
actor->set_int_z(l + (50 << 8)); actor->spr.pos.Z = c + 50;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
} }
@ -3618,22 +3622,22 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
} }
else if (actor->spr.picnum != ORGANTIC) else if (actor->spr.picnum != ORGANTIC)
{ {
if (actor->spr.zvel > 0 && actor->__int_floorz < actor->int_pos().Z) if (actor->spr.zvel > 0 && actor->floorz < actor->spr.pos.Z)
actor->set_int_z(actor->__int_floorz); actor->spr.pos.Z = actor->floorz;
if (actor->spr.zvel < 0) if (actor->spr.zvel < 0)
{ {
l = getceilzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double c = getceilzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->int_pos().Z - l) < (66 << 8)) if (actor->spr.pos.Z < c + 66)
{ {
actor->set_int_z(l + (66 << 8)); actor->spr.pos.Z = c + 66;
actor->spr.zvel >>= 1; actor->spr.zvel >>= 1;
} }
} }
} }
} }
else if (actor->spr.picnum == APLAYER) else if (actor->spr.picnum == APLAYER)
if ((actor->int_pos().Z - actor->__int_ceilingz) < (32 << 8)) if ((actor->spr.pos.Z - actor->ceilingz) < 32)
actor->set_int_z(actor->__int_ceilingz + (32 << 8)); actor->spr.pos.Z = actor->ceilingz + 32;
daxvel = actor->spr.xvel; daxvel = actor->spr.xvel;
angdif = actor->spr.ang; angdif = actor->spr.ang;

View file

@ -3024,7 +3024,7 @@ void moveexplosions_r(void) // STATNUM 5
if (!money(act, BLOODPOOL)) continue; if (!money(act, BLOODPOOL)) continue;
if (act->sector()->lotag == 800) if (act->sector()->lotag == 800)
if (act->int_pos().Z >= act->sector()->int_floorz() - (8 << 8)) if (act->spr.pos.Z >= act->sector()->floorz - 8)
{ {
deletesprite(act); deletesprite(act);
continue; continue;
@ -3472,7 +3472,6 @@ int adjustfall(DDukeActor *actor, int c)
void move_r(DDukeActor *actor, int pnum, int xvel) void move_r(DDukeActor *actor, int pnum, int xvel)
{ {
int l;
int goalang, angdif; int goalang, angdif;
int daxvel; int daxvel;
@ -3640,43 +3639,38 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{ {
if (actor->spr.zvel > 0) if (actor->spr.zvel > 0)
{ {
actor->__int_floorz = l = getflorzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double dist = isRRRA() ? 28 : 30;
if (isRRRA()) double f = getflorzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
{ actor->floorz = f;
if (actor->int_pos().Z > (l - (28 << 8))) if (actor->spr.pos.Z > f - dist)
actor->set_int_z(l - (28 << 8)); actor->spr.pos.Z = f - dist;
}
else
{
if (actor->int_pos().Z > (l - (30 << 8)))
actor->set_int_z(l - (30 << 8));
}
} }
else else
{ {
actor->__int_ceilingz = l = getceilzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double c = getceilzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->int_pos().Z - l) < (50 << 8)) actor->ceilingz = c;
if (actor->spr.pos.Z < c + 50)
{ {
actor->set_int_z(l + (50 << 8)); actor->spr.pos.Z = c + 50;
actor->spr.zvel = 0; actor->spr.zvel = 0;
} }
} }
} }
if (actor->spr.zvel > 0 && actor->__int_floorz < actor->int_pos().Z) if (actor->spr.zvel > 0 && actor->floorz < actor->spr.pos.Z)
actor->set_int_z(actor->__int_floorz); actor->spr.pos.Z = actor->floorz;
if (actor->spr.zvel < 0) if (actor->spr.zvel < 0)
{ {
l = getceilzofslopeptr(actor->sector(), actor->int_pos().X, actor->int_pos().Y); double c = getceilzofslopeptrf(actor->sector(), actor->spr.pos.X, actor->spr.pos.Y);
if ((actor->int_pos().Z - l) < (66 << 8)) if (actor->spr.pos.Z < c + 66)
{ {
actor->set_int_z(l + (66 << 8)); actor->spr.pos.Z = c + 66;
actor->spr.zvel >>= 1; actor->spr.zvel >>= 1;
} }
} }
} }
else if (actor->spr.picnum == APLAYER) else if (actor->spr.picnum == APLAYER)
if ((actor->int_pos().Z - actor->__int_ceilingz) < (32 << 8)) if ((actor->spr.pos.Z - actor->ceilingz) < 32)
actor->set_int_z(actor->__int_ceilingz + (32 << 8)); actor->spr.pos.Z = actor->ceilingz + 32;
daxvel = actor->spr.xvel; daxvel = actor->spr.xvel;
angdif = actor->spr.ang; angdif = actor->spr.ang;

View file

@ -51,7 +51,6 @@ public:
short timetosleep; short timetosleep;
vec2_t ovel; vec2_t ovel;
double floorz, ceilingz; double floorz, ceilingz;
int __int_floorz, __int_ceilingz;
union union
{ {
int saved_ammo; int saved_ammo;