}
else { setproperty(VF_ORIGIN, trace_endpos); }
- setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
+ setproperty(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles, autocvar_in_pitch_min, autocvar_in_pitch_max));
}
else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
{
float autocvar_cl_deathglow;
float autocvar_developer_csqcentities;
float autocvar_g_jetpack_attenuation;
+float autocvar_in_pitch_min;
+float autocvar_in_pitch_max;
.float cvar_cl_gunalign;
.float cvar_cl_noantilag;
+.float cvar_in_pitch_min;
+.float cvar_in_pitch_max;
+
.string weaponorder_byimpulse;
.float cvar_cl_allow_uid2name;
GetCvars_handleFloat(s, f, cvar_cl_voice_directional_taunt_attenuation, "cl_voice_directional_taunt_attenuation");
GetCvars_handleFloat(s, f, cvar_cl_accuracy_data_share, "cl_accuracy_data_share");
GetCvars_handleFloat(s, f, cvar_cl_accuracy_data_receive, "cl_accuracy_data_receive");
+ GetCvars_handleFloat(s, f, cvar_in_pitch_min, "in_pitch_min");
+ GetCvars_handleFloat(s, f, cvar_in_pitch_max, "in_pitch_max");
self.cvar_cl_accuracy_data_share = boolean(self.cvar_cl_accuracy_data_share);
self.cvar_cl_accuracy_data_receive = boolean(self.cvar_cl_accuracy_data_receive);
crosshair_trace(player);
ad = vectoangles(normalize(trace_endpos - ad));
ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
- ad = AnglesTransform_Normalize(ad, TRUE);
+ ad = AnglesTransform_Normalize(ad, TRUE, -90, 90);
//UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
// Rotate head
vtag = gettaginfo(_turrret, gettagindex(_turrret, _tagname));
vtmp = vectoangles(normalize(_target - vtag));
vtmp = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(_vehic.angles), AnglesTransform_FromAngles(vtmp))) - _turrret.angles;
- vtmp = AnglesTransform_Normalize(vtmp, TRUE);
+ vtmp = AnglesTransform_Normalize(vtmp, TRUE, _pichlimit_min, _pichlimit_max);
ftmp = _aimspeed * frametime;
vtmp_y = bound(-ftmp, vtmp_y, ftmp);
vtmp_x = bound(-ftmp, vtmp_x, ftmp);
return AnglesTransform_Multiply(AnglesTransform_Invert(from_transform), to_transform);
}
-vector AnglesTransform_Normalize(vector t, float minimize_roll)
+vector AnglesTransform_Normalize(vector t, float minimize_roll, float pitchmin, float pitchmax)
{
float need_flip;
// first, bring all angles in their range...
if(minimize_roll)
need_flip = (t_z > 90 || t_z <= -90);
else
- need_flip = (t_x > 90 || t_x < -90); // for pitch we prefer to allow exactly -90 degrees for looking straight down
+ {
+ // Smaller values break the math.
+ pitchmin = min(-90, pitchmin);
+ pitchmax = max(90, pitchmax);
+ // And...
+ if (t_z > 90 || t_z <= -90)
+ {
+ // Roll is bad. Prefer flipping, but let's end up in the good range.
+ need_flip = (t_x >= pitchmin + 180 || t_x <= pitchmax - 180);
+ // NOTE: Is this the right decision or should it be > and <?
+ // This will in the equality case prefer the output with less roll.
+ // Is that right?
+ }
+ else
+ {
+ // Roll is ok. Prefer not flipping.
+ need_flip = (t_x > pitchmax || t_x < pitchmin);
+ // for pitch we prefer to allow exactly the border angles degrees for looking straight down
+ }
+ }
if(need_flip)
{
if(t_x >= 0) t_x = 180 - t_x; else t_x = -180 - t_x;
vector AnglesTransform_RightDivide(vector to_transform, vector from_transform); // A B^-1
vector AnglesTransform_LeftDivide(vector from_transform, vector to_transform); // A^-1 B
-vector AnglesTransform_Normalize(vector t, float minimize_roll); // makes sure all angles are in their range: yaw in -180..180, pitch in -90..90, roll in -180..180 (or if minimize_roll is set, pitch in -180..180, roll in -90..90)
+vector AnglesTransform_Normalize(vector t, float minimize_roll, float pitchmin, float pitchmax); // makes sure all angles are in their range: yaw in -180..180, pitch in -90..90, roll in -180..180 (or if minimize_roll is set, pitch in -180..180, roll in -90..90)
vector AnglesTransform_ApplyToAngles(vector transform, vector v);
vector AnglesTransform_ApplyToVAngles(vector transform, vector v);
}
void CL_RotateMoves(vector ang) = #638;
+float autocvar_in_pitch_min;
+float autocvar_in_pitch_max;
void WarpZone_Teleported_Read(float isnew)
{
vector v;
if(!isnew)
return;
self.warpzone_transform = v;
- setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, getpropertyvec(VF_CL_VIEWANGLES)));
+ setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, getpropertyvec(VF_CL_VIEWANGLES), autocvar_in_pitch_min, autocvar_in_pitch_max));
if(checkextension("DP_CSQC_ROTATEMOVES"))
CL_RotateMoves(v);
//CL_RotateMoves('0 90 0');
if(e)
{
pmove_org = WarpZone_TransformOrigin(e, pmove_org);
- input_angles = WarpZone_TransformVAngles(e, input_angles);
+ input_angles = WarpZone_TransformVAngles(e, input_angles, autocvar_in_pitch_min, autocvar_in_pitch_max);
}
}
if(e)
{
org = WarpZone_TransformOrigin(e, org);
- ang = WarpZone_TransformVAngles(e, ang);
+ ang = WarpZone_TransformVAngles(e, ang, autocvar_in_pitch_min, autocvar_in_pitch_max);
#ifdef WORKAROUND_XON010
dirty = 1;
#endif
return AnglesTransform_ApplyToAngles(wz.warpzone_transform, v);
}
-vector WarpZone_TransformVAngles(entity wz, vector ang)
+vector WarpZone_TransformVAngles(entity wz, vector ang, float pitchmin, float pitchmax)
{
#ifdef KEEP_ROLL
float roll;
ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
#ifdef KEEP_ROLL
- ang = AnglesTransform_Normalize(ang, TRUE);
+ ang = AnglesTransform_Normalize(ang, TRUE, pitchmin, pitchmax);
ang = AnglesTransform_CancelRoll(ang);
ang_z = roll;
#else
- ang = AnglesTransform_Normalize(ang, FALSE);
+ ang = AnglesTransform_Normalize(ang, FALSE, pitchmin, pitchmax);
#endif
return ang;
ang_z = 0;
ang = AnglesTransform_ApplyToVAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
- ang = AnglesTransform_Normalize(ang, TRUE);
+ ang = AnglesTransform_Normalize(ang, TRUE, -90, 90);
ang = AnglesTransform_CancelRoll(ang);
ang_z = roll;
if(from.WarpZone_refsys)
ang = WarpZone_UnTransformVAngles(from.WarpZone_refsys, ang);
if(to.WarpZone_refsys)
- ang = WarpZone_TransformVAngles(to.WarpZone_refsys, ang);
+ ang = WarpZone_TransformVAngles(to.WarpZone_refsys, ang, -90, 90);
return ang;
}
void WarpZone_RefSys_Copy(entity me, entity from)
vector WarpZone_TransformOrigin(entity wz, vector v);
vector WarpZone_TransformVelocity(entity wz, vector v);
vector WarpZone_TransformAngles(entity wz, vector v);
-vector WarpZone_TransformVAngles(entity wz, vector v);
+vector WarpZone_TransformVAngles(entity wz, vector v, float pitchmin, float pitchmax);
vector WarpZone_UnTransformOrigin(entity wz, vector v);
vector WarpZone_UnTransformVelocity(entity wz, vector v);
vector WarpZone_UnTransformAngles(entity wz, vector v);
o10 = o1 = WarpZone_TransformOrigin(wz, o0);
v1 = WarpZone_TransformVelocity(wz, v0);
if not(IS_NOT_A_CLIENT(player))
- a1 = WarpZone_TransformVAngles(wz, player.v_angle);
+ a1 = WarpZone_TransformVAngles(wz, player.v_angle, player.cvar_in_pitch_min, player.cvar_in_pitch_max);
else
a1 = WarpZone_TransformAngles(wz, a0);
if(self.v_angle_z <= 360) // if not already adjusted
if(time - self.ping * 0.001 < self.warpzone_teleport_time)
{
- self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
+ self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle, self.cvar_in_pitch_min, self.cvar_in_pitch_max);
self.v_angle_z += 720; // mark as adjusted
}
#endif