From c8fa79fbd67e8362b3b36b06e46ca4f257bf4b4e Mon Sep 17 00:00:00 2001 From: "Sha..rd" Date: Sun, 15 Apr 2012 17:20:04 +0000 Subject: [PATCH] * 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 --- engine/src/core/com/jme3/animation/Animation.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/src/core/com/jme3/animation/Animation.java b/engine/src/core/com/jme3/animation/Animation.java index a0999f260..a910d1362 100644 --- a/engine/src/core/com/jme3/animation/Animation.java +++ b/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); + } } }