]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/SGPagedLOD.cxx
Do not modify danymically generated textures.
[simgear.git] / simgear / scene / model / SGPagedLOD.cxx
index ee68b499875bc887ddb89a299e3584b61ebc70b4..545aadb72b91e8d38833ba11731db8dded3d4a3c 100644 (file)
@@ -17,6 +17,7 @@
 #include <osgDB/ReadFile>
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/structure/OSGVersion.hxx>
 
 #include "modellib.hxx"
 #include "SGReaderWriterXMLOptions.hxx"
@@ -47,28 +48,29 @@ bool SGPagedLOD::addChild(osg::Node *child)
     if (!PagedLOD::addChild(child))
         return false;
 
-    // if the model was an .xml-file it will have UserData set
-    osg::ref_ptr<SGModelData> d = dynamic_cast<SGModelData*>(child->getUserData());
-    if (d.valid())
-        d->modelLoaded(getFileName(getNumChildren()-1), d->getProperties(), this);
-    else // this calls modelLoaded for non-xml models
+    setRadius(getBound().radius());
+    setCenter(getBound().center());
+    SGReaderWriterXMLOptions* opts;
+    opts = dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
+    if(opts)
     {
-        SGReaderWriterXMLOptions *o=dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
-        if(o)
-        {
-            d = o->getModelData();
-            if(d.valid())
-                d->modelLoaded(getFileName(getNumChildren()-1), 0, this);
-        }
+        osg::ref_ptr<SGModelData> d = opts->getModelData();
+        if(d.valid())
+            d->modelLoaded(getFileName(getNumChildren()-1), opts->getPropRoot(),
+                           this);
     }
     return true;
 }
 
 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp)
 {
-    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" << getFileName(getNumChildren()) << ")");
-    setTimeStamp(getNumChildren(),0);
+    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
+    //getFileName(getNumChildren()) << ")");
+    unsigned childNum = getNumChildren();
+    setTimeStamp(childNum, 0);
     double priority=1.0;
-    dbp->requestNodeFile(getFileName(getNumChildren()),this,priority,0, _readerWriterOptions.get());
+    dbp->requestNodeFile(getFileName(childNum),this,priority,0,
+                         getDatabaseRequest(childNum),
+                         _readerWriterOptions.get());
 }