- zvel wrapping, part 1.

This commit is contained in:
Christoph Oelckers 2022-08-31 23:49:56 +02:00
parent f78cfb590d
commit 3f7b423a4a
18 changed files with 61 additions and 56 deletions

View file

@ -111,6 +111,11 @@ public:
spr.angle = spr.angle.Normalized360();
}
int int_zvel() const
{
return spr. zvel;
}
// Same as above but with inverted y and z axes to match the renderer's coordinate system.
double interpolatedx(double const smoothratio, int const scale = 16)

View file

@ -615,7 +615,7 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
tspr->angle = actor->spr.angle;
tspr->xvel = actor->spr.xvel;
tspr->yvel = actor->spr.yvel;
tspr->zvel = actor->spr.zvel;
tspr->zvel = actor->int_zvel();
tspr->lotag = actor->spr.lotag;
tspr->hitag = actor->spr.hitag;
tspr->extra = actor->spr.extra;

View file

@ -226,7 +226,7 @@ int ssp(DDukeActor* const actor, unsigned int cliptype) //The set sprite functio
return movesprite_ex(actor,
MulScale(actor->spr.xvel, bcos(actor->int_ang()), 14),
MulScale(actor->spr.xvel, bsin(actor->int_ang()), 14), actor->spr.zvel,
MulScale(actor->spr.xvel, bsin(actor->int_ang()), 14), actor->int_zvel(),
cliptype, c) == kHitNone;
}
@ -1259,7 +1259,7 @@ void bounce(DDukeActor* actor)
{
int xvect = MulScale(actor->spr.xvel, bcos(actor->int_ang()), 10);
int yvect = MulScale(actor->spr.xvel, bsin(actor->int_ang()), 10);
int zvect = actor->spr.zvel;
int zvect = actor->int_zvel();
auto sectp = actor->sector();
@ -4192,7 +4192,7 @@ void handle_se21(DDukeActor* actor)
if (sc->extra == 0)
{
lp += actor->spr.zvel;
lp += actor->int_zvel();
if (abs(lp - actor->int_pos().Z) < 1024)
{

View file

@ -1315,7 +1315,7 @@ static bool movefireball(DDukeActor* actor)
ball->spr.xvel = actor->spr.xvel;
ball->spr.yvel = actor->spr.yvel;
ball->spr.zvel = actor->spr.zvel;
ball->spr.zvel = actor->int_zvel();
if (actor->temp_data[0] > 1)
{
if (trail)
@ -1517,7 +1517,7 @@ static void weaponcommon_d(DDukeActor* proj)
else
{
k = proj->spr.xvel;
ll = proj->spr.zvel;
ll = proj->int_zvel();
}
getglobalz(proj);
@ -2476,7 +2476,7 @@ static void flamethrowerflame(DDukeActor *actor)
Collision coll;
movesprite_ex(actor, MulScale(xvel, bcos(actor->int_ang()), 14),
MulScale(xvel, bsin(actor->int_ang()), 14), actor->spr.zvel, CLIPMASK1, coll);
MulScale(xvel, bsin(actor->int_ang()), 14), actor->int_zvel(), CLIPMASK1, coll);
if (!actor->insector())
{
@ -2599,7 +2599,7 @@ static void heavyhbomb(DDukeActor *actor)
movesprite_ex(actor,
MulScale(actor->spr.xvel, bcos(actor->int_ang()), 14),
MulScale(actor->spr.xvel, bsin(actor->int_ang()), 14),
actor->spr.zvel, CLIPMASK0, coll);
actor->int_zvel(), CLIPMASK0, coll);
if (actor->sector()->lotag == 1 && actor->spr.zvel == 0)
{
@ -3671,7 +3671,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
Collision coll;
actor->movflag = movesprite_ex(actor,
MulScale(daxvel, bcos(angdif), 14),
MulScale(daxvel, bsin(angdif), 14), actor->spr.zvel, CLIPMASK0, coll);
MulScale(daxvel, bsin(angdif), 14), actor->int_zvel(), CLIPMASK0, coll);
}
if (a)

View file

@ -1188,7 +1188,7 @@ static void weaponcommon_r(DDukeActor *proj)
else
{
k = proj->spr.xvel;
ll = proj->spr.zvel;
ll = proj->int_zvel();
}
auto oldpos = proj->spr.pos;
@ -2377,7 +2377,7 @@ static void heavyhbomb(DDukeActor *actor)
movesprite_ex(actor,
MulScale(actor->spr.xvel, bcos(actor->int_ang()), 14),
MulScale(actor->spr.xvel, bsin(actor->int_ang()), 14),
actor->spr.zvel, CLIPMASK0, coll);
actor->int_zvel(), CLIPMASK0, coll);
if (actor->sector()->lotag == 1 && actor->spr.zvel == 0)
{
@ -2565,7 +2565,7 @@ static int henstand(DDukeActor *actor)
movesprite_ex(actor,
MulScale(bcos(actor->int_ang()), actor->spr.xvel, 14),
MulScale(bsin(actor->int_ang()), actor->spr.xvel, 14),
actor->spr.zvel, CLIPMASK0, coll);
actor->int_zvel(), CLIPMASK0, coll);
if (coll.type)
{
if (coll.type == kHitWall)
@ -2681,7 +2681,7 @@ void moveactors_r(void)
movesprite_ex(act,
MulScale(act->spr.xvel, bcos(act->int_ang()), 14),
MulScale(act->spr.xvel, bsin(act->int_ang()), 14),
act->spr.zvel,CLIPMASK0, coll);
act->int_zvel(),CLIPMASK0, coll);
switch (sectp->lotag)
{
case 901:
@ -2722,7 +2722,7 @@ void moveactors_r(void)
movesprite_ex(act,
MulScale(act->spr.xvel, bcos(act->int_ang()), 14),
MulScale(act->spr.xvel, bsin(act->int_ang()), 14),
act->spr.zvel,CLIPMASK0, coll);
act->int_zvel(),CLIPMASK0, coll);
if (coll.type > kHitSector)
{
deletesprite(act);
@ -2753,7 +2753,7 @@ void moveactors_r(void)
movesprite_ex(act,
MulScale(act->spr.xvel, bcos(act->int_ang()), 14),
MulScale(act->spr.xvel, bsin(act->int_ang()), 14),
act->spr.zvel,CLIPMASK0, coll);
act->int_zvel(),CLIPMASK0, coll);
if (act->spr.pos.Z >= sectp->floorz - 8)
{
if (sectp->lotag == 1)
@ -2852,7 +2852,7 @@ void moveactors_r(void)
movesprite_ex(act,
MulScale(act->spr.xvel, bcos(act->int_ang()), 14),
MulScale(act->spr.xvel, bsin(act->int_ang()), 14),
act->spr.zvel,CLIPMASK0, coll);
act->int_zvel(),CLIPMASK0, coll);
act->spr.xvel--;
}
break;
@ -3744,7 +3744,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
Collision coll;
actor->movflag = movesprite_ex(actor,
MulScale(daxvel, bcos(angdif), 14),
MulScale(daxvel, bsin(angdif), 14), actor->spr.zvel, CLIPMASK0, coll);
MulScale(daxvel, bsin(angdif), 14), actor->int_zvel(), CLIPMASK0, coll);
}
if (a)

View file

@ -1246,7 +1246,7 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case ACTOR_ZVEL:
if (bSet) act->spr.zvel = lValue;
else SetGameVarID(lVar2, act->spr.zvel, sActor, sPlayer);
else SetGameVarID(lVar2, act->int_zvel(), sActor, sPlayer);
break;
case ACTOR_LOTAG:
if (bSet) act->spr.lotag = lValue;
@ -1969,11 +1969,11 @@ int ParseState::parse(void)
break;
case concmd_strafeleft:
insptr++;
movesprite_ex(g_ac, -bsin(g_ac->int_ang(), -10), bcos(g_ac->int_ang(), -10), g_ac->spr.zvel, CLIPMASK0, coll);
movesprite_ex(g_ac, -bsin(g_ac->int_ang(), -10), bcos(g_ac->int_ang(), -10), g_ac->int_zvel(), CLIPMASK0, coll);
break;
case concmd_straferight:
insptr++;
movesprite_ex(g_ac, bsin(g_ac->int_ang(), -10), -bcos(g_ac->int_ang(), -10), g_ac->spr.zvel, CLIPMASK0, coll);
movesprite_ex(g_ac, bsin(g_ac->int_ang(), -10), -bcos(g_ac->int_ang(), -10), g_ac->int_zvel(), CLIPMASK0, coll);
break;
case concmd_larrybird:
insptr++;

View file

@ -2473,7 +2473,7 @@ void onMotorcycleHit(int snum, DDukeActor* victim)
{
Collision coll;
int ang = int(p->TiltStatus * 20 + p->angle.ang.Buildang());
movesprite_ex(victim, bcos(ang, -8), bsin(ang, -8), victim->spr.zvel, CLIPMASK0, coll);
movesprite_ex(victim, bcos(ang, -8), bsin(ang, -8), victim->int_zvel(), CLIPMASK0, coll);
}
}
else
@ -2533,7 +2533,7 @@ void onBoatHit(int snum, DDukeActor* victim)
{
Collision coll;
int ang = int(p->TiltStatus * 20 + p->angle.ang.Buildang());
movesprite_ex(victim, bcos(ang, -9), bsin(ang, -9), victim->spr.zvel, CLIPMASK0, coll);
movesprite_ex(victim, bcos(ang, -9), bsin(ang, -9), victim->int_zvel(), CLIPMASK0, coll);
}
}
else

View file

@ -119,7 +119,7 @@ void AIFishLimb::Tick(RunListEvent* ev)
}
else
{
auto coll = movesprite(pActor, pActor->spr.xvel << 8, pActor->spr.yvel << 8, pActor->spr.zvel, 2560, -2560, CLIPMASK1);
auto coll = movesprite(pActor, pActor->spr.xvel << 8, pActor->spr.yvel << 8, pActor->int_zvel(), 2560, -2560, CLIPMASK1);
if (coll.type != kHitNone)
{
pActor->spr.xvel = 0;
@ -198,12 +198,12 @@ void IdleFish(DExhumedActor* pActor, int edx)
if (!edx)
{
if (RandomBit()) {
pActor->spr.zvel = -pActor->spr.zvel;
pActor->spr.zvel = -pActor->int_zvel();
}
}
else if (edx < 0)
{
pActor->spr.zvel = -pActor->spr.zvel;
pActor->spr.zvel = -pActor->int_zvel();
}
}

View file

@ -85,7 +85,7 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
else
{
pActor->nTurn = 0;
pActor->spr.zvel = pPlayerActor->spr.zvel;
pActor->spr.zvel = pPlayerActor->int_zvel();
}
pActor->x = bcos(nAngle, -4) * pActor->nTurn;
@ -277,10 +277,10 @@ void AIGrenade::Tick(RunListEvent* ev)
return;
}
int zVel = pActor->spr.zvel;
int zVel = pActor->int_zvel();
Gravity(pActor);
auto nMov = movesprite(pActor, pActor->x, pActor->y, pActor->spr.zvel, pActor->spr.clipdist >> 1, pActor->spr.clipdist >> 1, CLIPMASK1);
auto nMov = movesprite(pActor, pActor->x, pActor->y, pActor->int_zvel(), pActor->spr.clipdist >> 1, pActor->spr.clipdist >> 1, CLIPMASK1);
if (!nMov.type && !nMov.exbits)
return;

View file

@ -420,8 +420,8 @@ void DoRegenerates()
pActor->spr.yrepeat = (uint8_t)pActor->spr.xvel;
pActor->spr.xrepeat = (uint8_t)pActor->spr.xvel;
pActor->spr.pal = (uint8_t)pActor->spr.yvel;
pActor->spr.yvel = pActor->spr.zvel; // setting to 0
pActor->spr.xvel = pActor->spr.zvel; // setting to 0
pActor->spr.yvel = pActor->int_zvel(); // setting to 0
pActor->spr.xvel = pActor->int_zvel(); // setting to 0
if (pActor->spr.statnum == kStatExplodeTrigger) {
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;

View file

@ -73,7 +73,7 @@ void AILavaDudeLimb::Tick(RunListEvent* ev)
pActor->spr.shade += 3;
auto coll = movesprite(pActor, pActor->spr.xvel << 12, pActor->spr.yvel << 12, pActor->spr.zvel, 2560, -2560, CLIPMASK1);
auto coll = movesprite(pActor, pActor->spr.xvel << 12, pActor->spr.yvel << 12, pActor->int_zvel(), 2560, -2560, CLIPMASK1);
if (coll.type || pActor->spr.shade > 100)
{

View file

@ -612,7 +612,7 @@ void Gravity(DExhumedActor* pActor)
Collision MoveCreature(DExhumedActor* pActor)
{
return movesprite(pActor, pActor->spr.xvel << 8, pActor->spr.yvel << 8, pActor->spr.zvel, 15360, -5120, CLIPMASK0);
return movesprite(pActor, pActor->spr.xvel << 8, pActor->spr.yvel << 8, pActor->int_zvel(), 15360, -5120, CLIPMASK0);
}
Collision MoveCreatureWithCaution(DExhumedActor* pActor)
@ -1150,7 +1150,7 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int ebx, int
}
nAngle = (nAngDelta + pActor->int_ang()) & kAngleMask;
int nAngDeltaD = AngleDelta(pActor->spr.zvel, var_18, 24);
int nAngDeltaD = AngleDelta(pActor->int_zvel(), var_18, 24);
pActor->spr.zvel = (pActor->spr.zvel + nAngDeltaD) & kAngleMask;
}
@ -1352,7 +1352,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
auto pSector = pActor->sector();
pActor->spr.pal = pSector->ceilingpal;
auto nVal = movesprite(pActor, pActor->spr.xvel << 10, pActor->spr.yvel << 10, pActor->spr.zvel, 2560, -2560, CLIPMASK1);
auto nVal = movesprite(pActor, pActor->spr.xvel << 10, pActor->spr.yvel << 10, pActor->int_zvel(), 2560, -2560, CLIPMASK1);
if (pActor->spr.pos.Z >= pSector->floorz)
{
@ -1381,7 +1381,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
{
pActor->spr.xvel >>= 1;
pActor->spr.yvel >>= 1;
pActor->spr.zvel = -pActor->spr.zvel;
pActor->spr.zvel = -pActor->int_zvel();
return;
}
else if (nVal.type == kHitSprite)

View file

@ -1436,7 +1436,7 @@ void AISpark::Tick(RunListEvent* ev)
pActor->spr.zvel += 128;
auto nMov = movesprite(pActor, pActor->spr.xvel << 12, pActor->spr.yvel << 12, pActor->spr.zvel, 2560, -2560, CLIPMASK1);
auto nMov = movesprite(pActor, pActor->spr.xvel << 12, pActor->spr.yvel << 12, pActor->int_zvel(), 2560, -2560, CLIPMASK1);
if (!nMov.type && !nMov.exbits) {
return;
}
@ -1888,7 +1888,7 @@ void AIObject::Tick(RunListEvent* ev)
FUNCOBJECT_GOTO:
if (nStat != kStatExplodeTarget)
{
auto nMov = movesprite(pActor, pActor->spr.xvel << 6, pActor->spr.yvel << 6, pActor->spr.zvel, 0, 0, CLIPMASK0);
auto nMov = movesprite(pActor, pActor->spr.xvel << 6, pActor->spr.yvel << 6, pActor->int_zvel(), 0, 0, CLIPMASK0);
if (pActor->spr.statnum == kStatExplodeTrigger) {
pActor->spr.pal = 1;

View file

@ -830,7 +830,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}
// pPlayerActor->spr.zvel is modified within Gravity()
int zVel = pPlayerActor->spr.zvel;
int zVel = pPlayerActor->int_zvel();
Gravity(pPlayerActor);
@ -865,7 +865,7 @@ void AIPlayer::Tick(RunListEvent* ev)
// TODO
// nSectFlag & kSectUnderwater;
zVel = pPlayerActor->spr.zvel;
zVel = pPlayerActor->int_zvel();
Collision nMove;
nMove.setNone();

View file

@ -325,12 +325,12 @@ Collision QueenAngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int val
nAngle = (nAngDelta + pActor->int_ang()) & kAngleMask;
pActor->spr.zvel = (AngleDelta(pActor->spr.zvel, var_14, 24) + pActor->spr.zvel) & kAngleMask;
pActor->spr.zvel = (AngleDelta(pActor->int_zvel(), var_14, 24) + pActor->spr.zvel) & kAngleMask;
}
pActor->set_int_ang(nAngle);
int da = pActor->spr.zvel;
int da = pActor->int_zvel();
int x = abs(bcos(da));
int v26 = x * ((val1 * bcos(nAngle)) >> 14);

View file

@ -139,7 +139,7 @@ void AISoul::Tick(RunListEvent* ev)
int nVel = bcos(pActor->spr.extra, -7);
auto coll = movesprite(pActor, bcos(pActor->int_ang()) * nVel, bsin(pActor->int_ang()) * nVel, pActor->spr.zvel, 5120, 0, CLIPMASK0);
auto coll = movesprite(pActor, bcos(pActor->int_ang()) * nVel, bsin(pActor->int_ang()) * nVel, pActor->int_zvel(), 5120, 0, CLIPMASK0);
if (coll.exbits & 0x10000)
{
DExhumedActor* pSet = pActor->pTarget;

View file

@ -275,7 +275,7 @@ void AISpider::Tick(RunListEvent* ev)
spp->spr.yvel = 0;
}
auto nMov = movesprite(spp, spp->spr.xvel << nVel, spp->spr.yvel << nVel, spp->spr.zvel, 1280, -1280, CLIPMASK0);
auto nMov = movesprite(spp, spp->spr.xvel << nVel, spp->spr.yvel << nVel, spp->int_zvel(), 1280, -1280, CLIPMASK0);
if (nMov.type == kHitNone && nMov.exbits == 0)
return;

View file

@ -9291,7 +9291,7 @@ int SpawnExtraMicroMini(DSWActor* actor)
actorNew->spr.cstat = actor->spr.cstat;
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() + RandomRange(64) - 32));
actorNew->spr.zvel = actor->spr.zvel;
actorNew->spr.zvel = actor->int_zvel();
actorNew->spr.zvel += RandomRange(Z(16)) - Z(8);
UpdateChange(actorNew);
@ -9319,7 +9319,7 @@ int DoMicro(DSWActor* actor)
actorNew->spr.xrepeat = 20;
actorNew->spr.yrepeat = 20;
actorNew->opos = actor->opos;
actorNew->spr.zvel = actor->spr.zvel;
actorNew->spr.zvel = actor->int_zvel();
actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER);
actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -10883,7 +10883,7 @@ bool MissileSetPos(DSWActor* actor, ANIMATOR* DoWeapon, int dist)
// backup values
auto oldc = actor->user.change;
oldvel = actor->spr.xvel;
oldzvel = actor->spr.zvel;
oldzvel = actor->int_zvel();
// make missile move in smaller increments
actor->spr.xvel = short((dist * 6) / MISSILEMOVETICS);
@ -10917,7 +10917,7 @@ bool TestMissileSetPos(DSWActor* actor, ANIMATOR* DoWeapon, int dist, int zvel)
// backup values
auto oldc = actor->user.change;
oldvel = actor->spr.xvel;
oldzvel = actor->spr.zvel;
oldzvel = actor->int_zvel();
// make missile move in smaller increments
actor->spr.xvel = short((dist * 6) / MISSILEMOVETICS);
@ -12406,7 +12406,7 @@ int InitStar(PLAYER* pp)
if (WeaponAutoAim(pp->actor, actorNew, 32, false) != -1)
{
zvel = actorNew->spr.zvel;
zvel = actorNew->int_zvel();
}
UpdateChangeXY(actorNew);
@ -12919,7 +12919,7 @@ int InitRail(PLAYER* pp)
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - 4));
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -12987,7 +12987,7 @@ int InitZillaRail(DSWActor* actor)
actorNew->spr.angle -= DAngle::fromBuild(4);
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -13096,7 +13096,7 @@ int InitRocket(PLAYER* pp)
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - 5));
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -13200,7 +13200,7 @@ int InitBunnyRocket(PLAYER* pp)
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - 5));
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -13292,7 +13292,7 @@ int InitNuke(PLAYER* pp)
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - 5));
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -13368,7 +13368,7 @@ int InitEnemyNuke(DSWActor* actor)
actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - 5));
}
else
zvel = actorNew->spr.zvel; // Let autoaiming set zvel now
zvel = actorNew->int_zvel(); // Let autoaiming set zvel now
UpdateChangeXY(actorNew);
actorNew->user.set_int_change_z(zvel);
@ -15910,7 +15910,7 @@ int InitGrenade(PLAYER* pp)
actor->spr.clipdist = oclipdist;
zvel = actorNew->spr.zvel;
zvel = actorNew->int_zvel();
if (WeaponAutoAim(pp->actor, actorNew, 32, false) >= 0)
{
auto_aim = true;
@ -16233,7 +16233,7 @@ int InitEnemyFireball(DSWActor* actor)
actorNew->user.set_int_change_z(actorNew->spr.zvel = (GORO_FIREBALL_VELOCITY * (targ_z - actorNew->int_pos().Z)) / dist);
// back up first one
lastvel = actorNew->spr.zvel;
lastvel = actorNew->int_zvel();
}
else
{