- migrated all FAFhitscan calls to the DVector3 variant.

Most with temporary wraps - this is needed to migrate the function itself to DVector3.
This commit is contained in:
Christoph Oelckers 2022-09-05 22:04:12 +02:00
parent 2be5ea9f15
commit 2936cb022c
4 changed files with 32 additions and 57 deletions

View file

@ -1760,13 +1760,13 @@ inline bool FAF_ConnectArea(sectortype* sect)
} }
void FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect, void FAFhitscan_(int32_t x, int32_t y, int32_t z, sectortype* sect,
int32_t xvect, int32_t yvect, int32_t zvect, int32_t xvect, int32_t yvect, int32_t zvect,
HitInfo& hit, int32_t clipmask); HitInfo& hit, int32_t clipmask);
inline void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask) inline void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask)
{ {
FAFhitscan(int(start.X * worldtoint), int(start.Y * worldtoint), int(start.Z * zworldtoint), sect, FAFhitscan_(int(start.X * worldtoint), int(start.Y * worldtoint), int(start.Z * zworldtoint), sect,
int(vect.X * worldtoint), int(vect.Y * worldtoint), int(vect.Z * zworldtoint), hit, clipmask); int(vect.X * worldtoint), int(vect.Y * worldtoint), int(vect.Z * zworldtoint), hit, clipmask);
} }

View file

@ -149,7 +149,7 @@ void ResetWallWarpHitscan(sectortype* sect)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void void
FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect, FAFhitscan_(int32_t x, int32_t y, int32_t z, sectortype* sect,
int32_t xvect, int32_t yvect, int32_t zvect, int32_t xvect, int32_t yvect, int32_t zvect,
HitInfo& hit, int32_t clipmask) HitInfo& hit, int32_t clipmask)
{ {

View file

@ -2196,13 +2196,8 @@ bool NearThings(PLAYER* pp)
// This only gets called if nothing else worked, check for nearness to a wall // This only gets called if nothing else worked, check for nearness to a wall
{ {
HitInfo hit{}; HitInfo hit{};
short dang = pp->angle.ang.Buildang();
FAFhitscan(pp->int_ppos().X, pp->int_ppos().Y, pp->int_ppos().Z - Z(30), pp->cursector, // Start position FAFhitscan(pp->pos.plusZ(-30), pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK_MISSILE);
bcos(dang), // X vector of 3D ang
bsin(dang), // Y vector of 3D ang
0, // Z vector of 3D ang
hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
return false; return false;

View file

@ -11625,22 +11625,15 @@ int InitSwordAttack(PLAYER* pp)
// all this is to break glass // all this is to break glass
{ {
HitInfo hit{}; HitInfo hit{};
short daang;
int daz;
daang = pp->angle.ang.Buildang(); double daz = (-MulScale(pp->horizon.horiz.asq16(), 2000, 16) + (RandomRange(24000) - 12000)) * zinttoworld;
daz = -MulScale(pp->horizon.horiz.asq16(), 2000, 16) + (RandomRange(24000) - 12000); int daang = pp->angle.ang.Buildang();
FAFhitscan(pp->pos, pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, daz), hit, CLIPMASK_MISSILE);
FAFhitscan(pp->int_ppos().X, pp->int_ppos().Y, pp->int_ppos().Z, pp->cursector, // Start position
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
return 0; return 0;
if (FindDistance3D(pp->int_ppos() - hit.int_hitpos()) < 700) if ((pp->pos - hit.hitpos).Length() < 43.75)
{ {
if (hit.actor() != nullptr) if (hit.actor() != nullptr)
@ -11748,7 +11741,7 @@ int InitFistAttack(PLAYER* pp)
bubble = SpawnBubble(pp->actor); bubble = SpawnBubble(pp->actor);
if (bubble != nullptr) if (bubble != nullptr)
{ {
bubble->set_int_ang(pp->angle.ang.Buildang()); bubble->spr.angle = pp->angle.ang;
auto random_amt = RandomAngle(DAngle22_5 / 4) - DAngle22_5 / 8; auto random_amt = RandomAngle(DAngle22_5 / 4) - DAngle22_5 / 8;
@ -11803,22 +11796,14 @@ int InitFistAttack(PLAYER* pp)
// all this is to break glass // all this is to break glass
{ {
HitInfo hit{}; HitInfo hit{};
short daang; double daz = (-MulScale(pp->horizon.horiz.asq16(), 2000, 16) + (RandomRange(24000) - 12000)) * zinttoworld;
int daz; int daang = pp->angle.ang.Buildang();
FAFhitscan(pp->pos, pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, daz), hit, CLIPMASK_MISSILE);
daang = pp->angle.ang.Buildang();
daz = -MulScale(pp->horizon.horiz.asq16(), 2000, 16) + (RandomRange(24000) - 12000);
FAFhitscan(pp->int_ppos().X, pp->int_ppos().Y, pp->int_ppos().Z, pp->cursector, // Start position
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
return 0; return 0;
if (FindDistance3D(pp->int_ppos() - hit.int_hitpos()) < 700) if ((pp->pos - hit.hitpos).Length() < 43.75)
{ {
if (hit.actor() != nullptr) if (hit.actor() != nullptr)
@ -12462,9 +12447,9 @@ int ContinueHitscan(PLAYER* pp, sectortype* sect, int x, int y, int z, short ang
HitInfo hit{}; HitInfo hit{};
DSWActor* actor = pp->actor; DSWActor* actor = pp->actor;
FAFhitscan(x, y, z, sect, DVector3 start(x * inttoworld, y * inttoworld, z * zmaptoworld);
xvect, yvect, zvect, DVector3 vect(xvect * inttoworld, yvect * inttoworld, zvect * zmaptoworld);
hit, CLIPMASK_MISSILE); FAFhitscan(start, sect, vect, hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
return 0; return 0;
@ -14674,7 +14659,6 @@ int InitUzi(PLAYER* pp)
if (WeaponAutoAimHitscan(pp->actor, &daz, &daang, false) != nullptr) if (WeaponAutoAimHitscan(pp->actor, &daz, &daang, false) != nullptr)
{ {
daang += RandomRange(24) - 12; daang += RandomRange(24) - 12;
daang = NORM_ANGLE(daang);
daz += RandomRange(10000) - 5000; daz += RandomRange(10000) - 5000;
} }
else else
@ -14688,9 +14672,9 @@ int InitUzi(PLAYER* pp)
xvect = bcos(daang); xvect = bcos(daang);
yvect = bsin(daang); yvect = bsin(daang);
zvect = daz; zvect = daz;
FAFhitscan(pp->int_ppos().X, pp->int_ppos().Y, nz, pp->cursector, // Start position DVector3 vect(xvect * inttoworld, yvect * inttoworld, zvect * zmaptoworld);
xvect,yvect,zvect,
hit, CLIPMASK_MISSILE); FAFhitscan(DVector3(pp->pos, nz * zinttoworld), pp->cursector, vect, hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
{ {
@ -15149,11 +15133,10 @@ int InitSobjMachineGun(DSWActor* actor, PLAYER* pp)
daang = actor->int_ang(); daang = actor->int_ang();
} }
FAFhitscan(nx, ny, nz, actor->sector(), // Start position DVector3 start(nx * inttoworld, ny * inttoworld, nz * zmaptoworld);
bcos(daang), // X vector of 3D ang DVector3 vect(bcos(daang) * inttoworld, bsin(daang) * inttoworld, daz * zmaptoworld);
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang FAFhitscan(start, actor->sector(), vect, hit, CLIPMASK_MISSILE);
hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
{ {
@ -15467,7 +15450,6 @@ int InitTurretMgun(SECTOR_OBJECT* sop)
int nx,ny,nz; int nx,ny,nz;
short cstat = 0; short cstat = 0;
short delta; short delta;
int xvect,yvect,zvect;
PlaySound(DIGI_BOATFIRE, sop->pmid, v3df_dontpan|v3df_doppler); PlaySound(DIGI_BOATFIRE, sop->pmid, v3df_dontpan|v3df_doppler);
@ -15526,13 +15508,13 @@ int InitTurretMgun(SECTOR_OBJECT* sop)
} }
} }
xvect = bcos(daang); DVector3 start(nx * inttoworld, ny * inttoworld, nz * zmaptoworld);
yvect = bsin(daang); int xvect = bcos(daang);
zvect = daz; int yvect = bsin(daang);
int zvect = daz;
DVector3 vect(xvect * inttoworld, yvect * inttoworld, zvect * zmaptoworld);
FAFhitscan(nx, ny, nz, actor->sector(), // Start position FAFhitscan(start, actor->sector(), vect, hit, CLIPMASK_MISSILE);
xvect, yvect, zvect,
hit, CLIPMASK_MISSILE);
if (RANDOM_P2(1024) < 400) if (RANDOM_P2(1024) < 400)
{ {
@ -17086,11 +17068,9 @@ DSWActor* QueueWallBlood(DSWActor* actor, DAngle bang)
daz -= (Z(128)<<2); daz -= (Z(128)<<2);
dang = (bang.Buildang() + (RANDOM_P2(128 << 5) >> 5)) - (64); dang = (bang.Buildang() + (RANDOM_P2(128 << 5) >> 5)) - (64);
FAFhitscan(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - Z(30), actor->sector(), // Start position DVector3 vect(bcos(dang) * inttoworld, bsin(dang) * inttoworld, daz * zmaptoworld);
bcos(dang), // X vector of 3D ang
bsin(dang), // Y vector of 3D ang FAFhitscan(actor->spr.pos.plusZ(-30), actor->sector(), vect, hit, CLIPMASK_MISSILE);
daz, // Z vector of 3D ang
hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr) if (hit.hitSector == nullptr)
return nullptr; return nullptr;