]> git.mxchange.org Git - flightgear.git/commitdiff
accomodate changes to osgDB::DatabasePager interface
authorTim Moore <timoore33@gmail.com>
Tue, 15 Feb 2011 11:30:56 +0000 (12:30 +0100)
committerTim Moore <timoore33@gmail.com>
Tue, 15 Feb 2011 11:42:53 +0000 (12:42 +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.

src/Scenery/SceneryPager.cxx
src/Scenery/SceneryPager.hxx

index 183511361991777dffc86d1f63a1f7194cb184b3..9328973ef4c6162deb3c5e1ca60d690a41269106 100644 (file)
@@ -44,15 +44,12 @@ SceneryPager::~SceneryPager()
 {
 }
 
+#if SG_PAGEDLOD_HAS_OPTIONS
+#else
 void SceneryPager::requestNodeFile(const std::string& fileName, Group* group,
                                    float priority, const FrameStamp* framestamp,
                                    ref_ptr<Referenced>& databaseRequest,
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
-                                   const osg::Referenced* options
-#else
-                                   osgDB::ReaderWriter::Options* options
-#endif
-                                   )
+                                   osgDB::ReaderWriter::Options* options)
 {
     simgear::SGPagedLOD *sgplod = dynamic_cast<simgear::SGPagedLOD*>(group);
     if(sgplod)
@@ -64,6 +61,7 @@ void SceneryPager::requestNodeFile(const std::string& fileName, Group* group,
                                        databaseRequest,
                                        options);
 }
+#endif
 
 void SceneryPager::queueRequest(const std::string& fileName, Group* group,
                                 float priority, FrameStamp* frameStamp,
@@ -81,6 +79,35 @@ void SceneryPager::queueDeleteRequest(osg::ref_ptr<osg::Object>& objptr)
     _deleteRequests.push_back(objptr);
     objptr = 0;
 }
+
+// Work around interface change in
+// osgDB::DatabasePager::requestNodeFile
+namespace
+{
+struct NodePathProxy
+{
+    NodePathProxy(NodePath& nodePath)
+        : _nodePath(nodePath)
+    {
+    }
+    operator Group* () { return static_cast<Group*>(_nodePath.back()); }
+    operator NodePath& () { return _nodePath; }
+    NodePath& _nodePath;
+};
+}
+
+void SceneryPager::PagerRequest::doRequest(SceneryPager* pager)
+{
+    if (_group->getNumChildren() == 0) {
+        NodePath path;
+        path.push_back(_group.get());
+        pager->requestNodeFile(_fileName, NodePathProxy(path), _priority,
+                               _frameStamp.get(),
+                               *_databaseRequest,
+                               _options.get());
+    }
+}
+
 void SceneryPager::signalEndFrame()
 {
     using namespace std;
index ba018993c6075b04f481425b9e6efbe85a485b10..04e6ef5c499e016cf13108363baa3a7ceb57a80b 100644 (file)
@@ -28,6 +28,7 @@
 #include <osgDB/DatabasePager>
 
 #include <simgear/structure/OSGVersion.hxx>
+#include <simgear/scene/model/SGPagedLOD.hxx>
 
 namespace flightgear
 {
@@ -39,16 +40,14 @@ public:
     // Unhide DatabasePager::requestNodeFile
     using osgDB::DatabasePager::requestNodeFile;
     // reimplement to add readerWriterOptions from SGPagedLOD
+#if SG_PAGEDLOD_HAS_OPTIONS
+#else
     virtual void requestNodeFile(const std::string& fileName, osg::Group* group,
                                  float priority,
                                  const osg::FrameStamp* framestamp,
                                  osg::ref_ptr<osg::Referenced>& databaseRequest,
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
-                                 const osg::Referenced* options
-#else
-                                 osgDB::ReaderWriter::Options* options
+                                 osgDB::ReaderWriter::Options* options);
 #endif
-                                 );
     void queueRequest(const std::string& fileName, osg::Group* node,
                       float priority, osg::FrameStamp* frameStamp,
                       osg::ref_ptr<osg::Referenced>& databaseRequest,
@@ -77,15 +76,7 @@ protected:
             _databaseRequest(&databaseRequest)
         {}
 
-        void doRequest(SceneryPager* pager)
-        {
-            if (_group->getNumChildren() == 0)
-                pager->requestNodeFile(_fileName, _group.get(), _priority,
-                                       _frameStamp.get(),
-                                       *_databaseRequest,
-                                       _options.get());
-        }
-
+        void doRequest(SceneryPager* pager);
         std::string _fileName;
         osg::ref_ptr<osg::Group> _group;
         float _priority;