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