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 <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
#include <osg/Geode>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/scene/material/EffectCullVisitor.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/TileEntry.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.
|
||||
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
||||
|
||||
SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
|
||||
btgOptions->getDatabasePathList() = filePathList;
|
||||
btgOptions->setMatlib(globals->get_matlib());
|
||||
btgOptions->setUseRandomObjects(fgGetBool("/sim/rendering/random-objects", false));
|
||||
btgOptions->setUseRandomVegetation(fgGetBool("/sim/rendering/random-vegetation", false));
|
||||
simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
|
||||
options->getDatabasePathList() = filePathList;
|
||||
options->setMaterialLib(globals->get_matlib());
|
||||
options->setPropertyNode(globals->get_props());
|
||||
|
||||
// read the scene from the list of file specified command line args.
|
||||
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 (!loadedModel.valid()) {
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/structure/exception.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 <Main/globals.hxx>
|
||||
|
@ -55,33 +55,11 @@ using simgear::TileEntry;
|
|||
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():
|
||||
state( Start ),
|
||||
vis( 16000 ),
|
||||
_terra_sync(NULL),
|
||||
_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);
|
||||
}
|
||||
|
||||
|
@ -91,8 +69,6 @@ FGTileMgr::~FGTileMgr()
|
|||
// remove all nodes we might have left behind
|
||||
osg::Group* group = globals->get_scenery()->get_terrain_branch();
|
||||
group->removeChildren(0, group->getNumChildren());
|
||||
delete _propListener;
|
||||
_propListener = NULL;
|
||||
// clear OSG cache
|
||||
osgDB::Registry::instance()->clearObjectCache();
|
||||
}
|
||||
|
@ -102,12 +78,9 @@ FGTileMgr::~FGTileMgr()
|
|||
void FGTileMgr::init() {
|
||||
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
|
||||
|
||||
_options = new SGReaderWriterBTGOptions;
|
||||
_options->setMatlib(globals->get_matlib());
|
||||
|
||||
_randomObjects.get()->addChangeListener(_propListener, false);
|
||||
_randomVegetation.get()->addChangeListener(_propListener, false);
|
||||
configChanged();
|
||||
_options = new simgear::SGReaderWriterOptions;
|
||||
_options->setMaterialLib(globals->get_matlib());
|
||||
_options->setPropertyNode(globals->get_props());
|
||||
|
||||
osgDB::FilePathList &fp = _options->getDatabasePathList();
|
||||
const string_list &sc = globals->get_fg_scenery();
|
||||
|
@ -153,12 +126,6 @@ void FGTileMgr::reinit()
|
|||
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.
|
||||
* Returns true if tile is already loaded. */
|
||||
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/TileCache.hxx>
|
||||
|
||||
class SGReaderWriterBTGOptions;
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Node;
|
||||
|
@ -41,6 +39,7 @@ class Node;
|
|||
namespace simgear
|
||||
{
|
||||
class SGTerraSync;
|
||||
class SGReaderWriterOptions;
|
||||
}
|
||||
|
||||
class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
|
||||
|
@ -65,7 +64,7 @@ private:
|
|||
SGBucket previous_bucket;
|
||||
SGBucket current_bucket;
|
||||
SGBucket pending;
|
||||
osg::ref_ptr<SGReaderWriterBTGOptions> _options;
|
||||
osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
|
||||
|
||||
// x and y distance of tiles to load/draw
|
||||
float vis;
|
||||
|
@ -89,9 +88,6 @@ private:
|
|||
static void refresh_tile(void* tileMgr, long tileIndex);
|
||||
|
||||
SGPropertyNode* _visibilityMeters;
|
||||
SGPropertyChangeListener* _propListener;
|
||||
SGPropertyNode_ptr _randomObjects;
|
||||
SGPropertyNode_ptr _randomVegetation;
|
||||
SGPropertyNode_ptr _maxTileRangeM;
|
||||
|
||||
public:
|
||||
|
@ -105,9 +101,6 @@ public:
|
|||
|
||||
virtual void update(double dt);
|
||||
|
||||
// update loader configuration options
|
||||
void configChanged();
|
||||
|
||||
int schedule_tiles_at(const SGGeod& location, double rangeM);
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/scene/material/EffectCullVisitor.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/TileEntry.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.
|
||||
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
|
||||
|
||||
SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
|
||||
btgOptions->getDatabasePathList() = filePathList;
|
||||
btgOptions->setMatlib(ml);
|
||||
simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
|
||||
options->getDatabasePathList() = filePathList;
|
||||
options->setMaterialLib(ml);
|
||||
options->setPropertyNode(props);
|
||||
|
||||
// Here, all arguments are processed
|
||||
arguments.reportRemainingOptionsAsUnrecognized();
|
||||
|
@ -161,7 +162,7 @@ main(int argc, char** argv)
|
|||
|
||||
// read the scene from the list of file specified command line args.
|
||||
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 (!loadedModel.valid()) {
|
||||
|
|
Loading…
Reference in a new issue