+ // player can look around, so take the origin from the entity,
+ // and the angles from the input system
+ Matrix4x4_OriginFromMatrix(&ent->render.matrix, vieworg);
+ VectorCopy(cl.viewangles, viewangles);
+
+ // update the stairoffset if the player entity has gone up or down without leaving the ground
+ //Con_Printf("cl.onground %i oldz %f newz %f vel %f %f %f\n", cl.onground, oldz, vieworg[2], cl.movement_velocity[0], cl.movement_velocity[1], cl.movement_velocity[2]);
+ cl.stairoffset -= vieworg[2] - oldz;
+ oldz = vieworg[2];
+ cl.stairoffset = bound(-16, cl.stairoffset, 16);
+
+ // interpolate the angles if playing a demo or spectating someone
+ if (cls.demoplayback || cl.fixangle[0])
+ {
+ int i;
+ float frac = bound(0, (cl.time - cl.mtime[1]) / (cl.mtime[0] - cl.mtime[1]), 1);
+ for (i = 0;i < 3;i++)
+ {
+ float d = cl.mviewangles[0][i] - cl.mviewangles[1][i];
+ if (d > 180)
+ d -= 360;
+ else if (d < -180)
+ d += 360;
+ viewangles[i] = cl.mviewangles[1][i] + frac * d;
+ }
+ }