- Remove all remaining q16horiz() calls, also correcting a long-standing Duke bug.

This commit is contained in:
Mitchell Richters 2022-09-28 13:32:15 +10:00 committed by Christoph Oelckers
parent 8697e5f054
commit ca8f8d6d36
7 changed files with 5 additions and 20 deletions

View file

@ -67,7 +67,6 @@ class fixedhoriz
constexpr fixedhoriz(fixed_t v) : value(v) {}
friend constexpr fixedhoriz q16horiz(fixed_t v);
friend constexpr fixedhoriz buildhoriz(int v);
friend constexpr fixedhoriz tanhoriz(double v);
friend fixedhoriz pitchhoriz(double v);
@ -178,7 +177,6 @@ public:
}
};
inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); }
inline constexpr fixedhoriz tanhoriz(double v) { return fixedhoriz(FloatToFixed<23>(v)); }
inline fixedhoriz pitchhoriz(double v) { return fixedhoriz(fixed_t(clamp<double>(IntToFixed(128) * tan(v * (pi::pi() / 180.)), -INT32_MAX, INT32_MAX))); }

View file

@ -392,18 +392,6 @@ Average: 4.375;
static constexpr double HORIZOFFSPEED = (1. / 8.) * 35.;
enum
{
// Values used by Duke/SW, where this function originated from.
DEFSINSHIFT = 5,
DEFVIEWPITCH = 160,
// Values used by Blood since it calculates differently to Duke/SW.
BLOODSINSHIFT = 8,
SINSHIFTDELTA = BLOODSINSHIFT - DEFSINSHIFT,
BLOODVIEWPITCH = (0x4000 >> SINSHIFTDELTA) - (DEFVIEWPITCH << (SINSHIFTDELTA - 1)), // 1408.
};
void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing)
{
if (cl_slopetilting && cursectnum != nullptr)
@ -429,7 +417,7 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co
// accordingly
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4))
{
horizoff += q16horiz(fixed_t(scaleAdjust * ((j - k) * 256 * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
horizoff += maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5)));
}
}
}

View file

@ -66,7 +66,7 @@ struct PlayerHorizon
if (!SyncInput() && !backup)
{
target = value.Sgn() ? value : q16horiz(1);
target = value.Sgn() ? value : pitchhoriz(minAngle.Degrees());
}
else
{

View file

@ -241,7 +241,7 @@ static void fakeProcessInput(PLAYER* pPlayer, InputPacket* pInput)
if (nSector2 == nSector)
{
int z2 = getflorzofslope(nSector2, x2, y2);
predict.horizoff = interpolatedvalue(predict.horizoff, q16horiz((z1 - z2) << 13), 0x4000);
predict.horizoff = interpolatedvalue(predict.horizoff, maphoriz((z1 - z2) * 8), 0x4000);
}
}
else

View file

@ -735,7 +735,7 @@ void viewDrawScreen(bool sceneonly)
}
if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, basepal, interpfrac);
fixedhoriz deliriumPitchI = interpolatedvalue(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), interpfrac);
fixedhoriz deliriumPitchI = interpolatedvalue(maphoriz(deliriumPitchO), maphoriz(deliriumPitch), interpfrac);
auto bakCstat = pPlayer->actor->spr.cstat;
pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
render_drawrooms(pPlayer->actor, cPos, pSector, cA, cH + deliriumPitchI, rotscrnang, interpfrac);

View file

@ -151,7 +151,7 @@ void resetplayerstats(int snum)
p->footprintpal = 0;
p->footprintshade = 0;
p->jumping_toggle = 0;
p->horizon.ohoriz = p->horizon.horiz = q16horiz(40);
p->horizon.ohoriz = p->horizon.horiz = pitchhoriz(17.354);
p->horizon.ohorizoff = p->horizon.horizoff = pitchhoriz(nullAngle.Degrees());
p->bobcounter = 0;
p->on_ground = 0;

View file

@ -65,7 +65,6 @@ extern short NormalVisibility;
void JAnalyzeSprites(tspritetype* tspr);
void JS_CameraParms(PLAYER* pp, const DVector3& tpos);
void JS_DrawMirrors(PLAYER* pp,int tx,int ty,int tz,fixed_t tpq16ang,fixed_t tpq16horiz);
void JS_InitMirrors(void);
void JS_ProcessEchoSpot(void);
void JS_SpriteSetup(void);