// $Id$
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <simgear/compiler.h>
#include <stdio.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
-#include <simgear/math/fg_random.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
+#include <simgear/math/sg_random.h>
+#include <simgear/debug/logstream.hxx>
#include "cloud.hxx"
}
-// build the moon object
+// build the cloud object
void SGCloudLayer::build( double s, double asl, double thickness,
double transition, ssgSimpleState *state )
{
sgSetVec3( vertex, -size, -size, 0.0f );
sgVec2 base;
- sgSetVec2( base, fg_random(), fg_random() );
+ sgSetVec2( base, sg_random(), sg_random() );
sgSetVec2( tc, base[0], base[1] );
cl->add( color );
vl->add( vertex );
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;