mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 07:31:03 +00:00
- 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:
parent
5a33caa635
commit
3c4afaa6ee
4 changed files with 6 additions and 2 deletions
|
@ -1024,6 +1024,7 @@ int RunGame()
|
||||||
playername = userConfig.CommandName;
|
playername = userConfig.CommandName;
|
||||||
}
|
}
|
||||||
GameTicRate = 30;
|
GameTicRate = 30;
|
||||||
|
InputScalePercentage = 0.14125;
|
||||||
CheckUserMap();
|
CheckUserMap();
|
||||||
|
|
||||||
palindexmap[0] = 255;
|
palindexmap[0] = 255;
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
static int WeaponToSend = 0;
|
static int WeaponToSend = 0;
|
||||||
ESyncBits ActionsToSend = 0;
|
ESyncBits ActionsToSend = 0;
|
||||||
static int dpad_lock = 0;
|
static int dpad_lock = 0;
|
||||||
|
double InputScalePercentage = 0;
|
||||||
bool sendPause;
|
bool sendPause;
|
||||||
bool crouch_toggle;
|
bool crouch_toggle;
|
||||||
static double lastCheck;
|
static double lastCheck;
|
||||||
|
@ -483,12 +484,12 @@ double InputScale()
|
||||||
lastCheck = now;
|
lastCheck = now;
|
||||||
if (elapsedInputTicks == max) return 1;
|
if (elapsedInputTicks == max) return 1;
|
||||||
|
|
||||||
// Calculate a scale increase of upto 14% at 30Hz or 7% at 40Hz to correct an
|
// Calculate a scale increase of the percentage InputScalePercentage is set as to correct an
|
||||||
// inherent drift in this function that progressively causes the actions that depend
|
// 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.
|
// 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.
|
// 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 result = elapsedInputTicks * GameTicRate / 1000.;
|
||||||
const double scaler = cl_preciseinputscaling ? 1. + 80. / (GameTicRate - 11.2) / GameTicRate * (1. + result - result * 2.) : 1.;
|
const double scaler = cl_preciseinputscaling ? 1. + InputScalePercentage * (1. + result - result * 2.) : 1.;
|
||||||
return result * scaler;
|
return result * scaler;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -106,6 +106,7 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput, bool cons
|
||||||
extern ESyncBits ActionsToSend;
|
extern ESyncBits ActionsToSend;
|
||||||
double InputScale();
|
double InputScale();
|
||||||
extern bool gamesetinput;
|
extern bool gamesetinput;
|
||||||
|
extern double InputScalePercentage;
|
||||||
|
|
||||||
inline bool SyncInput()
|
inline bool SyncInput()
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,6 +179,7 @@ void GameInterface::LoadGameTextures()
|
||||||
void GameInterface::app_init()
|
void GameInterface::app_init()
|
||||||
{
|
{
|
||||||
GameTicRate = 40;
|
GameTicRate = 40;
|
||||||
|
InputScalePercentage = 0.070625;
|
||||||
InitCheats();
|
InitCheats();
|
||||||
automapping = 1;
|
automapping = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue