]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sky/cloud.cxx
Replaced some cout's with SG_LOG (fixes namespace problem with
[simgear.git] / simgear / sky / cloud.cxx
index 8a69e3150fca822aef0da067fec832127d0f77a2..a93c0c62e8fc7c94a5e11c6969d6eaf9e6c505f0 100644 (file)
@@ -27,6 +27,7 @@
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_random.h>
+#include <simgear/debug/logstream.hxx>
 
 #include "cloud.hxx"
 
@@ -204,12 +205,31 @@ bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat,
        base = tl->get( 0 );
 
        base[0] += xoff;
-       while ( base[0] > 1.0 ) { base[0] -= 1.0; }
-       while ( base[0] < 0.0 ) { base[0] += 1.0; }
+
+       // the while loops can lead to *long* pauses if base[0] comes
+       // with a bogus value.
+        // while ( base[0] > 1.0 ) { base[0] -= 1.0; }
+       // while ( base[0] < 0.0 ) { base[0] += 1.0; }
+        if ( base[0] > -10.0 && base[0] < 10.0 ) {
+            base[0] -= (int)base[0];
+        } else {
+            base[0] = 0.0;
+           SG_LOG(SG_ASTRO, SG_ALERT,
+                  "Error: base = " << base[0] << "," << base[1]);
+        }
 
        base[1] += yoff;
-       while ( base[1] > 1.0 ) { base[1] -= 1.0; }
-       while ( base[1] < 0.0 ) { base[1] += 1.0; }
+       // the while loops can lead to *long* pauses if base[0] comes
+       // with a bogus value.
+       // while ( base[1] > 1.0 ) { base[1] -= 1.0; }
+       // while ( base[1] < 0.0 ) { base[1] += 1.0; }
+        if ( base[1] > -10.0 && base[1] < 10.0 ) {
+            base[1] -= (int)base[1];
+        } else {
+            base[1] = 0.0;
+           SG_LOG(SG_ASTRO, SG_ALERT,
+                  "Error: base = " << base[0] << "," << base[1]);
+        }
 
        // cout << "base = " << base[0] << "," << base[1] << endl;