]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix stair smoothing while observing
authorMario <mario@smbclan.net>
Wed, 28 Aug 2019 10:03:23 +0000 (20:03 +1000)
committerMario <mario@smbclan.net>
Wed, 28 Aug 2019 10:03:23 +0000 (20:03 +1000)
qcsrc/client/view.qc
qcsrc/client/view.qh
qcsrc/lib/csqcmodel/cl_player.qc

index 917d795ca2c21724e8c95d0b5ef748d5b3e9669a..3546342a55f217af46f62dfd2cecb64fed36535a 100644 (file)
@@ -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)
 {
index f3c1f4139fff3543ca272c7a750a3cd3328422b5..448361d05f2075d992d3f47a11e83fba5964c439 100644 (file)
@@ -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;
index d791c5b5bfcbc2dcbe0ea6fda19b7d59d1a4d0b6..184888dc4388e6fc3778838c97ab79b70e80e37c 100644 (file)
@@ -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);
                }