From 3d38b634d51b691e6e296b3a79175df34241e895 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 17 Jan 2013 19:44:05 +0000 Subject: [PATCH] Added functionality that will ignore modifiers that cause no changes to the model due to incomplete (but not invalid) definition. This caused errors when object had for example two armature modifiers and only the second one had armature model attached. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10087 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../plugins/blender/modifiers/ArmatureModifier.java | 2 ++ .../scene/plugins/blender/modifiers/Modifier.java | 13 +++++++++++++ .../plugins/blender/modifiers/ModifierHelper.java | 10 +++++++--- 3 files changed, 22 insertions(+), 3 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 f077a198c..51e2d76bf 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 @@ -177,6 +177,8 @@ import com.jme3.util.BufferUtils; blenderContext.setAnimData(boneOma, animData); } } + } else { + modifying = false; } } } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java index a7a3a1a80..6138dae5f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/Modifier.java @@ -23,6 +23,12 @@ public abstract class Modifier { /** This variable indicates if the modifier is invalid (true) or not (false). */ protected boolean invalid; + /** + * A variable that tells if the modifier causes modification. Some modifiers like ArmatureModifier might have no + * Armature object attached and thus not really modifying the feature. In such cases it is good to know if it is + * sense to add the modifier to the list of object's modifiers. + */ + protected boolean modifying = true; /** * This method applies the modifier to the given node. @@ -62,4 +68,11 @@ public abstract class Modifier { invalid = pError.isNotNull(); return !invalid; } + + /** + * @return true if the modifier causes feature's modification or false if not + */ + public boolean isModifying() { + return modifying; + } } 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 5688083f2..e7cdcc2dc 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 @@ -101,9 +101,13 @@ public class ModifierHelper extends AbstractBlenderHelper { } if (modifier != null) { - result.add(modifier); - blenderContext.addModifier(objectStructure.getOldMemoryAddress(), modifier); - alreadyReadModifiers.add(modifierType); + if(modifier.isModifying()) { + result.add(modifier); + blenderContext.addModifier(objectStructure.getOldMemoryAddress(), modifier); + alreadyReadModifiers.add(modifierType); + } else { + LOGGER.log(Level.WARNING, "The modifier {0} will cause no changes in the model. It will be ignored!", modifierStructure.getName()); + } } else { LOGGER.log(Level.WARNING, "Unsupported modifier type: {0}", modifierStructure.getType()); }