From 74c715a123e45dd43b6032ae5f9e151985241dd9 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 2 May 2010 14:08:30 +0000 Subject: [PATCH] Minor optimizations From: MirceaKitsune git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10149 d7cf8633-e32d-0410-b094-e92efae38249 --- client.h | 3 +-- view.c | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/client.h b/client.h index 0c183a2c..e47a3d14 100644 --- a/client.h +++ b/client.h @@ -965,8 +965,7 @@ typedef struct client_state_s double hitgroundtime; // used by lean/follow view models - vec_t viewmodel_push_x, viewmodel_push_y; - vec3_t gunorg_follow; + vec3_t viewmodel_lean, viewmodel_drag; // don't change view angle, full screen, etc int intermission; diff --git a/view.c b/view.c index 1ed91142..5267bd5a 100644 --- a/view.c +++ b/view.c @@ -539,57 +539,57 @@ void V_CalcRefdef (void) if(cl_leanmodel_up.value && cl_leanmodel_up_speed.value * ef_speed < 1) // bad things happen if this goes over 1, so prevent the effect { // prevent the gun from doing a 360* rotation when going around the 0 <-> 360 border - if(cl.viewangles[PITCH] - cl.viewmodel_push_x >= 180) - cl.viewmodel_push_x += 360; - if(cl.viewmodel_push_x - cl.viewangles[PITCH] >= 180) - cl.viewmodel_push_x -= 360; + if(cl.viewangles[PITCH] - cl.viewmodel_lean[PITCH] >= 180) + cl.viewmodel_lean[PITCH] += 360; + if(cl.viewmodel_lean[PITCH] - cl.viewangles[PITCH] >= 180) + cl.viewmodel_lean[PITCH] -= 360; - d = cl.viewangles[PITCH] - cl.viewmodel_push_x; + d = cl.viewangles[PITCH] - cl.viewmodel_lean[PITCH]; cl_leanmodel_up_speed.value = bound(0, cl_leanmodel_up_speed.value, 1); - cl.viewmodel_push_x = bound(cl.viewangles[PITCH] - cl_leanmodel_up_limit.value, cl.viewmodel_push_x * (1 - cl_leanmodel_up_speed.value) + cl.viewangles[PITCH] * cl_leanmodel_up_speed.value, cl.viewangles[PITCH] + cl_leanmodel_up_limit.value); + cl.viewmodel_lean[PITCH] = bound(cl.viewangles[PITCH] - cl_leanmodel_up_limit.value, cl.viewmodel_lean[PITCH] * (1 - cl_leanmodel_up_speed.value) + cl.viewangles[PITCH] * cl_leanmodel_up_speed.value, cl.viewangles[PITCH] + cl_leanmodel_up_limit.value); } else - cl.viewmodel_push_x = cl.viewangles[PITCH]; + cl.viewmodel_lean[PITCH] = cl.viewangles[PITCH]; if(cl_leanmodel_side.value && cl_leanmodel_side_speed.value * ef_speed < 1) // bad things happen if this goes over 1, so prevent the effect { // prevent the gun from doing a 360* rotation when going around the 0 <-> 360 border - if(cl.viewangles[YAW] - cl.viewmodel_push_y >= 180) - cl.viewmodel_push_y += 360; - if(cl.viewmodel_push_y - cl.viewangles[YAW] >= 180) - cl.viewmodel_push_y -= 360; + if(cl.viewangles[YAW] - cl.viewmodel_lean[YAW] >= 180) + cl.viewmodel_lean[YAW] += 360; + if(cl.viewmodel_lean[YAW] - cl.viewangles[YAW] >= 180) + cl.viewmodel_lean[YAW] -= 360; - d = cl.viewangles[YAW] - cl.viewmodel_push_y; + d = cl.viewangles[YAW] - cl.viewmodel_lean[YAW]; cl_leanmodel_side_speed.value = bound(0, cl_leanmodel_side_speed.value, 1); - cl.viewmodel_push_y = bound(cl.viewangles[YAW] - cl_leanmodel_side_limit.value, cl.viewmodel_push_y * (1 - cl_leanmodel_side_speed.value) + cl.viewangles[YAW] * cl_leanmodel_side_speed.value, cl.viewangles[YAW] + cl_leanmodel_side_limit.value); + cl.viewmodel_lean[YAW] = bound(cl.viewangles[YAW] - cl_leanmodel_side_limit.value, cl.viewmodel_lean[YAW] * (1 - cl_leanmodel_side_speed.value) + cl.viewangles[YAW] * cl_leanmodel_side_speed.value, cl.viewangles[YAW] + cl_leanmodel_side_limit.value); } else - cl.viewmodel_push_y = cl.viewangles[YAW]; + cl.viewmodel_lean[YAW] = cl.viewangles[YAW]; - VectorSet(gunangles, cl.viewmodel_push_x, cl.viewmodel_push_y, viewangles[2]); + VectorSet(gunangles, cl.viewmodel_lean[PITCH], cl.viewmodel_lean[YAW], viewangles[2]); // gun model following code if(cl_followmodel_side.value) { - cl.gunorg_follow[0] = vieworg[0] - bound(-cl_followmodel_side_limit.value, cl.movement_velocity[0] * cl_followmodel_side_speed.value, cl_followmodel_side_limit.value); - cl.gunorg_follow[1] = vieworg[1] - bound(-cl_followmodel_side_limit.value, cl.movement_velocity[1] * cl_followmodel_side_speed.value, cl_followmodel_side_limit.value); + cl.viewmodel_drag[0] = vieworg[0] - bound(-cl_followmodel_side_limit.value, cl.movement_velocity[0] * cl_followmodel_side_speed.value, cl_followmodel_side_limit.value); + cl.viewmodel_drag[1] = vieworg[1] - bound(-cl_followmodel_side_limit.value, cl.movement_velocity[1] * cl_followmodel_side_speed.value, cl_followmodel_side_limit.value); } else { - cl.gunorg_follow[0] = vieworg[0]; - cl.gunorg_follow[1] = vieworg[1]; + cl.viewmodel_drag[0] = vieworg[0]; + cl.viewmodel_drag[1] = vieworg[1]; } if(cl_followmodel_up.value) { - cl.gunorg_follow[2] = vieworg[2] - bound(-cl_followmodel_up_limit.value, cl.movement_velocity[2] * cl_followmodel_up_speed.value, cl_followmodel_up_limit.value); + cl.viewmodel_drag[2] = vieworg[2] - bound(-cl_followmodel_up_limit.value, cl.movement_velocity[2] * cl_followmodel_up_speed.value, cl_followmodel_up_limit.value); } else { - cl.gunorg_follow[2] = vieworg[2]; + cl.viewmodel_drag[2] = vieworg[2]; } - VectorCopy(cl.gunorg_follow, gunorg); + VectorCopy(cl.viewmodel_drag, gunorg); // view bobbing code xyspeed = sqrt(cl.movement_velocity[0]*cl.movement_velocity[0] + cl.movement_velocity[1]*cl.movement_velocity[1]); -- 2.39.2