From: frohlich Date: Thu, 11 Jun 2009 18:53:19 +0000 (+0000) Subject: Finally get rid of that member in the SGModelData callback. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6d05fc6f575040d42220ddf60f60889c16e35d52;p=simgear.git Finally get rid of that member in the SGModelData callback. 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 --- diff --git a/simgear/scene/model/SGPagedLOD.cxx b/simgear/scene/model/SGPagedLOD.cxx index d66fee0d..88777b80 100644 --- a/simgear/scene/model/SGPagedLOD.cxx +++ b/simgear/scene/model/SGPagedLOD.cxx @@ -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(_readerWriterOptions.get()); - if(opts) - { - osg::ref_ptr d = opts->getModelData(); - if(d.valid()) - d->modelLoaded(getFileName(getNumChildren()-1), - d->getConfigProperties(), this); - } return true; } diff --git a/simgear/scene/model/SGReaderWriterXML.cxx b/simgear/scene/model/SGReaderWriterXML.cxx index 9a6602ee..00c113be 100644 --- a/simgear/scene/model/SGReaderWriterXML.cxx +++ b/simgear/scene/model/SGReaderWriterXML.cxx @@ -114,7 +114,7 @@ sgLoad3DModel_internal(const string &path, SGSharedPtr prop_root; osg::Node *(*load_panel)(SGPropertyNode *)=0; - SGModelData *data=0; + osg::ref_ptr data; if (xmlOptions) { prop_root = xmlOptions->getPropRoot(); @@ -227,8 +227,11 @@ sgLoad3DModel_internal(const string &path, } else { submodelpath = submodelFileName; } + osg::ref_ptr 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 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"); diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx index 4da108a1..b4317547 100644 --- a/simgear/scene/model/modellib.cxx +++ b/simgear/scene/model/modellib.cxx @@ -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; diff --git a/simgear/scene/model/modellib.hxx b/simgear/scene/model/modellib.hxx index 8840f400..7c38b10a 100644 --- a/simgear/scene/model/modellib.hxx +++ b/simgear/scene/model/modellib.hxx @@ -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 _configProperties; }; }