]> git.mxchange.org Git - simgear.git/commitdiff
Enable OSG cache (default) and option to disable.
authorThorstenB <brehmt@gmail.com>
Sun, 3 Apr 2011 16:56:09 +0000 (18:56 +0200)
committerThorstenB <brehmt@gmail.com>
Sun, 3 Apr 2011 16:56:09 +0000 (18:56 +0200)
(also requires flightgear update)

simgear/scene/model/SGPagedLOD.cxx
simgear/scene/model/SGPagedLOD.hxx
simgear/scene/model/modellib.cxx
simgear/scene/model/modellib.hxx

index f503544ac6226308e520e0d915e25ac2d51f3b3f..b44019b7ec5ada7b3168f8cee6b6af4ce48d3508 100644 (file)
@@ -35,6 +35,8 @@
 using namespace osg;
 using namespace simgear;
 
+bool SGPagedLOD::_cache = true;
+
 SGPagedLOD::SGPagedLOD()
         : 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)
 {
     if (!PagedLOD::addChild(child))
index 25a0e133c3a2a69f22f59fd37649a574d26ba7a0..69f8dc21edcf4a8dc6c21fd6ea136bf587fd3ed5 100644 (file)
@@ -52,14 +52,7 @@ public:
     // reimplemented to notify the loading through ModelData
     bool addChild(osg::Node *child);
 
-    void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) {
-        options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
-#if SG_PAGEDLOD_HAS_OPTIONS
-        setDatabaseOptions(options);
-#else
-        _readerWriterOptions = options;
-#endif
-    }
+    void setReaderWriterOptions(osgDB::ReaderWriter::Options *options);
 
     osgDB::ReaderWriter::Options* getReaderWriterOptions() {
 #if SG_PAGEDLOD_HAS_OPTIONS
@@ -69,11 +62,14 @@ public:
 #endif
     }
 
+    static void setRenderingCache(bool cache) {_cache = cache;}
 protected:
     virtual ~SGPagedLOD();
 #if !SG_PAGEDLOD_HAS_OPTIONS
     osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions;
 #endif
+private:
+    static bool _cache;
 };
 }
 #endif
index 45c014309a8e4f2c576d997bf28f30c5ad27d8ca..886825f89325b60d4fd677cddeccb4d53c53a6bb 100644 (file)
@@ -52,16 +52,13 @@ SGModelLib::panel_func SGModelLib::static_panelFunc = NULL;
 ////////////////////////////////////////////////////////////////////////
 // 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);
+    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)
 {
   static_panelFunc = pf;
index 63358855b31a07a7f4a1893421713f91fa1aa92e..61091085f057900063b796ea3af929ed1153583e 100644 (file)
@@ -44,10 +44,8 @@ class SGModelLib
 public:
     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);
     
     // Load a 3D model (any format)