Fix broken recoil with r_stereo
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 30 Jun 2020 15:00:02 +0000 (15:00 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 30 Jun 2020 15:00:02 +0000 (15:00 +0000)
Patch by Gustaf Alhäll
https://gitlab.com/xonotic/darkplaces/-/merge_requests/50

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12761 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
view.c

index 7a8bf93..ac6b643 100644 (file)
@@ -125,6 +125,8 @@ int                 scr_con_margin_bottom;
 
 extern int     con_vislines;
 
+extern int cl_punchangle_applied;
+
 static void SCR_ScreenShot_f(cmd_state_t *cmd);
 static void R_Envmap_f(cmd_state_t *cmd);
 
@@ -2718,6 +2720,9 @@ void CL_UpdateScreen(void)
        double drawscreendelta;
        r_viewport_t viewport;
 
+       // TODO: Move to a better place.
+       cl_punchangle_applied = 0;
+
        if(drawscreenstart)
        {
                drawscreendelta = Sys_DirtyTime() - drawscreenstart;
diff --git a/view.c b/view.c
index 8f9b9bf..315738c 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;