]> git.mxchange.org Git - simgear.git/commitdiff
Finally get rid of that member in the SGModelData callback.
authorfrohlich <frohlich>
Thu, 11 Jun 2009 18:53:19 +0000 (18:53 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 15 Jun 2009 08:23:21 +0000 (10:23 +0200)
Move call of SGModelData::modelLoaded directly into the xml reader.

Modified Files:
  simgear/scene/model/SGPagedLOD.cxx
  simgear/scene/model/modellib.hxx
  simgear/scene/model/modellib.cxx
  simgear/scene/model/SGReaderWriterXML.cxx

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

index d66fee0d5306a1737c9f5ddd18161bf75243bb97..88777b8043fc50fee914d35fc27803197ee3d925 100644 (file)
@@ -44,21 +44,11 @@ SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
 
 bool SGPagedLOD::addChild(osg::Node *child)
 {
-    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::addChild(" << getFileName(getNumChildren()) << ")");
     if (!PagedLOD::addChild(child))
         return false;
 
     setRadius(getBound().radius());
     setCenter(getBound().center());
-    SGReaderWriterXMLOptions* opts;
-    opts = dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
-    if(opts)
-    {
-        osg::ref_ptr<SGModelData> d = opts->getModelData();
-        if(d.valid())
-            d->modelLoaded(getFileName(getNumChildren()-1),
-                           d->getConfigProperties(), this);
-    }
     return true;
 }
 
index 9a6602ee02d764276bb6220a507b15be6a5d72ef..00c113be0f8b2dfd4eae584ab8db99d789a80a7e 100644 (file)
@@ -114,7 +114,7 @@ sgLoad3DModel_internal(const string &path,
 
     SGSharedPtr<SGPropertyNode> prop_root;
     osg::Node *(*load_panel)(SGPropertyNode *)=0;
-    SGModelData *data=0;
+    osg::ref_ptr<SGModelData> data;
 
     if (xmlOptions) {
         prop_root = xmlOptions->getPropRoot();
@@ -227,8 +227,11 @@ sgLoad3DModel_internal(const string &path,
         } else {
             submodelpath = submodelFileName;
         }
+        osg::ref_ptr<SGReaderWriterXMLOptions> options;
+        options = new SGReaderWriterXMLOptions(*options_);
+        options->setPropRoot(prop_root);
         try {
-            submodel = sgLoad3DModel_internal(submodelpath.str(), options_,
+            submodel = sgLoad3DModel_internal(submodelpath.str(), options.get(),
                                               sub_props->getNode("overlay"));
         } catch (const sg_throwable &t) {
             SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
@@ -299,11 +302,6 @@ sgLoad3DModel_internal(const string &path,
                         options.get()));
     }
 
-    if (data) {
-        data->setConfigProperties(props);
-        options->setModelData(data);
-    }
-
     std::vector<SGPropertyNode_ptr> animation_nodes;
     animation_nodes = props->getChildren("animation");
     for (unsigned i = 0; i < animation_nodes.size(); ++i)
@@ -314,9 +312,12 @@ sgLoad3DModel_internal(const string &path,
     if (!needTransform && group->getNumChildren() < 2) {
         model = group->getChild(0);
         group->removeChild(model.get());
-        model->setUserData(group->getUserData());
+        if (data.valid())
+            data->modelLoaded(modelpath.str(), props, model.get());
         return model.release();
     }
+    if (data.valid())
+        data->modelLoaded(modelpath.str(), props, group.get());
     if (props->hasChild("debug-outfile")) {
         std::string outputfile = props->getStringValue("debug-outfile",
                                  "debug-model.osg");
index 4da108a1d2c63065a013c1908805b104fa9b1e2b..b431754795247e645ede551a929295bcd3990a83 100644 (file)
@@ -66,8 +66,6 @@ SGModelLib::loadModel(const string &path,
     opt->setPropRoot(prop_root);
     opt->setModelData(data);
     osg::Node *n = readNodeFile(path, opt.get());
-    if(data)
-        data->modelLoaded(path, data->getConfigProperties(), n);
     if (n && n->getName().empty())
         n->setName("Direct loaded model \"" + path + "\"");
     return n;
index 8840f400aa80fa98a5614f8fe1939e3f08d0d1d1..7c38b10abedd6adcfcf659d601a7b5b1452145db 100644 (file)
@@ -85,13 +85,6 @@ public:
     virtual ~SGModelData() {}
     virtual void modelLoaded(const string& path, SGPropertyNode *prop,
                              osg::Node* branch) = 0;
-    void setConfigProperties(SGPropertyNode *configProperties)
-    { _configProperties = configProperties; }
-    SGPropertyNode *getConfigProperties()
-    { return _configProperties; }
-
-private:
-    SGSharedPtr<SGPropertyNode> _configProperties;
 };
 
 }