]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
zone: Add Z_ counterparts for Realloc and strdup
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 333c1c269b18ca00b95fd9d9675a6d5f5a975c35..f3f59b428ce6e494e8b0313e09d8b03bd47aa9bb 100644 (file)
--- a/view.c
+++ b/view.c
@@ -45,12 +45,12 @@ cvar_t cl_bobfall = {CF_CLIENT | CF_ARCHIVE, "cl_bobfall","0", "how much the vie
 cvar_t cl_bobfallcycle = {CF_CLIENT | CF_ARCHIVE, "cl_bobfallcycle","3", "speed of the bobfall swing"};
 cvar_t cl_bobfallminspeed = {CF_CLIENT | CF_ARCHIVE, "cl_bobfallminspeed","200", "necessary amount of speed for bob-falling to occur"};
 cvar_t cl_bobmodel = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel", "1", "enables gun bobbing"};
-cvar_t cl_bobmodel_side = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_side", "0", "gun bobbing sideways sway amount"};
-cvar_t cl_bobmodel_up = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_up", "0", "gun bobbing upward movement amount"};
-cvar_t cl_bobmodel_forward = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_forward", "0.25", "gun bobbing forward movement amount"};
+cvar_t cl_bobmodel_side = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_side", "0.15", "gun bobbing sideways sway amount"};
+cvar_t cl_bobmodel_up = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_up", "0.06", "gun bobbing upward movement amount"};
+cvar_t cl_bobmodel_forward = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_forward", "0", "gun bobbing forward movement amount"};
 cvar_t cl_bobmodel_classic = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_classic", "1", "classic Quake-style forward gun bobbing"};
-cvar_t cl_bobmodel_speed = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_speed", "6", "gun bobbing speed"};
-cvar_t cl_bob_limit = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit", "4", "limits bobbing to this much distance from view_ofs"};
+cvar_t cl_bobmodel_speed = {CF_CLIENT | CF_ARCHIVE, "cl_bobmodel_speed", "7", "gun bobbing speed"};
+cvar_t cl_bob_limit = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit", "7", "limits bobbing to this much distance from view_ofs"};
 cvar_t cl_bob_limit_heightcheck = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit_heightcheck", "0", "check ceiling and floor height against cl_bob_limit and scale down all view bobbing if could result in camera being in solid"};
 cvar_t cl_bob_limit_heightcheck_dontcrosswatersurface = {CF_CLIENT | CF_ARCHIVE, "cl_bob_limit_heightcheck_dontcrosswatersurface", "1", "limit cl_bob_limit to not crossing liquid surfaces also"};
 cvar_t cl_bob_velocity_limit = {CF_CLIENT | CF_ARCHIVE, "cl_bob_velocity_limit", "400", "limits the xyspeed value in the bobbing code"};
@@ -645,8 +645,8 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                        VectorAdd(vieworg, cl.punchvector, vieworg);
                        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 xyspeed = 0, bob = 0, bobfall = 0;
+                               double cycle = 0; // 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;
@@ -711,7 +711,7 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                // vertical view bobbing code
                                if (cl_bob.value && cl_bobcycle.value)
                                {
-                                       float bob_limit = cl_bob_limit.value;
+                                       float bob_limit = cl_bobmodel_classic.integer ? 4 : cl_bob_limit.value;
 
                                        if (cl_bob_limit_heightcheck.integer)
                                        {
@@ -750,7 +750,7 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                        // (don't count Z, or jumping messes it up)
                                        bob = xyspeed * cl_bob.value;
                                        bob = bob*0.3 + bob*0.7*sin(cycle);
-                                       bob = bound(-7, bob, 4);
+                                       bob = bound(-7, bob, bob_limit);
 
                                        vieworg[2] += bob;
 
@@ -889,18 +889,14 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                                VectorMA (gunorg, bob, right, gunorg);
                                                bob = bspeed * cl_bobmodel_up.value * cl_viewmodel_scale.value * cos (s * 2) * t;
                                                VectorMA (gunorg, bob, up, gunorg);
-
-                                               //bob = (bspeed * cl_bobmodel_forward.value * cos(s * 2) * t) * cl_viewmodel_scale.value;
-
                                        }
                                        else
                                        {
-                                               vieworg[2] += viewheight;
                                                // Classic Quake bobbing
-                                               gunorg[2] += viewheight;
-                                               for (int i=0 ; i<3 ; i++)
+                                               for (int i = 0; i < 3; i++)
                                                        gunorg[i] += forward[i]*bob*0.4;
                                                gunorg[2] += bob;
+
                                                if (r_viewmodel_quake.value)
                                                {
                                                        if (scr_viewsize.value == 110)