瀏覽代碼

Blender Importer: Don't crash when a packed texture couldn't be loaded

MeFisto94 8 年之前
父節點
當前提交
1b76160410

+ 7 - 1
jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java

@@ -251,7 +251,13 @@ public class TextureHelper extends AbstractBlenderHelper {
                     blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition());
                     blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition());
 
 
                     // Should the texture be flipped? It works for sinbad ..
                     // Should the texture be flipped? It works for sinbad ..
-                    result = new Texture2D(new ImageLoader().loadImage(blenderContext.getInputStream(), dataFileBlock.getBlockPosition(), true));
+                    Image img = new ImageLoader().loadImage(blenderContext.getInputStream(), dataFileBlock.getBlockPosition(), true);
+                    
+                    if (img != null) {
+                        result = new Texture2D(img);
+                    } else {
+                        LOGGER.fine("ImageLoader returned null. It probably failed to load the packed texture");
+                    }
                 }
                 }
             }
             }
         //} else {
         //} else {