- partial floatification of FAFgetzrange/point

This commit is contained in:
Christoph Oelckers 2022-10-03 23:31:02 +02:00
parent 5b52af9b85
commit 5cda92b629
7 changed files with 70 additions and 31 deletions

View file

@ -145,6 +145,19 @@ inline void getzrange(const vec3_t& pos, sectortype* sect, double* ceilz, Collis
*florz = f * zinttoworld;
}
inline void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz,
CollisionBase& florhit, int32_t walldist, uint32_t cliptype)
{
vec3_t ipos(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) );
int c = int(*ceilz * zworldtoint);
int f = int(*florz * zworldtoint);
getzrange(ipos, sect, &c, ceilhit, &f, florhit, walldist, cliptype);
*ceilz = c * zinttoworld;
*florz = f * zinttoworld;
}
extern vec2_t hitscangoal;
struct HitInfoBase;

View file

@ -4772,7 +4772,7 @@ void getglobalz(DDukeActor* actor)
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.
getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
getzrange(actor->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0);
actor->spr.cstat2 = cc;
actor->spr.cstat2 &= ~CSTAT2_SPRITE_NOSHADOW;
@ -4834,7 +4834,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))
{
Collision coll;
getzrange({ actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 127, CLIPMASK0);
getzrange(actor->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 127, CLIPMASK0);
}
else
{

View file

@ -310,7 +310,7 @@ void InitLevelGlobals(void)
automapMode = am_off;
PlayerGravity = 24;
wait_active_check_offset = 0;
PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500);
PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = 500;
FinishedLevel = false;
AnimCnt = 0;
left_foot = false;

View file

@ -1712,6 +1712,15 @@ short AnimSetVelAdj(short anim_ndx, double vel_adj);
void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITY* person);
void getzrangepoint(int x, int y, int z, sectortype* sect, int32_t* ceilz, Collision* ceilhit, int32_t* florz, Collision* florhit);
inline void getzrangepoint(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit)
{
int32_t hi, lo;
getzrangepoint(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint), sect, &hi, ceilhit, &lo, florhit);
*hiz = hi * zinttoworld;
*loz = lo * zinttoworld;
}
Collision move_sprite(DSWActor* , int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics);
inline Collision move_sprite(DSWActor* actor, const DVector3& change, double ceildist, double flordist, uint32_t cliptype, int numtics)
{
@ -1915,7 +1924,7 @@ void computergetinput(int snum,InputPacket *syn); // jplayer.c
void SetupMirrorTiles(void); // rooms.c
bool FAF_Sector(sectortype* sect); // rooms.c
int GetZadjustment(sectortype* sect,short hitag); // rooms.c
double GetZadjustment(sectortype* sect,short hitag); // rooms.c
void InitSetup(void); // setup.c
@ -1977,7 +1986,7 @@ extern int OrigCommPlayers;
extern uint8_t PlayerGravity;
extern short wait_active_check_offset;
//extern short Zombies;
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
extern double PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
extern bool left_foot;
extern bool bosswasseen[3];
extern DSWActor* BossSpriteNum[3];

View file

@ -3139,7 +3139,7 @@ void StackedWaterSplash(PLAYER* pp)
void DoPlayerFall(PLAYER* pp)
{
short i;
int depth;
double depth;
// reset flag key for double jumps
if (!(pp->input.actions & SB_JUMP))
@ -3178,7 +3178,7 @@ void DoPlayerFall(PLAYER* pp)
depth = GetZadjustment(pp->cursector, FLOOR_Z_ADJUST)>>8;
depth = GetZadjustment(pp->cursector, FLOOR_Z_ADJUST);
if (depth == 0)
depth = pp->WadeDepth;

View file

@ -327,7 +327,7 @@ bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, se
//
//---------------------------------------------------------------------------
int GetZadjustment(sectortype* sect, short hitag)
double GetZadjustment(sectortype* sect, short hitag)
{
if (sect == nullptr || !(sect->extra & SECTFX_Z_ADJUST))
return 0;
@ -337,7 +337,7 @@ int GetZadjustment(sectortype* sect, short hitag)
{
if (itActor->spr.hitag == hitag && itActor->sector() == sect)
{
return Z(itActor->spr.lotag);
return itActor->spr.lotag;
}
}
@ -350,10 +350,9 @@ int GetZadjustment(sectortype* sect, short hitag)
//
//---------------------------------------------------------------------------
bool SectorZadjust(const Collision& ceilhit, int32_t* hiz, const Collision& florhit, int32_t* loz)
bool SectorZadjust(const Collision& ceilhit, double* hiz, const Collision& florhit, double* loz)
{
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
int z_amt = 0;
double z_amt = 0;
bool SkipFAFcheck = false;
@ -470,7 +469,7 @@ bool SectorZadjust(const Collision& ceilhit, int32_t* hiz, const Collision& flor
//
//---------------------------------------------------------------------------
void WaterAdjust(const Collision& florhit, int32_t* loz)
void WaterAdjust(const Collision& florhit, double* loz)
{
if (florhit.type == kHitSector)
{
@ -478,7 +477,7 @@ void WaterAdjust(const Collision& florhit, int32_t* loz)
if (!sect->hasU()) return;
if (sect->hasU() && FixedToInt(sect->depth_fixed))
*loz += Z(FixedToInt(sect->depth_fixed));
*loz += FixedToInt(sect->depth_fixed);
}
}
@ -503,14 +502,20 @@ void FAFgetzrange(vec3_t pos, sectortype* sect, int32_t* hiz, Collision* ceilhit
if (sect == nullptr || !FAF_ConnectArea(sect))
{
getzrange(pos, sect, hiz, *ceilhit, loz, *florhit, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
double hizf = *hiz * inttoworld, lozf = *loz * inttoworld;
SectorZadjust(*ceilhit, &hizf, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
*hiz = hizf * worldtoint;
*loz = lozf * worldtoint;
return;
}
getzrange(pos, sect, hiz, *ceilhit, loz, *florhit, clipdist, clipmask);
SkipFAFcheck = SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
double hizf = *hiz * inttoworld, lozf = *loz * inttoworld;
SkipFAFcheck = SectorZadjust(*ceilhit, &hizf, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
*hiz = hizf * worldtoint;
*loz = lozf * worldtoint;
if (SkipFAFcheck)
return;
@ -528,7 +533,9 @@ void FAFgetzrange(vec3_t pos, sectortype* sect, int32_t* hiz, Collision* ceilhit
vec3_t npos = pos;
npos.Z = newz;
getzrange(npos, uppersect, hiz, *ceilhit, &foo1, foo2, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, trash, nullptr);
hizf = *hiz * inttoworld;
SectorZadjust(*ceilhit, &hizf, trash, nullptr);
*hiz = hizf * worldtoint;
}
else if (FAF_ConnectFloor(sect) && !(sect->floorstat & CSTAT_SECTOR_FAF_BLOCK_HITSCAN))
{
@ -543,8 +550,10 @@ void FAFgetzrange(vec3_t pos, sectortype* sect, int32_t* hiz, Collision* ceilhit
vec3_t npos = pos;
npos.Z = newz;
getzrange(npos, lowersect, &foo1, foo2, loz, *florhit, clipdist, clipmask);
SectorZadjust(trash, nullptr, *florhit, loz);
WaterAdjust(*florhit, loz);
lozf = *loz * inttoworld;
SectorZadjust(trash, nullptr, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
*loz = lozf * worldtoint;
}
}
@ -571,14 +580,19 @@ void FAFgetzrangepoint_(int32_t x, int32_t y, int32_t z, sectortype* const sect,
if (!FAF_ConnectArea(sect))
{
getzrangepoint(x, y, z, sect, hiz, ceilhit, loz, florhit);
SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
double hizf = *hiz * inttoworld, lozf = *loz * inttoworld;
SectorZadjust(*ceilhit, &hizf, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
*hiz = hizf * worldtoint;
*loz = lozf * worldtoint;
return;
}
getzrangepoint(x, y, z, sect, hiz, ceilhit, loz, florhit);
SkipFAFcheck = SectorZadjust(*ceilhit, hiz, *florhit, loz);
WaterAdjust(*florhit, loz);
double lozf = *loz * inttoworld;
SkipFAFcheck = SectorZadjust(trash, nullptr, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
*loz = lozf * worldtoint;
if (SkipFAFcheck)
return;
@ -594,7 +608,9 @@ void FAFgetzrangepoint_(int32_t x, int32_t y, int32_t z, sectortype* const sect,
if (uppersect == nullptr)
return;
getzrangepoint(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2);
SectorZadjust(*ceilhit, hiz, trash, nullptr);
double hizf = *hiz * inttoworld;
SectorZadjust(*ceilhit, &hizf, trash, nullptr);
*hiz = hizf * worldtoint;
}
else if (FAF_ConnectFloor(sect) && !(sect->floorstat & CSTAT_SECTOR_FAF_BLOCK_HITSCAN))
{
@ -606,8 +622,9 @@ void FAFgetzrangepoint_(int32_t x, int32_t y, int32_t z, sectortype* const sect,
if (lowersect == nullptr)
return;
getzrangepoint(x, y, newz, lowersect, &foo1, &foo2, loz, florhit);
SectorZadjust(trash, nullptr, *florhit, loz);
WaterAdjust(*florhit, loz);
lozf = *loz * inttoworld;
SectorZadjust(trash, nullptr, *florhit, &lozf);
WaterAdjust(*florhit, &lozf);
}
}

View file

@ -106,7 +106,7 @@ static double globhiz, globloz;
static Collision globhihit, globlohit;
short wait_active_check_offset;
int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
double PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
void SetSectorWallBits(sectortype* sect, int bit_mask, bool set_sectwall, bool set_nextwall);
int DoActorDebris(DSWActor* actor);
void ActorWarpUpdatePos(DSWActor*,sectortype* sect);
@ -2596,8 +2596,8 @@ void SpriteSetup(void)
case PLAX_GLOB_Z_ADJUST:
{
actor->sector()->extra |= (SECTFX_Z_ADJUST);
PlaxCeilGlobZadjust = SP_TAG2(actor);
PlaxFloorGlobZadjust = SP_TAG3(actor);
PlaxCeilGlobZadjust = SP_TAG2(actor) * zmaptoworld;
PlaxFloorGlobZadjust = SP_TAG3(actor) * zmaptoworld;
KillActor(actor);
break;
}