Browse Source

If we are loading a material from a J3O file, do not crash on missing material parameters, but log it instead.
Fixes test crash on any tests using cornellbox.j3o

shadowislord 11 years ago
parent
commit
bf2656abf3
1 changed files with 7 additions and 2 deletions
  1. 7 2
      jme3-core/src/main/java/com/jme3/material/Material.java

+ 7 - 2
jme3-core/src/main/java/com/jme3/material/Material.java

@@ -1320,8 +1320,13 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
                 param.setName(param.getName().substring(2));
             }
             
-            checkSetParam(param.getVarType(), param.getName());
-            paramValues.put(param.getName(), param);
+            if (def.getMaterialParam(name) == null) {
+                logger.log(Level.WARNING, "The material parameter is not defined: " + 
+                                          name + ". Ignoring..");
+            } else {
+                checkSetParam(param.getVarType(), param.getName());
+                paramValues.put(param.getName(), param);
+            }
         }
 
         if (applyDefaultValues) {