//cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed));
}
+vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3)
+{
+ float nearclipdistance;
+ vector mi, ma;
+ entity e;
+ float pd;
+
+ mi_x = min5(o_x, c0_x, c1_x, c2_x, c3_x);
+ ma_x = max5(o_x, c0_x, c1_x, c2_x, c3_x);
+ mi_y = min5(o_y, c0_y, c1_y, c2_y, c3_y);
+ ma_y = max5(o_y, c0_y, c1_y, c2_y, c3_y);
+ mi_z = min5(o_z, c0_z, c1_z, c2_z, c3_z);
+ ma_z = max5(o_z, c0_z, c1_z, c2_z, c3_z);
+
+ e = WarpZone_Find(mi, ma);
+ if(e)
+ {
+ if(WarpZone_PlaneDist(e, o) < 0)
+ return '0 0 0';
+ // can't really be, though, but if it is, this is not my warpzone, but a random different one in the same mins/maxs
+ pd = min(
+ WarpZone_PlaneDist(e, c0),
+ WarpZone_PlaneDist(e, c1),
+ WarpZone_PlaneDist(e, c2),
+ WarpZone_PlaneDist(e, c3)
+ );
+ if(pd < 0)
+ return e.warpzone_forward * -pd;
+ }
+
+ return '0 0 0';
+}
+
float warpzone_saved;
vector warpzone_saved_origin;
vector warpzone_saved_angles;
void WarpZone_FixView()
{
float pd, f;
+ vector o;
entity e;
+ vector corner0, corner1, corner2, corner3, nearclip;
+
warpzone_saved = 0;
warpzone_saved_origin = warpzone_fixview_origin;
warpzone_saved_angles = warpzone_fixview_angles;
warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
+ nearclip = '0 0 1' * (cvar("r_nearclip") * cvar("cl_warpzonenudge"));
+ 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);
+
#ifndef KEEP_ROLL
if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
{
{
warpzone_saved = 1;
warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
+ corner0 = WarpZone_TransformOrigin(e, corner0);
+ corner1 = WarpZone_TransformOrigin(e, corner1);
+ corner2 = WarpZone_TransformOrigin(e, corner2);
+ corner3 = WarpZone_TransformOrigin(e, corner3);
warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
WarpZone_Inside();
WarpZone_Outside();
// if we are near any warpzone planes - MOVE AWAY (work around nearclip)
- float nearclip = 4;
- e = WarpZone_Find(warpzone_fixview_origin - '1 1 1' * nearclip, warpzone_fixview_origin + '1 1 1' * nearclip);
- if(e)
+ o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
+ if(o != '0 0 0')
{
- pd = WarpZone_PlaneDist(e, warpzone_fixview_origin);
- if(pd >= 0 && pd < nearclip)
- {
- warpzone_saved = 1;
- warpzone_fixview_origin = warpzone_fixview_origin + e.warpzone_forward * (nearclip - pd);
- }
+ warpzone_saved = 1;
+ warpzone_fixview_origin += o;
}
if(warpzone_saved == 1)