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, -90, 90);
+ ad = AnglesTransform_Normalize(ad, -360, 360);
//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, _pichlimit_min, _pichlimit_max);
+ vtmp = AnglesTransform_Normalize(vtmp, -360, 360);
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, float pitchmin, float pitchmax)
+vector AnglesTransform_Normalize(vector t, float pitchmin, float pitchmax)
{
float need_flip;
// first, bring all angles in their range...
t_x = t_x - 360 * rint(t_x / 360);
t_y = t_y - 360 * rint(t_y / 360);
t_z = t_z - 360 * rint(t_z / 360);
- if(minimize_roll)
- need_flip = (t_z > 90 || t_z <= -90);
+ // 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
{
- // 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
- }
+ // 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)
{
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, 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_Normalize(vector t, 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);
ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
#ifdef KEEP_ROLL
- ang = AnglesTransform_Normalize(ang, TRUE, pitchmin, pitchmax);
+ ang = AnglesTransform_Normalize(ang, -360, 360);
ang = AnglesTransform_CancelRoll(ang);
ang_z = roll;
#else
- ang = AnglesTransform_Normalize(ang, FALSE, pitchmin, pitchmax);
+ ang = AnglesTransform_Normalize(ang, pitchmin, pitchmax);
#endif
return ang;
ang_z = 0;
ang = AnglesTransform_ApplyToVAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
- ang = AnglesTransform_Normalize(ang, TRUE, -90, 90);
+ ang = AnglesTransform_Normalize(ang, -360, 360);
ang = AnglesTransform_CancelRoll(ang);
ang_z = roll;