From 01873e6f80f934824f039fa7198665521b718c99 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 24 Jan 2013 19:40:05 +0000 Subject: [PATCH] Bugfix: NPE was thrown when object animation was loaded. To fix that modifiers are now loaded after the whole object is loaded to the blenderContext. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10142 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../plugins/blender/objects/ObjectHelper.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java index 58ccbfae6..c4dc55945 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java @@ -127,7 +127,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Structure parentStructure = pParent.fetchData(blenderContext.getInputStream()).get(0); parent = this.toObject(parentStructure, blenderContext); } - + Transform t = this.getTransformation(objectStructure, blenderContext); try { @@ -158,13 +158,6 @@ public class ObjectHelper extends AbstractBlenderHelper { } node.setLocalTransform(t); - //reading and applying all modifiers - ModifierHelper modifierHelper = blenderContext.getHelper(ModifierHelper.class); - Collection modifiers = modifierHelper.readModifiers(objectStructure, blenderContext); - for(Modifier modifier : modifiers) { - modifier.apply(node, blenderContext); - } - //setting the parent if(parent instanceof Node) { ((Node)parent).attachChild(node); @@ -216,7 +209,7 @@ public class ObjectHelper extends AbstractBlenderHelper { Node armature = new Node(name); armature.setLocalTransform(t); armature.setUserData(ArmatureHelper.ARMETURE_NODE_MARKER, Boolean.TRUE); - //TODO: modifiers for armature ???? + if(parent instanceof Node) { ((Node)parent).attachChild(armature); } @@ -234,6 +227,14 @@ public class ObjectHelper extends AbstractBlenderHelper { blenderContext.addLoadedFeatures(objectStructure.getOldMemoryAddress(), name, objectStructure, result); + //applying modifiers + LOGGER.log(Level.FINE, "Reading and applying object's modifiers."); + ModifierHelper modifierHelper = blenderContext.getHelper(ModifierHelper.class); + Collection modifiers = modifierHelper.readModifiers(objectStructure, blenderContext); + for(Modifier modifier : modifiers) { + modifier.apply(result, blenderContext); + } + //loading constraints connected with this object ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class); constraintHelper.loadConstraints(objectStructure, blenderContext);