From 7561b9409abbb9d02068d5ebf8d4a802eea8ef4e Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 2 May 2010 14:03:49 +0000 Subject: [PATCH] TODO 1 done. Gun no longer spins when when passing the 0 <-> 360 border (I miss such obvious maths :P) From: MirceaKitsune git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10124 d7cf8633-e32d-0410-b094-e92efae38249 --- view.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/view.c b/view.c index 7b915b4b..d3cf4345 100644 --- a/view.c +++ b/view.c @@ -586,13 +586,20 @@ void V_CalcRefdef (void) // gun model leaning code - // TODO 1: Fix bug where model does a 360* turn when YAW jumps around the 0 - 360 rotation border. - // [18:53:17] <@div0> search for AnglesFromVectors and AngleVectors - // [18:53:27] <@div0> I am quite sure interpolation (lerp) uses it - + // TODO 1 (done): Fix bug where model does a 360* turn when YAW jumps around the 0 - 360 rotation border // TODO 2: Implement limits (weapon model must not lean past a certain limit) + // TODO 3: Cvar everything once the first TODOs are ready + + // prevent the gun from doing a 360* rotation when going around the 0 <-> 360 border + if(cl.viewangles[YAW] - viewmodel_push_y >= 180) + viewmodel_push_y += 360; + if(viewmodel_push_y - cl.viewangles[YAW] >= 180) + viewmodel_push_y -= 360; - // TODO 3: Cvar everything once the first TODOs are ready. + if(cl.viewangles[PITCH] - viewmodel_push_x >= 180) + viewmodel_push_x += 360; + if(viewmodel_push_x - cl.viewangles[PITCH] >= 180) + viewmodel_push_x -= 360; if(viewmodel_push_x < cl.viewangles[PITCH]) viewmodel_push_x += (cl.viewangles[PITCH] - viewmodel_push_x) * 0.01; @@ -605,6 +612,8 @@ void V_CalcRefdef (void) viewmodel_push_y -= (viewmodel_push_y - cl.viewangles[YAW]) * 0.01; VectorSet(gunangles, viewmodel_push_x, viewmodel_push_y, viewangles[2]); + + // void AnglesFromVectors (vec3_t angles, const vec3_t forward, const vec3_t up, qboolean flippitch); } } // calculate a view matrix for rendering the scene -- 2.39.2