- reverted ClockTicks to an integer so that interpolation can be reimplemented without it affecting the global game timer.

The entire method at use here is essentially not correct. Interpolation should be handled independently of the game timer directly based on the underlying clock, like in ZDoom.
There's interpolation bugs in the Build games that cannot be fixed if totalclock is used for it, but if we use something else we do not need a fractional totalclock.
This commit is contained in:
Christoph Oelckers 2020-07-14 11:52:38 +02:00
parent a24034e087
commit 481ac965cf
4 changed files with 6 additions and 4 deletions

View file

@ -3088,7 +3088,7 @@ void viewDrawScreen(bool sceneonly)
lastUpdate = totalclock;
if (!paused && (!M_Active() || gGameOptions.nGameType != 0))
{
gInterpolate = ((totalclock-gNetFifoClock)+4).toScale16()/4;
gInterpolate = ((totalclock - gNetFifoClock) + 4) << 14;// .toScale16() / 4;
}
if (gInterpolate < 0 || gInterpolate > 65536)
{

View file

@ -17,6 +17,7 @@
// (so we might as well check it).
EDUKE32_STATIC_ASSERT(-1 >> 1 == -1);
#if 0
class ClockTicks
{
public:
@ -159,5 +160,8 @@ private:
ticksS32 &= VALUE_MASK;
}
};
#else
using ClockTicks = int;
#endif
#endif /* CLOCKTICKS_HPP_ */

View file

@ -45,7 +45,6 @@ ATTRIBUTE((flatten)) void timerUpdateClock(void)
uint64_t numerator = (elapsedTime.count() * (uint64_t) timerticspersec * steady_clock::period::num);
uint64_t freq = timerGetFreqU64();
int n = tabledivide64(numerator, freq);
totalclock.setFraction(tabledivide64((numerator - n*timerGetFreqU64()) * 65536, freq));
if (n <= 0) return;

View file

@ -1031,13 +1031,12 @@ int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int
const double TICRATE = 120.;
double rfreq = refreshfreq * TICRATE / timerGetClockRate();
double elapsedTime = (totalclk - ototalclk).toScale16F();
double elapsedTime = (totalclk - ototalclk);
double elapsedFrames = elapsedTime * rfreq * (1. / TICRATE);
double ratio = (elapsedFrames * realgameticspersec) / rfreq;
return clamp(xs_RoundToInt(ratio * 65536), 0, 65536);
}
FString G_GetDemoPath()
{
FString path = M_GetDemoPath();