From: Mircea Kitsune Date: Thu, 31 Mar 2011 14:58:03 +0000 (+0300) Subject: Don't allow the camera to go through walls. Thanks tZork for the help :) X-Git-Tag: xonotic-v0.5.0~268^2^2~30 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5786dc06d6269b2949ec045ab89c2a7603b20782;p=xonotic%2Fxonotic-data.pk3dir.git Don't allow the camera to go through walls. Thanks tZork for the help :) --- diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 1f667721b..029f92e0f 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -410,16 +410,24 @@ void CSQC_UpdateView(float w, float h) if((autocvar_cl_chase_death && getstati(STAT_HEALTH) <= 0 && !intermission) || (autocvar_cl_chase_intermission && intermission) && intermission <= 1) // not during the map voting screen { if(!autocvar_chase_active) - cvar_set("chase_active", "-1"); // -1 enables chase_active as well as marking it as enabled by this code, and not by the user (which would be 1) + cvar_set("chase_active", "-1"); // -1 enables chase_active as well as marking it as set by this code, and not by the user (which would be 1) // make the camera smooth back if(autocvar_cl_chase_speed && chase_current_distance < autocvar_cl_chase_distance) - chase_current_distance += autocvar_cl_chase_speed * (autocvar_cl_chase_distance - chase_current_distance) * frametime; + chase_current_distance += autocvar_cl_chase_speed * (autocvar_cl_chase_distance - chase_current_distance) * frametime; // slow down smoothly else if(chase_current_distance != autocvar_cl_chase_distance) chase_current_distance = autocvar_cl_chase_distance; - makevectors(view_angles); - R_SetView(VF_ORIGIN, pmove_org - view_forward * chase_current_distance); + vector target_origin; + target_origin = pmove_org - view_forward * chase_current_distance; + + // don't allow the camera to go through walls + traceline(pmove_org, target_origin, MOVE_NORMAL, self); + if(trace_fraction == 1) + { + makevectors(view_angles); + R_SetView(VF_ORIGIN, target_origin); + } } else if(autocvar_chase_active < 0) {