Model loading; overlay properties earlier

This is to permit an <overlay> section in <model> to be present whilst the rest of the model is loaded - otherwise the overlay is only present after the model is loaded;

e.g. to allow a model specific registration to be applied to a shared model;

    <model>
        <overlay>
            <texture-file>island_68.png</texture-file>
            <carrier-name>Nimitz</carrier-name>
            <carrier-registration>CVN-68</carrier-registration>
        </overlay>
        <path>nimitz-class.xml</path>
    </model>
This commit is contained in:
Richard Harrison 2020-11-21 12:16:40 +01:00
parent e2596eaeea
commit 2cb6499f1c

View File

@ -528,7 +528,10 @@ sgLoad3DModel_internal(const SGPath& path,
// Check for an XML wrapper // Check for an XML wrapper
if (modelpath.extension() == "xml") { if (modelpath.extension() == "xml") {
try { try {
readProperties(modelpath, props); if (overlay)
copyProperties(overlay, props);
readProperties(modelpath, props);
} catch (const sg_exception &t) { } catch (const sg_exception &t) {
SG_LOG(SG_IO, SG_DEV_ALERT, "Failed to load xml: " SG_LOG(SG_IO, SG_DEV_ALERT, "Failed to load xml: "
<< t.getFormattedMessage()); << t.getFormattedMessage());
@ -538,9 +541,6 @@ sgLoad3DModel_internal(const SGPath& path,
addTooltipAnimations(path, props, model, options->getAutoTooltipsMasterMax()); addTooltipAnimations(path, props, model, options->getAutoTooltipsMasterMax());
} }
if (overlay)
copyProperties(overlay, props);
if (previewMode && props->hasChild("nopreview")) { if (previewMode && props->hasChild("nopreview")) {
return std::make_tuple(0, (osg::Node *) NULL); return std::make_tuple(0, (osg::Node *) NULL);
} }