From 952081b1925a78aa3f4d058be3e401ba114041c9 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Wed, 5 Oct 2011 05:56:12 +0000 Subject: [PATCH] Fixing a bug that caused NPE to be thrown when no actions where applied to armature. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8360 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/modifiers/ArmatureModifier.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java index dc4be4945..dec836874 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java @@ -118,23 +118,25 @@ import com.jme3.util.BufferUtils; //read animations ArrayList animations = new ArrayList(); List actionHeaders = blenderContext.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); - for (FileBlockHeader header : actionHeaders) { - Structure actionStructure = header.getStructure(blenderContext); - String actionName = actionStructure.getName(); - - Track[] tracks = armatureHelper.getTracks(actionStructure, blenderContext); - //determining the animation time - float maximumTrackLength = 0; - for(Track track : tracks) { - float length = track.getLength(); - if(length > maximumTrackLength) { - maximumTrackLength = length; + if(actionHeaders != null) {//it may happen that the model has armature with no actions + for (FileBlockHeader header : actionHeaders) { + Structure actionStructure = header.getStructure(blenderContext); + String actionName = actionStructure.getName(); + + Track[] tracks = armatureHelper.getTracks(actionStructure, blenderContext); + //determining the animation time + float maximumTrackLength = 0; + for(Track track : tracks) { + float length = track.getLength(); + if(length > maximumTrackLength) { + maximumTrackLength = length; + } } + + Animation boneAnimation = new Animation(actionName, maximumTrackLength); + boneAnimation.setTracks(tracks); + animations.add(boneAnimation); } - - Animation boneAnimation = new Animation(actionName, maximumTrackLength); - boneAnimation.setTracks(tracks); - animations.add(boneAnimation); } animData = new AnimData(new Skeleton(bones), animations); }