]> git.mxchange.org Git - simgear.git/commitdiff
#348: Missing model/texture files not reported properly
authorThorstenB <brehmt@gmail.com>
Sat, 25 Jun 2011 22:36:19 +0000 (00:36 +0200)
committerThorstenB <brehmt@gmail.com>
Sat, 25 Jun 2011 22:36:19 +0000 (00:36 +0200)
Whenever resolving a (relative) path to an absolute path with
'findDataFile', check if the result is empty and report original
(relative) path as missing. Otherwise no or a meaningless message is
issued ("File '' not found.").

simgear/scene/material/Effect.cxx
simgear/scene/material/TextureBuilder.cxx
simgear/scene/model/SGReaderWriterXML.cxx

index 6517bd2390171be9de11901dbfefcdaa0ddb643c..33e272c1cd4530ad8d6ab41f1046e446a6dfa2c6 100644 (file)
@@ -724,10 +724,10 @@ void reload_shaders()
 {
     for(ShaderMap::iterator sitr = shaderMap.begin(); sitr != shaderMap.end(); ++sitr)
     {
-       Shader *shader = sitr->second.get();
+        Shader *shader = sitr->second.get();
         string fileName = SGModelLib::findDataFile(sitr->first.first);
         if (!fileName.empty()) {
-           shader->loadShaderSourceFromFile(fileName);
+            shader->loadShaderSourceFromFile(fileName);
         }
     }
 }
index 797dae25c816c54aaeeeb32c2e9d0829f7035ecb..f53fe5265910acdae34eef9b29e57c1317793904 100644 (file)
@@ -211,9 +211,17 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
     const SGPropertyNode* pImage
         = getEffectPropertyChild(effect, props, "image");
     string imageName;
+    string absFileName;
     if (pImage)
+    {
         imageName = pImage->getStringValue();
-    string absFileName = SGModelLib::findDataFile(imageName, options);
+        absFileName = SGModelLib::findDataFile(imageName, options);
+        if (absFileName.empty())
+        {
+            SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '"
+                   << imageName << "'");
+        }
+    }
 
     const SGPropertyNode* pMipmapControl
         = getEffectPropertyChild(effect, props, "mipmap-control");
index 0b5def18b10c8cfb6f9a5fb2d902b1d8a8b0d107..b17c776ad79ca07aeb050098c3abb74f03297e60 100644 (file)
@@ -245,9 +245,18 @@ sgLoad3DModel_internal(const SGPath& path,
             copyProperties(overlay, props);
 
         if (props->hasValue("/path")) {
-            modelpath = SGModelLib::findDataFile(props->getStringValue("/path"), NULL, modelDir);
+            string modelPathStr = props->getStringValue("/path");
+            modelpath = SGModelLib::findDataFile(modelPathStr, NULL, modelDir);
+            if (modelpath.isNull())
+                throw sg_io_exception("Model file not found: '" + modelPathStr + "'",
+                        path.str());
+
             if (props->hasValue("/texture-path")) {
-                texturepath = SGModelLib::findDataFile(props->getStringValue("/texture-path"), NULL, modelDir);
+                string texturePathStr = props->getStringValue("/texture-path");
+                texturepath = SGModelLib::findDataFile(texturePathStr, NULL, modelDir);
+                if (texturepath.isNull())
+                    throw sg_io_exception("Texture file not found: '" + texturePathStr + "'",
+                            path.str());
             }
         } else {
             model = new osg::Node;
@@ -336,9 +345,15 @@ sgLoad3DModel_internal(const SGPath& path,
         SGPath submodelpath;
         osg::ref_ptr<osg::Node> submodel;
         
-        SGPath submodelPath = SGModelLib::findDataFile(sub_props->getStringValue("path"), 
+        string subPathStr = sub_props->getStringValue("path");
+        SGPath submodelPath = SGModelLib::findDataFile(subPathStr, 
           NULL, modelDir);
 
+        if (submodelPath.isNull()) {
+          SG_LOG(SG_INPUT, SG_ALERT, "Failed to load file: \"" << subPathStr << "\"");
+          continue;
+        }
+
         osg::ref_ptr<SGReaderWriterXMLOptions> options;
         options = new SGReaderWriterXMLOptions(*options_);
         options->setPropRoot(prop_root);