- floatified GetZRangeAtXYZ

This commit is contained in:
Christoph Oelckers 2022-09-28 14:06:29 +02:00
parent 9b9116986b
commit 99da5d78ab
2 changed files with 14 additions and 22 deletions

View file

@ -525,43 +525,42 @@ void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* f
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilColl, int* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax) void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilColl, double* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax)
{ {
Collision scratch; Collision scratch;
int32_t nTemp1; double nTemp1;
vec3_t lpos = { x, y, z }; getzrange(pos, pSector, ceilZ, *ceilColl, floorZ, *floorColl, nDist, nMask);
getzrange(lpos, pSector, (int32_t*)ceilZ, *ceilColl, (int32_t*)floorZ, *floorColl, nDist, nMask);
if (floorColl->type == kHitSector) if (floorColl->type == kHitSector)
{ {
auto pHitSect = floorColl->hitSector; auto pHitSect = floorColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pHitSect->floorstat & CSTAT_SECTOR_SKY)) if ((nClipParallax & PARALLAXCLIP_FLOOR) == 0 && (pHitSect->floorstat & CSTAT_SECTOR_SKY))
*floorZ = 0x7fffffff; *floorZ = 0x800000;
if (pHitSect->hasX()) if (pHitSect->hasX())
{ {
XSECTOR* pXSector = &pHitSect->xs(); XSECTOR* pXSector = &pHitSect->xs();
*floorZ += pXSector->Depth << 10; *floorZ += pXSector->Depth << 2;
} }
auto actor = barrier_cast<DBloodActor*>(pHitSect->upperLink); auto actor = barrier_cast<DBloodActor*>(pHitSect->upperLink);
if (actor) if (actor)
{ {
auto link = actor->GetOwner(); auto link = actor->GetOwner();
vec3_t newpos = lpos + link->int_pos() - actor->int_pos(); auto newpos = pos + link->spr.pos - actor->spr.pos;
getzrange(newpos, link->sector(), &nTemp1, scratch, (int32_t*)floorZ, *floorColl, nDist, nMask); getzrange(newpos, link->sector(), &nTemp1, scratch, floorZ, *floorColl, nDist, nMask);
*floorZ -= link->int_pos().Z - actor->int_pos().Z; *floorZ -= link->spr.pos.Z - actor->spr.pos.Z;
} }
} }
if (ceilColl->type == kHitSector) if (ceilColl->type == kHitSector)
{ {
auto pHitSect = ceilColl->hitSector; auto pHitSect = ceilColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pHitSect->ceilingstat & CSTAT_SECTOR_SKY)) if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pHitSect->ceilingstat & CSTAT_SECTOR_SKY))
*ceilZ = 0x80000000; *ceilZ = -0x800000;
auto actor = barrier_cast<DBloodActor*>(pHitSect->lowerLink); auto actor = barrier_cast<DBloodActor*>(pHitSect->lowerLink);
if (actor) if (actor)
{ {
auto link = actor->GetOwner(); auto link = actor->GetOwner();
vec3_t newpos = lpos + link->int_pos() - actor->int_pos(); auto newpos = pos + link->spr.pos - actor->spr.pos;
getzrange(newpos, link->sector(), (int32_t*)ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask); getzrange(newpos, link->sector(), ceilZ, *ceilColl, &nTemp1, scratch, nDist, nMask);
*ceilZ -= link->int_pos().Z - actor->int_pos().Z; *ceilZ -= link->spr.pos.Z - actor->spr.pos.Z;
} }
} }
} }

View file

@ -54,15 +54,8 @@ int VectorScan(DBloodActor* pSprite, double nOffset, double nZOffset, const DVec
void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* 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);
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);
void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0)
{
vec3_t ipos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint)};
int cz, fz;
GetZRangeAtXYZ(ipos.X, ipos.Y, ipos.Z, pSector, &cz, ceilHit, &fz, floorHit, nDist, nMask);
*ceilZ = cz * zinttoworld;
*floorZ = fz * zinttoworld;
}
int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3); int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3);
void ClipMove(vec3_t& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3); void ClipMove(vec3_t& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3);
inline void ClipMove(DVector3& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3) inline void ClipMove(DVector3& pos, sectortype** pSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask, CollisionBase& hit, int tracecount = 3)