- don't use DAngle for calculating bobbing amplitudes.

It makes more sense here to have a dedicated function since this is not really angular math.
This commit is contained in:
Christoph Oelckers 2022-09-04 00:04:01 +02:00
parent 86c557653b
commit 92379863f1
9 changed files with 23 additions and 18 deletions

View file

@ -603,4 +603,9 @@ inline void alignflorslope(sectortype* sect, const DVector3& pos)
sect->setfloorslope(getslopeval(sect, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, sect->int_floorz()));
}
inline double BobVal(int val)
{
return g_sinbam((unsigned)val << 21);
}
#include "updatesector.h"

View file

@ -1679,7 +1679,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin();
p->pyoff = BobVal(p->pycount);
if (p->jetpack_on && S_CheckActorSoundPlaying(pact, DUKE_SCREAM))
{
@ -1764,7 +1764,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz_, in
i = 34;
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin() * 2;
p->pyoff = BobVal(p->pycount) * 2;
}
else i = 12;
@ -1942,7 +1942,7 @@ static void underwater(int snum, ESyncBits actions, int fz_, int cz_)
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin();
p->pyoff = BobVal(p->pycount);
if (!S_CheckActorSoundPlaying(pact, DUKE_UNDERWATER))
S_PlayActorSound(DUKE_UNDERWATER, pact);
@ -3059,10 +3059,10 @@ HORIZONLY:
{
p->pycount += 52;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin() * pact->int_xvel();
p->pyoff = BobVal(p->pycount) * pact->int_xvel();
const double factor = 64. / 1596; // What is 1596?
p->pyoff = abs(pact->int_xvel() * DAngle::fromBuild(p->pycount).Sin()) * factor;
p->pyoff = abs(pact->int_xvel() * BobVal(p->pycount)) * factor;
}
}
else if (psectlotag != 2 && psectlotag != 1)

View file

@ -2080,7 +2080,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz_, in
i = 34;
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin() * 2;
p->pyoff = BobVal(p->pycount) * 2;
}
else i = 12;
@ -2300,7 +2300,7 @@ static void underwater(int snum, ESyncBits actions, int fz_, int cz_)
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin();
p->pyoff = BobVal(p->pycount);
if (!S_CheckActorSoundPlaying(pact, DUKE_UNDERWATER))
S_PlayActorSound(DUKE_UNDERWATER, pact);
@ -3605,7 +3605,7 @@ void processinput_r(int snum)
{
p->pycount += 32;
p->pycount &= 2047;
p->pyoff = DAngle::fromBuild(p->pycount).Sin() * (p->SeaSick? 32 : 1);
p->pyoff = BobVal(p->pycount) * (p->SeaSick? 32 : 1);
}
if (psectlotag == ST_2_UNDERWATER)
@ -3889,7 +3889,7 @@ HORIZONLY:
p->pycount += 52;
p->pycount &= 2047;
const double factor = 64. / 1596; // What is 1596?
p->pyoff = abs(pact->int_xvel() * DAngle::fromBuild(p->pycount).Sin()) * factor;
p->pyoff = abs(pact->int_xvel() * BobVal(p->pycount)) * factor;
}
}
else if (psectlotag != ST_2_UNDERWATER && psectlotag != 1 && (!isRRRA() || !p->sea_sick_stat))

View file

@ -421,7 +421,7 @@ int DoActorDebris(DSWActor* actor)
if (actor->sector()->hasU() && FixedToInt(actor->sector()->depth_fixed) > 10) // JBF: added null check
{
actor->user.WaitTics = (actor->user.WaitTics + (ACTORMOVETICS << 3)) & 1023;
actor->spr.pos.Z = actor->user.loz - 2 * DAngle::fromBuild(actor->user.WaitTics).Sin();
actor->spr.pos.Z = actor->user.loz - 2 * BobVal(actor->user.WaitTics);
}
}
else
@ -443,7 +443,7 @@ int DoFireFly(DSWActor* actor)
actor->user.WaitTics = (actor->user.WaitTics + (ACTORMOVETICS << 1)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + 32 * DAngle::fromBuild(actor->user.WaitTics).Sin();
actor->spr.pos.Z = actor->user.pos.Z + 32 * BobVal(actor->user.WaitTics);
return 0;
}

View file

@ -658,7 +658,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
actor->user.pos.Z = max(actor->user.pos.Z, hiz + actor->user.ceiling_dist);
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS<<3)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + COOLG_BOB_AMT * DAngle::fromBuild(actor->user.Counter).Sin();
actor->spr.pos.Z = actor->user.pos.Z + COOLG_BOB_AMT * BobVal(actor->user.Counter);
bound = actor->user.hiz + actor->user.ceiling_dist + COOLG_BOB_AMT;
if (actor->spr.pos.Z < bound)

View file

@ -494,7 +494,7 @@ int DoEelMatchPlayerZ(DSWActor* actor)
actor->user.pos.Z = max(actor->user.pos.Z, hiz + actor->user.ceiling_dist);
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + EEL_BOB_AMT * DAngle::fromBuild(actor->user.Counter).Sin();
actor->spr.pos.Z = actor->user.pos.Z + EEL_BOB_AMT * BobVal(actor->user.Counter);
bound = actor->user.hiz + actor->user.ceiling_dist + EEL_BOB_AMT;
if (actor->spr.pos.Z < bound)

View file

@ -390,7 +390,7 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
actor->user.pos.Z = max(actor->user.pos.Z, hiz + actor->user.ceiling_dist);
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + HORNET_BOB_AMT * DAngle::fromBuild(actor->user.Counter).Sin();
actor->spr.pos.Z = actor->user.pos.Z + HORNET_BOB_AMT * BobVal(actor->user.Counter);
bound = actor->user.hiz + actor->user.ceiling_dist + HORNET_BOB_AMT;
if (actor->spr.pos.Z < bound)

View file

@ -1607,7 +1607,7 @@ void DoPlayerBob(PLAYER* pp)
pp->bcnt &= 2047;
// move pp->q16horiz up and down from 100 using sintable
pp->bob_z = amt * DAngle::fromBuild(pp->bcnt).Sin();
pp->bob_z = amt * BobVal(pp->bcnt);
}
void DoPlayerBeginRecoil(PLAYER* pp, short pix_amt)
@ -1643,7 +1643,7 @@ void DoPlayerRecoil(PLAYER* pp)
void DoPlayerSpriteBob(PLAYER* pp, double player_height, double bobamt, short bob_speed)
{
pp->bob_ndx = (pp->bob_ndx + (synctics << bob_speed)) & 2047;
pp->pbob_amt = bobamt * DAngle::fromBuild(pp->bob_ndx).Sin();
pp->pbob_amt = bobamt * BobVal(pp->bob_ndx);
pp->actor->spr.pos.Z = pp->pos.Z + player_height + pp->pbob_amt;
}

View file

@ -404,7 +404,7 @@ int DoSkullBob(DSWActor* actor)
const int SKULL_BOB_AMT = 16;
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + SKULL_BOB_AMT * 1.5 * DAngle::fromBuild(actor->user.Counter).Sin();
actor->spr.pos.Z = actor->user.pos.Z + SKULL_BOB_AMT * 1.5 * BobVal(actor->user.Counter);
return 0;
}
@ -771,7 +771,7 @@ int DoBettyBob(DSWActor* actor)
const int BETTY_BOB_AMT = 16;
actor->user.Counter = (actor->user.Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
actor->spr.pos.Z = actor->user.pos.Z + BETTY_BOB_AMT * 1.5 * DAngle::fromBuild(actor->user.Counter).Sin();
actor->spr.pos.Z = actor->user.pos.Z + BETTY_BOB_AMT * 1.5 * BobVal(actor->user.Counter);
return 0;
}