Fix tile reloading issue.
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")
# 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.)],)
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
target_link_libraries(fgfs
${FG_LIBS}
- ${HLA_LIBRARIES}
+ ${HLA_LIBRARIES}
${SIMGEAR_LIBRARIES}
${OPENSCENEGRAPH_LIBRARIES}
${OPENAL_LIBRARY}
-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) \
-lz \
$(opengl_LIBS) \
$(openal_LIBS) \
- $(EVENT_LIBS)
+ $(EVENT_LIBS) \
+ $(svn_LIBS)
fgfs_LDFLAGS = $(fgfs_PLIB_FW) $(fgfs_OSG_FW) $(LDFLAGS)
#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>
////////////////////////////////////////////////////////////////////
// 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();
{"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 },
#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>
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());
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);
}
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,
// 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; }
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,
}
} 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++;
// << 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" );
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;
class Node;
}
+namespace simgear
+{
+class SGTerraSync;
+}
+
class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
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.)
SGPropertyChangeListener* _propListener;
SGPropertyNode_ptr _randomObjects;
SGPropertyNode_ptr _randomVegetation;
+ SGPropertyNode_ptr _maxTileRangeM;
public:
FGTileMgr();