From: Mario Date: Wed, 28 Aug 2019 10:03:23 +0000 (+1000) Subject: Fix stair smoothing while observing X-Git-Tag: xonotic-v0.8.5~1105^2~59^2~8 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=49226f5f663418dd45de24bdb95c69c41eb635ff;p=xonotic%2Fxonotic-data.pk3dir.git Fix stair smoothing while observing --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 917d795ca..3546342a5 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -394,7 +394,6 @@ STATIC_INIT(fpscounter_init) showfps_prevfps_time = currentTime; // we must initialize it to avoid an instant low frame sending } -float drawtime; float avgspeed; vector GetCurrentFov(float fov) { diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index f3c1f4139..448361d05 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -20,3 +20,5 @@ const int CURSOR_NORMAL = 0; const int CURSOR_MOVE = 1; const int CURSOR_RESIZE = 2; const int CURSOR_RESIZE2 = 3; + +float drawtime; diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index d791c5b5b..184888dc4 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -214,14 +214,17 @@ float smooth_prevtime; float viewheightavg; vector CSQCPlayer_ApplySmoothing(entity this, vector v) { - if(this.csqcmodel_teleported || !IS_ONGROUND(this) || autocvar_cl_stairsmoothspeed <= 0) + float smoothtime = bound(0, time - smooth_prevtime, 0.1); + smooth_prevtime = max(smooth_prevtime, drawtime); // drawtime is the previous frame's time at this point + + if(this.csqcmodel_teleported || !(this.pmove_flags & PMF_ONGROUND) || autocvar_cl_stairsmoothspeed <= 0) stairsmoothz = v.z; else { - if(v.z > stairsmoothz) - v.z = stairsmoothz = bound(v.z - PHYS_STEPHEIGHT(this), stairsmoothz + frametime * autocvar_cl_stairsmoothspeed, v.z); - else if(v.z < stairsmoothz) - v.z = stairsmoothz = bound(v.z, stairsmoothz - frametime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this)); + if(stairsmoothz < v.z) + v.z = stairsmoothz = bound(v.z - PHYS_STEPHEIGHT(this), stairsmoothz + smoothtime * autocvar_cl_stairsmoothspeed, v.z); + else if(stairsmoothz > v.z) + v.z = stairsmoothz = bound(v.z, stairsmoothz - smoothtime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this)); } float viewheight = bound(0, (time - smooth_prevtime) / max(0.0001, autocvar_cl_smoothviewheight), 1); @@ -406,8 +409,6 @@ bool autocvar_chase_overhead; float autocvar_chase_pitchangle; vector CSQCPlayer_ApplyChase(entity this, vector v) { - // don't need to do offset for view height here, it's done in smoothing! - //v += this.view_ofs; vector forward; vector chase_dest; @@ -577,8 +578,8 @@ void CSQCPlayer_SetCamera() // origin vieworg = vieworg + view_punchvector; vieworg = CSQCPlayer_ApplyBobbing(view, vieworg); - CSQCPlayer_ApplyIdleScaling(view); } + CSQCPlayer_ApplyIdleScaling(view); setproperty(VF_ORIGIN, vieworg); setproperty(VF_ANGLES, view_angles); }