]> git.mxchange.org Git - flightgear.git/commitdiff
Introduce terrasync subsystem.
authorThorstenB <brehmt@gmail.com>
Sat, 11 Jun 2011 22:44:07 +0000 (00:44 +0200)
committerThorstenB <brehmt@gmail.com>
Sat, 11 Jun 2011 22:44:07 +0000 (00:44 +0200)
Fix tile reloading issue.

CMakeLists.txt
configure.ac
src/Main/CMakeLists.txt
src/Main/Makefile.am
src/Main/main.cxx
src/Main/options.cxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index ae3117a14fcbceebcfc69ae9d38d3ba479401cc1..293d8b41f6fd0f54f3c5f93f496382ef2a270521 100644 (file)
@@ -55,7 +55,7 @@ option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
 option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
 option(ENABLE_FGADMIN "Set to ON to build FlightGear with FGADMIN" ON)
 option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" OFF)
-option(ENABLE_LIBSVN "Set to ON to build terrasync with libsvnclient support" OFF)
+option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support" OFF)
 
 set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
 
index 693740442dc09ac4a11cd8143782bad217200e78..179d63f514e6d55b33fea8c6b569ce039a65bd9c 100644 (file)
@@ -819,13 +819,13 @@ dnl Check for Subversion library support
 # libsvn support defaults to yes
 save_LIBS=$LIBS
 save_CPPFLAGS=$CPPFLAGS
-AC_ARG_WITH(libsvn, [  --without-libsvn        Do not use libsvn for terrasync [default=no]], [], [with_libsvn=yes])
+AC_ARG_WITH(libsvn, [  --without-libsvn        Do not use built-in subversion (libsvn) for terrasync/fgfs [default=no]], [], [with_libsvn=yes])
 if test "x$with_libsvn" = "xyes"; then
     LIBS="`apr-1-config --link-ld`"
     CPPFLAGS="-I/usr/include/subversion-1 `apr-1-config --includes --cppflags`"
     AC_CHECK_HEADERS([svn_client.h])
        if test "x$ac_cv_header_svn_client_h" = "xyes"; then
-       echo "TerraSync will use libsvn"
+       echo "Using built-in subversion (libsvn) for scenery downloads."
        AC_SEARCH_LIBS(svn_client_checkout, svn_client-1,
                       [AC_DEFINE([HAVE_LIBSVN_CLIENT_1], [1], [Define to 1 if you have libsvn_client-1])],
                       [AC_MSG_ERROR(svn_client-1 library not found.)],)
@@ -836,12 +836,12 @@ if test "x$with_libsvn" = "xyes"; then
        AC_SUBST(svn_LIBS)
        AC_SUBST(svn_CPPFLAGS)
        else
-       echo "Libsvn not found. TerraSync will use command line subversion"
+       echo "Libsvn not found. Will use command line subversion for scenery downloads."
        svn_LIBS=""
        svn_CPPFLAGS=""
        fi
 else
-echo "Libsvn explicitly disabled. TerraSync will use command line subversion"
+echo "Libsvn explicitly disabled. Will use command line subversion for scenery downloads."
   svn_LIBS=""
   svn_CPPFLAGS=""
 fi
index 954c020bccfdaa5f1a1bea736c1fe364ab823082..d28d78d26a571436d0579f434936b9f49eddfdca 100644 (file)
@@ -49,7 +49,7 @@ endif()
 
 target_link_libraries(fgfs 
        ${FG_LIBS}
-        ${HLA_LIBRARIES}
+       ${HLA_LIBRARIES}
        ${SIMGEAR_LIBRARIES}
        ${OPENSCENEGRAPH_LIBRARIES} 
        ${OPENAL_LIBRARY} 
index c4525ed8b29f34a9da3cf92bae450605606d060a..65d2ccd3bd0a148a9770243758bfec5deb79eca1 100644 (file)
@@ -113,7 +113,7 @@ fgfs_LDADD = \
        -lsgroute -lsgsky -lsgsound -lsgephem -lsgtgdb -lsgmodel -lsgbvh \
        -lsgmaterial -lsgutil -lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket \
        -lsgprops -lsgdebug -lsgmagvar -lsgmisc -lsgnasal -lsgxml -lsgsound \
-       -lsgserial -lsgstructure -lsgenvironment \
+       -lsgserial -lsgstructure -lsgenvironment -lsgtsync\
         $(fgfs_PLIB_LIBS) \
        $(OSG_LIBS) \
        $(thread_LIBS) \
@@ -121,7 +121,8 @@ fgfs_LDADD = \
        -lz \
        $(opengl_LIBS) \
        $(openal_LIBS) \
-       $(EVENT_LIBS)
+       $(EVENT_LIBS) \
+       $(svn_LIBS)
 
 fgfs_LDFLAGS = $(fgfs_PLIB_FW) $(fgfs_OSG_FW) $(LDFLAGS)
 
index 58883a8865e7713948610470b01ab4fa72db39eb..1c4a7410f03666feff3835735c53aab8aa620cb8 100644 (file)
@@ -50,6 +50,7 @@
 #include <simgear/magvar/magvar.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/io/raw_socket.hxx>
+#include <simgear/scene/tsync/terrasync.hxx>
 #include <simgear/misc/sg_sleep.hxx>
 
 #include <Time/light.hxx>
@@ -394,6 +395,8 @@ static void fgIdleFunction ( void ) {
         ////////////////////////////////////////////////////////////////////
         // Initialize the TG scenery subsystem.
         ////////////////////////////////////////////////////////////////////
+        simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
+        globals->add_subsystem("terrasync", terra_sync);
         globals->set_scenery( new FGScenery );
         globals->get_scenery()->init();
         globals->get_scenery()->bind();
index 01f1e4438ca859981758b04a24f60bc293d9c876..342412e538c8b6017de0fc7a8e1a8e9e315190ce 100644 (file)
@@ -1390,6 +1390,9 @@ struct OptionDesc {
     {"texture-filtering",            false, OPTION_INT,    "/sim/rendering/filtering", 1, "", 0 },
     {"disable-wireframe",            false, OPTION_BOOL,   "/sim/rendering/wireframe", false, "", 0 },
     {"enable-wireframe",             false, OPTION_BOOL,   "/sim/rendering/wireframe", true, "", 0 },
+    {"disable-terrasync",            false, OPTION_BOOL,   "/sim/terrasync/enabled", false, "", 0 },
+    {"enable-terrasync",             false, OPTION_BOOL,   "/sim/terrasync/enabled", true, "", 0 },
+    {"terrasync-dir",                false, OPTION_STRING, "/sim/terrasync/scenery-dir", false, "", 0 },
     {"geometry",                     true,  OPTION_FUNC,   "", false, "", fgOptGeometry },
     {"bpp",                          true,  OPTION_FUNC,   "", false, "", fgOptBpp },
     {"units-feet",                   false, OPTION_STRING, "/sim/startup/units", false, "feet", 0 },
index 7b59d60b0e5008c44a7807395c35b37a72f67f2d..efdd83856fa77b63d556961cebc1f48899e4fe0b 100644 (file)
@@ -35,6 +35,7 @@
 #include <simgear/structure/exception.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/tsync/terrasync.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -75,14 +76,20 @@ private:
 FGTileMgr::FGTileMgr():
     state( Start ),
     vis( 16000 ),
-    _propListener(new LoaderPropertyWatcher(this))
+    _propListener(new LoaderPropertyWatcher(this)),
+    _terra_sync(NULL)
 {
     _randomObjects = fgGetNode("/sim/rendering/random-objects", true);
     _randomVegetation = fgGetNode("/sim/rendering/random-vegetation", true);
+    _maxTileRangeM = fgGetNode("/sim/rendering/static-lod/bare", true);
 }
 
 
-FGTileMgr::~FGTileMgr() {
+FGTileMgr::~FGTileMgr()
+{
+    if (_terra_sync)
+        _terra_sync->setTileCache(NULL);
+
     // remove all nodes we might have left behind
     osg::Group* group = globals->get_scenery()->get_terrain_branch();
     group->removeChildren(0, group->getNumChildren());
@@ -135,7 +142,11 @@ void FGTileMgr::reinit()
     previous_bucket.make_bad();
     current_bucket.make_bad();
     longitude = latitude = -1000.0;
-    
+
+    _terra_sync = (simgear::SGTerraSync*) globals->get_subsystem("terrasync");
+    if (_terra_sync)
+        _terra_sync->setTileCache(&tile_cache);
+
     // force an update now
     update(0.0);
 }
@@ -189,10 +200,7 @@ void FGTileMgr::schedule_needed(const SGBucket& curr_bucket, double vis)
         SG_LOG( SG_TERRAIN, SG_ALERT,
                 "Attempting to schedule tiles for bogus lon and lat  = ("
                 << longitude << "," << latitude << ")" );
-        return;                // FIXME
-        SG_LOG( SG_TERRAIN, SG_ALERT,
-                "This is a FATAL error.  Exiting!" );
-        exit(-1);
+        return;
     }
 
     SG_LOG( SG_TERRAIN, SG_INFO,
@@ -203,8 +211,9 @@ void FGTileMgr::schedule_needed(const SGBucket& curr_bucket, double vis)
     // cout << "tile width = " << tile_width << "  tile_height = "
     //      << tile_height << endl;
 
-    xrange = (int)(vis / tile_width) + 1;
-    yrange = (int)(vis / tile_height) + 1;
+    double tileRangeM = min(vis,_maxTileRangeM->getDoubleValue());
+    xrange = (int)(tileRangeM / tile_width) + 1;
+    yrange = (int)(tileRangeM / tile_height) + 1;
     if ( xrange < 1 ) { xrange = 1; }
     if ( yrange < 1 ) { yrange = 1; }
 
@@ -309,7 +318,8 @@ void FGTileMgr::update_queues()
             e->prep_ssg_node(vis);
 
             if (( !e->is_loaded() )&&
-                ( !e->is_expired(current_time) ))
+                ((!e->is_expired(current_time))||
+                  e->is_current_view() ))
             {
                 // schedule tile for loading with osg pager
                 pager->queueRequest(e->tileFileName,
@@ -322,7 +332,7 @@ void FGTileMgr::update_queues()
             }
         } else
         {
-            SG_LOG(SG_INPUT, SG_ALERT, "warning ... empty tile in cache");
+            SG_LOG(SG_INPUT, SG_ALERT, "Warning: empty tile in cache!");
         }
         tile_cache.next();
         sz++;
@@ -388,7 +398,7 @@ int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
     //         << current_bucket );
     fgSetInt( "/environment/current-tile-id", current_bucket.gen_index() );
 
-    // do tile load scheduling. 
+    // do tile load scheduling.
     // Note that we need keep track of both viewer buckets and fdm buckets.
     if ( state == Running ) {
         SG_LOG( SG_TERRAIN, SG_DEBUG, "State == Running" );
@@ -398,6 +408,8 @@ int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
             SG_LOG( SG_TERRAIN, SG_INFO, "FGTileMgr::update()" );
             scheduled_visibility = range_m;
             schedule_needed(current_bucket, range_m);
+            if (_terra_sync)
+                _terra_sync->schedulePosition(latitude,longitude);
         }
         // save bucket
         previous_bucket = current_bucket;
index 6b4a4e7ef5bfbae3357a83365466c371ce34c764..2c6648182e4a1714cac8f28216e43ffd337e86ec 100644 (file)
@@ -38,6 +38,11 @@ namespace osg
 class Node;
 }
 
+namespace simgear
+{
+class SGTerraSync;
+}
+
 class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
 
 private:
@@ -75,6 +80,7 @@ private:
      * tile cache
      */
     simgear::TileCache tile_cache;
+    simgear::SGTerraSync* _terra_sync;
 
     // Update the various queues maintained by the tilemagr (private
     // internal function, do not call directly.)
@@ -84,6 +90,7 @@ private:
     SGPropertyChangeListener* _propListener;
     SGPropertyNode_ptr _randomObjects;
     SGPropertyNode_ptr _randomVegetation;
+    SGPropertyNode_ptr _maxTileRangeM;
     
 public:
     FGTileMgr();