]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/weaponmodel_effects_tweaks' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 28 Feb 2016 06:26:56 +0000 (06:26 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 28 Feb 2016 06:26:56 +0000 (06:26 +0000)
Weaponmodel effects tweaks

See merge request !286

defaultXonotic.cfg
qcsrc/client/view.qc

index 50e0ad7e724bcf15dc9466f4940d0e08563a1a9a..8ef0f0da26771236f38ee1cbf93479d054d36d44 100644 (file)
@@ -161,12 +161,12 @@ cl_bobfallcycle 3 "speed of the bobfall swing"
 cl_bobfallspeed 200 "necessary amount of speed for bob-falling to occur"
 cl_bobmodel 1 // whether to have gun model move around on screen when moving (only works if cl_bob is not 0), default is 1
 cl_bobmodel_side 0.2 // amount the gun sways to the sides
-cl_bobmodel_speed 5 // rate at which the gun sways
+cl_bobmodel_speed 10 // rate at which the gun sways
 cl_bobmodel_up 0.1 // amount the gun sways up and down
 
 cl_followmodel 1 // enables weapon pushing / pulling effect when walking
 seta cl_followmodel_speed 0.3 "gun following speed"
-seta cl_followmodel_limit 1000 "gun following limit"
+seta cl_followmodel_limit 135 "gun following limit"
 seta cl_followmodel_velocity_absolute 0 "make the effect ignore velocity direction changes (side effect: it causes a glitch when teleporting / passing through a warpzone)"
 seta cl_followmodel_velocity_lowpass 0.05 "gun following velocity lowpass averaging time"
 seta cl_followmodel_highpass 0.05 "gun following highpass averaging time"
@@ -174,7 +174,7 @@ seta cl_followmodel_lowpass 0.03 "gun following lowpass averaging time"
 
 cl_leanmodel 1 // enables weapon leaning effect when looking around
 seta cl_leanmodel_speed 0.3 "gun leaning speed"
-seta cl_leanmodel_limit 1000 "gun leaning limit"
+seta cl_leanmodel_limit 30 "gun leaning limit"
 seta cl_leanmodel_highpass1 0.2 "gun leaning pre-highpass averaging time"
 seta cl_leanmodel_highpass 0.2 "gun leaning highpass averaging time"
 seta cl_leanmodel_lowpass 0.05 "gun leaning lowpass averaging time"
index d7207fc6f833aa71d2bcf5680a7736d55b26ea3e..edf56a87d0864fb80529df007349020a4c31a859 100644 (file)
@@ -40,14 +40,15 @@ float autocvar_cl_bobmodel_up;
 
 float autocvar_cl_followmodel;
 float autocvar_cl_followmodel_speed = 0.3;
-float autocvar_cl_followmodel_limit = 1000;
+float autocvar_cl_followmodel_limit = 135;
 float autocvar_cl_followmodel_velocity_lowpass = 0.05;
 float autocvar_cl_followmodel_highpass = 0.05;
 float autocvar_cl_followmodel_lowpass = 0.03;
+bool autocvar_cl_followmodel_velocity_absolute;
 
 float autocvar_cl_leanmodel;
 float autocvar_cl_leanmodel_speed = 0.3;
-float autocvar_cl_leanmodel_limit = 1000;
+float autocvar_cl_leanmodel_limit = 30;
 float autocvar_cl_leanmodel_highpass1 = 0.2;
 float autocvar_cl_leanmodel_highpass = 0.2;
 float autocvar_cl_leanmodel_lowpass = 0.05;
@@ -82,12 +83,6 @@ float autocvar_cl_leanmodel_lowpass = 0.05;
        lowpass(value.y, frac, ref_store.y, ref_out.y); \
 } MACRO_END
 
-#define lowpass2_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
-{ \
-       lowpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
-       lowpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
-} MACRO_END
-
 #define highpass2(value, frac, ref_store, ref_out) MACRO_BEGIN \
 { \
        highpass(value.x, frac, ref_store.x, ref_out.x); \
@@ -114,21 +109,6 @@ float autocvar_cl_leanmodel_lowpass = 0.05;
        highpass(value.z, frac, ref_store.z, ref_out.z); \
 } MACRO_END
 
-#define highpass3_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
-{ \
-       highpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
-       highpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
-       highpass_limited(value.z, frac, limit, ref_store.z, ref_out.z); \
-} MACRO_END
-
-#define lowpass3_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
-{ \
-       lowpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
-       lowpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
-       lowpass_limited(value.z, frac, limit, ref_store.z, ref_out.z); \
-} MACRO_END
-
-bool autocvar_cl_followmodel_velocity_absolute;
 void viewmodel_animate(entity this)
 {
        static float prevtime;
@@ -143,13 +123,11 @@ void viewmodel_animate(entity this)
        bool clonground = !(view.anim_implicit_state & ANIMIMPLICITSTATE_INAIR);
        static bool oldonground;
        static float hitgroundtime;
-       static float lastongroundtime;
        if (clonground)
        {
                float f = time; // cl.movecmd[0].time
                if (!oldonground)
                        hitgroundtime = f;
-               lastongroundtime = f;
        }
        oldonground = clonground;
 
@@ -177,8 +155,12 @@ void viewmodel_animate(entity this)
                        vel.z = view.velocity * up;
                }
 
+               vel.x = bound(vel_average.x - autocvar_cl_followmodel_limit, vel.x, vel_average.x + autocvar_cl_followmodel_limit);
+               vel.y = bound(vel_average.y - autocvar_cl_followmodel_limit, vel.y, vel_average.y + autocvar_cl_followmodel_limit);
+               vel.z = bound(vel_average.z - autocvar_cl_followmodel_limit, vel.z, vel_average.z + autocvar_cl_followmodel_limit);
+
                frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
-               lowpass3_limited(vel, frac, autocvar_cl_followmodel_limit, vel_average, gunorg);
+               lowpass3(vel, frac, vel_average, gunorg);
 
                gunorg *= -autocvar_cl_followmodel_speed * 0.042;
 
@@ -254,35 +236,27 @@ void viewmodel_animate(entity this)
        {
                // calculate for swinging gun model
                // the gun bobs when running on the ground, but doesn't bob when you're in the air.
-               // Sajt: I tried to smooth out the transitions between bob and no bob, which works
-               // for the most part, but for some reason when you go through a message trigger or
-               // pick up an item or anything like that it will momentarily jolt the gun.
-               float bspeed;
-               float t = 1;
-               float s = time * autocvar_cl_bobmodel_speed;
+               static float bobmodel_scale = 0;
+               static float time_ofs = 0; // makes the effect always restart in the same way
                if (clonground)
                {
-                       if (time - hitgroundtime < 0.2)
-                       {
-                               // just hit the ground, speed the bob back up over the next 0.2 seconds
-                               t = time - hitgroundtime;
-                               t = bound(0, t, 0.2);
-                               t *= 5;
-                       }
+                       if (time - hitgroundtime > 0.05)
+                               bobmodel_scale = min(1, bobmodel_scale + frametime * 5);
                }
                else
+                       bobmodel_scale = max(0, bobmodel_scale - frametime * 5);
+               if(bobmodel_scale && xyspeed)
                {
-                       // recently left the ground, slow the bob down over the next 0.2 seconds
-                       t = time - lastongroundtime;
-                       t = 0.2 - bound(0, t, 0.2);
-                       t *= 5;
-               }
-               bspeed = xyspeed * 0.01;
-               vector gunorg = '0 0 0';
-               gunorg.y += bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
-               gunorg.z += bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
+                       float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale;
+                       float s = (time - time_ofs) * autocvar_cl_bobmodel_speed;
+                       vector gunorg = '0 0 0';
+                       gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s);
+                       gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2);
 
-               this.origin += gunorg;
+                       this.origin += gunorg;
+               }
+               else
+                       time_ofs = time;
        }
 }