- floatified GetZRange

This commit is contained in:
Christoph Oelckers 2022-09-28 14:01:20 +02:00
parent 60e9e4d93a
commit 6e03f87671
4 changed files with 15 additions and 24 deletions

View file

@ -474,46 +474,46 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto
//
//---------------------------------------------------------------------------
void GetZRange(DBloodActor* actor, int* ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax)
void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax)
{
assert(actor != nullptr);
Collision scratch;
auto bakCstat = actor->spr.cstat;
int32_t nTemp1;
double nTemp1;
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
getzrange(actor->int_pos(), actor->sector(), (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask);
getzrange(actor->spr.pos, actor->sector(), ceilZ, *ceilColl, floorZ, *floorColl, nDist, nMask);
if (floorColl->type == kHitSector)
{
auto pSector = floorColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pSector->floorstat & CSTAT_SECTOR_SKY))
*floorZ = 0x7fffffff;
*floorZ = 0x800000;
if (pSector->hasX())
{
XSECTOR* pXSector = &pSector->xs();
*floorZ += pXSector->Depth << 10;
*floorZ += pXSector->Depth << 2;
}
auto linkActor = barrier_cast<DBloodActor*>(pSector->upperLink);
if (linkActor)
{
auto linkOwner = linkActor->GetOwner();
vec3_t lpos = actor->int_pos() + linkOwner->int_pos() - linkActor->int_pos();
getzrange(lpos, linkOwner->sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask);
*floorZ -= linkOwner->int_pos().Z - linkActor->int_pos().Z;
auto lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos;
getzrange(lpos, linkOwner->sector(), &nTemp1, scratch, floorZ, *floorColl, nDist, nMask);
*floorZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z;
}
}
if (ceilColl->type == kHitSector)
{
auto pSector = ceilColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & CSTAT_SECTOR_SKY))
*ceilZ = 0x80000000;
*ceilZ = -(int)0x800000;
auto linkActor = barrier_cast<DBloodActor*>(pSector->lowerLink);
if (linkActor)
{
auto linkOwner = linkActor->GetOwner();
vec3_t lpos = actor->int_pos() + linkOwner->int_pos() - linkActor->int_pos();
getzrange(lpos, linkOwner->sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask);
*ceilZ -= linkOwner->int_pos().Z - linkActor->int_pos().Z;
auto lpos = actor->spr.pos + linkOwner->spr.pos - linkActor->spr.pos;
getzrange(lpos, linkOwner->sector(), ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask);
*ceilZ -= linkOwner->spr.pos.Z - linkActor->spr.pos.Z;
}
}
actor->spr.cstat = bakCstat;

View file

@ -52,14 +52,8 @@ inline int HitScan_(DBloodActor* pSprite, double z, const DVector3& pos, unsigne
}
int VectorScan(DBloodActor* pSprite, double nOffset, double nZOffset, const DVector3& vel, double nRange, int ac);
void GetZRange(DBloodActor* pSprite, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0);
void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0)
{
int cz, fz;
GetZRange(pSprite, &cz, ceilHit, &fz, floorHit, nDist, nMask, nClipParallax);
*ceilZ = cz * zinttoworld;
*floorZ = fz * zinttoworld;
}
void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0);
void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0);
void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0)
{

View file

@ -8401,7 +8401,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
patrolBonkles[i].max = ClipLow((gGameOptions.nDifficulty + 1) >> 1, 1);
}
int i, j, mod, sndCnt = 0, seeChance, hearChance;
int i, mod, sndCnt = 0, seeChance, hearChance;
bool stealth = (actor->xspr.unused1 & kDudeFlagStealth);
bool blind = (actor->xspr.dudeGuard);
bool deaf = (actor->xspr.dudeDeaf);

View file

@ -742,9 +742,6 @@ void viewDrawScreen(bool sceneonly)
bDeliriumOld = bDelirium && gDeliriumBlur;
int nClipDist = pPlayer->actor->int_clipdist();
int vec, vf4;
Collision c1, c2;
GetZRange(pPlayer->actor, &vf4, &c1, &vec, &c2, nClipDist, 0);
if (sceneonly) return;
double look_anghalf = pPlayer->angle.look_anghalf(interpfrac);
DrawCrosshair(kCrosshairTile, pPlayer->actor->xspr.health >> 4, -look_anghalf, 0, 2);