]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix centering, works exactly as intended now
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Jul 2010 18:03:02 +0000 (18:03 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Jul 2010 18:03:02 +0000 (18:03 +0000)
From: MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>

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

view.c

diff --git a/view.c b/view.c
index 22ccda2c4751f1e5bb53292e9fe92cf340099897..26f7364469c2c678e2d5442e1f6016873a39349c 100644 (file)
--- a/view.c
+++ b/view.c
@@ -666,7 +666,7 @@ void V_CalcRefdef (void)
                                        }
 
                                        // view rolling code
-                                       // TODO 1: Make it work around the center rather than the left side
+                                       // TODO 1 (DONE): Make it work around the center rather than the left side
                                        // TODO 2: Make the roll smoothly return to 0 when you stop touching the ground, rather than instantly
                                        // TODO 3: Write cvars to darkplaces.txt, set better defaults and possibly disable by default once the first TODOs are ready
                                        if (cl_bobroll.value && cl_bobrollcycle.value)
@@ -674,14 +674,13 @@ void V_CalcRefdef (void)
                                        {
                                                cycle2 = cl.time / cl_bobrollcycle.value;
                                                cycle2 -= (int) cycle2;
-                                               if (cycle2 < cl_bobrollup.value)
-                                                       cycle2 = sin(M_PI * cycle2 / cl_bobrollup.value);
+                                               if (cycle2 < 0.5)
+                                                       cycle2 = sin(M_PI * cycle2 / 0.5);
                                                else
-                                                       cycle2 = sin(M_PI + M_PI * (cycle2-cl_bobrollup.value)/(1.0 - cl_bobrollup.value));
-
-                                               bobroll = xyspeed * cl_bobroll.value;
-                                               bobroll = bobroll*0.3 + bobroll*0.7*cycle2;
-                                               viewangles[2] = bound(-5, bobroll, 5);
+                                                       cycle2 = sin(M_PI + M_PI * (cycle2-0.5)/0.5);
+                                               cycle2 *= cl_bobrollup.value;
+                                               bobroll = xyspeed * cl_bobroll.value * cycle2;
+                                               viewangles[2] = bound(-45, bobroll, 45);
                                        }
 
                                        // gun model bobbing code