Enable OSG cache (default) and option to disable.

(also requires flightgear update)
This commit is contained in:
ThorstenB
2011-04-03 18:56:09 +02:00
parent 3c0c51a946
commit 83243f471a
4 changed files with 24 additions and 17 deletions
+16
View File
@@ -35,6 +35,8 @@
using namespace osg; using namespace osg;
using namespace simgear; using namespace simgear;
bool SGPagedLOD::_cache = true;
SGPagedLOD::SGPagedLOD() SGPagedLOD::SGPagedLOD()
: PagedLOD() : PagedLOD()
{ {
@@ -53,6 +55,20 @@ SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
{ {
} }
void
SGPagedLOD::setReaderWriterOptions(osgDB::ReaderWriter::Options *options)
{
if (_cache)
options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
else
options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
#if SG_PAGEDLOD_HAS_OPTIONS
setDatabaseOptions(options);
#else
_readerWriterOptions = options;
#endif
}
bool SGPagedLOD::addChild(osg::Node *child) bool SGPagedLOD::addChild(osg::Node *child)
{ {
if (!PagedLOD::addChild(child)) if (!PagedLOD::addChild(child))
+4 -8
View File
@@ -52,14 +52,7 @@ public:
// reimplemented to notify the loading through ModelData // reimplemented to notify the loading through ModelData
bool addChild(osg::Node *child); bool addChild(osg::Node *child);
void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) { void setReaderWriterOptions(osgDB::ReaderWriter::Options *options);
options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
#if SG_PAGEDLOD_HAS_OPTIONS
setDatabaseOptions(options);
#else
_readerWriterOptions = options;
#endif
}
osgDB::ReaderWriter::Options* getReaderWriterOptions() { osgDB::ReaderWriter::Options* getReaderWriterOptions() {
#if SG_PAGEDLOD_HAS_OPTIONS #if SG_PAGEDLOD_HAS_OPTIONS
@@ -69,11 +62,14 @@ public:
#endif #endif
} }
static void setRenderingCache(bool cache) {_cache = cache;}
protected: protected:
virtual ~SGPagedLOD(); virtual ~SGPagedLOD();
#if !SG_PAGEDLOD_HAS_OPTIONS #if !SG_PAGEDLOD_HAS_OPTIONS
osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions; osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions;
#endif #endif
private:
static bool _cache;
}; };
} }
#endif #endif
+3 -6
View File
@@ -52,16 +52,13 @@ SGModelLib::panel_func SGModelLib::static_panelFunc = NULL;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGModelLib. // Implementation of SGModelLib.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void SGModelLib::init(const string &root_dir) void SGModelLib::init(const string &root_dir, SGPropertyNode* root)
{ {
osgDB::Registry::instance()->getDataFilePathList().push_front(root_dir); osgDB::Registry::instance()->getDataFilePathList().push_front(root_dir);
static_propRoot = root;
SGPagedLOD::setRenderingCache(root->getBoolValue("/sim/rendering/cache",true));
} }
void SGModelLib::setPropRoot(SGPropertyNode* root)
{
static_propRoot = root;
}
void SGModelLib::setPanelFunc(panel_func pf) void SGModelLib::setPanelFunc(panel_func pf)
{ {
static_panelFunc = pf; static_panelFunc = pf;
+1 -3
View File
@@ -44,10 +44,8 @@ class SGModelLib
public: public:
typedef osg::Node *(*panel_func)(SGPropertyNode *); typedef osg::Node *(*panel_func)(SGPropertyNode *);
static void init(const std::string &root_dir); static void init(const std::string &root_dir, SGPropertyNode* root);
static void setPropRoot(SGPropertyNode* root);
static void setPanelFunc(panel_func pf); static void setPanelFunc(panel_func pf);
// Load a 3D model (any format) // Load a 3D model (any format)