]> git.mxchange.org Git - simgear.git/commitdiff
accomodate changes to osgDB::DatabasePager interface
authorTim Moore <timoore33@gmail.com>
Tue, 15 Feb 2011 11:28:03 +0000 (12:28 +0100)
committerTim Moore <timoore33@gmail.com>
Tue, 15 Feb 2011 11:41:23 +0000 (12:41 +0100)
The change was introduced in OSG SVN revision 12080. Note: that
revision has a bug that causes fgfs to crash. The bug is fixed in
revision 12170.

simgear/scene/model/CheckSceneryVisitor.cxx
simgear/scene/model/SGPagedLOD.cxx
simgear/scene/model/SGPagedLOD.hxx
simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx

index a21f103b3745c33c423e9a85a92634776cfc4640..4a0625bc2ea325e11e6a64ddaabab6bd0bafaec5 100644 (file)
@@ -54,7 +54,7 @@ void CheckSceneryVisitor::apply(osg::PagedLOD& node)
                 // if the DatabasePager would load LODs while the splashscreen
                 // is there, we could just wait for the models to be loaded
                 // by only setting setLoaded(false) here
-                sgplod->forceLoad(_dbp,_framestamp);
+                sgplod->forceLoad(_dbp,_framestamp, getNodePath());
                 setLoaded(false);
             }
         }
index 02b187ea9b3db9f422be5fc2682eae33492ee70a..531b45b0b74efc9e012b81ef4867dcd9138f1083 100644 (file)
@@ -61,37 +61,30 @@ bool SGPagedLOD::addChild(osg::Node *child)
     return true;
 }
 
-void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, osg::FrameStamp* framestamp)
+// Work around interface change in osgDB::DatabasePager::requestNodeFile
+struct NodePathProxy
+{
+    NodePathProxy(NodePath& nodePath)
+        : _nodePath(nodePath)
+    {
+    }
+    operator Group* () { return static_cast<Group*>(_nodePath.back()); }
+    operator NodePath& () { return _nodePath; }
+    NodePath& _nodePath;
+};
+
+void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, FrameStamp* framestamp,
+                           NodePath& path)
 {
     //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
     //getFileName(getNumChildren()) << ")");
     unsigned childNum = getNumChildren();
     setTimeStamp(childNum, 0);
     double priority=1.0;
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,11)
-    // osgDB::DatabasePager::requestNodeFile changed with OSG 2.9.11 
-
-    #ifdef __GNUC__
-        #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-        #warning !! Your version of OpenSceneGraph is currently unsupported.
-        #warning !! Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10.
-        #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    #else
-        // Alas! Why is MSVC different (again)? :)
-        #pragma WARNING( Your version of OpenSceneGraph is currently unsupported. )
-        #pragma WARNING( Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. )
-    #endif
-
-    //TODO We need to adapt to OSG 2.9.11 (and future releases). This doesn't work yet...
-    dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp,
+    dbp->requestNodeFile(getFileName(childNum), NodePathProxy(path),
+                         priority, framestamp,
                          getDatabaseRequest(childNum),
                          _readerWriterOptions.get());
-#else
-    // OSG revisions up to 2.9.10 
-    dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp,
-                         getDatabaseRequest(childNum),
-                         _readerWriterOptions.get());
-#endif
 }
 
 bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
index fe256446b7ae6dd4aebc33a3cedbb776df87d065..a9e55d96f7d76034473fdbb4e6dbade13cf23a6c 100644 (file)
 #define SGPAGEDLOD_HXX 1
 
 #include <simgear/structure/OSGVersion.hxx>
+
+#define SG_PAGEDLOD_HAS_OPTIONS \
+    (SG_OSG_VERSION >= 29005 \
+     || (SG_OSG_VERSION < 29000 && SG_OSG_VERSION >= 28003))
+
 #include <osg/PagedLOD>
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
-#include <osgDB/Options>
-#endif
+#include <osgDB/Registry>
 #include <osgDB/ReaderWriter>
 #include <simgear/props/props.hxx>
 
@@ -43,26 +46,35 @@ public:
     META_Node(simgear, SGPagedLOD);
 
     // virtual void traverse(osg::NodeVisitor& nv);
-    virtual void forceLoad(osgDB::DatabasePager* dbp, osg::FrameStamp* framestamp);
+    virtual void forceLoad(osgDB::DatabasePager* dbp,
+                           osg::FrameStamp* framestamp,
+                           osg::NodePath& path);
 
     // reimplemented to notify the loading through ModelData
     bool addChild(osg::Node *child);
 
     void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) {
-        _readerWriterOptions = options;
         options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
+#if SG_PAGEDLOD_HAS_OPTIONS
         setDatabaseOptions(options);
+#else
+        _readerWriterOptions = options;
 #endif
     }
 
     osgDB::ReaderWriter::Options* getReaderWriterOptions() {
+#if SG_PAGEDLOD_HAS_OPTIONS
+        return static_cast<osgDB::ReaderWriter::Options*>(getDatabaseOptions());
+#else
         return _readerWriterOptions.get();
+#endif
     }
 
 protected:
     virtual ~SGPagedLOD();
+#if SG_PAGEDLOD_HAS_OPTIONS
     osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions;
+#endif
 };
 }
 #endif
index b1d21b5dde70c865a9615d9e9a427a709db46e50..097d3fcd92dcf1dd40d93b4206a849d0d42b3dfc 100644 (file)
@@ -21,6 +21,7 @@
 #include <simgear/scene/tgdb/obj.hxx>
 class SGReaderWriterBTGOptions : public osgDB::ReaderWriter::Options {
 public:
+    META_Object(simgear,SGReaderWriterBTGOptions);
     SGReaderWriterBTGOptions(const std::string& str = std::string()) :
         osgDB::ReaderWriter::Options(str),
         _matlib(0), _calcLights(true),