Browse Source

Towards #252 Try to not crash for GLTF Files.

MeFisto94 5 years ago
parent
commit
c9fb82917c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java

+ 5 - 1
jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java

@@ -286,7 +286,11 @@ public class SpatialUtil {
                             logger.log(Level.INFO, "Control for {0} was added automatically", mySpatial.getName());
                         }
                         if (mySpatial.getControl(SkeletonControl.class) == null) {
-                            mySpatial.addControl(new SkeletonControl(animControl.getSkeleton()));
+                            if (animControl.getSkeleton() == null) {
+                                logger.log(Level.INFO, "Could not add a SkeletonControl for {0}, because animControl.getSkeleton() return null. Broken file? Gltf?", mySpatial.getName());
+                            } else {
+                                mySpatial.addControl(new SkeletonControl(animControl.getSkeleton()));
+                            }
                         } else {
                             logger.log(Level.INFO, "SkeletonControl for {0} was added by AnimControl already", mySpatial.getName());
                         }