]> git.mxchange.org Git - flightgear.git/commitdiff
Add scenery functions working on SGGeod in place of SGLocation.
authorfrohlich <frohlich>
Sat, 7 Mar 2009 11:24:47 +0000 (11:24 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 11 Mar 2009 22:14:33 +0000 (23:14 +0100)
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index 26ce7135a5b1e7640c7e03e3e4521aad77334120..cc53e63aee027b60fdda958b29374c92516f0823 100644 (file)
@@ -316,29 +316,29 @@ void FGTileMgr::update_queues()
 int FGTileMgr::update( double visibility_meters )
 {
     SGLocation *location = globals->get_current_view()->getSGLocation();
-    return update( location, visibility_meters );
+    double lon = location->getLongitude_deg();
+    double lat = location->getLatitude_deg();
+    return update(SGGeod::fromDegM(lon, lat, 0), visibility_meters);
 }
 
+int FGTileMgr::update( SGLocation *location, double visibility_meters)
+{
+    double lon = location->getLongitude_deg();
+    double lat = location->getLatitude_deg();
+    return update(SGGeod::fromDegM(lon, lat, 0), visibility_meters);
+}
 
-int FGTileMgr::update( SGLocation *location, double visibility_meters )
+int FGTileMgr::update( const SGGeod& location, double visibility_meters)
 {
     SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update()" );
 
-    longitude = location->getLongitude_deg();
-    latitude = location->getLatitude_deg();
-    // add 1.0m to the max altitude to give a little leeway to the
-    // ground reaction code.
-    altitude_m = location->getAltitudeASL_ft() * SG_FEET_TO_METER + 1.0;
+    longitude = location.getLongitudeDeg();
+    latitude = location.getLatitudeDeg();
 
-    // if current altitude is apparently not initialized, set max
-    // altitude to something big.
-    if ( altitude_m < -1000 ) {
-        altitude_m = 10000;
-    }
     // SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
     //         << longitude << " " << latatitude );
 
-    current_bucket.set_bucket( longitude, latitude );
+    current_bucket.set_bucket( location );
     // SG_LOG( SG_TERRAIN, SG_DEBUG, "Updating tile list for "
     //         << current_bucket );
     fgSetInt( "/environment/current-tile-id", current_bucket.gen_index() );
@@ -391,6 +391,12 @@ void FGTileMgr::prep_ssg_nodes(float vis) {
     }
 }
 
+bool FGTileMgr::scenery_available(const SGGeod& position, double range_m)
+{
+    return scenery_available(position.getLatitudeDeg(),
+                             position.getLongitudeDeg(), range_m);
+}
+
 bool FGTileMgr::scenery_available(double lat, double lon, double range_m)
 {
   // sanity check (unfortunately needed!)
index f8e4f4b684394b5f8dcf7f9bd356047cfe88fb3a..d8c1054318df0a3c6d79fce96ee76f9032b73619 100644 (file)
@@ -72,7 +72,6 @@ private:
     // current longitude latitude
     double longitude;
     double latitude;
-    double altitude_m;
 
     /**
      * tile cache
@@ -96,6 +95,7 @@ public:
     // read it from disk.
     int update( double visibility_meters );
     int update( SGLocation *location, double visibility_meters);
+    int update( const SGGeod& location, double visibility_meters);
 
     // Prepare the ssg nodes corresponding to each tile.  For each
     // tile, set the ssg transform and update it's range selector
@@ -109,6 +109,7 @@ public:
     /// within a range of range_m.
     /// lat and lon are expected to be in degrees.
     bool scenery_available(double lat, double lon, double range_m);
+    bool scenery_available(const SGGeod& position, double range_m);
 
     // Load a model for a tile
     osg::Node* loadTileModel(const string& modelPath, bool cacheModel);