From 91d848f0a2225b47721e2f0f55f1b2c57c5fbfed Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 12 Jul 2010 18:03:02 +0000 Subject: [PATCH] Fix centering, works exactly as intended now From: MirceaKitsune git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10280 d7cf8633-e32d-0410-b094-e92efae38249 --- view.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/view.c b/view.c index 22ccda2c..26f73644 100644 --- 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 -- 2.39.2