]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Apply stair smoothing to the player model in addition to the player's view, allows...
authorMario <mario.mario@y7mail.com>
Mon, 3 Aug 2020 12:12:54 +0000 (22:12 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 3 Aug 2020 12:12:54 +0000 (22:12 +1000)
qcsrc/lib/csqcmodel/cl_player.qc

index d8ea2a070c4cb26031d99965d3a6d018c39ff4a9..46beffa68e449927bdb27a55ab4df79dc4b05c77 100644 (file)
@@ -238,6 +238,29 @@ vector CSQCPlayer_ApplySmoothing(entity this, vector v)
        return v;
 }
 
+// simplified copy of CSQCPlayer_ApplySmoothing for use on player models
+float mdl_stairsmoothz;
+float mdl_smooth_prevtime;
+vector CSQCModel_ApplyStairSmoothing(entity this, vector v)
+{
+       float smoothtime = bound(0, time - mdl_smooth_prevtime, 0.1);
+       mdl_smooth_prevtime = max(mdl_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 || this.ground_networkentity)
+               mdl_stairsmoothz = v.z;
+       else
+       {
+               if(mdl_stairsmoothz < v.z)
+                       v.z = mdl_stairsmoothz = bound(v.z - PHYS_STEPHEIGHT(this), mdl_stairsmoothz + smoothtime * autocvar_cl_stairsmoothspeed, v.z);
+               else if(mdl_stairsmoothz > v.z)
+                       v.z = mdl_stairsmoothz = bound(v.z, mdl_stairsmoothz - smoothtime * autocvar_cl_stairsmoothspeed, v.z + PHYS_STEPHEIGHT(this));
+       }
+
+       mdl_smooth_prevtime = time;
+
+       return v;
+}
+
 bool autocvar_v_deathtilt;
 float autocvar_v_deathtiltangle;
 void CSQCPlayer_ApplyDeathTilt(entity this)
@@ -574,6 +597,7 @@ void CSQCPlayer_SetCamera()
                }
 
                // relink
+               e.origin = CSQCModel_ApplyStairSmoothing(e, e.origin);
                setorigin(e, e.origin);
        }