- gunorg_prev = view_origin;
- }
-
- static vector gunorg_highpass = '0 0 0';
-
- // 2. for the gun origin, only keep the high frequency (non-DC) parts, which is "somewhat like velocity"
- gunorg_highpass += gunorg_prev;
- highpass3_limited(view_origin,
- frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
- frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
- frametime * autocvar_cl_followmodel_up_highpass1, autocvar_cl_followmodel_up_limit,
- gunorg_highpass, gunorg);
- gunorg_prev = view_origin;
- gunorg_highpass -= gunorg_prev;
-
- static vector gunangles_highpass = '0 0 0';
-
- // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
- gunangles_highpass += gunangles_prev;
- PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
- YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
- ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
- highpass3_limited(view_angles,
- frametime * autocvar_cl_leanmodel_up_highpass1, autocvar_cl_leanmodel_up_limit,
- frametime * autocvar_cl_leanmodel_side_highpass1, autocvar_cl_leanmodel_side_limit,
- 0, 0,
- gunangles_highpass, gunangles);
- gunangles_prev = view_angles;
- gunangles_highpass -= gunangles_prev;
-
- // 3. calculate the RAW adjustment vectors
- gunorg.x *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
- gunorg.y *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
- gunorg.z *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_up_speed : 0);
-
- PITCH(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_up_speed : 0);
- YAW(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_side_speed : 0);
- ROLL(gunangles) = 0;
-
- static vector gunorg_adjustment_highpass;
- static vector gunorg_adjustment_lowpass;
- static vector gunangles_adjustment_highpass;
- static vector gunangles_adjustment_lowpass;
-
- // 4. perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
- // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
- highpass3(gunorg,
- frametime * autocvar_cl_followmodel_side_highpass,
- frametime * autocvar_cl_followmodel_side_highpass,
- frametime * autocvar_cl_followmodel_up_highpass,
- gunorg_adjustment_highpass, gunorg);
- lowpass3(gunorg,
- frametime * autocvar_cl_followmodel_side_lowpass,
- frametime * autocvar_cl_followmodel_side_lowpass,
- frametime * autocvar_cl_followmodel_up_lowpass,
- gunorg_adjustment_lowpass, gunorg);
- // we assume here: PITCH = 0, YAW = 1, ROLL = 2
- highpass3(gunangles,
- frametime * autocvar_cl_leanmodel_up_highpass,
- frametime * autocvar_cl_leanmodel_side_highpass,
- 0,
- gunangles_adjustment_highpass, gunangles);
- lowpass3(gunangles,
- frametime * autocvar_cl_leanmodel_up_lowpass,
- frametime * autocvar_cl_leanmodel_side_lowpass,
- 0,
- gunangles_adjustment_lowpass, gunangles);
+ gunangles_highpass -= gunangles_prev;
+
+ PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
+ YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
+
+ // we assume here: PITCH = 0, YAW = 1, ROLL = 2
+ frac = avg_factor(autocvar_cl_leanmodel_highpass);
+ highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
+ frac = avg_factor(autocvar_cl_leanmodel_lowpass);
+ lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
+
+ gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
+ this.angles += gunangles;
+ }
+