]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/tilemgr.cxx
Currently, when the sim pauses, all IO is also halted. To me it generally
[flightgear.git] / src / Scenery / tilemgr.cxx
index 49d04c2e7866b4e343cea2521dbd4be0560de120..2b16af01838cb629a7c5d9c1744931f5a14e9730 100644 (file)
@@ -33,7 +33,7 @@
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/vector.hxx>
-#include <simgear/misc/exception.hxx>
+#include <simgear/structure/exception.hxx>
 #include <simgear/scene/model/modellib.hxx>
 
 #include <Main/globals.hxx>
@@ -280,7 +280,7 @@ void FGTileMgr::update_queues()
         try
         {
             ssgEntity *obj_model =
-                globals->get_model_lib()->load_model( globals->get_fg_root(),
+                globals->get_model_lib()->load_model( ".",
                                                       dm->get_model_path(),
                                                       globals->get_props(),
                                                       globals->get_sim_time_sec() );
@@ -316,6 +316,7 @@ void FGTileMgr::update_queues()
 #endif
         e->add_ssg_nodes( globals->get_scenery()->get_terrain_branch(),
                           globals->get_scenery()->get_gnd_lights_root(),
+                          globals->get_scenery()->get_taxi_lights_root(),
                           globals->get_scenery()->get_rwy_lights_root(),
                           globals->get_scenery()->get_taxi_lights_root() );
         // cout << "Adding ssg nodes for "
@@ -366,12 +367,22 @@ int FGTileMgr::update( SGLocation *location, double visibility_meters,
 {
     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;
+
+    // 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 );
     // SG_LOG( SG_TERRAIN, SG_DEBUG, "Updating tile list for "
     //         << current_bucket );
+    fgSetInt( "/environment/current-tile-id", current_bucket.gen_index() );
 
     // set global scenery center from current tile center
     current_tile = tile_cache.get_tile( current_bucket );
@@ -409,7 +420,7 @@ int FGTileMgr::update( SGLocation *location, double visibility_meters,
     // no reason to update this if we haven't moved...
     if ( longitude != last_longitude || latitude != last_latitude ) {
         // update current elevation... 
-        if ( updateCurrentElevAtPos( abs_pos_vector,
+        if ( updateCurrentElevAtPos( abs_pos_vector, altitude_m,
                                      location->get_tile_center() ) )
         {
             last_longitude = longitude;
@@ -430,8 +441,10 @@ void FGTileMgr::refresh_view_timestamps() {
 }
 
 
-int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
-
+int FGTileMgr::updateCurrentElevAtPos( sgdVec3 abs_pos_vector,
+                                       double max_alt_m,
+                                       Point3D center)
+{
     sgdVec3 sc;
 
     sgdSetVec3( sc, center[0], center[1], center[2]);
@@ -447,7 +460,11 @@ int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
         // scenery center has been properly defined so any hit should
         // be valid (and not just luck)
         hit = fgCurrentElev(abs_pos_vector,
+                            max_alt_m,
                             sc,
+               // uncomment next paramater to fly under
+               // bridges and a slightly faster algorithm
+               // but you won't be able to land on aircraft carriers
                             // current_tile->get_terra_transform(),
                             &hit_list,
                             &hit_elev,