The code works as intended! Change some names and comments in the meantime.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jul 2010 22:25:00 +0000 (22:25 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jul 2010 22:25:00 +0000 (22:25 +0000)
From: MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>

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

client.h
view.c

index a50f227..0666a09 100644 (file)
--- a/client.h
+++ b/client.h
@@ -978,9 +978,8 @@ typedef struct client_state_s
        double lastongroundtime;
        double hitgroundtime;
        float bob2_smooth;
-
-       float ground_hit_speed;
-       float ground_hit_counter;
+       float bobfall_speed;
+       float bobfall_swing;
 
        // don't change view angle, full screen, etc
        int intermission;
diff --git a/view.c b/view.c
index 279f445..fe3e813 100644 (file)
--- a/view.c
+++ b/view.c
@@ -712,31 +712,25 @@ void V_CalcRefdef (void)
                                                gunorg[0] += bob2vel[0];
                                                gunorg[1] += bob2vel[1];
                                        }
-                                       
-                                       
-                                       // TEST!!!
 
-                                       // get the speed while in the air, apply it while we're not
+                                       // fall bobbing code
+                                       // causes the view to swing down and back up when touching the ground
                                        if (!cl.onground)
                                        {
-                                               cl.ground_hit_speed = cl.velocity[2] * 0.1; // replace 0.1 with cvar
-                                               cl.ground_hit_counter = 1;
+                                               cl.bobfall_speed = cl.velocity[2] * 0.1; // replace 0.1 with cvar
+                                               cl.bobfall_swing = 1;
                                        }
                                        else
                                        {
-                                               if(cl.ground_hit_counter > 0)
-                                                       cl.ground_hit_counter -= 0.1; // replace 0.1 with cvar
+                                               if(cl.bobfall_swing > 0)
+                                                       cl.bobfall_swing -= 0.01; // replace 0.1 with cvar
                                                else
-                                                       cl.ground_hit_counter = 0;
+                                                       cl.bobfall_swing = 0;
 
-                                               vieworg[2] += sin(M_PI + M_PI * cl.ground_hit_counter) * -cl.ground_hit_speed;
-                                               gunorg[2] += sin(M_PI + M_PI * cl.ground_hit_counter) * -cl.ground_hit_speed;
+                                               vieworg[2] += sin(M_PI + M_PI * cl.bobfall_swing) * -cl.bobfall_speed;
+                                               gunorg[2] += sin(M_PI + M_PI * cl.bobfall_swing) * -cl.bobfall_speed;
                                        }
 
-                                       // End of TEST!!!
-                                       
-                                       
-
                                        // gun model bobbing code
                                        if (cl_bob.value || cl_bob2.value)
                                        if (cl_bobmodel.value)