]> git.mxchange.org Git - flightgear.git/commitdiff
Singularity avoidance fix for the flightgear Viewer.
authorEdward d'Auvergne <edward@nmr-relax.com>
Sun, 3 May 2015 18:04:33 +0000 (20:04 +0200)
committerEdward d'Auvergne <edward@nmr-relax.com>
Sun, 3 May 2015 18:04:33 +0000 (20:04 +0200)
This was reported at https://sourceforge.net/p/flightgear/codetickets/1740/ and
discussed at http://thread.gmane.org/gmane.games.flightgear.devel/77562 .

The flightgear Viewer no longer causes aircraft to disappear due to the
singularity at the poles resulting in an undefined azimuthal angle.

src/Viewer/viewer.cxx

index a18c51b239beb2bcaeaf821f4cb804a7118e8f8a..7061f76cb77f2526f33a8bf185211d9d31f2a37d 100644 (file)
@@ -310,11 +310,15 @@ FGViewer::setGoalPitchOffset_deg (double goal_pitch_offset_deg)
 {
   _dirty = true;
   _goal_pitch_offset_deg = goal_pitch_offset_deg;
-  if ( _goal_pitch_offset_deg < -90 ) {
-    _goal_pitch_offset_deg = -90.0;
+  /* The angle is set to 1/1000th of a degree from the poles to avoid the
+   * singularity where the azimuthal angle becomes undefined, inducing optical
+   * artefacts.  The arbitrary angle offset is visually unnoticeable while
+   * avoiding any possible floating point truncation artefacts. */
+  if ( _goal_pitch_offset_deg < -89.999 ) {
+    _goal_pitch_offset_deg = -89.999;
   }
-  if ( _goal_pitch_offset_deg > 90.0 ) {
-    _goal_pitch_offset_deg = 90.0;
+  if ( _goal_pitch_offset_deg > 89.999 ) {
+    _goal_pitch_offset_deg = 89.999;
   }
 
 }