- InputScale(): Add enabled-by-default scaler to returned value from function to correct drift that occurs as the frame-rate increases, taking into account different scaling ratios needed for differing ticrates.

This commit is contained in:
Mitch Richters 2021-11-10 20:13:06 +11:00
parent 9433e9bdb1
commit 5a33caa635
3 changed files with 14 additions and 3 deletions

View file

@ -89,6 +89,7 @@ CVARD(Bool, cl_bloodqavinterp, true, CVAR_ARCHIVE, "enable/disable Blood's QAV i
CVARD(Bool, cl_bloodweapinterp, false, CVAR_ARCHIVE, "enable/disable Blood's weapon interpolation. Depends on 'cl_bloodqavinterp'")
CVARD(Bool, cl_bloodoldweapbalance, false, CVAR_ARCHIVE, "enable/disable legacy 1.0 weapon handling for Blood")
CVARD(Bool, cl_loadingscreens, true, CVAR_ARCHIVE, "enable/disable loading screens for games")
CVARD(Bool, cl_preciseinputscaling, true, CVAR_ARCHIVE, "enable/disable precise scaling of unsynchronised input fraction")
CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable weapon autoaim")

View file

@ -34,6 +34,7 @@ EXTERN_CVAR(Bool, cl_bloodqavinterp)
EXTERN_CVAR(Bool, cl_bloodweapinterp)
EXTERN_CVAR(Bool, cl_bloodoldweapbalance)
EXTERN_CVAR(Bool, cl_loadingscreens)
EXTERN_CVAR(Bool, cl_preciseinputscaling)
EXTERN_CVAR(Bool, demorec_seeds_cvar)
EXTERN_CVAR(Bool, demoplay_diffs)

View file

@ -477,10 +477,19 @@ double InputScale()
{
if (!SyncInput())
{
double now = I_msTimeF();
double elapsedInputTicks = lastCheck > 0 ? min(now - lastCheck, 1000.0 / GameTicRate) : 1;
const double max = 1000. / GameTicRate;
const double now = I_msTimeF();
const double elapsedInputTicks = lastCheck > 0 ? min(now - lastCheck, max) : 1.;
lastCheck = now;
return elapsedInputTicks * GameTicRate / 1000.0;
if (elapsedInputTicks == max) return 1;
// Calculate a scale increase of upto 14% at 30Hz or 7% at 40Hz to correct an
// inherent drift in this function that progressively causes the actions that depend
// on this fractional scale to increase by over 100 ms as the framerate increases.
// This isn't pretty, but it's accurate to within 1-2 ms from 60 fps to at least 1000 fps.
const double result = elapsedInputTicks * GameTicRate / 1000.;
const double scaler = cl_preciseinputscaling ? 1. + 80. / (GameTicRate - 11.2) / GameTicRate * (1. + result - result * 2.) : 1.;
return result * scaler;
}
else
{