浏览代码

* Fixed issue where an ogre3d animation with no tracks would load, but cause a NPE when loaded again from J3O

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9317 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Sha..rd 13 年之前
父节点
当前提交
c8fa79fbd6
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      engine/src/core/com/jme3/animation/Animation.java

+ 8 - 2
engine/src/core/com/jme3/animation/Animation.java

@@ -168,7 +168,13 @@ public class Animation implements Savable, Cloneable {
         length = in.readFloat("length", 0f);
         
         Savable[] arr = in.readSavableArray("tracks", null);
-        tracks = new Track[arr.length];
-        System.arraycopy(arr, 0, tracks, 0, arr.length);
+        if (arr != null) {
+            // NOTE: Backward compat only .. Some animations have no
+            // tracks set at all even though it makes no sense.
+            // Since there's a null check in setTime(),
+            // its only appropriate that the check is made here as well.
+            tracks = new Track[arr.length];
+            System.arraycopy(arr, 0, tracks, 0, arr.length);
+        }
     }
 }