+ frac = bound(0, frac, 1);
+ return (*store = *store * (1 - frac) + value * frac);
+}
+
+static vec_t lowpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
+{
+ lowpass(value, frac, store);
+ return (*store = bound(value - limit, *store, value + limit));
+}
+
+static vec_t highpass(vec_t value, vec_t frac, vec_t *store)
+{
+ return value - lowpass(value, frac, store);
+}
+
+static vec_t highpass_limited(vec_t value, vec_t frac, vec_t limit, vec_t *store)
+{
+ return value - lowpass_limited(value, frac, limit, store);
+}
+
+static void lowpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
+{
+ out[0] = lowpass(value[0], fracx, &store[0]);
+ out[1] = lowpass(value[1], fracy, &store[1]);
+ out[2] = lowpass(value[2], fracz, &store[2]);
+}
+
+static void highpass3(vec3_t value, vec_t fracx, vec_t fracy, vec_t fracz, vec3_t store, vec3_t out)
+{
+ out[0] = highpass(value[0], fracx, &store[0]);
+ out[1] = highpass(value[1], fracy, &store[1]);
+ out[2] = highpass(value[2], fracz, &store[2]);
+}
+
+static void highpass3_limited(vec3_t value, vec_t fracx, vec_t limitx, vec_t fracy, vec_t limity, vec_t fracz, vec_t limitz, vec3_t store, vec3_t out)
+{
+ out[0] = highpass_limited(value[0], fracx, limitx, &store[0]);
+ out[1] = highpass_limited(value[1], fracy, limity, &store[1]);
+ out[2] = highpass_limited(value[2], fracz, limitz, &store[2]);
+}
+
+/*
+ * State:
+ * cl.bob2_smooth
+ * cl.bobfall_speed
+ * cl.bobfall_swing
+ * cl.gunangles_adjustment_highpass
+ * cl.gunangles_adjustment_lowpass
+ * cl.gunangles_highpass
+ * cl.gunangles_prev
+ * cl.gunorg_adjustment_highpass
+ * cl.gunorg_adjustment_lowpass
+ * cl.gunorg_highpass
+ * cl.gunorg_prev
+ * cl.hitgroundtime
+ * cl.lastongroundtime
+ * cl.oldongrounbd
+ * cl.stairsmoothtime
+ * cl.stairsmoothz
+ * cl.calcrefdef_prevtime
+ * Extra input:
+ * cl.movecmd[0].time
+ * cl.movevars_stepheight
+ * cl.movevars_timescale
+ * cl.oldtime
+ * cl.punchangle
+ * cl.punchvector
+ * cl.qw_intermission_angles
+ * cl.qw_intermission_origin
+ * cl.qw_weaponkick
+ * cls.protocol
+ * cl.time
+ * Output:
+ * cl.csqc_viewanglesfromengine
+ * cl.csqc_viewmodelmatrixfromengine
+ * cl.csqc_vieworiginfromengine
+ * r_refdef.view.matrix
+ * viewmodelmatrix_nobob
+ * viewmodelmatrix_withbob
+ */
+void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight, qboolean cldead, qboolean clintermission, const vec3_t clvelocity)
+{
+ float vieworg[3], viewangles[3], smoothtime;
+ float gunorg[3], gunangles[3];
+ matrix4x4_t tmpmatrix;
+
+ static float viewheightavg;
+ float viewheight;