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
This commit is contained in:
frohlich
2009-06-11 18:53:19 +00:00
committed by Tim Moore
parent ca53add820
commit 6d05fc6f57
4 changed files with 9 additions and 27 deletions

View 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;
}

View 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");

View 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;

View 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;
};
}