mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 11:40:44 +00:00
- Consolidate all game interpolation code into inline functions.
This commit is contained in:
parent
f254eeb465
commit
e76f63e2c0
22 changed files with 130 additions and 146 deletions
|
@ -317,39 +317,41 @@ struct spritetype
|
|||
|
||||
int32_t interpolatedx(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return ox + MulScale(x - ox, smoothratio, scale);
|
||||
return interpolatedvalue(ox, x, smoothratio, scale);
|
||||
}
|
||||
|
||||
int32_t interpolatedy(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return oy + MulScale(y - oy, smoothratio, scale);
|
||||
return interpolatedvalue(oy, y, smoothratio, scale);
|
||||
}
|
||||
|
||||
int32_t interpolatedz(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return oz + MulScale(z - oz, smoothratio, scale);
|
||||
return interpolatedvalue(oz, z, smoothratio, scale);
|
||||
}
|
||||
|
||||
vec2_t interpolatedvec2(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return vec2_t({
|
||||
return
|
||||
{
|
||||
interpolatedx(smoothratio, scale),
|
||||
interpolatedy(smoothratio, scale)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
vec3_t interpolatedvec3(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return vec3_t({
|
||||
return
|
||||
{
|
||||
interpolatedx(smoothratio, scale),
|
||||
interpolatedy(smoothratio, scale),
|
||||
interpolatedz(smoothratio, scale)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
int16_t interpolatedang(double const smoothratio)
|
||||
{
|
||||
return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, 16);
|
||||
return interpolatedangle(oang, ang, smoothratio, 16);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -364,3 +364,30 @@ inline binangle bvectangbam(int32_t x, int32_t y)
|
|||
{
|
||||
return radang(atan2(y, x));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Interpolation functions for use throughout games.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
inline int32_t interpolatedvalue(int32_t oval, int32_t val, double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return oval + MulScale(val - oval, smoothratio, scale);
|
||||
}
|
||||
|
||||
inline double interpolatedvaluef(double oval, double val, double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return oval + MulScaleF(val - oval, smoothratio, scale);
|
||||
}
|
||||
|
||||
inline int32_t interpolatedangle(int32_t oang, int32_t ang, double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, scale);
|
||||
}
|
||||
|
||||
inline binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale));
|
||||
}
|
||||
|
|
|
@ -11,15 +11,6 @@ double getincanglef(double a, double na);
|
|||
fixed_t getincangleq16(fixed_t a, fixed_t na);
|
||||
binangle getincanglebam(binangle a, binangle na);
|
||||
|
||||
inline binangle interpolatedbamang(binangle oang, binangle ang, double const smoothratio)
|
||||
{
|
||||
double const ratio = smoothratio * (1. / FRACUNIT);
|
||||
uint32_t const dang = UINT32_MAX >> 1;
|
||||
int64_t const prev = oang.asbam();
|
||||
int64_t const curr = ang.asbam();
|
||||
return bamang(prev + xs_CRoundToUInt(ratio * (((curr + dang - prev) & 0xFFFFFFFF) - dang)));
|
||||
}
|
||||
|
||||
struct PlayerHorizon
|
||||
{
|
||||
fixedhoriz horiz, ohoriz, horizoff, ohorizoff;
|
||||
|
@ -220,17 +211,17 @@ struct PlayerAngle
|
|||
|
||||
binangle interpolatedsum(double const smoothratio)
|
||||
{
|
||||
return interpolatedbamang(osum(), sum(), smoothratio);
|
||||
return interpolatedangle(osum(), sum(), smoothratio);
|
||||
}
|
||||
|
||||
binangle interpolatedlookang(double const smoothratio)
|
||||
{
|
||||
return interpolatedbamang(olook_ang, look_ang, smoothratio);
|
||||
return interpolatedangle(olook_ang, look_ang, smoothratio);
|
||||
}
|
||||
|
||||
binangle interpolatedrotscrn(double const smoothratio)
|
||||
{
|
||||
return interpolatedbamang(orotscrnang, rotscrnang, smoothratio);
|
||||
return interpolatedangle(orotscrnang, rotscrnang, smoothratio);
|
||||
}
|
||||
|
||||
double look_anghalf(double const smoothratio)
|
||||
|
|
|
@ -52,9 +52,9 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation)
|
|||
pTSprite->owner = pSprite->index;
|
||||
pTSprite->extra = pSprite->extra;
|
||||
pTSprite->flags = pSprite->hitag | 0x200;
|
||||
pTSprite->x = dx + interpolate(pSprite->ox, pSprite->x, interpolation);
|
||||
pTSprite->y = dy + interpolate(pSprite->oy, pSprite->y, interpolation);
|
||||
pTSprite->z = dz + interpolate(pSprite->oz, pSprite->z, interpolation);
|
||||
pTSprite->x = dx + interpolatedvalue(pSprite->ox, pSprite->x, interpolation);
|
||||
pTSprite->y = dy + interpolatedvalue(pSprite->oy, pSprite->y, interpolation);
|
||||
pTSprite->z = dz + interpolatedvalue(pSprite->oz, pSprite->z, interpolation);
|
||||
pTSprite->ang = pSprite->interpolatedang(interpolation);
|
||||
|
||||
int nAnim = 0;
|
||||
|
@ -147,7 +147,7 @@ RORHACK:
|
|||
int ror_status[16];
|
||||
for (int i = 0; i < 16; i++)
|
||||
ror_status[i] = TestBitString(gotpic, 4080 + i);
|
||||
fixed_t deliriumPitchI = interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
|
||||
fixed_t deliriumPitchI = interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
|
||||
DrawMirrors(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, gInterpolate, gViewIndex);
|
||||
int bakCstat = gView->pSprite->cstat;
|
||||
if (gViewPos == 0)
|
||||
|
|
|
@ -527,26 +527,6 @@ inline int ClipRange(int a, int b, int c)
|
|||
return a;
|
||||
}
|
||||
|
||||
inline int interpolate(int a, int b, int c)
|
||||
{
|
||||
return a+MulScale(b-a,c, 16);
|
||||
}
|
||||
|
||||
inline double finterpolate(double a, double b, double c)
|
||||
{
|
||||
return a+MulScaleF(b-a,c, 16);
|
||||
}
|
||||
|
||||
inline int interpolateang(int a, int b, int c)
|
||||
{
|
||||
return a+MulScale(((b-a+1024)&2047)-1024, c, 16);
|
||||
}
|
||||
|
||||
inline fixed_t interpolateangfix16(fixed_t a, fixed_t b, int c)
|
||||
{
|
||||
return a+MulScale(((b-a+0x4000000)&0x7ffffff)-0x4000000, c, 16);
|
||||
}
|
||||
|
||||
inline char Chance(int a1)
|
||||
{
|
||||
return wrand() < (a1>>1);
|
||||
|
|
|
@ -1640,14 +1640,14 @@ void playerProcess(PLAYER *pPlayer)
|
|||
}
|
||||
ProcessInput(pPlayer);
|
||||
int nSpeed = approxDist(xvel[nSprite], yvel[nSprite]);
|
||||
pPlayer->zViewVel = interpolate(pPlayer->zViewVel, zvel[nSprite], 0x7000);
|
||||
pPlayer->zViewVel = interpolatedvalue(pPlayer->zViewVel, zvel[nSprite], 0x7000);
|
||||
int dz = pPlayer->pSprite->z-pPosture->eyeAboveZ-pPlayer->zView;
|
||||
if (dz > 0)
|
||||
pPlayer->zViewVel += MulScale(dz<<8, 0xa000, 16);
|
||||
else
|
||||
pPlayer->zViewVel += MulScale(dz<<8, 0x1800, 16);
|
||||
pPlayer->zView += pPlayer->zViewVel>>8;
|
||||
pPlayer->zWeaponVel = interpolate(pPlayer->zWeaponVel, zvel[nSprite], 0x5000);
|
||||
pPlayer->zWeaponVel = interpolatedvalue(pPlayer->zWeaponVel, zvel[nSprite], 0x5000);
|
||||
dz = pPlayer->pSprite->z-pPosture->weaponAboveZ-pPlayer->zWeapon;
|
||||
if (dz > 0)
|
||||
pPlayer->zWeaponVel += MulScale(dz<<8, 0x8000, 16);
|
||||
|
|
|
@ -250,12 +250,12 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
|||
if (nSector2 == nSector)
|
||||
{
|
||||
int z2 = getflorzofslope(nSector2, x2, y2);
|
||||
predict.horizoff = q16horiz(interpolate(predict.horizoff.asq16(), IntToFixed(z1 - z2) >> 3, 0x4000));
|
||||
predict.horizoff = q16horiz(interpolatedvalue(predict.horizoff.asq16(), IntToFixed(z1 - z2) >> 3, 0x4000));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
predict.horizoff = q16horiz(interpolate(predict.horizoff.asq16(), 0, 0x4000));
|
||||
predict.horizoff = q16horiz(interpolatedvalue(predict.horizoff.asq16(), 0, 0x4000));
|
||||
if (abs(predict.horizoff.asq16()) < 4)
|
||||
predict.horizoff = q16horiz(0);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
|
|||
|
||||
int nSpeed = approxDist(predict.xvel, predict.yvel);
|
||||
|
||||
predict.at3c = interpolate(predict.at3c, predict.zvel, 0x7000);
|
||||
predict.at3c = interpolatedvalue(predict.at3c, predict.zvel, 0x7000);
|
||||
int dz = predict.z-pPosture->eyeAboveZ-predict.viewz;
|
||||
if (dz > 0)
|
||||
predict.at3c += MulScale(dz<<8, 0xa000, 16);
|
||||
|
@ -297,7 +297,7 @@ void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
|
|||
predict.at3c += MulScale(dz<<8, 0x1800, 16);
|
||||
predict.viewz += predict.at3c>>8;
|
||||
|
||||
predict.at44 = interpolate(predict.at44, predict.zvel, 0x5000);
|
||||
predict.at44 = interpolatedvalue(predict.at44, predict.zvel, 0x5000);
|
||||
dz = predict.z-pPosture->weaponAboveZ-predict.at40;
|
||||
if (dz > 0)
|
||||
predict.at44 += MulScale(dz<<8, 0x8000, 16);
|
||||
|
|
|
@ -839,14 +839,14 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7
|
|||
int x, y;
|
||||
int nXSector = sector[nSector].extra;
|
||||
XSECTOR *pXSector = &xsector[nXSector];
|
||||
int v20 = interpolate(a6, a9, a2);
|
||||
int vc = interpolate(a6, a9, a3);
|
||||
int v20 = interpolatedvalue(a6, a9, a2);
|
||||
int vc = interpolatedvalue(a6, a9, a3);
|
||||
int v28 = vc - v20;
|
||||
int v24 = interpolate(a7, a10, a2);
|
||||
int v8 = interpolate(a7, a10, a3);
|
||||
int v24 = interpolatedvalue(a7, a10, a2);
|
||||
int v8 = interpolatedvalue(a7, a10, a3);
|
||||
int v2c = v8 - v24;
|
||||
int v44 = interpolate(a8, a11, a2);
|
||||
int vbp = interpolate(a8, a11, a3);
|
||||
int v44 = interpolatedvalue(a8, a11, a2);
|
||||
int vbp = interpolatedvalue(a8, a11, a3);
|
||||
int v14 = vbp - v44;
|
||||
int nWall = sector[nSector].wallptr;
|
||||
if (a12)
|
||||
|
|
|
@ -450,8 +450,8 @@ static void DrawMap(spritetype* pSprite)
|
|||
tm = 1;
|
||||
}
|
||||
VIEW* pView = &gPrevView[gViewIndex];
|
||||
int x = interpolate(pView->x, pSprite->x, gInterpolate);
|
||||
int y = interpolate(pView->y, pSprite->y, gInterpolate);
|
||||
int x = interpolatedvalue(pView->x, pSprite->x, gInterpolate);
|
||||
int y = interpolatedvalue(pView->y, pSprite->y, gInterpolate);
|
||||
int ang = (!SyncInput() ? gView->angle.sum() : gView->angle.interpolatedsum(gInterpolate)).asbuild();
|
||||
DrawOverheadMap(x, y, ang, gInterpolate);
|
||||
if (tm)
|
||||
|
@ -466,14 +466,14 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSe
|
|||
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
|
||||
{
|
||||
nSectnum = predict.sectnum;
|
||||
cX = interpolate(predictOld.x, predict.x, gInterpolate);
|
||||
cY = interpolate(predictOld.y, predict.y, gInterpolate);
|
||||
cZ = interpolate(predictOld.viewz, predict.viewz, gInterpolate);
|
||||
zDelta = finterpolate(predictOld.weaponZ, predict.weaponZ, gInterpolate);
|
||||
bobWidth = interpolate(predictOld.bobWidth, predict.bobWidth, gInterpolate);
|
||||
bobHeight = interpolate(predictOld.bobHeight, predict.bobHeight, gInterpolate);
|
||||
shakeX = finterpolate(predictOld.shakeBobX, predict.shakeBobX, gInterpolate);
|
||||
shakeY = finterpolate(predictOld.shakeBobY, predict.shakeBobY, gInterpolate);
|
||||
cX = interpolatedvalue(predictOld.x, predict.x, gInterpolate);
|
||||
cY = interpolatedvalue(predictOld.y, predict.y, gInterpolate);
|
||||
cZ = interpolatedvalue(predictOld.viewz, predict.viewz, gInterpolate);
|
||||
zDelta = interpolatedvaluef(predictOld.weaponZ, predict.weaponZ, gInterpolate);
|
||||
bobWidth = interpolatedvalue(predictOld.bobWidth, predict.bobWidth, gInterpolate);
|
||||
bobHeight = interpolatedvalue(predictOld.bobHeight, predict.bobHeight, gInterpolate);
|
||||
shakeX = interpolatedvaluef(predictOld.shakeBobX, predict.shakeBobX, gInterpolate);
|
||||
shakeY = interpolatedvaluef(predictOld.shakeBobY, predict.shakeBobY, gInterpolate);
|
||||
|
||||
if (!SyncInput())
|
||||
{
|
||||
|
@ -485,26 +485,26 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSe
|
|||
{
|
||||
auto oang = predictOld.angle + predictOld.look_ang;
|
||||
auto ang = predict.angle + predict.look_ang;
|
||||
cA = interpolatedbamang(oang, ang, gInterpolate);
|
||||
cA = interpolatedangle(oang, ang, gInterpolate);
|
||||
|
||||
fixed_t ohoriz = (predictOld.horiz + predictOld.horizoff).asq16();
|
||||
fixed_t horiz = (predict.horiz + predict.horizoff).asq16();
|
||||
cH = q16horiz(interpolate(ohoriz, horiz, gInterpolate));
|
||||
cH = q16horiz(interpolatedvalue(ohoriz, horiz, gInterpolate));
|
||||
|
||||
rotscrnang = interpolatedbamang(predictOld.rotscrnang, predict.rotscrnang, gInterpolate);
|
||||
rotscrnang = interpolatedangle(predictOld.rotscrnang, predict.rotscrnang, gInterpolate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VIEW* pView = &gPrevView[gViewIndex];
|
||||
cX = interpolate(pView->x, gView->pSprite->x, gInterpolate);
|
||||
cY = interpolate(pView->y, gView->pSprite->y, gInterpolate);
|
||||
cZ = interpolate(pView->viewz, gView->zView, gInterpolate);
|
||||
zDelta = finterpolate(pView->weaponZ, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
|
||||
bobWidth = interpolate(pView->bobWidth, gView->bobWidth, gInterpolate);
|
||||
bobHeight = interpolate(pView->bobHeight, gView->bobHeight, gInterpolate);
|
||||
shakeX = finterpolate(pView->shakeBobX, gView->swayWidth, gInterpolate);
|
||||
shakeY = finterpolate(pView->shakeBobY, gView->swayHeight, gInterpolate);
|
||||
cX = interpolatedvalue(pView->x, gView->pSprite->x, gInterpolate);
|
||||
cY = interpolatedvalue(pView->y, gView->pSprite->y, gInterpolate);
|
||||
cZ = interpolatedvalue(pView->viewz, gView->zView, gInterpolate);
|
||||
zDelta = interpolatedvaluef(pView->weaponZ, gView->zWeapon - gView->zView - (12 << 8), gInterpolate);
|
||||
bobWidth = interpolatedvalue(pView->bobWidth, gView->bobWidth, gInterpolate);
|
||||
bobHeight = interpolatedvalue(pView->bobHeight, gView->bobHeight, gInterpolate);
|
||||
shakeX = interpolatedvaluef(pView->shakeBobX, gView->swayWidth, gInterpolate);
|
||||
shakeY = interpolatedvaluef(pView->shakeBobY, gView->swayHeight, gInterpolate);
|
||||
|
||||
if (!SyncInput())
|
||||
{
|
||||
|
@ -688,7 +688,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
binangle rotscrnang;
|
||||
SetupView(cX, cY, cZ, cA, cH, nSectnum, zDelta, shakeX, shakeY, rotscrnang);
|
||||
|
||||
int tilt = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate);
|
||||
int tilt = interpolatedangle(gScreenTiltO, gScreenTilt, gInterpolate);
|
||||
uint8_t v14 = 0;
|
||||
uint8_t v10 = 0;
|
||||
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0;
|
||||
|
@ -745,7 +745,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
}
|
||||
}
|
||||
g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0));
|
||||
cA += q16ang(interpolateangfix16(IntToFixed(deliriumTurnO), IntToFixed(deliriumTurn), gInterpolate));
|
||||
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);
|
||||
|
||||
int ceilingZ, floorZ;
|
||||
getzsofslope(nSectnum, cX, cY, &ceilingZ, &floorZ);
|
||||
|
@ -773,7 +773,7 @@ void viewDrawScreen(bool sceneonly)
|
|||
|
||||
if (testnewrenderer)
|
||||
{
|
||||
fixedhoriz deliriumPitchI = q16horiz(interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
|
||||
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
|
||||
int bakCstat = gView->pSprite->cstat;
|
||||
gView->pSprite->cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANSLUCENT_INVERT;
|
||||
render_drawrooms(gView->pSprite, { cX, cY, cZ }, nSectnum, cA, cH + deliriumPitchI, rotscrnang);
|
||||
|
|
|
@ -466,9 +466,9 @@ void UpdateAimVector(PLAYER * pPlayer)
|
|||
aim2 = aim;
|
||||
RotateVector((int*)&aim2.dx, (int*)&aim2.dy, -pPSprite->ang);
|
||||
aim2.dz -= pPlayer->slope;
|
||||
pPlayer->relAim.dx = interpolate(pPlayer->relAim.dx, aim2.dx, pWeaponTrack->aimSpeedHorz);
|
||||
pPlayer->relAim.dy = interpolate(pPlayer->relAim.dy, aim2.dy, pWeaponTrack->aimSpeedHorz);
|
||||
pPlayer->relAim.dz = interpolate(pPlayer->relAim.dz, aim2.dz, pWeaponTrack->aimSpeedVert);
|
||||
pPlayer->relAim.dx = interpolatedvalue(pPlayer->relAim.dx, aim2.dx, pWeaponTrack->aimSpeedHorz);
|
||||
pPlayer->relAim.dy = interpolatedvalue(pPlayer->relAim.dy, aim2.dy, pWeaponTrack->aimSpeedHorz);
|
||||
pPlayer->relAim.dz = interpolatedvalue(pPlayer->relAim.dz, aim2.dz, pWeaponTrack->aimSpeedVert);
|
||||
pPlayer->aim = pPlayer->relAim;
|
||||
RotateVector((int*)&pPlayer->aim.dx, (int*)&pPlayer->aim.dy, pPSprite->ang);
|
||||
pPlayer->aim.dz += pPlayer->slope;
|
||||
|
|
|
@ -177,7 +177,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
|
|||
{
|
||||
t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posx - ps[s->yvel].oposx, 16);
|
||||
t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posy - ps[s->yvel].oposy, 16);
|
||||
t->z = ps[s->yvel].oposz + MulScale(smoothratio, ps[s->yvel].posz - ps[s->yvel].oposz, 16);
|
||||
t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].posz, smoothratio);
|
||||
t->z += (40 << 8);
|
||||
}
|
||||
else if (s->picnum != CRANEPOLE)
|
||||
|
@ -328,10 +328,10 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
|
|||
t->cstat |= 2;
|
||||
if (screenpeek == myconnectindex && numplayers >= 2)
|
||||
{
|
||||
t->x = omyx + MulScale((int)(myx - omyx), smoothratio, 16);
|
||||
t->y = omyy + MulScale((int)(myy - omyy), smoothratio, 16);
|
||||
t->z = omyz + MulScale((int)(myz - omyz), smoothratio, 16) + (40 << 8);
|
||||
t->ang = myang.asbuild() + MulScale((((myang.asbuild() + 1024 - myang.asbuild()) & 2047) - 1024), smoothratio, 16);
|
||||
t->x = interpolatedvalue(omyx, myx, smoothratio);
|
||||
t->y = interpolatedvalue(omyy, myy, smoothratio);
|
||||
t->z = interpolatedvalue(omyz, myz, smoothratio) + (40 << 8);
|
||||
t->ang = interpolatedangle(omyang, myang, smoothratio).asbuild();
|
||||
t->sectnum = mycursectnum;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int
|
|||
{
|
||||
t->x -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posx - ps[s->yvel].oposx, 16);
|
||||
t->y -= MulScale(MaxSmoothRatio - smoothratio, ps[s->yvel].posy - ps[s->yvel].oposy, 16);
|
||||
t->z = ps[s->yvel].oposz + MulScale(smoothratio, ps[s->yvel].posz - ps[s->yvel].oposz, 16);
|
||||
t->z = interpolatedvalue(ps[s->yvel].oposz, ps[s->yvel].posz, smoothratio);
|
||||
t->z += (40 << 8);
|
||||
s->xrepeat = 24;
|
||||
s->yrepeat = 17;
|
||||
|
@ -374,10 +374,10 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int
|
|||
t->cstat |= 2;
|
||||
if (screenpeek == myconnectindex && numplayers >= 2)
|
||||
{
|
||||
t->x = omyx + MulScale((int)(myx - omyx), smoothratio, 16);
|
||||
t->y = omyy + MulScale((int)(myy - omyy), smoothratio, 16);
|
||||
t->z = omyz + MulScale((int)(myz - omyz), smoothratio, 16) + (40 << 8);
|
||||
t->ang = omyang.asbuild() + MulScale((((myang.asbuild() + 1024 - omyang.asbuild()) & 2047) - 1024), smoothratio, 16);
|
||||
t->x = interpolatedvalue(omyx, myx, smoothratio);
|
||||
t->y = interpolatedvalue(omyy, myy, smoothratio);
|
||||
t->z = interpolatedvalue(omyz, myz, smoothratio) + (40 << 8);
|
||||
t->ang = interpolatedangle(omyang, myang, smoothratio).asbuild();
|
||||
t->sectnum = mycursectnum;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,15 +266,15 @@ void drawoverlays(double smoothratio)
|
|||
{
|
||||
if (screenpeek == myconnectindex && numplayers > 1)
|
||||
{
|
||||
cposx = omyx + MulScale(myx - omyx, smoothratio, 16);
|
||||
cposy = omyy + MulScale(myy - omyy, smoothratio, 16);
|
||||
cang = !SyncInput() ? myang.asbuild() : omyang.asbuild() + MulScale(((myang.asbuild() + 1024 - omyang.asbuild()) & 2047) - 1024, smoothratio, 16);
|
||||
cposx = interpolatedvalue(omyx, myx, smoothratio);
|
||||
cposy = interpolatedvalue(omyy, myy, smoothratio);
|
||||
cang = (!SyncInput() ? myang : interpolatedangle(omyang, myang, smoothratio)).asbuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
cposx = pp->oposx + MulScale(pp->posx - pp->oposx, smoothratio, 16);
|
||||
cposy = pp->oposy + MulScale(pp->posy - pp->oposy, smoothratio, 16);
|
||||
cang = !SyncInput() ? pp->angle.ang.asbuild() : pp->angle.oang.asbuild() + MulScale(((pp->angle.ang.asbuild() + 1024 - pp->angle.oang.asbuild()) & 2047) - 1024, smoothratio, 16);
|
||||
cposx = interpolatedvalue(pp->oposx, pp->posx, smoothratio);
|
||||
cposy = interpolatedvalue(pp->oposy, pp->posy, smoothratio);
|
||||
cang = (!SyncInput() ? pp->angle.ang : interpolatedangle(pp->angle.oang, pp->angle.ang, smoothratio)).asbuild();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -284,10 +284,10 @@ void displayweapon_d(int snum, double smoothratio)
|
|||
horiz16th = get16thOfHoriz(snum, SyncInput(), smoothratio);
|
||||
look_anghalf = p->angle.look_anghalf(smoothratio);
|
||||
looking_arc = fabs(look_anghalf) / 4.5;
|
||||
weapon_sway = p->oweapon_sway + MulScaleF(p->weapon_sway - p->oweapon_sway, smoothratio, 16);
|
||||
kickback_pic = p->okickback_pic + MulScaleF(*kb - p->okickback_pic, smoothratio, 16);
|
||||
random_club_frame = p->orandom_club_frame + MulScaleF(p->random_club_frame - p->orandom_club_frame, smoothratio, 16);
|
||||
hard_landing = p->ohard_landing + MulScaleF(p->hard_landing - p->ohard_landing, smoothratio, 16);
|
||||
weapon_sway = interpolatedvaluef(p->oweapon_sway, p->weapon_sway, smoothratio);
|
||||
kickback_pic = interpolatedvaluef(p->okickback_pic, p->kickback_pic, smoothratio);
|
||||
random_club_frame = interpolatedvaluef(p->orandom_club_frame, p->random_club_frame, smoothratio);
|
||||
hard_landing = interpolatedvaluef(p->ohard_landing, p->hard_landing, smoothratio);
|
||||
|
||||
shade = p->GetActor()->s.shade;
|
||||
if(shade > 24) shade = 24;
|
||||
|
@ -301,9 +301,7 @@ void displayweapon_d(int snum, double smoothratio)
|
|||
|
||||
animateknee(shade,snum,hard_landing,look_anghalf,horiz16th);
|
||||
|
||||
int opos = p->oweapon_pos * p->oweapon_pos;
|
||||
int npos = p->weapon_pos * p->weapon_pos;
|
||||
gun_pos = 80 - (opos + MulScaleF(npos - opos, smoothratio, 16));
|
||||
gun_pos = 80 - interpolatedvaluef(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, smoothratio);
|
||||
|
||||
weapon_xoffset = (160)-90;
|
||||
weapon_xoffset -= bcosf(weapon_sway * 0.5) * (1. / 1536.);
|
||||
|
|
|
@ -127,8 +127,8 @@ void displayweapon_r(int snum, double smoothratio)
|
|||
|
||||
look_anghalf = p->angle.look_anghalf(smoothratio);
|
||||
looking_arc = fabs(look_anghalf) / 4.5;
|
||||
weapon_sway = p->oweapon_sway + MulScaleF((p->weapon_sway - p->oweapon_sway), smoothratio, 16);
|
||||
TiltStatus = !SyncInput() ? p->TiltStatus : p->oTiltStatus + MulScaleF((p->TiltStatus - p->oTiltStatus), smoothratio, 16);
|
||||
weapon_sway = interpolatedvaluef(p->oweapon_sway, p->weapon_sway, smoothratio);
|
||||
TiltStatus = !SyncInput() ? p->TiltStatus : interpolatedvaluef(p->oTiltStatus, p->TiltStatus, smoothratio);
|
||||
|
||||
if (shadedsector[p->cursectnum] == 1)
|
||||
shade = 16;
|
||||
|
@ -139,9 +139,7 @@ void displayweapon_r(int snum, double smoothratio)
|
|||
if(p->newOwner != nullptr || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->s.pal != 1 && p->GetActor()->s.extra <= 0))
|
||||
return;
|
||||
|
||||
int opos = p->oweapon_pos * p->oweapon_pos;
|
||||
int npos = p->weapon_pos * p->weapon_pos;
|
||||
gun_pos = 80 - (opos + MulScaleF(npos - opos, smoothratio, 16));
|
||||
gun_pos = 80 - interpolatedvaluef(p->oweapon_pos * p->oweapon_pos, p->weapon_pos * p->weapon_pos, smoothratio);
|
||||
|
||||
weapon_xoffset = (160)-90;
|
||||
weapon_xoffset -= bcosf(weapon_sway * 0.5) * (1. / 1536.);
|
||||
|
@ -150,7 +148,7 @@ void displayweapon_r(int snum, double smoothratio)
|
|||
gun_pos -= fabs(bsinf(weapon_sway * 4., -9));
|
||||
else gun_pos -= fabs(bsinf(weapon_sway * 0.5, -10));
|
||||
|
||||
gun_pos -= (p->ohard_landing + MulScaleF(p->hard_landing - p->ohard_landing, smoothratio, 16)) * 8.;
|
||||
gun_pos -= interpolatedvaluef(p->ohard_landing, p->hard_landing, smoothratio) * 8.;
|
||||
|
||||
if(p->last_weapon >= 0)
|
||||
cw = p->last_weapon;
|
||||
|
|
|
@ -297,7 +297,7 @@ void displayrooms(int snum, double smoothratio)
|
|||
if (s->yvel < 0) s->yvel = -100;
|
||||
else if (s->yvel > 199) s->yvel = 300;
|
||||
|
||||
cang = buildfang(ud.cameraactor->tempang + MulScaleF(((s->ang + 1024 - ud.cameraactor->tempang) & 2047) - 1024, smoothratio, 16));
|
||||
cang = buildang(interpolatedangle(ud.cameraactor->tempang, s->ang, smoothratio));
|
||||
|
||||
auto bh = buildhoriz(s->yvel);
|
||||
renderView(s, s->sectnum, s->x, s->y, s->z - (4 << 8), cang, bh, buildang(0), smoothratio);
|
||||
|
@ -318,15 +318,13 @@ void displayrooms(int snum, double smoothratio)
|
|||
|
||||
if ((snum == myconnectindex) && (numplayers > 1))
|
||||
{
|
||||
cposx = omyx + xs_CRoundToInt(MulScaleF(myx - omyx, smoothratio, 16));
|
||||
cposy = omyy + xs_CRoundToInt(MulScaleF(myy - omyy, smoothratio, 16));
|
||||
cposz = omyz + xs_CRoundToInt(MulScaleF(myz - omyz, smoothratio, 16));
|
||||
cposx = interpolatedvalue(omyx, myx, smoothratio);
|
||||
cposy = interpolatedvalue(omyy, myy, smoothratio);
|
||||
cposz = interpolatedvalue(omyz, myz, smoothratio);
|
||||
if (SyncInput())
|
||||
{
|
||||
fixed_t ohorz = (omyhoriz + omyhorizoff).asq16();
|
||||
fixed_t horz = (myhoriz + myhorizoff).asq16();
|
||||
choriz = q16horiz(ohorz + xs_CRoundToInt(MulScaleF(horz - ohorz, smoothratio, 16)));
|
||||
cang = bamang(xs_CRoundToUInt(omyang.asbam() + MulScaleF((myang - omyang).asbam(), smoothratio, 16)));
|
||||
choriz = q16horiz(interpolatedvalue((omyhoriz + omyhorizoff).asq16(), (myhoriz + myhorizoff).asq16(), smoothratio));
|
||||
cang = interpolatedangle(omyang, myang, smoothratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -337,9 +335,9 @@ void displayrooms(int snum, double smoothratio)
|
|||
}
|
||||
else
|
||||
{
|
||||
cposx = p->oposx + xs_CRoundToInt(MulScaleF(p->posx - p->oposx, smoothratio, 16));
|
||||
cposy = p->oposy + xs_CRoundToInt(MulScaleF(p->posy - p->oposy, smoothratio, 16));
|
||||
cposz = p->oposz + xs_CRoundToInt(MulScaleF(p->posz - p->oposz, smoothratio, 16));
|
||||
cposx = interpolatedvalue(p->oposx, p->posx, smoothratio);
|
||||
cposy = interpolatedvalue(p->oposy, p->posy, smoothratio);
|
||||
cposz = interpolatedvalue(p->oposz, p->posz, smoothratio);;
|
||||
if (SyncInput())
|
||||
{
|
||||
// Original code for when the values are passed through the sync struct
|
||||
|
@ -370,7 +368,7 @@ void displayrooms(int snum, double smoothratio)
|
|||
}
|
||||
else if (p->over_shoulder_on == 0)
|
||||
{
|
||||
if (cl_viewbob) cposz += p->opyoff + xs_CRoundToInt(MulScaleF(p->pyoff - p->opyoff, smoothratio, 16));
|
||||
if (cl_viewbob) cposz += interpolatedvalue(p->opyoff, p->pyoff, smoothratio);
|
||||
viewer = &p->GetActor()->s;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -965,8 +965,8 @@ void DrawWeapons(double smooth)
|
|||
if (cl_weaponsway)
|
||||
{
|
||||
// CHECKME - not & 0x7FF?
|
||||
double nBobAngle = obobangle + MulScaleF(((bobangle + 1024 - obobangle) & 2047) - 1024, smooth, 16);
|
||||
double nVal = (ototalvel[nLocalPlayer] + MulScaleF(totalvel[nLocalPlayer] - ototalvel[nLocalPlayer], smooth, 16)) * 0.5;
|
||||
double nBobAngle = interpolatedangle(buildang(obobangle), buildang(bobangle), smooth).asbuildf();
|
||||
double nVal = interpolatedvaluef(ototalvel[nLocalPlayer], totalvel[nLocalPlayer], smooth, 17);
|
||||
yOffset = MulScaleF(nVal, bsinf(fmod(nBobAngle, 1024.), -8), 9);
|
||||
|
||||
if (var_34 == 1)
|
||||
|
|
|
@ -194,11 +194,6 @@ void ResetView()
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline int interpolate16(int a, int b, int smooth)
|
||||
{
|
||||
return a + MulScale(b - a, smooth, 16);
|
||||
}
|
||||
|
||||
static TextOverlay subtitleOverlay;
|
||||
|
||||
void DrawView(double smoothRatio, bool sceneonly)
|
||||
|
@ -251,7 +246,7 @@ void DrawView(double smoothRatio, bool sceneonly)
|
|||
auto psp = &sprite[nPlayerSprite];
|
||||
playerX = psp->interpolatedx(smoothRatio);
|
||||
playerY = psp->interpolatedy(smoothRatio);
|
||||
playerZ = psp->interpolatedz(smoothRatio) + interpolate16(oeyelevel[nLocalPlayer], eyelevel[nLocalPlayer], smoothRatio);
|
||||
playerZ = psp->interpolatedz(smoothRatio) + interpolatedvalue(oeyelevel[nLocalPlayer], eyelevel[nLocalPlayer], smoothRatio);
|
||||
|
||||
nSector = nPlayerViewSect[nLocalPlayer];
|
||||
updatesector(playerX, playerY, &nSector);
|
||||
|
|
|
@ -43,10 +43,5 @@ extern int gFov;
|
|||
extern spritetype* mytsprite;
|
||||
extern int* myspritesortcnt;
|
||||
|
||||
static inline int angle_interpolate16(int a, int b, int smooth)
|
||||
{
|
||||
return a + MulScale(((b+1024-a)&2047)-1024, smooth, 16);
|
||||
}
|
||||
|
||||
END_PS_NS
|
||||
|
||||
|
|
|
@ -218,9 +218,9 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
|
|||
|
||||
mirrorinview = true;
|
||||
|
||||
// tx = pp->oposx + MulScale(pp->posx - pp->oposx, smoothratio, 16);
|
||||
// ty = pp->oposy + MulScale(pp->posy - pp->oposy, smoothratio, 16);
|
||||
// tz = pp->oposz + MulScale(pp->posz - pp->oposz, smoothratio, 16);
|
||||
// tx = interpolatedvalue(pp->oposx, pp->posx, smoothratio);
|
||||
// ty = interpolatedvalue(pp->oposy, pp->posy, smoothratio);
|
||||
// tz = interpolatedvalue(pp->oposz, pp->posz, smoothratio);
|
||||
// tpq16ang = pp->angle.ang.asq16();
|
||||
|
||||
|
||||
|
|
|
@ -1504,9 +1504,9 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
else
|
||||
camerapp = pp;
|
||||
|
||||
tx = camerapp->oposx + xs_CRoundToInt(MulScaleF(camerapp->posx - camerapp->oposx, smoothratio, 16));
|
||||
ty = camerapp->oposy + xs_CRoundToInt(MulScaleF(camerapp->posy - camerapp->oposy, smoothratio, 16));
|
||||
tz = camerapp->oposz + xs_CRoundToInt(MulScaleF(camerapp->posz - camerapp->oposz, smoothratio, 16));
|
||||
tx = interpolatedvalue(camerapp->oposx, camerapp->posx, smoothratio);
|
||||
ty = interpolatedvalue(camerapp->oposy, camerapp->posy, smoothratio);
|
||||
tz = interpolatedvalue(camerapp->oposz, camerapp->posz, smoothratio);
|
||||
|
||||
// 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.
|
||||
|
@ -1595,7 +1595,7 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
if (cl_viewbob)
|
||||
{
|
||||
tz += bob_amt;
|
||||
tz += pp->obob_z + xs_CRoundToInt(MulScaleF(pp->bob_z - pp->obob_z, smoothratio, 16));
|
||||
tz += interpolatedvalue(pp->obob_z, pp->bob_z, smoothratio);
|
||||
}
|
||||
|
||||
// recoil only when not in camera
|
||||
|
|
|
@ -6905,8 +6905,8 @@ pDisplaySprites(PLAYERp pp, double smoothratio)
|
|||
ang = psp->rotate_ang;
|
||||
shade = 0;
|
||||
flags = 0;
|
||||
x = (psp->ox + MulScaleF(psp->x - psp->ox, smoothratio, 16)) - look_anghalf;
|
||||
y = (psp->oy + MulScaleF(psp->y - psp->oy, smoothratio, 16)) + looking_arc;
|
||||
x = interpolatedvaluef(psp->ox, psp->x, smoothratio) - look_anghalf;
|
||||
y = interpolatedvaluef(psp->oy, psp->y, smoothratio) + looking_arc;
|
||||
// initilize pal here - jack with it below
|
||||
pal = psp->pal;
|
||||
|
||||
|
|
Loading…
Reference in a new issue