Pārlūkot izejas kodu

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
Kae..pl 14 gadi atpakaļ
vecāks
revīzija
952081b192

+ 17 - 15
engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java

@@ -118,23 +118,25 @@ import com.jme3.util.BufferUtils;
 				//read animations
 				ArrayList<Animation> animations = new ArrayList<Animation>();
 				List<FileBlockHeader> 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);
 			}