From 2e5b35f90664d0dd15e371d81895216589362e3c Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@xonotic.org>
Date: Fri, 27 May 2011 22:23:04 +0200
Subject: [PATCH] do the nearclip hack in the chasecam too

---
 qcsrc/client/View.qc        | 10 ++++++++++
 qcsrc/warpzonelib/client.qh |  1 +
 2 files changed, 11 insertions(+)

diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc
index 20bebc764..5868c56b0 100644
--- a/qcsrc/client/View.qc
+++ b/qcsrc/client/View.qc
@@ -455,6 +455,16 @@ void CSQC_UpdateView(float w, float h)
 
 			R_SetView(VF_ORIGIN, trace_endpos);
 			R_SetView(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
+
+			vector o, corner0, corner1, corner2, corner3, nearclip;
+			nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
+			corner0 = cs_unproject('0 0 0' + nearclip);
+			corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
+			corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
+			corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
+			o = trace_endpos;
+			o = o + WarpZone_FixNearClip(trace_endpos, corner0, corner1, corner2, corner3);
+			R_SetView(VF_ORIGIN, o);
 		}
 		else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
 		{
diff --git a/qcsrc/warpzonelib/client.qh b/qcsrc/warpzonelib/client.qh
index d5b3ac2fc..46296bb34 100644
--- a/qcsrc/warpzonelib/client.qh
+++ b/qcsrc/warpzonelib/client.qh
@@ -7,6 +7,7 @@ vector warpzone_fixview_angles;
 vector warpzone_fixview_cl_viewangles;
 void WarpZone_FixView(); // this saves the previous values
 void WarpZone_UnFixView(); // and restores them
+vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3);
 
 void WarpZone_Init();
 void WarpZone_Shutdown();
-- 
2.39.5