Consolidate the different ReaderWriterOptions classes.
This commit is contained in:
parent
1366336a87
commit
42fb9b8e9f
5 changed files with 20 additions and 59 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/scene/material/EffectCullVisitor.hxx>
|
#include <simgear/scene/material/EffectCullVisitor.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
#include <simgear/scene/tgdb/TileEntry.hxx>
|
#include <simgear/scene/tgdb/TileEntry.hxx>
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
|
@ -223,15 +223,14 @@ fgviewerMain(int argc, char** argv)
|
||||||
// The file path list must be set in the registry.
|
// The file path list must be set in the registry.
|
||||||
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
||||||
|
|
||||||
SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
|
simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
|
||||||
btgOptions->getDatabasePathList() = filePathList;
|
options->getDatabasePathList() = filePathList;
|
||||||
btgOptions->setMatlib(globals->get_matlib());
|
options->setMaterialLib(globals->get_matlib());
|
||||||
btgOptions->setUseRandomObjects(fgGetBool("/sim/rendering/random-objects", false));
|
options->setPropertyNode(globals->get_props());
|
||||||
btgOptions->setUseRandomVegetation(fgGetBool("/sim/rendering/random-vegetation", false));
|
|
||||||
|
|
||||||
// read the scene from the list of file specified command line args.
|
// read the scene from the list of file specified command line args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel;
|
osg::ref_ptr<osg::Node> loadedModel;
|
||||||
loadedModel = osgDB::readNodeFiles(dataFiles, btgOptions);
|
loadedModel = osgDB::readNodeFiles(dataFiles, options);
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
if (!loadedModel.valid()) {
|
if (!loadedModel.valid()) {
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
#include <simgear/scene/model/modellib.hxx>
|
#include <simgear/scene/model/modellib.hxx>
|
||||||
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tsync/terrasync.hxx>
|
#include <simgear/scene/tsync/terrasync.hxx>
|
||||||
|
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
@ -55,33 +55,11 @@ using simgear::TileEntry;
|
||||||
using simgear::TileCache;
|
using simgear::TileCache;
|
||||||
|
|
||||||
|
|
||||||
// helper: listen to property changes affecting tile loading
|
|
||||||
class LoaderPropertyWatcher : public SGPropertyChangeListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LoaderPropertyWatcher(FGTileMgr* pTileMgr) :
|
|
||||||
_pTileMgr(pTileMgr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void valueChanged(SGPropertyNode*)
|
|
||||||
{
|
|
||||||
_pTileMgr->configChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
FGTileMgr* _pTileMgr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
FGTileMgr::FGTileMgr():
|
FGTileMgr::FGTileMgr():
|
||||||
state( Start ),
|
state( Start ),
|
||||||
vis( 16000 ),
|
vis( 16000 ),
|
||||||
_terra_sync(NULL),
|
_terra_sync(NULL)
|
||||||
_propListener(new LoaderPropertyWatcher(this))
|
|
||||||
{
|
{
|
||||||
_randomObjects = fgGetNode("/sim/rendering/random-objects", true);
|
|
||||||
_randomVegetation = fgGetNode("/sim/rendering/random-vegetation", true);
|
|
||||||
_maxTileRangeM = fgGetNode("/sim/rendering/static-lod/bare", true);
|
_maxTileRangeM = fgGetNode("/sim/rendering/static-lod/bare", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +69,6 @@ FGTileMgr::~FGTileMgr()
|
||||||
// remove all nodes we might have left behind
|
// remove all nodes we might have left behind
|
||||||
osg::Group* group = globals->get_scenery()->get_terrain_branch();
|
osg::Group* group = globals->get_scenery()->get_terrain_branch();
|
||||||
group->removeChildren(0, group->getNumChildren());
|
group->removeChildren(0, group->getNumChildren());
|
||||||
delete _propListener;
|
|
||||||
_propListener = NULL;
|
|
||||||
// clear OSG cache
|
// clear OSG cache
|
||||||
osgDB::Registry::instance()->clearObjectCache();
|
osgDB::Registry::instance()->clearObjectCache();
|
||||||
}
|
}
|
||||||
|
@ -102,12 +78,9 @@ FGTileMgr::~FGTileMgr()
|
||||||
void FGTileMgr::init() {
|
void FGTileMgr::init() {
|
||||||
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
|
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
|
||||||
|
|
||||||
_options = new SGReaderWriterBTGOptions;
|
_options = new simgear::SGReaderWriterOptions;
|
||||||
_options->setMatlib(globals->get_matlib());
|
_options->setMaterialLib(globals->get_matlib());
|
||||||
|
_options->setPropertyNode(globals->get_props());
|
||||||
_randomObjects.get()->addChangeListener(_propListener, false);
|
|
||||||
_randomVegetation.get()->addChangeListener(_propListener, false);
|
|
||||||
configChanged();
|
|
||||||
|
|
||||||
osgDB::FilePathList &fp = _options->getDatabasePathList();
|
osgDB::FilePathList &fp = _options->getDatabasePathList();
|
||||||
const string_list &sc = globals->get_fg_scenery();
|
const string_list &sc = globals->get_fg_scenery();
|
||||||
|
@ -153,12 +126,6 @@ void FGTileMgr::reinit()
|
||||||
update(0.0);
|
update(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGTileMgr::configChanged()
|
|
||||||
{
|
|
||||||
_options->setUseRandomObjects(_randomObjects.get()->getBoolValue());
|
|
||||||
_options->setUseRandomVegetation(_randomVegetation.get()->getBoolValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* schedule a tile for loading, keep request for given amount of time.
|
/* schedule a tile for loading, keep request for given amount of time.
|
||||||
* Returns true if tile is already loaded. */
|
* Returns true if tile is already loaded. */
|
||||||
bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)
|
bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <simgear/scene/tgdb/TileEntry.hxx>
|
#include <simgear/scene/tgdb/TileEntry.hxx>
|
||||||
#include <simgear/scene/tgdb/TileCache.hxx>
|
#include <simgear/scene/tgdb/TileCache.hxx>
|
||||||
|
|
||||||
class SGReaderWriterBTGOptions;
|
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Node;
|
class Node;
|
||||||
|
@ -41,6 +39,7 @@ class Node;
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
class SGTerraSync;
|
class SGTerraSync;
|
||||||
|
class SGReaderWriterOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
|
class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
|
||||||
|
@ -65,7 +64,7 @@ private:
|
||||||
SGBucket previous_bucket;
|
SGBucket previous_bucket;
|
||||||
SGBucket current_bucket;
|
SGBucket current_bucket;
|
||||||
SGBucket pending;
|
SGBucket pending;
|
||||||
osg::ref_ptr<SGReaderWriterBTGOptions> _options;
|
osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
|
||||||
|
|
||||||
// x and y distance of tiles to load/draw
|
// x and y distance of tiles to load/draw
|
||||||
float vis;
|
float vis;
|
||||||
|
@ -89,9 +88,6 @@ private:
|
||||||
static void refresh_tile(void* tileMgr, long tileIndex);
|
static void refresh_tile(void* tileMgr, long tileIndex);
|
||||||
|
|
||||||
SGPropertyNode* _visibilityMeters;
|
SGPropertyNode* _visibilityMeters;
|
||||||
SGPropertyChangeListener* _propListener;
|
|
||||||
SGPropertyNode_ptr _randomObjects;
|
|
||||||
SGPropertyNode_ptr _randomVegetation;
|
|
||||||
SGPropertyNode_ptr _maxTileRangeM;
|
SGPropertyNode_ptr _maxTileRangeM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -105,9 +101,6 @@ public:
|
||||||
|
|
||||||
virtual void update(double dt);
|
virtual void update(double dt);
|
||||||
|
|
||||||
// update loader configuration options
|
|
||||||
void configChanged();
|
|
||||||
|
|
||||||
int schedule_tiles_at(const SGGeod& location, double rangeM);
|
int schedule_tiles_at(const SGGeod& location, double rangeM);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/scene/material/EffectCullVisitor.hxx>
|
#include <simgear/scene/material/EffectCullVisitor.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
#include <simgear/scene/tgdb/TileEntry.hxx>
|
#include <simgear/scene/tgdb/TileEntry.hxx>
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
|
@ -151,9 +151,10 @@ main(int argc, char** argv)
|
||||||
// The file path list must be set in the registry.
|
// The file path list must be set in the registry.
|
||||||
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
||||||
|
|
||||||
SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
|
simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
|
||||||
btgOptions->getDatabasePathList() = filePathList;
|
options->getDatabasePathList() = filePathList;
|
||||||
btgOptions->setMatlib(ml);
|
options->setMaterialLib(ml);
|
||||||
|
options->setPropertyNode(props);
|
||||||
|
|
||||||
// Here, all arguments are processed
|
// Here, all arguments are processed
|
||||||
arguments.reportRemainingOptionsAsUnrecognized();
|
arguments.reportRemainingOptionsAsUnrecognized();
|
||||||
|
@ -161,7 +162,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
// read the scene from the list of file specified command line args.
|
// read the scene from the list of file specified command line args.
|
||||||
osg::ref_ptr<osg::Node> loadedModel;
|
osg::ref_ptr<osg::Node> loadedModel;
|
||||||
loadedModel = osgDB::readNodeFiles(arguments, btgOptions);
|
loadedModel = osgDB::readNodeFiles(arguments, options);
|
||||||
|
|
||||||
// if no model has been successfully loaded report failure.
|
// if no model has been successfully loaded report failure.
|
||||||
if (!loadedModel.valid()) {
|
if (!loadedModel.valid()) {
|
||||||
|
|
Loading…
Reference in a new issue