From 98904039b77a1c8afa0eb2d2477ea908b72f766e Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Mon, 13 Oct 2014 16:32:49 +1300 Subject: [PATCH] Final work on prediction lerping Added cl_predict_lerpscale and cl_predict_lerpthreshold Added options in menudef Made sure that lerping cannot extrapolate or run on small scales Lerping gets reset when rendering interpolation does or respawn --- src/p_user.cpp | 19 ++++++++++++------- wadsrc/static/menudef.txt | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index 7d93f6f24..abf9256f7 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -64,14 +64,14 @@ static FRandom pr_skullpop ("SkullPop"); CVAR (Bool, cl_noprediction, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, cl_predict_specials, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Float, cl_predict_lerpscale, 0.05f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { P_PredictionLerpReset(); } -CUSTOM_CVAR(Float, cl_predict_lerpthreshold, 2.00, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { - if (self < 0.1) - self = 0.1; + if (self < 0.1f) + self = 0.1f; P_PredictionLerpReset(); } @@ -2671,7 +2671,8 @@ bool P_LerpCalculate(FVector3 from, FVector3 to, FVector3 &result, float scale) result = result + from; FVector3 delta = result - to; - return (delta.LengthSquared() > cl_predict_lerpthreshold); + // As a fail safe, assume extrapolation is the threshold. + return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f); } void P_PredictPlayer (player_t *player) @@ -2759,7 +2760,8 @@ void P_PredictPlayer (player_t *player) } act->BlockNode = NULL; - bool CanLerp = (cl_predict_lerpscale > 0), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus(); + // Values too small to be usable for lerping can be considered "off". + bool CanLerp = !(cl_predict_lerpscale < 0.01f), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus(); for (int i = gametic; i < maxtic; ++i) { if (!NoInterpolateOld) @@ -2779,7 +2781,10 @@ void P_PredictPlayer (player_t *player) if (CanLerp) { - if (DoLerp) + if (NoInterpolateOld) + P_PredictionLerpReset(); + + else if (DoLerp) { // If lerping is already in effect, use the previous camera postion so the view doesn't suddenly snap PredictionLerpFrom = (PredictionLerptics == 0) ? PredictionLast : PredictionLerpResult; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 627c11385..1fd8dfe2b 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1612,8 +1612,8 @@ OptionMenu NetworkOptions StaticText "Local options", 1 Option "Movement prediction", "cl_noprediction", "OffOn" Option "Predict line actions", "cl_predict_specials", "OnOff" - Option "Prediction Lerp Scale", "cl_predict_lerpscale", 0.0, 0.5, 0.01 - Option "Lerp Threshold", "cl_predict_lerpthreshold", 0.1, 16.0, 0.1 + Slider "Prediction Lerp Scale", "cl_predict_lerpscale", 0.0, 0.5, 0.05 + Slider "Lerp Threshold", "cl_predict_lerpthreshold", 0.1, 16.0, 0.1 StaticText " " StaticText "Host options", 1 Option "Extra Tics", "net_extratic", "ExtraTicMode"