]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
progs: Implement new extension DP_QC_FS_SEARCH_PACKFILE
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 5683ff097dd074455fdddb2a87c513f0b5147bbd..315738c2289b0b0c4599320a8b951f1b880edc0c 100644 (file)
--- a/view.c
+++ b/view.c
@@ -144,6 +144,7 @@ cvar_t v_yshearing = {CVAR_CLIENT, "v_yshearing", "0", "be all out of gum (set t
 
 float  v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
+int cl_punchangle_applied;
 
 /*
 ===============
@@ -684,8 +685,15 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                        // angles
                        if (cldead && v_deathtilt.integer)
                                viewangles[ROLL] = v_deathtiltangle.value;
-                       VectorAdd(viewangles, cl.punchangle, viewangles);
+
+                       // Hanicef: don't apply punchangle twice if the scene is rendered more than once.
+                       if (!cl_punchangle_applied)
+                       {
+                               VectorAdd(viewangles, cl.punchangle, viewangles);
+                               cl_punchangle_applied = 1;
+                       }
                        viewangles[ROLL] += V_CalcRoll(clviewangles, clvelocity);
+
                        if (v_dmg_time > 0)
                        {
                                viewangles[ROLL] += v_dmg_time/v_kicktime.value*v_dmg_roll;
@@ -696,7 +704,7 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                        if (!cldead)
                        {
                                double xyspeed, bob, bobfall;
-                               double cycle; // double-precision because cl.time can be a very large number, where float would get stuttery at high time values
+                               double bobcycle = 0, cycle; // double-precision because cl.time can be a very large number, where float would get stuttery at high time values
                                vec_t frametime;
 
                                frametime = (cl.time - cl.calcrefdef_prevtime) * cl.movevars_timescale;
@@ -793,9 +801,9 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                        cycle = cl.time / cl_bobcycle.value;
                                        cycle -= (int) cycle;
                                        if (cycle < cl_bobup.value)
-                                               cycle = sin(M_PI * cycle / cl_bobup.value);
+                                               bobcycle = cycle = sin(M_PI * cycle / cl_bobup.value);
                                        else
-                                               cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
+                                               bobcycle = cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
                                        // bob is proportional to velocity in the xy plane
                                        // (don't count Z, or jumping messes it up)
                                        bob = xyspeed * cl_bob.value;
@@ -919,7 +927,7 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                        bob = bspeed * cl_bobmodel_up.value * cl_viewmodel_scale.value * cos (s * 2) * t;
                                        VectorMA (gunorg, bob, up, gunorg);
                                        // Classic Quake bobbing
-                                       bob = (cl_bobmodel_classic.integer ? xyspeed * cl_bob.value * 0.25 * cycle : bspeed * cl_bobmodel_forward.value * cos(s * 2) * t) * cl_viewmodel_scale.value;
+                                       bob = (cl_bobmodel_classic.integer ? xyspeed * cl_bob.value * 0.25 * bobcycle : bspeed * cl_bobmodel_forward.value * cos(s * 2) * t) * cl_viewmodel_scale.value;
                                        VectorMA (gunorg, (cl_bobmodel_classic.integer ? (bob > 1 ? 1 : bob) : bob), forward, gunorg);
                                }
                        }