]> git.mxchange.org Git - flightgear.git/commitdiff
Change to WeatherCM so that it doesn't triger an floating point exception
authorcurt <curt>
Mon, 10 Dec 2001 22:39:05 +0000 (22:39 +0000)
committercurt <curt>
Mon, 10 Dec 2001 22:39:05 +0000 (22:39 +0000)
when queried for too low (i.e. < -1000 meters) altitudes. So now there's
now valid weather information for altitudes below -500 meters sea level.

src/WeatherCM/FGLocalWeatherDatabase.cpp

index 262414451d3f80d581e0dd51cbbea35d16199291..0bc7098da746a1046d335a9e0112553b8a578dab 100644 (file)
@@ -76,8 +76,6 @@ void FGLocalWeatherDatabase::init( const WeatherPrecision visibility,
                                   const DatabaseWorkingType type,
                                   const string &root )
 {
-    FGPhysicalProperties f[2];  //make an standard weather that's the same at the whole world
-
     cerr << "Initializing FGLocalWeatherDatabase\n";
     cerr << "-----------------------------------\n";
 
@@ -197,6 +195,7 @@ void FGLocalWeatherDatabase::init( const WeatherPrecision visibility,
            double x[2] = {0.0,  0.0};  //make an standard weather that's the same at the whole world
            double y[2] = {0.0,  0.0};  //make an standard weather that's the same at the whole world
            double z[2] = {1.0, -1.0};  //make an standard weather that's the same at the whole world
+            FGPhysicalProperties f[2];  //make an standard weather that's the same at the whole world
            database = new SphereInterpolate<FGPhysicalProperties>(2,x,y,z,f);
        }
        break;
@@ -262,7 +261,12 @@ void FGLocalWeatherDatabase::update(const sgVec3& p, const WeatherPrecision dt)
 /****************************************************************************/
 FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const
 {
-    return FGPhysicalProperty(database->Evaluate(p), p[2]);
+  // check for bogous altitudes. Dunno why, but FGFS want's to know the
+  // weather at an altitude of roughly -3000 meters...
+  if (p[2] < -500.0f)
+    return FGPhysicalProperty(database->Evaluate(p), -500.0f);
+
+  return FGPhysicalProperty(database->Evaluate(p), p[2]);
 }
 
 #ifdef macintosh