cl_followmodel 1 // enables weapon pushing / pulling effect when walking
seta cl_followmodel_speed 0.3 "gun following speed"
seta cl_followmodel_limit 1000 "gun following limit"
+seta cl_followmodel_velocity_absolute 0 "make the effect ignore velocity direction changes (side effect: it causes a glitch when teleporting / passing through a warpzone)"
seta cl_followmodel_velocity_lowpass 0.05 "gun following velocity lowpass averaging time"
seta cl_followmodel_highpass 0.05 "gun following highpass averaging time"
seta cl_followmodel_lowpass 0.03 "gun following lowpass averaging time"
lowpass_limited(value.z, frac, limit, ref_store.z, ref_out.z); \
} MACRO_END
+bool autocvar_cl_followmodel_velocity_absolute;
void viewmodel_animate(entity this)
{
static float prevtime;
static vector gunorg_adjustment_lowpass;
vector vel;
- vector forward, right = '0 0 0', up = '0 0 0';
- MAKEVECTORS(makevectors, view_angles, forward, right, up);
- vel.x = view.velocity * forward;
- vel.y = view.velocity * right * -1;
- vel.z = view.velocity * up;
+ if(autocvar_cl_followmodel_velocity_absolute)
+ vel = view.velocity;
+ else
+ {
+ vector forward, right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ vel.x = view.velocity * forward;
+ vel.y = view.velocity * right * -1;
+ vel.z = view.velocity * up;
+ }
+
frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
lowpass3_limited(vel, frac, autocvar_cl_followmodel_limit, vel_average, gunorg);
frac = avg_factor(autocvar_cl_followmodel_lowpass);
lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
+ if(autocvar_cl_followmodel_velocity_absolute)
+ {
+ vector fixed_gunorg;
+ vector forward, right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ fixed_gunorg.x = gunorg * forward;
+ fixed_gunorg.y = gunorg * right * -1;
+ fixed_gunorg.z = gunorg * up;
+ gunorg = fixed_gunorg;
+ }
+
this.origin += gunorg;
}