Introduce terrasync subsystem.
Fix tile reloading issue.
This commit is contained in:
parent
50479f47f3
commit
ee40e8ae3f
8 changed files with 46 additions and 20 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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());
|
||||
|
@ -136,6 +143,10 @@ void FGTileMgr::reinit()
|
|||
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++;
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue