From 5e2c814086461dfb69ee02c62844ef0bcab66200 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Fri, 16 Nov 2012 12:47:54 +0000 Subject: [PATCH] Issue 540: NullPointerException when loading blender model git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9998 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scene/plugins/blender/animations/ArmatureHelper.java | 4 +++- .../scene/plugins/blender/modifiers/ArmatureModifier.java | 1 - .../scene/plugins/blender/modifiers/ModifierHelper.java | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java index bd98cad3a..6af3cefca 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java @@ -236,7 +236,9 @@ public class ArmatureHelper extends AbstractBlenderHelper { if (!p.isNull()) { Structure ipoStructure = p.fetchData(blenderContext.getInputStream()).get(0); Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext); - tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, 0, ipo.getLastFrame(), fps, false)); + if(ipo != null) { + tracks.add((BoneTrack) ipo.calculateTrack(boneIndex, 0, ipo.getLastFrame(), fps, false)); + } } } } 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 573f13d5d..ee5da3002 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 @@ -325,7 +325,6 @@ import com.jme3.util.BufferUtils; if (boneIndex != null) { float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue(); if (weight == 0.0f) { - weight = 1; boneIndex = Integer.valueOf(0); } // we apply the weight to all referenced vertices diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java index f21a2ff9e..5688083f2 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ModifierHelper.java @@ -149,8 +149,10 @@ public class ModifierHelper extends AbstractBlenderHelper { IpoHelper ipoHelper = blenderContext.getHelper(IpoHelper.class); Structure ipoStructure = pIpo.fetchData(blenderContext.getInputStream()).get(0); Ipo ipo = ipoHelper.fromIpoStructure(ipoStructure, blenderContext); - result = new ObjectAnimationModifier(ipo, objectStructure.getName(), objectStructure.getOldMemoryAddress(), blenderContext); - blenderContext.addModifier(objectStructure.getOldMemoryAddress(), result); + if(ipo != null) { + result = new ObjectAnimationModifier(ipo, objectStructure.getName(), objectStructure.getOldMemoryAddress(), blenderContext); + blenderContext.addModifier(objectStructure.getOldMemoryAddress(), result); + } } return result; }