mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-19 15:10:52 +00:00
- add r_ticstability for a smoother experience playing mods with high think times
This commit is contained in:
parent
7fb7d2e242
commit
5d469a532b
1 changed files with 49 additions and 0 deletions
|
@ -28,6 +28,8 @@
|
|||
#include <stddef.h>
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "version.h"
|
||||
#include "menu/menu.h"
|
||||
|
@ -1810,7 +1812,46 @@ void D_QuitNetGame (void)
|
|||
fclose (debugfile);
|
||||
}
|
||||
|
||||
// Forces playsim processing time to be consistent across frames.
|
||||
// This improves interpolation for frames in between tics.
|
||||
//
|
||||
// With this cvar off the mods with a high playsim processing time will appear
|
||||
// less smooth as the measured time used for interpolation will vary.
|
||||
|
||||
CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
static uint64_t stabilityticduration = 0;
|
||||
static uint64_t stabilitystarttime = 0;
|
||||
|
||||
static void TicStabilityWait()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace std::this_thread;
|
||||
|
||||
if (!r_ticstability)
|
||||
return;
|
||||
|
||||
uint64_t start = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
while (true)
|
||||
{
|
||||
uint64_t cur = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
if (cur - start > stabilityticduration)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void TicStabilityBegin()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
stabilitystarttime = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
static void TicStabilityEnd()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
uint64_t stabilityendtime = duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count();
|
||||
stabilityticduration = std::min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000);
|
||||
}
|
||||
|
||||
//
|
||||
// TryRunTics
|
||||
|
@ -1880,6 +1921,8 @@ void TryRunTics (void)
|
|||
// Uncapped framerate needs seprate checks
|
||||
if (counts == 0 && !doWait)
|
||||
{
|
||||
TicStabilityWait();
|
||||
|
||||
// Check possible stall conditions
|
||||
Net_CheckLastReceived(counts);
|
||||
if (realtics >= 1)
|
||||
|
@ -1947,6 +1990,7 @@ void TryRunTics (void)
|
|||
P_UnPredictPlayer();
|
||||
while (counts--)
|
||||
{
|
||||
TicStabilityBegin();
|
||||
if (gametic > lowtic)
|
||||
{
|
||||
I_Error ("gametic>lowtic");
|
||||
|
@ -1962,10 +2006,15 @@ void TryRunTics (void)
|
|||
gametic++;
|
||||
|
||||
NetUpdate (); // check for new console commands
|
||||
TicStabilityEnd();
|
||||
}
|
||||
P_PredictPlayer(&players[consoleplayer]);
|
||||
S_UpdateSounds (players[consoleplayer].camera); // move positional sounds
|
||||
}
|
||||
else
|
||||
{
|
||||
TicStabilityWait();
|
||||
}
|
||||
}
|
||||
|
||||
void Net_CheckLastReceived (int counts)
|
||||
|
|
Loading…
Reference in a new issue