- floatified Blood's velFloor and velCeil

This commit is contained in:
Christoph Oelckers 2022-09-04 00:28:30 +02:00
parent 38bb103cdd
commit 057d2a565a
6 changed files with 39 additions and 40 deletions

View file

@ -310,8 +310,8 @@ struct sectortype
TObjPtr<DCoreActor*> lowerLink;
double baseFloor;
double baseCeil;
int _velFloor;
int _velCeil;
double velFloor;
double velCeil;
uint8_t slopewallofs; // This was originally the repurposed filler byte.
};
struct // Exhumed

View file

@ -553,8 +553,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("lowerlink", c.lowerLink, def->lowerLink)
("basefloor", c.baseFloor, def->baseFloor)
("baseCeil", c.baseCeil, def->baseCeil)
("velfloor", c._velFloor, def->_velFloor)
("velCeil", c._velCeil, def->_velCeil)
("velfloor", c.velFloor, def->velFloor)
("velCeil", c.velCeil, def->velCeil)
("slopwwallofs", c.slopewallofs, def->slopewallofs);
if (arc.isWriting())

View file

@ -4608,13 +4608,12 @@ static Collision MoveThing(DBloodActor* actor)
actor->hit.florhit = floorColl;
actor->add_int_z(floorZ - bottom);
int v20 = actor->int_vel().Z - actor->sector()->_velFloor;
if (v20 > 0)
double veldiff = actor->vel.Z - actor->sector()->velFloor;
if (veldiff > 0)
{
actor->spr.flags |= 4;
auto vec4 = actFloorBounceVector(actor, FixedToFloat(v20), actor->sector(), FixedToFloat(pThingInfo->elastic));
auto vec4 = actFloorBounceVector(actor, veldiff, actor->sector(), FixedToFloat(pThingInfo->elastic));
actor->vel.XY() = vec4.XY();
int vax = FloatToFixed(vec4.W);
@ -4622,7 +4621,7 @@ static Collision MoveThing(DBloodActor* actor)
if (nDamage > 0) actDamageSprite(actor, actor, kDamageFall, nDamage);
actor->set_int_bvel_z(FloatToFixed(vec4.Z));
if (actor->sector()->_velFloor == 0 && abs(actor->int_vel().Z) < 0x10000)
if (actor->sector()->velFloor == 0 && abs(actor->vel.Z) < 1)
{
actor->vel.Z = 0;
actor->spr.flags &= ~4;
@ -5097,10 +5096,10 @@ void MoveDude(DBloodActor* actor)
{
actor->hit.florhit = floorColl;
actor->add_int_z(floorZ - bottom);
int v30 = actor->int_vel().Z - actor->sector()->_velFloor;
if (v30 > 0)
double veldiff = actor->vel.Z - actor->sector()->velFloor;
if (veldiff > 0)
{
auto vec4 = actFloorBounceVector(actor, FixedToFloat(v30), actor->sector(), 0);
auto vec4 = actFloorBounceVector(actor, veldiff, actor->sector(), 0);
actor->vel.XY() = vec4.XY();
int vax = FloatToFixed(vec4.W);
@ -5118,9 +5117,9 @@ void MoveDude(DBloodActor* actor)
if (nDamage > 0)
actDamageSprite(actor, actor, kDamageFall, nDamage);
actor->set_int_bvel_z(FloatToFixed(vec4.Z));
if (abs(actor->int_vel().Z) < 0x10000)
if (abs(actor->vel.Z) < 1)
{
actor->set_int_bvel_z(actor->sector()->_velFloor);
actor->vel.Z = actor->sector()->velFloor;
actor->spr.flags &= ~4;
}
else
@ -5682,7 +5681,7 @@ static void actCheckThings()
actAirDrag(actor, 128);
if (((actor->GetIndex() >> 8) & 15) == (gFrameCount & 15) && (actor->spr.flags & 2)) actor->spr.flags |= 4;
if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->_velFloor || actor->sector()->_velCeil)
if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil)
{
Collision hit = MoveThing(actor);
if (hit.type)
@ -6110,7 +6109,7 @@ static void actCheckDudes()
if (pXSector && pXSector->Underwater) actAirDrag(actor, 5376);
else actAirDrag(actor, 128);
if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->_velFloor || actor->sector()->_velCeil)
if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil)
MoveDude(actor);
}
}

View file

@ -517,15 +517,15 @@ void fxBouncingSleeve(DBloodActor* actor, sectortype*) // 16
int top, bottom; GetActorExtents(actor, &top, &bottom);
actor->add_int_z(floorZ - bottom);
int zv = actor->int_vel().Z - actor->sector()->_velFloor;
double veldiff = actor->vel.Z - actor->sector()->velFloor;
if (actor->vel.Z == 0) sleeveStopBouncing(actor);
else if (zv > 0)
else if (veldiff > 0)
{
auto vec4 = actFloorBounceVector(actor, FixedToFloat(zv), actor->sector(), FixedToFloat(0x9000));
auto vec4 = actFloorBounceVector(actor, veldiff, actor->sector(), FixedToFloat(0x9000));
actor->vel = vec4.XYZ();
if (actor->sector()->_velFloor == 0 && abs(actor->int_vel().Z) < 0x20000) {
if (actor->sector()->velFloor == 0 && abs(actor->vel.Z) < 0x2) {
sleeveStopBouncing(actor);
return;
}

View file

@ -1343,11 +1343,11 @@ void nnExtProcessSuperSprites()
}
if (debrisactor->xspr.physAttr & kPhysGravity) debrisactor->xspr.physAttr |= kPhysFalling;
if ((debrisactor->xspr.physAttr & kPhysFalling) || debrisactor->vel.X != 0 || debrisactor->vel.Y != 0 || debrisactor->vel.Z != 0 || debrisactor->sector()->_velFloor || debrisactor->sector()->_velCeil)
if ((debrisactor->xspr.physAttr & kPhysFalling) || debrisactor->vel.X != 0 || debrisactor->vel.Y != 0 || debrisactor->vel.Z != 0 || debrisactor->sector()->velFloor || debrisactor->sector()->velCeil)
debrisMove(i);
if (debrisactor->vel.X != 0 || debrisactor->int_vel().Y)
debrisactor->xspr.goalAng = getangle(debrisactor->int_vel().X, debrisactor->int_vel().Y) & 2047;
debrisactor->xspr.goalAng = getangle(debrisactor->vel) & 2047;
int ang = debrisactor->int_ang() & 2047;
if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble);
@ -1780,18 +1780,18 @@ void debrisMove(int listIndex)
if (floorZ <= bottom) {
actor->hit.florhit = floorColl;
int v30 = actor->int_vel().Z - actor->sector()->_velFloor;
double veldiff = actor->vel.Z - actor->sector()->velFloor;
if (v30 > 0)
if (veldiff > 0)
{
actor->xspr.physAttr |= kPhysFalling;
auto vec4 = actFloorBounceVector(actor, FixedToFloat(v30), actor->sector(), FixedToFloat(tmpFraction));
auto vec4 = actFloorBounceVector(actor, veldiff, actor->sector(), FixedToFloat(tmpFraction));
actor->vel = vec4.XYZ();
v30 = actor->int_vel().Z;
veldiff = actor->vel.Z;
if (abs(actor->int_vel().Z) < 0x10000)
if (abs(actor->vel.Z) < 1)
{
actor->set_int_bvel_z(actor->sector()->_velFloor);
actor->vel.Z = actor->sector()->velFloor;
actor->xspr.physAttr &= ~kPhysFalling;
}

View file

@ -1017,29 +1017,29 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (dfz != 0)
{
int oldZ = pSector->int_floorz();
double old_Z = pSector->floorz;
pSector->set_int_floorz((pXSector->offFloorZ + MulScale(dfz, GetWaveValue(a3, a4), 16)));
pSector->baseFloor = pSector->floorz;
pSector->_velFloor += (pSector->int_floorz() - oldZ) << 8;
pSector->velFloor += (pSector->floorz - old_Z);
BloodSectIterator it(pSector);
while (auto actor = it.Next())
{
if (actor->spr.statnum == kStatMarker || actor->spr.statnum == kStatPathMarker)
continue;
int top, bottom;
double top, bottom;
GetActorExtents(actor, &top, &bottom);
if (actor->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD)
{
viewBackupSpriteLoc(actor);
actor->add_int_z(pSector->int_floorz() - oldZ);
actor->spr.pos.Z += pSector->floorz - old_Z;
}
else if (actor->spr.flags & 2)
actor->spr.flags |= 4;
else if (oldZ <= bottom && !(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK))
else if (old_Z <= bottom && !(actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK))
{
viewBackupSpriteLoc(actor);
actor->add_int_z(pSector->int_floorz() - oldZ);
actor->spr.pos.Z += pSector->floorz - old_Z;
}
}
@ -1054,7 +1054,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (ac && (ac->spr.cstat & CSTAT_SPRITE_MOVE_FORWARD))
{
viewBackupSpriteLoc(ac);
ac->add_int_z(pSector->int_floorz() - oldZ);
ac->spr.pos.Z += pSector->floorz - old_Z;
}
}
}
@ -1065,10 +1065,10 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (dcz != 0)
{
int oldZ = pSector->int_ceilingz();
double old_Z = pSector->ceilingz;
pSector->set_int_ceilingz((pXSector->offCeilZ + MulScale(dcz, GetWaveValue(a3, a4), 16)));
pSector->baseCeil = pSector->ceilingz;
pSector->_velCeil += (pSector->int_ceilingz() - oldZ) << 8;
pSector->velCeil += pSector->ceilingz - old_Z;
BloodSectIterator it(pSector);
while (auto actor = it.Next())
@ -1078,7 +1078,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (actor->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE)
{
viewBackupSpriteLoc(actor);
actor->add_int_z(pSector->int_ceilingz() - oldZ);
actor->spr.pos.Z += pSector->ceilingz - old_Z;
}
}
@ -1093,7 +1093,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
if (ac && (ac->spr.cstat & CSTAT_SPRITE_MOVE_REVERSE))
{
viewBackupSpriteLoc(ac);
ac->add_int_z(pSector->int_ceilingz() - oldZ);
ac->spr.pos.Z += pSector->ceilingz - old_Z;
}
}
}
@ -2214,7 +2214,7 @@ void trProcessBusy(void)
{
for (auto& sect : sector)
{
sect._velCeil = sect._velFloor = 0;
sect.velCeil = sect.velFloor = 0;
}
for (int i = gBusy.Size()-1; i >= 0; i--)
{