From: Rudolf Polzer Date: Wed, 16 Oct 2013 21:16:39 +0000 (+0200) Subject: Fix pitch logic. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=70f6e172a11cd7496de8c254dbf228baec1a743f;p=xonotic%2Fxonotic-data.pk3dir.git Fix pitch logic. --- diff --git a/qcsrc/warpzonelib/anglestransform.qc b/qcsrc/warpzonelib/anglestransform.qc index 6aea44591..a3df93afa 100644 --- a/qcsrc/warpzonelib/anglestransform.qc +++ b/qcsrc/warpzonelib/anglestransform.qc @@ -108,7 +108,25 @@ vector AnglesTransform_Normalize(vector t, float pitchmin, float pitchmax) 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); + + // Want to achieve: + // after t_x' = 180 - t_x or -180: + // t_x' <= pitchmax && t_x' >= pitchmin + // ASSUME t_x >= 0: + // 180 - t_x <= pitchmax && 180 - t_x >= pitchmin + // t_x >= 180-pitchmax && t_x <= 180-pitchmin + // GUARANTEED + // t_x >= 180-pitchmax + // ASSUME t_x < 0: + // -180 - t_x <= pitchmax && -180 - t_x >= pitchmin + // t_x >= -180-pitchmax && t_x <= -180-pitchmin + // GUARANTEED + // t_x <= -180-pitchmin + // So good after flip means: + // t_x >= 0 ? t_x >= 180-pitchmax : t_x <= -180-pitchmin + // t_x outside -180-pitchmin .. 180-pitchmax + + need_flip = (t_x <= -180 - pitchmin || t_x >= 180 - pitchmax); // NOTE: Is this the right decision or should it be > and