Port step smoothing code from r1q2.

While the bugfix in a6f4a3b made the steping prediction working for
stairs, elevators are still stuttering. r1q2s code solves this problem
and is a little bit faster. Use it instead.
This commit is contained in:
Yamagi Burmeister 2016-08-14 12:45:16 +02:00
parent f16928f2cf
commit 93e9633382

View file

@ -227,13 +227,10 @@ CL_PredictMovement(void)
{ {
int ack, current; int ack, current;
int frame; int frame;
int oldframe;
usercmd_t *cmd; usercmd_t *cmd;
pmove_t pm; pmove_t pm;
int i; int i;
int step; int step;
int oldz;
static int last_step_frame = 0;
if (cls.state != ca_active) if (cls.state != ca_active)
{ {
@ -298,19 +295,13 @@ CL_PredictMovement(void)
VectorCopy(pm.s.origin, cl.predicted_origins[frame]); VectorCopy(pm.s.origin, cl.predicted_origins[frame]);
} }
/* We need to remove the current frame. Otherwise we're step = pm.s.origin[2] - (int)(cl.predicted_origin[2] * 8);
predicting one frame too far, leading to misses. */
--ack;
oldframe = (ack - 2) & (CMD_BACKUP - 1); if (((step > 62 && step < 66) || (step > 94 && step < 98) || (step > 126 && step < 130))
oldz = cl.predicted_origins[oldframe][2]; && !VectorCompare((float *)pm.s.velocity, vec3_origin) && (pm.s.pm_flags & PMF_ON_GROUND))
step = pm.s.origin[2] - oldz;
if (last_step_frame != current && step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND))
{ {
cl.predicted_step = step * 0.125f; cl.predicted_step = step * 0.125f;
cl.predicted_step_time = cls.realtime - cls.nframetime * 500; cl.predicted_step_time = cls.realtime - (int)(cls.nframetime * 500);
last_step_frame = current;
} }
/* copy results out for rendering */ /* copy results out for rendering */