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
3.0
Kae..pl 14 years ago
parent 7a0713cd59
commit 952081b192
  1. 32
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java

@ -118,23 +118,25 @@ import com.jme3.util.BufferUtils;
//read animations //read animations
ArrayList<Animation> animations = new ArrayList<Animation>(); ArrayList<Animation> animations = new ArrayList<Animation>();
List<FileBlockHeader> actionHeaders = blenderContext.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); List<FileBlockHeader> actionHeaders = blenderContext.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00));
for (FileBlockHeader header : actionHeaders) { if(actionHeaders != null) {//it may happen that the model has armature with no actions
Structure actionStructure = header.getStructure(blenderContext); for (FileBlockHeader header : actionHeaders) {
String actionName = actionStructure.getName(); Structure actionStructure = header.getStructure(blenderContext);
String actionName = actionStructure.getName();
Track<?>[] tracks = armatureHelper.getTracks(actionStructure, blenderContext);
//determining the animation time Track<?>[] tracks = armatureHelper.getTracks(actionStructure, blenderContext);
float maximumTrackLength = 0; //determining the animation time
for(Track<?> track : tracks) { float maximumTrackLength = 0;
float length = track.getLength(); for(Track<?> track : tracks) {
if(length > maximumTrackLength) { float length = track.getLength();
maximumTrackLength = length; if(length > maximumTrackLength) {
maximumTrackLength = length;
}
} }
}
Animation boneAnimation = new Animation(actionName, maximumTrackLength); Animation boneAnimation = new Animation(actionName, maximumTrackLength);
boneAnimation.setTracks(tracks); boneAnimation.setTracks(tracks);
animations.add(boneAnimation); animations.add(boneAnimation);
}
} }
animData = new AnimData(new Skeleton(bones), animations); animData = new AnimData(new Skeleton(bones), animations);
} }

Loading…
Cancel
Save