From 8c2bdebbae469db737a3eb188a996080aadb6c46 Mon Sep 17 00:00:00 2001 From: "Sha..rd" Date: Fri, 14 Sep 2012 05:22:31 +0000 Subject: [PATCH] * AnimControl now forces the animation map to be non-null in all cases - when creating a new AnimControl, cloning it or loading from J3O. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9725 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/animation/AnimControl.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/engine/src/core/com/jme3/animation/AnimControl.java b/engine/src/core/com/jme3/animation/AnimControl.java index 000b40b76..daf1c5d67 100644 --- a/engine/src/core/com/jme3/animation/AnimControl.java +++ b/engine/src/core/com/jme3/animation/AnimControl.java @@ -77,7 +77,7 @@ public final class AnimControl extends AbstractControl implements Cloneable { /** * List of animations */ - HashMap animationMap; + HashMap animationMap = new HashMap(); /** * Animation channels */ @@ -120,7 +120,6 @@ public final class AnimControl extends AbstractControl implements Cloneable { } // animationMap is cloned, but only ClonableTracks will be cloned as they need a reference to a cloned spatial - clone.animationMap = new HashMap(); for (Entry animEntry : animationMap.entrySet()) { clone.animationMap.put(animEntry.getKey(), animEntry.getValue().cloneForSpatial(spatial)); } @@ -147,9 +146,6 @@ public final class AnimControl extends AbstractControl implements Cloneable { * such named animation exists. */ public Animation getAnim(String name) { - if (animationMap == null) { - animationMap = new HashMap(); - } return animationMap.get(name); } @@ -159,9 +155,6 @@ public final class AnimControl extends AbstractControl implements Cloneable { * @param anim The animation to add. */ public void addAnim(Animation anim) { - if (animationMap == null) { - animationMap = new HashMap(); - } animationMap.put(anim.getName(), anim); } @@ -360,7 +353,10 @@ public final class AnimControl extends AbstractControl implements Cloneable { super.read(im); InputCapsule in = im.getCapsule(this); skeleton = (Skeleton) in.readSavable("skeleton", null); - animationMap = (HashMap) in.readStringSavableMap("animations", null); + HashMap loadedAnimationMap = (HashMap) in.readStringSavableMap("animations", null); + if (loadedAnimationMap != null) { + animationMap = loadedAnimationMap; + } if (im.getFormatVersion() == 0) { // Changed for backward compatibility with j3o files generated