]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
Refactor game/mod cvar defaults
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 7c70c058787a615e0ac6aa2222e526b6eed03af8..e8eaec7e26a7b5a81d3fa500124c1d693ee674a1 100644 (file)
--- a/view.c
+++ b/view.c
@@ -32,8 +32,8 @@ when crossing a water boudnary.
 
 */
 
-cvar_t cl_rollspeed = {CF_CLIENT, "cl_rollspeed", "200", "how much strafing is necessary to tilt the view"};
-cvar_t cl_rollangle = {CF_CLIENT, "cl_rollangle", "2.0", "how much to tilt the view when strafing"};
+cvar_t cl_rollspeed = {CF_CLIENT | CF_ARCHIVE, "cl_rollspeed", "200", "how much strafing is necessary to tilt the view"};
+cvar_t cl_rollangle = {CF_CLIENT | CF_ARCHIVE, "cl_rollangle", "2.0", "how much to tilt the view when strafing"};
 
 cvar_t cl_bob = {CF_CLIENT | CF_ARCHIVE, "cl_bob","0.02", "view bobbing amount"};
 cvar_t cl_bobcycle = {CF_CLIENT | CF_ARCHIVE, "cl_bobcycle","0.6", "view bobbing speed"};
@@ -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"};
@@ -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;
 
@@ -892,10 +892,8 @@ void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewa
                                        }
                                        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;
 
@@ -974,7 +972,7 @@ void V_MakeViewIsometric(void)
        matrix4x4_t modifiedview;
        matrix4x4_t modify;
        vec3_t forward, left, up, org;
-       float t[4][4];
+       float t[16];
 
        r_refdef.view.useperspective = false;
        r_refdef.view.usevieworiginculling = !r_trippy.value && v_isometric_usevieworiginculling.integer;
@@ -985,23 +983,23 @@ void V_MakeViewIsometric(void)
        r_refdef.view.ortho_x = r_refdef.view.frustum_x; // used by VM_CL_R_SetView
        r_refdef.view.ortho_y = r_refdef.view.frustum_y; // used by VM_CL_R_SetView
 
-       t[0][0] = v_isometric_xx.value;
-       t[0][1] = v_isometric_xy.value;
-       t[0][2] = v_isometric_xz.value;
-       t[0][3] = 0.0f;
-       t[1][0] = v_isometric_yx.value;
-       t[1][1] = v_isometric_yy.value;
-       t[1][2] = v_isometric_yz.value;
-       t[1][3] = 0.0f;
-       t[2][0] = v_isometric_zx.value;
-       t[2][1] = v_isometric_zy.value;
-       t[2][2] = v_isometric_zz.value;
-       t[2][3] = 0.0f;
-       t[3][0] = 0.0f;
-       t[3][1] = 0.0f;
-       t[3][2] = 0.0f;
-       t[3][3] = 1.0f;
-       Matrix4x4_FromArrayFloatGL(&modify, t[0]);
+       t[0]  = v_isometric_xx.value;
+       t[1]  = v_isometric_xy.value;
+       t[2]  = v_isometric_xz.value;
+       t[3]  = 0.0f;
+       t[4]  = v_isometric_yx.value;
+       t[5]  = v_isometric_yy.value;
+       t[6]  = v_isometric_yz.value;
+       t[7]  = 0.0f;
+       t[8]  = v_isometric_zx.value;
+       t[9]  = v_isometric_zy.value;
+       t[10] = v_isometric_zz.value;
+       t[11] = 0.0f;
+       t[12] = 0.0f;
+       t[13] = 0.0f;
+       t[14] = 0.0f;
+       t[15] = 1.0f;
+       Matrix4x4_FromArrayFloatGL(&modify, t);
 
        // if the orientation is locked, extract the origin and create just a translate matrix to start with
        if (v_isometric_locked_orientation.integer)
@@ -1061,6 +1059,7 @@ void V_CalcViewBlend(void)
                supercontents = CL_PointSuperContents(vieworigin);
                if (supercontents & SUPERCONTENTS_LIQUIDSMASK)
                {
+                       cl.view_underwater = true;
                        r_refdef.frustumscale_x *= 1 - (((sin(cl.time * 4.7) + 1) * 0.015) * r_waterwarp.value);
                        r_refdef.frustumscale_y *= 1 - (((sin(cl.time * 3.0) + 1) * 0.015) * r_waterwarp.value);
                        if (supercontents & SUPERCONTENTS_LAVA)
@@ -1085,6 +1084,7 @@ void V_CalcViewBlend(void)
                }
                else
                {
+                       cl.view_underwater = false;
                        cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 0;
                        cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 0;
                        cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 0;