]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
fix the EndIncreaseEdicts handlers as edicts beyond num_edicts are not initialized yet
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 7daca6bfbc93056598e6ee60b673b27cb394d256..eacc8d0e93947e7f9016d460a868dd6d2058583b 100644 (file)
--- a/view.c
+++ b/view.c
@@ -45,7 +45,7 @@ cvar_t cl_bobmodel_side = {CVAR_SAVE, "cl_bobmodel_side", "0.15", "gun bobbing s
 cvar_t cl_bobmodel_up = {CVAR_SAVE, "cl_bobmodel_up", "0.06", "gun bobbing upward movement amount"};
 cvar_t cl_bobmodel_speed = {CVAR_SAVE, "cl_bobmodel_speed", "7", "gun bobbing speed"};
 
-cvar_t cl_leanmodel = {CVAR_SAVE, "cl_leanmodel", "1", "enables gun leaning"};
+cvar_t cl_leanmodel = {CVAR_SAVE, "cl_leanmodel", "0", "enables gun leaning"};
 cvar_t cl_leanmodel_side_speed = {CVAR_SAVE, "cl_leanmodel_side_speed", "1", "gun leaning sideways speed"};
 cvar_t cl_leanmodel_side_limit = {CVAR_SAVE, "cl_leanmodel_side_limit", "35", "gun leaning sideways limit"};
 cvar_t cl_leanmodel_side_highpass1 = {CVAR_SAVE, "cl_leanmodel_side_highpass1", "5", "gun leaning sideways pre-highpass in 1/s"};
@@ -57,7 +57,7 @@ cvar_t cl_leanmodel_up_highpass1 = {CVAR_SAVE, "cl_leanmodel_up_highpass1", "5",
 cvar_t cl_leanmodel_up_highpass = {CVAR_SAVE, "cl_leanmodel_up_highpass", "15", "gun leaning upward highpass in 1/s"};
 cvar_t cl_leanmodel_up_lowpass = {CVAR_SAVE, "cl_leanmodel_up_lowpass", "30", "gun leaning upward lowpass in 1/s"};
 
-cvar_t cl_followmodel = {CVAR_SAVE, "cl_followmodel", "1", "enables gun following"};
+cvar_t cl_followmodel = {CVAR_SAVE, "cl_followmodel", "0", "enables gun following"};
 cvar_t cl_followmodel_side_speed = {CVAR_SAVE, "cl_followmodel_side_speed", "1", "gun following sideways speed"};
 cvar_t cl_followmodel_side_limit = {CVAR_SAVE, "cl_followmodel_side_limit", "4", "gun following sideways limit"};
 cvar_t cl_followmodel_side_highpass1 = {CVAR_SAVE, "cl_followmodel_side_highpass1", "5", "gun following sideways pre-highpass in 1/s"};
@@ -596,20 +596,24 @@ void V_CalcRefdef (void)
                                        {
                                                // try to fix the first highpass; result is NOT
                                                // perfect! TODO find a better fix
-                                               VectorCopy(cl.viewangles, cl.gunangles_highpass);
-                                               VectorCopy(cl.movement_origin, cl.gunorg_highpass);
-                                               // prevent further CHANGES caused by the high/lowpasses
-                                               // - a highpass will return the diff, a lowpass will
-                                               // return the saved value; note: the first diff will be 0!
-                                               frametime = 0;
+                                               VectorCopy(cl.viewangles, cl.gunangles_prev);
+                                               VectorCopy(cl.movement_origin, cl.gunorg_prev);
                                        }
 
                                        // 2. for the gun origin, only keep the high frequency (non-DC) parts, which is "somewhat like velocity"
+                                       VectorAdd(cl.gunorg_highpass, cl.gunorg_prev, cl.gunorg_highpass);
                                        highpass3_limited(cl.movement_origin, frametime*cl_followmodel_side_highpass1.value, cl_followmodel_side_limit.value, frametime*cl_followmodel_side_highpass1.value, cl_followmodel_side_limit.value, frametime*cl_followmodel_up_highpass1.value, cl_followmodel_up_limit.value, cl.gunorg_highpass, gunorg);
+                                       VectorCopy(cl.movement_origin, cl.gunorg_prev);
+                                       VectorSubtract(cl.gunorg_highpass, cl.gunorg_prev, cl.gunorg_highpass);
+
+                                       // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
+                                       VectorAdd(cl.gunangles_highpass, cl.gunangles_prev, cl.gunangles_highpass);
                                        cl.gunangles_highpass[PITCH] += 360 * floor((cl.viewangles[PITCH] - cl.gunangles_highpass[PITCH]) / 360 + 0.5);
                                        cl.gunangles_highpass[YAW] += 360 * floor((cl.viewangles[YAW] - cl.gunangles_highpass[YAW]) / 360 + 0.5);
                                        cl.gunangles_highpass[ROLL] += 360 * floor((cl.viewangles[ROLL] - cl.gunangles_highpass[ROLL]) / 360 + 0.5);
                                        highpass3_limited(cl.viewangles, frametime*cl_leanmodel_up_highpass1.value, cl_leanmodel_up_limit.value, frametime*cl_leanmodel_side_highpass1.value, cl_leanmodel_side_limit.value, 0, 0, cl.gunangles_highpass, gunangles);
+                                       VectorCopy(cl.viewangles, cl.gunangles_prev);
+                                       VectorSubtract(cl.gunangles_highpass, cl.gunangles_prev, cl.gunangles_highpass);
 
                                        // 3. calculate the RAW adjustment vectors
                                        gunorg[0] *= (cl_followmodel.value ? -cl_followmodel_side_speed.value : 0);
@@ -618,7 +622,7 @@ void V_CalcRefdef (void)
 
                                        gunangles[PITCH] *= (cl_leanmodel.value ? -cl_leanmodel_up_speed.value : 0);
                                        gunangles[YAW] *= (cl_leanmodel.value ? -cl_leanmodel_side_speed.value : 0);
-                                       gunangles[ROLL] = cl.viewangles[ROLL];
+                                       gunangles[ROLL] = 0;
 
                                        // 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!