]> git.mxchange.org Git - simgear.git/commitdiff
Attach the ModelData to the options instead of the userdata field.
authorfrohlich <frohlich>
Sat, 16 May 2009 17:46:12 +0000 (17:46 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 19 May 2009 21:53:24 +0000 (23:53 +0200)
Modified Files:
simgear/scene/model/SGPagedLOD.cxx
simgear/scene/model/SGReaderWriterXML.cxx

simgear/scene/model/SGPagedLOD.cxx
simgear/scene/model/SGReaderWriterXML.cxx

index b45af2046b9a55ecbca47272058c088896336dd3..8debb8d15cc482dc0eaefb46b83c8bcc42956f97 100644 (file)
@@ -50,19 +50,13 @@ bool SGPagedLOD::addChild(osg::Node *child)
 
     setRadius(getBound().radius());
     setCenter(getBound().center());
-    // 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
+    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), 0, this);
     }
     return true;
 }
index abdac8d0f68e43ba0fff2ecaf6680e5b35279ab5..7a3660f6f35577b13016aa4183e165914dee2cf0 100644 (file)
@@ -179,9 +179,8 @@ sgLoad3DModel_internal(const string &path,
             copyProperties(mp, prop_root);
     }
 
-    osg::ref_ptr<osgDB::ReaderWriter::Options> options
-    = new osgDB::ReaderWriter::Options(*osgDB::Registry::instance()
-                                       ->getOptions());
+    osg::ref_ptr<SGReaderWriterXMLOptions> options
+    = new SGReaderWriterXMLOptions(*osgDB::Registry::instance()->getOptions());
 
     // Assume that textures are in
     // the same location as the XML file.
@@ -311,7 +310,7 @@ sgLoad3DModel_internal(const string &path,
 
     if (data) {
         data->setProps(props);
-        group->setUserData(data);
+        options->setModelData(data);
     }
 
     std::vector<SGPropertyNode_ptr> animation_nodes;