- floatified walldist parameter of getzrange

This commit is contained in:
Christoph Oelckers 2022-09-29 19:52:01 +02:00
parent 3c3b602989
commit 22ccf33569
15 changed files with 44 additions and 37 deletions

View file

@ -112,6 +112,11 @@ class F2DDrawer;
void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz, CollisionBase& florhit, int32_t walldist, uint32_t cliptype);
inline
void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz, CollisionBase& florhit, double walldist, uint32_t cliptype)
{
getzrange(pos, sect, ceilz, ceilhit, florz, florhit, int(walldist * worldtoint), cliptype);
}
struct HitInfoBase;

View file

@ -4551,7 +4551,7 @@ static Collision MoveThing(DBloodActor* actor)
double ceilZ, floorZ;
Collision ceilColl, floorColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->int_clipdist(), CLIPMASK0);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0);
GetActorExtents(actor, &top, &bottom);
if ((actor->spr.flags & 2) && bottom < floorZ)
@ -4570,7 +4570,7 @@ static Collision MoveThing(DBloodActor* actor)
}
}
}
if (CheckLink(actor)) GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->int_clipdist(), CLIPMASK0);
if (CheckLink(actor)) GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0);
GetActorExtents(actor, &top, &bottom);
if (bottom >= floorZ)
@ -4706,7 +4706,7 @@ void MoveDude(DBloodActor* actor)
GetActorExtents(actor, &top, &bottom);
double bz = (bottom - actor->spr.pos.Z) / 4;
double tz = (actor->spr.pos.Z - top) / 4;
int wd = actor->int_clipdist();
double wdf = actor->fClipdist();
auto pSector = actor->sector();
int nAiStateType = (actor->xspr.aiState) ? actor->xspr.aiState->stateType : -1;
@ -4725,7 +4725,7 @@ void MoveDude(DBloodActor* actor)
auto bakCstat = actor->spr.cstat;
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
// Note: vel is Q16.16, ClipMove wants Q28.4, which passes it on to clipmove which wants Q14.18. Anyone confused yet...?
ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), wd, tz, bz, CLIPMASK0, actor->hit.hit);
ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), int(wdf * worldtoint), tz, bz, CLIPMASK0, actor->hit.hit);
if (pSector == nullptr)
{
pSector = actor->sector();
@ -4736,7 +4736,7 @@ void MoveDude(DBloodActor* actor)
if (pSector->type >= kSectorPath && pSector->type <= kSectorRotate)
{
auto pSector2 = pSector;
if (pushmove(actor, &pSector2, wd, tz, bz, CLIPMASK0) == -1)
if (pushmove(actor, &pSector2, int(wdf * worldtoint), tz, bz, CLIPMASK0) == -1)
actDamageSprite(actor, actor, kDamageFall, 1000 << 4);
if (pSector2 != nullptr)
pSector = pSector2;
@ -4834,12 +4834,12 @@ void MoveDude(DBloodActor* actor)
DCoreActor* pLowerLink = pSector->lowerLink;
if (pUpperLink && (pUpperLink->spr.type == kMarkerUpWater || pUpperLink->spr.type == kMarkerUpGoo)) bDepth = 1;
if (pLowerLink && (pLowerLink->spr.type == kMarkerLowWater || pLowerLink->spr.type == kMarkerLowGoo)) bDepth = 1;
if (pPlayer) wd += 16;
if (pPlayer) wdf += 1;
if (actor->vel.Z) actor->spr.pos.Z += actor->vel.Z;
double ceilZ, floorZ;
Collision ceilColl, floorColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, wd, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, wdf, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetActorExtents(actor, &top, &bottom);
if (actor->spr.flags & 2)
@ -4888,7 +4888,7 @@ void MoveDude(DBloodActor* actor)
int nLink = CheckLink(actor);
if (nLink)
{
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, wd, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, wdf, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
if (pPlayer)
playerCorrectInertia(pPlayer, oldpos);
switch (nLink)
@ -5052,7 +5052,7 @@ void MoveDude(DBloodActor* actor)
{
double floorZ2 = floorZ;
auto floorColl2 = floorColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->int_clipdist(), CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
if (bottom <= floorZ && actor->spr.pos.Z - floorZ2 < bz)
{
floorZ = floorZ2;
@ -5280,7 +5280,7 @@ int MoveMissile(DBloodActor* actor)
}
double ceilZ, floorZ;
Collision ceilColl, floorColl;
GetZRangeAtXYZ(ppos, pSector2, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->int_clipdist(), CLIPMASK0);
GetZRangeAtXYZ(ppos, pSector2, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist(), CLIPMASK0);
GetActorExtents(actor, &top, &bottom);
top += vel.Z;
bottom += vel.Z;

View file

@ -439,7 +439,7 @@ void fxBloodBits(DBloodActor* actor, sectortype*) // 14
if (!actor) return;
double ceilZ, floorZ;
Collision floorColl, ceilColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->native_clipdist(), CLIPMASK0);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0);
double top, bottom;
GetActorExtents(actor, &top, &bottom);
actor->spr.pos.Z += floorZ - bottom;
@ -497,7 +497,7 @@ void fxBouncingSleeve(DBloodActor* actor, sectortype*) // 16
double ceilZ, floorZ;
Collision floorColl, ceilColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->native_clipdist(), CLIPMASK0);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0);
double top, bottom;
GetActorExtents(actor, &top, &bottom);
actor->spr.pos.Z += floorZ - bottom;
@ -629,7 +629,7 @@ void fxPodBloodSplat(DBloodActor* actor, sectortype*) // 19
double ceilZ, floorZ;
Collision floorColl, ceilColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->native_clipdist(), CLIPMASK0);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, actor->fClipdist() * 0.25, CLIPMASK0);
double top, bottom;
GetActorExtents(actor, &top, &bottom);
actor->spr.pos.Z += floorZ - bottom;

View file

@ -413,7 +413,7 @@ int VectorScan(DBloodActor* actor, double nOffset, double nZOffset, const DVecto
//
//---------------------------------------------------------------------------
void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* floorZ, Collision* floorColl, int nDist, unsigned int nMask, unsigned int nClipParallax)
void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* floorZ, Collision* floorColl, double nDist, unsigned int nMask, unsigned int nClipParallax)
{
assert(actor != nullptr);
Collision scratch;
@ -464,7 +464,7 @@ void GetZRange(DBloodActor* actor, double* ceilZ, Collision* ceilColl, double* f
//
//---------------------------------------------------------------------------
void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilColl, double* 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, double nDist, unsigned int nMask, unsigned int nClipParallax)
{
Collision scratch;
double nTemp1;

View file

@ -36,8 +36,8 @@ bool CheckProximity(DBloodActor* pSprite, const DVector3& pos, sectortype* pSect
int HitScan(DBloodActor* pSprite, double z, const DVector3& pos, unsigned int nMask, double range = 0);
int VectorScan(DBloodActor* pSprite, double nOffset, double nZOffset, const DVector3& vel, double nRange, int ac);
void GetZRange(DBloodActor* pSprite, 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);
void GetZRange(DBloodActor* pSprite, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, double nDist, unsigned int nMask, unsigned int nClipParallax = 0);
void GetZRangeAtXYZ(const DVector3& pos, sectortype* pSector, double* ceilZ, Collision* ceilHit, double* floorZ, Collision* floorHit, double nDist, unsigned int nMask, unsigned int nClipParallax = 0);
[[deprecated]] // take care of this together with the engines clipmove.
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);

View file

@ -1645,7 +1645,7 @@ void debrisMove(int listIndex)
moveHit.setNone();
double floorDist = (bottom - actor->spr.pos.Z) * 0.25;
double ceilDist = (actor->spr.pos.Z - top) * 0.25;
int clipDist = actor->int_clipdist();
double clipDistf = actor->fClipdist();
int mass = actor->spriteMass.mass;
bool uwater = false;
@ -1661,7 +1661,7 @@ void debrisMove(int listIndex)
auto oldcstat = actor->spr.cstat;
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), clipDist, ceilDist, floorDist, CLIPMASK0, moveHit);
ClipMove(actor->spr.pos, &pSector, actor->vel.XY(), int(clipDistf * worldtoint), ceilDist, floorDist, CLIPMASK0, moveHit);
actor->hit.hit = moveHit;
actor->spr.cstat = oldcstat;
@ -1674,7 +1674,7 @@ void debrisMove(int listIndex)
if (pSector->type >= kSectorPath && pSector->type <= kSectorRotate)
{
auto pSector2 = pSector;
if (pushmove(actor, &pSector2, clipDist, ceilDist, floorDist, CLIPMASK0) != -1)
if (pushmove(actor, &pSector2, int(clipDistf * worldtoint), ceilDist, floorDist, CLIPMASK0) != -1)
pSector = pSector2;
}
@ -1705,7 +1705,7 @@ void debrisMove(int listIndex)
double ceilZ, floorZ;
Collision ceilColl, floorColl;
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDist, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDistf, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetActorExtents(actor, &top, &bottom);
if ((actor->xspr.physAttr & kPhysDebrisSwim) && uwater)
@ -1738,7 +1738,7 @@ void debrisMove(int listIndex)
int i;
if ((i = CheckLink(actor)) != 0)
{
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDist, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetZRange(actor, &ceilZ, &ceilColl, &floorZ, &floorColl, clipDistf, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
if (!(actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
{
switch (i)

View file

@ -4777,14 +4777,14 @@ void handle_se31(DDukeActor* actor, bool choosedir)
void getglobalz(DDukeActor* actor)
{
int zr;
double zr;
Collision hz, lz;
if( actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_STANDABLE || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PROJECTILE)
{
if(actor->spr.statnum == STAT_PROJECTILE)
zr = 4;
else zr = 127;
zr = 0.25;
else zr = 7.9375;
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.
@ -4850,7 +4850,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->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 127, CLIPMASK0);
getzrange(actor->spr.pos.plusZ(-1), actor->sector(), &actor->ceilingz, coll, &actor->floorz, coll, 7.9375, CLIPMASK0);
}
else
{

View file

@ -2778,7 +2778,7 @@ void processinput_d(int snum)
p->spritebridge = 0;
shrunk = (pact->spr.yrepeat < 32);
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 163, CLIPMASK0);
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0);
p->truefz = getflorzofslopeptr(psectp, p->pos);
p->truecz = getceilzofslopeptr(psectp, p->pos);

View file

@ -3397,12 +3397,12 @@ void processinput_r(int snum)
double tempfz;
if (pact->native_clipdist() == 64)
{
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 163L, CLIPMASK0);
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0);
tempfz = getflorzofslopeptr(psectp, p->pos);
}
else
{
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 4L, CLIPMASK0);
getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 0.25, CLIPMASK0);
tempfz = getflorzofslopeptr(psectp, p->pos);
}

View file

@ -291,7 +291,7 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli
double sprceiling, sprfloor;
auto pos = pActor->spr.pos.plusZ(-1);
getzrange(pos, pActor->sector(), &sprceiling, hiHit, &sprfloor, loHit, 128, CLIPMASK0);
getzrange(pos, pActor->sector(), &sprceiling, hiHit, &sprfloor, loHit, 8., CLIPMASK0);
double mySprfloor = sprfloor;

View file

@ -1677,7 +1677,7 @@ inline bool FAF_ConnectArea(sectortype* sect)
void FAFhitscan(const DVector3& start, sectortype* sect, const DVector3& vect, HitInfo& hit, int32_t clipmask);
bool FAFcansee(const DVector3& start, sectortype* sects, const DVector3& end, sectortype* secte);
void FAFgetzrange(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit, int32_t clipdist, int32_t clipmask);
void FAFgetzrange(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit, double clipdist, int32_t clipmask);
void FAFgetzrangepoint(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit);
@ -1716,7 +1716,6 @@ enum
TICSPERMOVEMENT = synctics,
ACTOR_GRAVITY = 8,
// subtract value from clipdist on getzrange calls
GETZRANGE_CLIP_ADJ = 8,
STAT_DAMAGE_LIST_SIZE = 20,
COLOR_PAIN = 128, // Light red range
@ -1726,6 +1725,9 @@ enum
};
constexpr double GETZRANGE_CLIP_ADJ = 0.5;
extern int *lastpacket2clock;

View file

@ -1945,7 +1945,7 @@ void DoPlayerZrange(PLAYER* pp)
auto bakcstat = actor->spr.cstat;
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK);
FAFgetzrange(pp->pos.plusZ(8), pp->cursector, &pp->hiz, &ceilhit, &pp->loz, &florhit, ((int)actor->int_clipdist()) - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER);
FAFgetzrange(pp->pos.plusZ(8), pp->cursector, &pp->hiz, &ceilhit, &pp->loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER);
actor->spr.cstat = bakcstat;
Collision ceilColl(ceilhit);

View file

@ -498,7 +498,7 @@ void WaterAdjust(const Collision& florhit, double* loz)
//
//---------------------------------------------------------------------------
void FAFgetzrange(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
void FAFgetzrange(const DVector3& pos, sectortype* sect, double* hiz, Collision* ceilhit, double* loz, Collision* florhit, double clipdist, int32_t clipmask)
{
double foo1;
Collision foo2;

View file

@ -4488,7 +4488,7 @@ void DoActorZrange(DSWActor* actor)
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK);
DVector3 pos = actor->spr.pos.plusZ(-ActorSizeZ(actor) * 0.5);
FAFgetzrange(pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->int_clipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_ACTOR);
FAFgetzrange(pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_ACTOR);
actor->spr.cstat |= save_cstat;
actor->user.lo_sectp = actor->user.hi_sectp = nullptr;
@ -6391,7 +6391,7 @@ Collision move_sprite(DSWActor* actor, const DVector3& change, double ceildist,
auto pos = actor->spr.pos.plusZ(-zH - maptoworld);
FAFgetzrange(pos, actor->sector(),
&globhiz, &globhihit, &globloz, &globlohit,
actor->int_clipdist() - GETZRANGE_CLIP_ADJ, cliptype);
actor->fClipdist() - GETZRANGE_CLIP_ADJ, cliptype);
actor->spr.cstat = tempstat;

View file

@ -11050,7 +11050,7 @@ int DoFindGround(DSWActor* actor)
auto save_cstat = actor->spr.cstat;
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
FAFgetzrange(actor->spr.pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->int_clipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER);
FAFgetzrange(actor->spr.pos, actor->sector(), &actor->user.hiz, &ceilhit, &actor->user.loz, &florhit, actor->fClipdist() - GETZRANGE_CLIP_ADJ, CLIPMASK_PLAYER);
actor->spr.cstat = save_cstat;
switch (florhit.type)