- Eliminate __interpvaluef() and clean up Q16.16 smoothratio values where it made sense to do so.

This commit is contained in:
Mitchell Richters 2022-09-07 15:34:55 +10:00 committed by Christoph Oelckers
parent 2c8cb8f052
commit f02035b15a
23 changed files with 131 additions and 140 deletions

View file

@ -46,8 +46,3 @@ inline constexpr int32_t __interpvalue(int32_t oval, int32_t val, int const smoo
{
return oval + MulScale(val - oval, smoothratio, scale);
}
inline constexpr double __interpvaluef(double oval, double val, double const smoothratio, int const scale = 16)
{
return oval + MulScaleF(val - oval, smoothratio, scale);
}

View file

@ -93,7 +93,7 @@ void CGameMenuItemQAV::Draw(void)
duration = data->duration;
}
auto currentDuration = data->duration - duration;
auto smoothratio = !cl_interpolate || cl_capfps? MaxSmoothRatio : I_GetTimeFrac(data->ticrate) * MaxSmoothRatio;
auto interpfrac = !cl_interpolate || cl_capfps? 1. : I_GetTimeFrac(data->ticrate);
data->Play(currentDuration - data->ticksPerFrame, currentDuration, -1, NULL);
@ -104,13 +104,13 @@ void CGameMenuItemQAV::Draw(void)
int backX = data->x;
for (int i = 0; i < nCount; i++)
{
data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, smoothratio);
data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, interpfrac);
data->x += 320;
}
data->x = backX;
}
else
data->Draw(currentDuration, 10, 0, 0, false, smoothratio);
data->Draw(currentDuration, 10, 0, 0, false, interpfrac);
}
}

View file

@ -7351,9 +7351,9 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5)
{
QAV* pQAV = pQavScene->qavResrc;
int v4;
double smoothratio;
double interpfrac;
qavProcessTimer(pPlayer, pQAV, &v4, &smoothratio);
qavProcessTimer(pPlayer, pQAV, &v4, &interpfrac);
int flags = 2; int nInv = powerupCheck(pPlayer, kPwUpShadowCloak);
if (nInv >= 120 * 8 || (nInv != 0 && (PlayClock & 32)))
@ -7365,7 +7365,7 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5)
if (!(actor->spr.flags & kModernTypeFlag1))
{
pQAV->x = int(a3); pQAV->y = int(a4);
pQAV->Draw(a3, a4, v4, flags, a2, a5, true, smoothratio);
pQAV->Draw(a3, a4, v4, flags, a2, a5, true, interpfrac);
// draw fullscreen (currently 4:3 only)
}
@ -7373,7 +7373,7 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5)
{
// What an awful hack. This throws proper ordering out of the window, but there is no way to reproduce this better with strict layering of elements.
// From the above commit it seems to be incomplete anyway...
pQAV->Draw(v4, flags, a2, a5, false, smoothratio);
pQAV->Draw(v4, flags, a2, a5, false, interpfrac);
}
}
}

View file

@ -164,7 +164,7 @@ void DrawFrame(double x, double y, double z, double a, double alpha, int picnum,
//
//---------------------------------------------------------------------------
void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio)
void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac)
{
assert(ticksPerFrame > 0);
@ -176,7 +176,7 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
auto const oFrame = clamp((nFrame == 0 && interpdata && interpdata->loopable ? nFrames : nFrame) - 1, 0, nFrames - 1);
FRAMEINFO* const prevFrame = &frames[oFrame];
bool const interpolate = interpdata && cl_hudinterpolation && cl_bloodqavinterp && (nFrames > 1) && (nFrame != oFrame) && (smoothratio != MaxSmoothRatio);
bool const interpolate = interpdata && cl_hudinterpolation && cl_bloodqavinterp && (nFrames > 1) && (nFrame != oFrame) && (interpfrac != 1.);
for (int i = 0; i < 8; i++)
{
@ -185,8 +185,8 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
TILE_FRAME* const thisTile = &thisFrame->tiles[i];
TILE_FRAME* const prevTile = interpolate && interpdata->CanInterpFrameTile(nFrame, i) ? interpdata->PrevTileFinder(thisFrame, prevFrame, i) : nullptr;
double tileX = x;
double tileY = y;
double tileX;
double tileY;
double tileZ;
double tileA;
double tileAlpha;
@ -195,26 +195,26 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
if (prevTile)
{
tileX += __interpvaluef(prevTile->x, thisTile->x, smoothratio);
tileY += __interpvaluef(prevTile->y, thisTile->y, smoothratio);
tileZ = __interpvaluef(prevTile->z, thisTile->z, smoothratio);
tileA = interpolatedvalue(DAngle::fromBuild(prevTile->angle), DAngle::fromBuild(thisTile->angle), smoothratio * (1. / MaxSmoothRatio)).Buildfang();
tileShade = __interpvalue(prevTile->shade, thisTile->shade, smoothratio) + shade;
auto prevAlpha = ((stat | prevTile->stat) & RS_TRANS1) ? glblend[0].def[!!((stat | prevTile->stat) & RS_TRANS2)].alpha : 1.;
auto thisAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.;
tileAlpha = __interpvaluef(prevAlpha, thisAlpha, smoothratio);
tileX = interpolatedvalue<double>(prevTile->x, thisTile->x, interpfrac);
tileY = interpolatedvalue<double>(prevTile->y, thisTile->y, interpfrac);
tileZ = interpolatedvalue<double>(prevTile->z, thisTile->z, interpfrac);
tileA = interpolatedvalue(DAngle::fromBuild(prevTile->angle), DAngle::fromBuild(thisTile->angle), interpfrac).Buildfang();
tileShade = interpolatedvalue(prevTile->shade, thisTile->shade, interpfrac) + shade;
auto prevAlpha = ((stat | prevTile->stat) & RS_TRANS1) ? glblend[0].def[!!((stat | prevTile->stat) & RS_TRANS2)].alpha : 1.f;
auto thisAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.f;
tileAlpha = interpolatedvalue(prevAlpha, thisAlpha, interpfrac);
}
else
{
tileX += thisTile->x;
tileY += thisTile->y;
tileX = thisTile->x;
tileY = thisTile->y;
tileZ = thisTile->z;
tileA = thisTile->angle;
tileShade = thisTile->shade + shade;
tileAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.;
tileAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.f;
}
DrawFrame(tileX, tileY, tileZ, tileA, tileAlpha, thisTile->picnum, tileStat, tileShade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview);
DrawFrame(tileX + x, tileY + y, tileZ, tileA, tileAlpha, thisTile->picnum, tileStat, tileShade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview);
}
}
}
@ -326,7 +326,7 @@ void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick)
//
//---------------------------------------------------------------------------
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* smoothratio, bool const fixedduration, bool const ignoreWeaponTimer)
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* interpfrac, bool const fixedduration, bool const ignoreWeaponTimer)
{
// Process if not paused.
if (!paused)
@ -338,24 +338,24 @@ void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, doub
{
// Check if we're playing an idle QAV as per the ticker's weapon timer.
*duration = fixedduration ? pQAV->duration - 1 : I_GetBuildTime() % pQAV->duration;
*smoothratio = MaxSmoothRatio;
*interpfrac = 1.;
}
else if (pPlayer->qavTimer == 0)
{
// If qavTimer is 0, play the last frame uninterpolated. Sometimes the timer can be just ahead of weaponTimer.
*duration = pQAV->duration - 1;
*smoothratio = MaxSmoothRatio;
*interpfrac = 1.;
}
else
{
// Apply normal values.
*duration = pQAV->duration - pPlayer->qavTimer;
*smoothratio = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac(pQAV->ticrate) * MaxSmoothRatio;
*interpfrac = !cl_interpolate || cl_capfps ? 1. : I_GetTimeFrac(pQAV->ticrate);
}
}
else
{
*smoothratio = MaxSmoothRatio;
*interpfrac = 1.;
}
}

View file

@ -229,15 +229,15 @@ struct QAV
int y; // 18
uint16_t res_id;
FRAMEINFO frames[1]; // 24
void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = MaxSmoothRatio);
void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = MaxSmoothRatio) { Draw(x, y, ticks, stat, shade, palnum, to3dview, smoothratio); }
void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac = 1.);
void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac = 1.) { Draw(x, y, ticks, stat, shade, palnum, to3dview, interpfrac); }
void Play(int, int, int, PLAYER*);
void Precache(int palette = 0);
};
QAV* getQAV(int res_id);
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick);
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* smoothratio, bool const fixedduration = false, bool const ignoreWeaponTimer = false);
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* interpfrac, bool const fixedduration = false, bool const ignoreWeaponTimer = false);
inline bool qavIsOriginal(const int res_id)
{

View file

@ -497,11 +497,11 @@ void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype
cX = __interpvalue(predictOld.x, predict.x, gInterpolate);
cY = __interpvalue(predictOld.y, predict.y, gInterpolate);
cZ = __interpvalue(predictOld.viewz, predict.viewz, gInterpolate);
zDelta = __interpvaluef(predictOld.weaponZ, predict.weaponZ, gInterpolate);
zDelta = interpolatedvalue(predictOld.weaponZ, predict.weaponZ, gInterpolate * (1. / MaxSmoothRatio));
bobWidth = __interpvalue(predictOld.bobWidth, predict.bobWidth, gInterpolate);
bobHeight = __interpvalue(predictOld.bobHeight, predict.bobHeight, gInterpolate);
shakeX = __interpvaluef(predictOld.shakeBobX, predict.shakeBobX, gInterpolate);
shakeY = __interpvaluef(predictOld.shakeBobY, predict.shakeBobY, gInterpolate);
shakeX = interpolatedvalue(predictOld.shakeBobX, predict.shakeBobX, gInterpolate * (1. / MaxSmoothRatio));
shakeY = interpolatedvalue(predictOld.shakeBobY, predict.shakeBobY, gInterpolate * (1. / MaxSmoothRatio));
if (!SyncInput())
{
@ -523,11 +523,11 @@ void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype
cX = __interpvalue(pView->x, gView->actor->int_pos().X, gInterpolate);
cY = __interpvalue(pView->y, gView->actor->int_pos().Y, gInterpolate);
cZ = __interpvalue(pView->viewz, gView->zView, gInterpolate);
zDelta = __interpvaluef(pView->weaponZ, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
zDelta = interpolatedvalue<double>(pView->weaponZ, gView->zWeapon - gView->zView - (12 << 8), gInterpolate * (1. / MaxSmoothRatio));
bobWidth = __interpvalue(pView->bobWidth, gView->bobWidth, gInterpolate);
bobHeight = __interpvalue(pView->bobHeight, gView->bobHeight, gInterpolate);
shakeX = __interpvaluef(pView->shakeBobX, gView->swayWidth, gInterpolate);
shakeY = __interpvaluef(pView->shakeBobY, gView->swayHeight, gInterpolate);
shakeX = interpolatedvalue<double>(pView->shakeBobX, gView->swayWidth, gInterpolate * (1. / MaxSmoothRatio));
shakeY = interpolatedvalue<double>(pView->shakeBobY, gView->swayHeight, gInterpolate * (1. / MaxSmoothRatio));
if (!SyncInput())
{

View file

@ -318,9 +318,9 @@ void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum
return;
auto pQAV = getQAV(pPlayer->weaponQav);
int duration;
double smoothratio;
double interpfrac;
qavProcessTimer(pPlayer, pQAV, &duration, &smoothratio, pPlayer->weaponState == -1, pPlayer->curWeapon == kWeapShotgun && pPlayer->weaponState == 7);
qavProcessTimer(pPlayer, pQAV, &duration, &interpfrac, pPlayer->weaponState == -1, pPlayer->curWeapon == kWeapShotgun && pPlayer->weaponState == 7);
pQAV->x = int(xpos);
pQAV->y = int(ypos);
@ -331,7 +331,7 @@ void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum
shade = -128;
flags |= 1;
}
pQAV->Draw(xpos, ypos, duration, flags, shade, palnum, true, smoothratio);
pQAV->Draw(xpos, ypos, duration, flags, shade, palnum, true, interpfrac);
}
//---------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@ EXTERN_CVAR(Bool, wt_commentary)
BEGIN_DUKE_NS
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothratio)
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, double interpfrac)
{
DVector2 viewVec(x * inttoworld, y * inttoworld);
int k, p;
@ -167,13 +167,11 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
{
t->pos.X -= MulScaleF(MaxSmoothRatio - smoothratio, pp->pos.X - pp->opos.X, 16);
t->pos.Y -= MulScaleF(MaxSmoothRatio - smoothratio, pp->pos.Y - pp->opos.Y, 16);
t->pos.Z = __interpvaluef(pp->opos.Z, pp->pos.Z, smoothratio) + gs.playerheight;
t->pos = interpolatedvalue(pp->opos, pp->pos, interpfrac).plusZ(gs.playerheight);
}
else if (!actorflag(h, SFLAG_NOINTERPOLATE))
{
t->pos = h->interpolatedpos(smoothratio * (1. / MaxSmoothRatio));
t->pos = h->interpolatedpos(interpfrac);
}
auto sectp = h->sector();
@ -307,10 +305,10 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
#if 0 // multiplayer only
if (screenpeek == myconnectindex && numplayers >= 2)
{
t->x = __interpvalue(omyx, myx, smoothratio);
t->y = __interpvalue(omyy, myy, smoothratio);
t->z = __interpvalue(omyz, myz, smoothratio) + gs_playerheight;
t->ang = interpolatedvalue(omyang, myang, smoothratio * (1. / MaxSmoothRatio)).asbuild();
t->x = __interpvalue(omyx, myx, interpfrac * MaxSmoothRatio);
t->y = __interpvalue(omyy, myy, interpfrac * MaxSmoothRatio);
t->z = __interpvalue(omyz, myz, interpfrac * MaxSmoothRatio) + gs_playerheight;
t->ang = interpolatedvalue(omyang, myang, interpfrac).asbuild();
t->sector = mycursectnum;
}
#endif

View file

@ -37,7 +37,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothratio)
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, double interpfrac)
{
DVector2 viewVec(x * inttoworld, y * inttoworld);
int k, p;
@ -147,15 +147,13 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
auto pp = &ps[h->PlayerIndex()];
if (h->spr.statnum != STAT_ACTOR && h->spr.picnum == APLAYER && pp->newOwner == nullptr && h->GetOwner())
{
t->pos.X -= MulScaleF(MaxSmoothRatio - smoothratio, pp->pos.X - pp->opos.X, 16);
t->pos.Y -= MulScaleF(MaxSmoothRatio - smoothratio, pp->pos.Y - pp->opos.Y, 16);
t->pos.Z = __interpvaluef(pp->opos.Z, pp->pos.Z, smoothratio) + gs.playerheight;
t->pos = interpolatedvalue(pp->opos, pp->pos, interpfrac).plusZ(gs.playerheight);
h->spr.xrepeat = 24;
h->spr.yrepeat = 17;
}
else if (!actorflag(h, SFLAG_NOINTERPOLATE))
{
t->pos = h->interpolatedpos(smoothratio * (1. / MaxSmoothRatio));
t->pos = h->interpolatedpos(interpfrac);
}
auto sectp = h->sector();
@ -349,10 +347,10 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
#if 0 // multiplayer only
if (screenpeek == myconnectindex && numplayers >= 2)
{
t->x = __interpvalue(omyx, myx, smoothratio);
t->y = __interpvalue(omyy, myy, smoothratio);
t->z = __interpvalue(omyz, myz, smoothratio) + gs.playerheight;
t->ang = interpolatedvalue(omyang, myang, smoothratio * (1. / MaxSmoothRatio)).asbuild();
t->x = __interpvalue(omyx, myx, interpfrac * MaxSmoothRatio);
t->y = __interpvalue(omyy, myy, interpfrac * MaxSmoothRatio);
t->z = __interpvalue(omyz, myz, interpfrac * MaxSmoothRatio) + gs.playerheight;
t->ang = interpolatedvalue(omyang, myang, interpfrac).asbuild();
t->sector = mycursectnum;
}
#endif

View file

@ -92,14 +92,14 @@ void checkweapons_d(player_struct* p);
void checkweapons_r(player_struct* p);
void processinput_d(int snum);
void processinput_r(int snum);
void displayweapon_d(int snum, double smoothratio);
void displayweapon_r(int snum, double smoothratio);
void displaymasks_d(int snum, int p, double smoothratio);
void displaymasks_r(int snum, int p, double smoothratio);
void displayweapon_d(int snum, double interpfrac);
void displayweapon_r(int snum, double interpfrac);
void displaymasks_d(int snum, int p, double interpfrac);
void displaymasks_r(int snum, int p, double interpfrac);
void think_d();
void think_r();
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, double interpfrac);
void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, double interpfrac);
Dispatcher fi;

View file

@ -105,10 +105,10 @@ struct Dispatcher
int (*doincrements)(player_struct* p);
void (*checkweapons)(player_struct* p);
void (*processinput)(int snum);
void (*displayweapon)(int snum, double smoothratio);
void (*displaymasks)(int snum, int p, double smoothratio);
void (*displayweapon)(int snum, double interpfrac);
void (*displaymasks)(int snum, int p, double interpfrac);
void (*animatesprites)(tspriteArray& tsprites, int x, int y, int a, int smoothratio);
void (*animatesprites)(tspriteArray& tsprites, int x, int y, int a, double interpfrac);
};

View file

@ -224,7 +224,7 @@ void OffBoat(player_struct *pl);
void cameratext(DDukeActor* i);
void dobonus(int bonusonly, const CompletionFunc& completion);
void drawweapon(double smoothratio);
void drawweapon(double interpfrac);
void drawoverlays(double smoothratio);
void drawbackground(void);
void displayrooms(int32_t playerNum, double smoothratio, bool sceneonly);

View file

@ -206,16 +206,16 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4])
//
//---------------------------------------------------------------------------
void drawweapon(double smoothratio)
void drawweapon(double interpfrac)
{
auto pp = &ps[screenpeek];
if (!isRR() && pp->newOwner != nullptr)
cameratext(pp->newOwner);
else
{
fi.displayweapon(screenpeek, smoothratio);
fi.displayweapon(screenpeek, interpfrac);
if (pp->over_shoulder_on == 0)
fi.displaymasks(screenpeek, pp->GetActor()->spr.pal == 1 || !pp->insector() ? 1 : pp->cursector->floorpal, smoothratio);
fi.displaymasks(screenpeek, pp->GetActor()->spr.pal == 1 || !pp->insector() ? 1 : pp->cursector->floorpal, interpfrac);
}
}

View file

@ -61,11 +61,11 @@ inline static void hud_drawpal(double x, double y, int tilenum, int shade, int o
//
//---------------------------------------------------------------------------
static void displayloogie(player_struct* p, double const smoothratio)
static void displayloogie(player_struct* p, double const interpfrac)
{
if (p->loogcnt == 0) return;
const double loogi = __interpvaluef(p->oloogcnt, p->loogcnt, smoothratio);
const double loogi = interpolatedvalue<double>(p->oloogcnt, p->loogcnt, interpfrac);
const double y = loogi * 4.;
for (int i = 0; i < p->numloogs; i++)
@ -84,9 +84,9 @@ static void displayloogie(player_struct* p, double const smoothratio)
//
//---------------------------------------------------------------------------
static bool animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal, double const smoothratio)
static bool animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal, double const interpfrac)
{
const double fisti = min(__interpvaluef(p->ofist_incs, p->fist_incs, smoothratio), 32.);
const double fisti = min(interpolatedvalue<double>(p->ofist_incs, p->fist_incs, interpfrac), 32.);
if (fisti <= 0) return false;
hud_drawsprite(
@ -103,12 +103,12 @@ static bool animatefist(int gs, player_struct* p, double look_anghalf, double lo
//
//---------------------------------------------------------------------------
static bool animateknee(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal, double const smoothratio)
static bool animateknee(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal, double const interpfrac)
{
if (p->knee_incs > 11 || p->knee_incs == 0 || p->GetActor()->spr.extra <= 0) return false;
static const int8_t knee_y[] = { 0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8 };
const double kneei = __interpvaluef(knee_y[p->oknee_incs], knee_y[p->knee_incs], smoothratio);
const double kneei = interpolatedvalue<double>(knee_y[p->oknee_incs], knee_y[p->knee_incs], interpfrac);
looking_arc += kneei;
hud_drawpal(105 + plravel - look_anghalf + (kneei * 0.25), looking_arc + 280 - horiz16th, KNEE, gs, 4, pal);
@ -140,7 +140,7 @@ static bool animateknuckles(int gs, player_struct* p, double look_anghalf, doubl
//
//---------------------------------------------------------------------------
void displaymasks_d(int snum, int p, double)
void displaymasks_d(int snum, int p, double interpfrac)
{
if (ps[snum].scuba_on)
{
@ -156,12 +156,12 @@ void displaymasks_d(int snum, int p, double)
//
//---------------------------------------------------------------------------
static bool animatetip(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal, double const smoothratio)
static bool animatetip(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, int pal, double const interpfrac)
{
if (p->tipincs == 0) return false;
static const int8_t tip_y[] = { 0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16 };
const double tipi = __interpvaluef(tip_y[p->otipincs], tip_y[p->tipincs], smoothratio) * 0.5;
const double tipi = interpolatedvalue<double>(tip_y[p->otipincs], tip_y[p->tipincs], interpfrac) * 0.5;
hud_drawpal(170 + plravel - look_anghalf, tipi + looking_arc + 240 - horiz16th, TIP + ((26 - p->tipincs) >> 4), gs, 0, pal);
@ -174,12 +174,12 @@ static bool animatetip(int gs, player_struct* p, double look_anghalf, double loo
//
//---------------------------------------------------------------------------
static bool animateaccess(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, double const smoothratio)
static bool animateaccess(int gs, player_struct* p, double look_anghalf, double looking_arc, double horiz16th, double plravel, double const interpfrac)
{
if (p->access_incs == 0 || p->GetActor()->spr.extra <= 0) return false;
static const int8_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16};
const double accessi = __interpvaluef(access_y[p->oaccess_incs], access_y[p->access_incs], smoothratio);
const double accessi = interpolatedvalue<double>(access_y[p->oaccess_incs], access_y[p->access_incs], interpfrac);
looking_arc += accessi;
const int pal = p->access_spritenum != nullptr ? p->access_spritenum->spr.pal : 0;
@ -198,7 +198,7 @@ static bool animateaccess(int gs, player_struct* p, double look_anghalf, double
//
//---------------------------------------------------------------------------
void displayweapon_d(int snum, double smoothratio)
void displayweapon_d(int snum, double interpfrac)
{
int cw;
int i, j;
@ -215,11 +215,11 @@ void displayweapon_d(int snum, double smoothratio)
if (cl_hudinterpolation)
{
weapon_sway = __interpvaluef(p->oweapon_sway, p->weapon_sway, smoothratio);
kickback_pic = __interpvaluef(p->okickback_pic, p->kickback_pic, smoothratio);
random_club_frame = __interpvaluef(p->orandom_club_frame, p->random_club_frame, smoothratio);
hard_landing = __interpvaluef(p->ohard_landing, p->hard_landing, smoothratio);
gun_pos = 80 - __interpvaluef(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, smoothratio);
weapon_sway = interpolatedvalue<double>(p->oweapon_sway, p->weapon_sway, interpfrac);
kickback_pic = interpolatedvalue<double>(p->okickback_pic, p->kickback_pic, interpfrac);
random_club_frame = interpolatedvalue<double>(p->orandom_club_frame, p->random_club_frame, interpfrac);
hard_landing = interpolatedvalue<double>(p->ohard_landing, p->hard_landing, interpfrac);
gun_pos = 80 - interpolatedvalue<double>(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, interpfrac);
}
else
{
@ -231,9 +231,9 @@ void displayweapon_d(int snum, double smoothratio)
}
plravel = getavel(snum) * (1. / 16.);
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));
horiz16th = p->horizon.horizsumfrac(interpfrac);
look_anghalf = p->angle.look_anghalf(interpfrac);
looking_arc = p->angle.looking_arc(interpfrac);
hard_landing *= 8.;
gun_pos -= fabs(p->GetActor()->spr.xrepeat < 32 ? bsinf(weapon_sway * 4., -9) : bsinf(weapon_sway * 0.5, -10));
@ -252,13 +252,13 @@ void displayweapon_d(int snum, double smoothratio)
auto adjusted_arc = looking_arc - hard_landing;
bool playerVars = p->newOwner != nullptr || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->spr.pal != 1 && p->GetActor()->spr.extra <= 0);
bool playerAnims = animatefist(shade, p, look_anghalf, looking_arc, plravel, pal, smoothratio) || animateknuckles(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) ||
animatetip(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, smoothratio) || animateaccess(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, smoothratio);
bool playerAnims = animatefist(shade, p, look_anghalf, looking_arc, plravel, pal, interpfrac) || animateknuckles(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal) ||
animatetip(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, interpfrac) || animateaccess(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, interpfrac);
if(playerVars || playerAnims)
return;
animateknee(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, smoothratio);
animateknee(shade, p, look_anghalf, adjusted_arc, horiz16th, plravel, pal, interpfrac);
if (isWW2GI())
{
@ -298,7 +298,7 @@ void displayweapon_d(int snum, double smoothratio)
if (p->GetActor()->spr.xrepeat < 40)
{
//shrunken..
animateshrunken(p, weapon_xoffset, looking_arc, look_anghalf, FIST, shade, o, smoothratio);
animateshrunken(p, weapon_xoffset, looking_arc, look_anghalf, FIST, shade, o, interpfrac);
}
else
{
@ -1224,7 +1224,7 @@ void displayweapon_d(int snum, double smoothratio)
}
}
displayloogie(p, smoothratio);
displayloogie(p, interpfrac);
}

View file

@ -65,13 +65,13 @@ inline static void rd3myospal(double x, double y, int tilenum, int shade, int or
//
//---------------------------------------------------------------------------
void displaymasks_r(int snum, int p, double smoothratio)
void displaymasks_r(int snum, int p, double interpfrac)
{
if (ps[snum].scuba_on)
{
//int pin = 0;
// to get the proper clock value with regards to interpolation we have add a smoothratio based offset to the value.
double interpclock = PlayClock + (+TICSPERFRAME/65536.) * smoothratio;
// to get the proper clock value with regards to interpolation we have add a interpfrac based offset to the value.
double interpclock = PlayClock + TICSPERFRAME * interpfrac;
int pin = RS_STRETCH;
hud_drawsprite((320 - (tileWidth(SCUBAMASK) >> 1) - 15), (200 - (tileHeight(SCUBAMASK) >> 1) + bsinf(interpclock, -10)), 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin);
hud_drawsprite((320 - tileWidth(SCUBAMASK + 4)), (200 - tileHeight(SCUBAMASK + 4)), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin);
@ -105,7 +105,7 @@ inline static void ShowBoat(double x, double y, int tilenum, int shade, int orie
//
//---------------------------------------------------------------------------
void displayweapon_r(int snum, double smoothratio)
void displayweapon_r(int snum, double interpfrac)
{
int cw;
int i, j;
@ -120,10 +120,10 @@ void displayweapon_r(int snum, double smoothratio)
if (cl_hudinterpolation)
{
weapon_sway = __interpvaluef(p->oweapon_sway, p->weapon_sway, smoothratio);
hard_landing = __interpvaluef(p->ohard_landing, p->hard_landing, smoothratio);
gun_pos = 80 - __interpvaluef(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, smoothratio);
TiltStatus = !SyncInput() ? p->TiltStatus : __interpvaluef(p->oTiltStatus, p->TiltStatus, smoothratio);
weapon_sway = interpolatedvalue<double>(p->oweapon_sway, p->weapon_sway, interpfrac);
hard_landing = interpolatedvalue<double>(p->ohard_landing, p->hard_landing, interpfrac);
gun_pos = 80 - interpolatedvalue<double>(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, interpfrac);
TiltStatus = !SyncInput() ? p->TiltStatus : interpolatedvalue<double>(p->oTiltStatus, p->TiltStatus, interpfrac);
}
else
{
@ -133,8 +133,8 @@ void displayweapon_r(int snum, double smoothratio)
TiltStatus = p->TiltStatus;
}
look_anghalf = p->angle.look_anghalf(smoothratio * (1. / MaxSmoothRatio));
looking_arc = p->angle.looking_arc(smoothratio * (1. / MaxSmoothRatio));
look_anghalf = p->angle.look_anghalf(interpfrac);
looking_arc = p->angle.looking_arc(interpfrac);
hard_landing *= 8.;
gun_pos -= fabs(p->GetActor()->spr.xrepeat < 8 ? bsinf(weapon_sway * 4., -9) : bsinf(weapon_sway * 0.5, -10));
@ -291,7 +291,7 @@ void displayweapon_r(int snum, double smoothratio)
if (p->GetActor()->spr.xrepeat < 8)
{
animateshrunken(p, weapon_xoffset, looking_arc, look_anghalf, FIST, shade, o, smoothratio);
animateshrunken(p, weapon_xoffset, looking_arc, look_anghalf, FIST, shade, o, interpfrac);
}
else
{

View file

@ -223,9 +223,9 @@ inline void hud_draw(double x, double y, int tilenum, int shade, int orientation
hud_drawsprite(x, y, 65536, 0, tilenum, shade, p, 2 | orientation);
}
inline void animateshrunken(player_struct* p, double weapon_xoffset, double looking_arc, double look_anghalf, int tilenum, int8_t shade, int o, double smoothratio)
inline void animateshrunken(player_struct* p, double weapon_xoffset, double looking_arc, double look_anghalf, int tilenum, int8_t shade, int o, double interpfrac)
{
const double fistsign = bsinf(__interpvaluef(p->ofistsign, p->fistsign, smoothratio), -10);
const double fistsign = bsinf(interpolatedvalue<double>(p->ofistsign, p->fistsign, interpfrac), -10);
if (p->jetpack_on == 0) looking_arc += 32 - (p->GetActor()->int_xvel() >> 1);
hud_draw(weapon_xoffset + fistsign + 250 - look_anghalf, looking_arc + 258 - fabs(fistsign * 4), tilenum, shade, o);
hud_draw(weapon_xoffset - fistsign + 40 - look_anghalf, looking_arc + 200 + fabs(fistsign * 4), tilenum, shade, o | 4);

View file

@ -61,7 +61,7 @@ BEGIN_DUKE_NS
void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, DAngle a, fixedhoriz h, DAngle rotscrnang, double smoothratio, bool sceneonly, float fov)
{
if (!sceneonly) drawweapon(smoothratio);
if (!sceneonly) drawweapon(smoothratio * (1. / MaxSmoothRatio));
render_drawrooms(playersprite, vec3_t( x, y, z ), sectnum(sect), a, h, rotscrnang, smoothratio, fov);
}
@ -339,7 +339,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
}
else if (p->over_shoulder_on == 0)
{
if (cl_viewbob) cposz += __interpvaluef(p->opyoff, p->pyoff, smoothratio) * zworldtoint;
if (cl_viewbob) cposz += interpolatedvalue(p->opyoff, p->pyoff, smoothratio * (1. / MaxSmoothRatio)) * zworldtoint;
viewer = p->GetActor();
}
else
@ -407,7 +407,7 @@ bool GameInterface::GenerateSavePic()
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio)
{
fi.animatesprites(tsprites, viewx, viewy, viewang.Buildang(), int(smoothRatio));
fi.animatesprites(tsprites, viewx, viewy, viewang.Buildang(), smoothRatio * (1. / MaxSmoothRatio));
}

View file

@ -137,7 +137,7 @@ void StopFiringWeapon(int nPlayer);
void FireWeapon(int nPlayer);
void CheckClip(int nPlayer);
void MoveWeapons(int nPlayer);
void DrawWeapons(double smooth);
void DrawWeapons(double interpfrac);
// items

View file

@ -869,7 +869,7 @@ loc_flag:
}
}
void DrawWeapons(double smooth)
void DrawWeapons(double interpfrac)
{
if (bCamera) {
return;
@ -910,8 +910,8 @@ void DrawWeapons(double smooth)
if (cl_hudinterpolation)
{
nBobAngle = interpolatedvalue(DAngle::fromBuild(obobangle), DAngle::fromBuild(bobangle), smooth * (1. / MaxSmoothRatio)).Buildfang();
nVal = __interpvaluef(PlayerList[nLocalPlayer].ototalvel, PlayerList[nLocalPlayer].totalvel, smooth, 16) * 0.5;
nBobAngle = interpolatedvalue(DAngle::fromBuild(obobangle), DAngle::fromBuild(bobangle), interpfrac).Buildfang();
nVal = interpolatedvalue(PlayerList[nLocalPlayer].ototalvel, PlayerList[nLocalPlayer].totalvel, interpfrac) * 0.5;
}
else
{
@ -943,8 +943,8 @@ void DrawWeapons(double smooth)
nShade = PlayerList[nLocalPlayer].pActor->spr.shade;
}
double const look_anghalf = PlayerList[nLocalPlayer].angle.look_anghalf(smooth * (1. / MaxSmoothRatio));
double const looking_arc = PlayerList[nLocalPlayer].angle.looking_arc(smooth * (1. / MaxSmoothRatio));
double const look_anghalf = PlayerList[nLocalPlayer].angle.look_anghalf(interpfrac);
double const looking_arc = PlayerList[nLocalPlayer].angle.looking_arc(interpfrac);
xOffset -= look_anghalf;
yOffset += looking_arc;

View file

@ -214,7 +214,7 @@ void DrawView(double interpfrac, bool sceneonly)
}
else
{
nCamerapos = pPlayerActor->interpolatedpos(interpfrac).plusZ(__interpvaluef(PlayerList[nLocalPlayer].oeyelevel, PlayerList[nLocalPlayer].eyelevel, interpfrac * MaxSmoothRatio) * zinttoworld);
nCamerapos = pPlayerActor->interpolatedpos(interpfrac).plusZ(interpolatedvalue<double>(PlayerList[nLocalPlayer].oeyelevel, PlayerList[nLocalPlayer].eyelevel, interpfrac) * zinttoworld);
pSector = PlayerList[nLocalPlayer].pPlayerViewSect;
updatesector(nCamerapos, &pSector);
@ -303,7 +303,7 @@ void DrawView(double interpfrac, bool sceneonly)
}
if (!nFreeze && !sceneonly)
DrawWeapons(interpfrac * MaxSmoothRatio);
DrawWeapons(interpfrac);
render_drawrooms(nullptr, nCamerapos, sectnum(pSector), nCameraang, nCamerapan, rotscrnang, interpfrac * MaxSmoothRatio);
if (HavePLURemap())

View file

@ -1363,7 +1363,7 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
DrawScreen = true;
PreDraw();
PreUpdatePanel(smoothratio);
PreUpdatePanel(smoothratio * (1. / MaxSmoothRatio));
int sr = (int)smoothratio;
if (!sceneonly)
@ -1380,9 +1380,9 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
else
camerapp = pp;
tx = int(__interpvaluef(camerapp->opos.X, camerapp->pos.X, smoothratio) * worldtoint);
ty = int(__interpvaluef(camerapp->opos.Y, camerapp->pos.Y, smoothratio) * worldtoint);
tz = int(__interpvaluef(camerapp->opos.Z, camerapp->pos.Z, smoothratio) * zworldtoint);
tx = int(interpolatedvalue<double>(camerapp->opos.X, camerapp->pos.X, smoothratio * (1. / MaxSmoothRatio)) * worldtoint);
ty = int(interpolatedvalue<double>(camerapp->opos.Y, camerapp->pos.Y, smoothratio * (1. / MaxSmoothRatio)) * worldtoint);
tz = int(interpolatedvalue<double>(camerapp->opos.Z, camerapp->pos.Z, smoothratio * (1. / MaxSmoothRatio)) * zworldtoint);
// Interpolate the player's angle while on a sector object, just like VoidSW.
// This isn't needed for the turret as it was fixable, but moving sector objects are problematic.
@ -1478,7 +1478,7 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
JS_CameraParms(pp, tx, ty, tz);
}
if (!sceneonly) UpdatePanel(smoothratio);
if (!sceneonly) UpdatePanel(smoothratio * (1. / MaxSmoothRatio));
UpdateWallPortalState();
render_drawrooms(pp->actor, vec3_t( tx, ty, tz ), sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
RestorePortalState();

View file

@ -6364,7 +6364,7 @@ void pWeaponBob(PANEL_SPRITE* psp, short condition)
//////////////////////////////////////////////////////////////////////////////////////////
bool DrawBeforeView = false;
void pDisplaySprites(PLAYER* pp, double smoothratio)
void pDisplaySprites(PLAYER* pp, double interpfrac)
{
DSWActor* plActor = pp->actor;
PANEL_SPRITE* next=nullptr;
@ -6376,8 +6376,8 @@ void pDisplaySprites(PLAYER* pp, double smoothratio)
short ang;
int flags;
double const look_anghalf = pp->angle.look_anghalf(smoothratio * (1. / MaxSmoothRatio));
double const looking_arc = pp->angle.looking_arc(smoothratio * (1. / MaxSmoothRatio));
double const look_anghalf = pp->angle.look_anghalf(interpfrac);
double const looking_arc = pp->angle.looking_arc(interpfrac);
auto list = pp->GetPanelSpriteList();
for (auto psp = list->Next; next = psp->Next, psp != list; psp = next)
@ -6387,8 +6387,8 @@ void pDisplaySprites(PLAYER* pp, double smoothratio)
flags = 0;
if (cl_hudinterpolation)
{
x = __interpvaluef(psp->opos.X, psp->pos.X, smoothratio);
y = __interpvaluef(psp->opos.Y, psp->pos.Y, smoothratio);
x = interpolatedvalue<double>(psp->opos.X, psp->pos.X, interpfrac);
y = interpolatedvalue<double>(psp->opos.Y, psp->pos.Y, interpfrac);
}
else
@ -6756,18 +6756,18 @@ void pStateControl(PANEL_SPRITE* psp)
}
void UpdatePanel(double smoothratio)
void UpdatePanel(double interpfrac)
{
short pnum;
TRAVERSE_CONNECT(pnum)
{
if (pnum == screenpeek)
pDisplaySprites(Player + pnum, smoothratio);
pDisplaySprites(Player + pnum, interpfrac);
}
}
void PreUpdatePanel(double smoothratio)
void PreUpdatePanel(double interpfrac)
{
short pnum;
DrawBeforeView = true;
@ -6776,7 +6776,7 @@ void PreUpdatePanel(double smoothratio)
TRAVERSE_CONNECT(pnum)
{
if (pnum == screenpeek)
pDisplaySprites(Player + pnum, smoothratio);
pDisplaySprites(Player + pnum, interpfrac);
}
DrawBeforeView = false;

View file

@ -194,7 +194,7 @@ PANEL_SPRITE* pSpawnSprite(PLAYER* pp, PANEL_STATE* state, uint8_t priority, dou
void pSetSuicide(PANEL_SPRITE* psp);
bool pKillScreenSpiteIDs(PLAYER* pp, short id);
void PreUpdatePanel(double smoothratio);
void UpdatePanel(double smoothratio);
void UpdatePanel(double interpfrac);
void PlayerUpdateArmor(PLAYER* pp,short value);
void pToggleCrosshair(void);
void pKillSprite(PANEL_SPRITE* psp);