mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- Add scaler operators to fixedhorizon
class and eliminate class-specific interpolatedhorizon()
inlines.
This commit is contained in:
parent
74167e1a7c
commit
39ac3b44b0
9 changed files with 23 additions and 21 deletions
|
@ -167,6 +167,18 @@ public:
|
|||
return fixedhoriz(value >> shift);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr fixedhoriz &operator*= (const T other)
|
||||
{
|
||||
value = value * other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr fixedhoriz operator* (const T other) const
|
||||
{
|
||||
return value * other;
|
||||
}
|
||||
};
|
||||
|
||||
inline constexpr fixedhoriz q16horiz(fixed_t v) { return fixedhoriz(v); }
|
||||
|
|
|
@ -43,7 +43,7 @@ struct PlayerHorizon
|
|||
// Commonly used getters.
|
||||
fixedhoriz osum() { return ohoriz + ohorizoff; }
|
||||
fixedhoriz sum() { return horiz + horizoff; }
|
||||
fixedhoriz interpolatedsum(double const smoothratio) { return interpolatedhorizon(osum(), sum(), smoothratio); }
|
||||
fixedhoriz interpolatedsum(double const smoothratio) { return interpolatedvalue(osum(), sum(), smoothratio); }
|
||||
|
||||
// Ticrate playsim adjustment helpers.
|
||||
void resetadjustment() { adjustment = 0; }
|
||||
|
|
|
@ -51,13 +51,3 @@ inline constexpr double __interpvaluef(double oval, double val, double const smo
|
|||
{
|
||||
return oval + MulScaleF(val - oval, smoothratio, scale);
|
||||
}
|
||||
|
||||
inline constexpr fixedhoriz interpolatedhorizon(fixedhoriz oval, fixedhoriz val, double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return q16horiz(oval.asq16() + MulScale((val - oval).asq16(), int(smoothratio), scale));
|
||||
}
|
||||
|
||||
inline constexpr fixedhoriz interpolatedhorizon(fixedhoriz oval, fixedhoriz val, int const smoothratio, int const scale = 16)
|
||||
{
|
||||
return q16horiz(oval.asq16() + MulScale((val - oval).asq16(), smoothratio, scale));
|
||||
}
|
||||
|
|
|
@ -247,12 +247,12 @@ static void fakeProcessInput(PLAYER* pPlayer, InputPacket* pInput)
|
|||
if (nSector2 == nSector)
|
||||
{
|
||||
int z2 = getflorzofslope(nSector2, x2, y2);
|
||||
predict.horizoff = interpolatedhorizon(predict.horizoff, q16horiz((z1 - z2) << 13), 0x4000);
|
||||
predict.horizoff = interpolatedvalue(predict.horizoff, q16horiz((z1 - z2) << 13), 0x4000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
predict.horizoff = interpolatedhorizon(predict.horizoff, q16horiz(0), 0x4000);
|
||||
predict.horizoff = interpolatedvalue(predict.horizoff, q16horiz(0), 0x4000);
|
||||
if (abs(predict.horizoff.asq16()) < 4)
|
||||
predict.horizoff = q16horiz(0);
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@ void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype
|
|||
else
|
||||
{
|
||||
cA = interpolatedvalue(predictOld.angle + predictOld.look_ang, predict.angle + predict.look_ang, gInterpolate * (1. / MaxSmoothRatio));
|
||||
cH = interpolatedhorizon(predictOld.horiz + predictOld.horizoff, predict.horiz + predict.horizoff, gInterpolate);
|
||||
cH = interpolatedvalue(predictOld.horiz + predictOld.horizoff, predict.horiz + predict.horizoff, gInterpolate);
|
||||
rotscrnang = interpolatedvalue(predictOld.rotscrnang, predict.rotscrnang, gInterpolate * (1. / MaxSmoothRatio));
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype
|
|||
else
|
||||
{
|
||||
cA = gView->angle.interpolatedsum(gInterpolate * (1. / MaxSmoothRatio));
|
||||
cH = gView->horizon.interpolatedsum(gInterpolate);
|
||||
cH = gView->horizon.interpolatedsum(gInterpolate * (1. / MaxSmoothRatio));
|
||||
rotscrnang = gView->angle.interpolatedrotscrn(gInterpolate * (1. / MaxSmoothRatio));
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
}
|
||||
|
||||
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate * (1. / MaxSmoothRatio));
|
||||
fixedhoriz deliriumPitchI = interpolatedhorizon(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), gInterpolate);
|
||||
fixedhoriz deliriumPitchI = interpolatedvalue(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), gInterpolate * (1. / MaxSmoothRatio));
|
||||
auto bakCstat = gView->actor->spr.cstat;
|
||||
gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
|
||||
render_drawrooms(gView->actor, vec3_t( cX, cY, cZ ), sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
|
||||
|
|
|
@ -231,7 +231,7 @@ void displayweapon_d(int snum, double smoothratio)
|
|||
}
|
||||
|
||||
plravel = getavel(snum) * (1. / 16.);
|
||||
horiz16th = p->horizon.horizsumfrac(smoothratio);
|
||||
horiz16th = p->horizon.horizsumfrac(smoothratio * (1. / MaxSmoothRatio));
|
||||
look_anghalf = p->angle.look_anghalf(smoothratio * (1. / MaxSmoothRatio));
|
||||
looking_arc = p->angle.looking_arc(smoothratio * (1. / MaxSmoothRatio));
|
||||
hard_landing *= 8.;
|
||||
|
|
|
@ -291,7 +291,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
|
|||
cposz = __interpvalue(omyz, myz, smoothratio);
|
||||
if (SyncInput())
|
||||
{
|
||||
choriz = interpolatedhorizon(omyhoriz + omyhorizoff, myhoriz + myhorizoff, smoothratio);
|
||||
choriz = interpolatedvalue(omyhoriz + omyhorizoff, myhoriz + myhorizoff, smoothratio * (1. / MaxSmoothRatio));
|
||||
cang = interpolatedvalue(omyang, myang, smoothratio * (1. / MaxSmoothRatio));
|
||||
}
|
||||
else
|
||||
|
@ -311,7 +311,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
|
|||
{
|
||||
// Original code for when the values are passed through the sync struct
|
||||
cang = p->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
|
||||
choriz = p->horizon.interpolatedsum(smoothratio);
|
||||
choriz = p->horizon.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -228,7 +228,7 @@ void DrawView(double interpfrac, bool sceneonly)
|
|||
}
|
||||
else
|
||||
{
|
||||
nCamerapan = PlayerList[nLocalPlayer].horizon.interpolatedsum(interpfrac * MaxSmoothRatio);
|
||||
nCamerapan = PlayerList[nLocalPlayer].horizon.interpolatedsum(interpfrac);
|
||||
nCameraang = PlayerList[nLocalPlayer].angle.interpolatedsum(interpfrac);
|
||||
rotscrnang = PlayerList[nLocalPlayer].angle.interpolatedrotscrn(interpfrac);
|
||||
}
|
||||
|
|
|
@ -1389,7 +1389,7 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
|
|||
if (SyncInput() || pp != Player+myconnectindex)
|
||||
{
|
||||
tang = camerapp->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
|
||||
thoriz = camerapp->horizon.interpolatedsum(smoothratio);
|
||||
thoriz = camerapp->horizon.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
|
||||
trotscrnang = camerapp->angle.interpolatedrotscrn(smoothratio * (1. / MaxSmoothRatio));
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue