From fab7536add6809d5a70fe1f49f975a4407749f56 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 1 Feb 2012 14:41:39 +0200 Subject: [PATCH] Fix camera angles not getting stuck with the latest engine. With this occasion, also port the intermission chasecam (does not interfere with intermission artwork) --- data/qcsrc/client/View.qc | 53 ++++++++++++++++++++---------- data/qcsrc/client/csqc_builtins.qc | 4 +++ docs/TODO.txt | 2 -- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 1a3cf5ca..33a38f08 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -244,7 +244,6 @@ void PostInit(void); void CSQC_Demo_Camera(); float Sbar_WouldDrawScoreboard (); float last_health, last_spectatee; -float view_set; float camera_mode; float reticle_type; float chase_active_old; @@ -257,6 +256,7 @@ float old_blurradius, old_bluralpha, old_cartoon_intensity; float stomachsplash_alpha; float eventchase_current_distance; float helper_pause, helper_health, helper_armor, helper_ammo, helper_speed, helper_stomachload; +vector freeze_org, freeze_ang; vector myhealth_gentlergb; vector liquidcolor_prev; vector damage_blurpostprocess, content_blurpostprocess; @@ -381,10 +381,13 @@ void CSQC_UpdateView(float w, float h) // event chase camera if(cvar("chase_active") <= 0) // greater than 0 means it's enabled manually, and this code is skipped { - if(!getstati(STAT_VORE_EATEN) && spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission)) + if(spectatee_status >= 0 && (cvar("cl_eventchase_death") && getstati(STAT_HEALTH) <= 0 && !intermission) || intermission) { + // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.) + vector current_view_origin = getpropertyvec(VF_ORIGIN); + // We must enable chase_active to get a third person view (weapon viewmodel hidden and own player model showing). - // Ideally, there should be another way to enable third person cameras, such as through R_SetView() + // Ideally, there should be another way to enable third person cameras, such as through setproperty() if(!cvar("chase_active")) cvar_set("chase_active", "-1"); // -1 enables chase_active while marking it as set by this code, and not by the user (which would be 1) @@ -397,15 +400,15 @@ void CSQC_UpdateView(float w, float h) vector eventchase_target_origin; makevectors(view_angles); // pass 1, used to check where the camera would go and obtain the trace_fraction - eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance; - - traceline(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self); + eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance; + WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self); // pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls // The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through - eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1); + eventchase_target_origin = current_view_origin - v_forward * eventchase_current_distance * (trace_fraction - 0.1); + WarpZone_TraceLine(current_view_origin, eventchase_target_origin, MOVE_WORLDONLY, self); - R_SetView(VF_ORIGIN, eventchase_target_origin); - R_SetView(VF_ANGLES, view_angles); + setproperty(VF_ORIGIN, trace_endpos); + setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles)); } else if(cvar("chase_active") < 0) // time to disable chase_active if it was set by this code { @@ -444,18 +447,26 @@ void CSQC_UpdateView(float w, float h) cvar_set("v_idlescale", ftos(apply_idlescale)); } - // Render the Scene - if(!intermission || !view_set) + // do lockview after event chase camera so that it still applies whenever necessary. + if(intermission > 1) + { + setproperty(VF_ORIGIN, freeze_org); + setproperty(VF_ANGLES, freeze_ang); + } + else { - view_origin = pmove_org + vo; - view_angles = input_angles; - makevectors(view_angles); - view_forward = v_forward; - view_right = v_right; - view_up = v_up; - view_set = 1; + freeze_org = getpropertyvec(VF_ORIGIN); + freeze_ang = getpropertyvec(VF_ANGLES); } + // Render the Scene + view_origin = getpropertyvec(VF_ORIGIN); + view_angles = getpropertyvec(VF_ANGLES); + makevectors(view_angles); + view_forward = v_forward; + view_right = v_right; + view_up = v_up; + vid_width = w; vid_height = h; @@ -544,6 +555,12 @@ void CSQC_UpdateView(float w, float h) // ALWAYS Clear Current Scene First R_ClearScene(); + if(checkextension("DP_CSQC_ROTATEMOVES")) + { + setproperty(VF_ORIGIN, view_origin); + setproperty(VF_ANGLES, view_angles); + } + // Assign Standard Viewflags // Draw the World (and sky) R_SetView(VF_DRAWWORLD, 1); diff --git a/data/qcsrc/client/csqc_builtins.qc b/data/qcsrc/client/csqc_builtins.qc index a582a9d0..9933b3ff 100644 --- a/data/qcsrc/client/csqc_builtins.qc +++ b/data/qcsrc/client/csqc_builtins.qc @@ -83,6 +83,10 @@ void () R_RenderScene = #304; void (vector org, float radius, vector rgb) R_AddDynamicLight = #305; void () R_CalcRefDef = #306; +float (float property, ...) setproperty = #303; +float (float property) getproperty = #309; +vector (float property) getpropertyvec = #309; + vector (vector v) cs_unproject = #310; vector (vector v) cs_project = #311; diff --git a/docs/TODO.txt b/docs/TODO.txt index 70e3f88f..857a6966 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -120,8 +120,6 @@ - 0.7 BUG: Default player model is broken? -- 0.7 BUG: With the latest engine, the view is no longer locked after match end, and you can still look around. See what changed in Xonotic and how to fix this. - - 0.7 | 0.8: Make the volume of footstep sounds depend on player size. - 0.7: Is the proper blue color used in team games, with the new colormap? \ No newline at end of file -- 2.39.2