diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java index 08a3e644f..2e46fd77d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java @@ -23,7 +23,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper; */ public class BoneContext { // the flags of the bone - private static final int CONNECTED_TO_PARENT = 0x10; + public static final int CONNECTED_TO_PARENT = 0x10; /** * The bones' matrices have, unlike objects', the coordinate system identical to JME's (Y axis is UP, X to the right and Z toward us). @@ -35,7 +35,7 @@ public class BoneContext { /** The OMA of the bone's armature object. */ private Long armatureObjectOMA; /** The OMA of the model that owns the bone's skeleton. */ - private Long skeletonOwnerOma; + private Long skeletonOwnerOma; /** The structure of the bone. */ private Structure boneStructure; /** Bone's name. */ @@ -186,7 +186,7 @@ public class BoneContext { public Long getArmatureObjectOMA() { return armatureObjectOMA; } - + /** * @return the OMA of the model that owns the bone's skeleton */ @@ -207,10 +207,10 @@ public class BoneContext { * the mask of the flag (constants defined in this class) * @return true if the bone IS of specified proeprty and false otherwise */ - private boolean is(int flagMask) { + public boolean is(int flagMask) { return (flag & flagMask) != 0; } - + @Override public String toString() { return "BoneContext: " + bone.getName(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionDistLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionDistLimit.java index b2ab36b6c..5185d1646 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionDistLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionDistLimit.java @@ -4,6 +4,7 @@ import com.jme3.animation.Bone; import com.jme3.math.Transform; import com.jme3.math.Vector3f; import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.animations.BoneContext; import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space; import com.jme3.scene.plugins.blender.file.Structure; @@ -28,8 +29,9 @@ import com.jme3.scene.plugins.blender.file.Structure; @Override public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) { - if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) { - // distance limit does not work on bones who have parent + if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null && + blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) { + // distance limit does not work on bones who are connected to their parent return; } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLike.java index 43250fec2..e2516e658 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLike.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLike.java @@ -4,6 +4,7 @@ import com.jme3.animation.Bone; import com.jme3.math.Transform; import com.jme3.math.Vector3f; import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.animations.BoneContext; import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space; import com.jme3.scene.plugins.blender.file.Structure; @@ -31,10 +32,9 @@ import com.jme3.scene.plugins.blender.file.Structure; int invY = flag & LOCLIKE_Y_INVERT; int z = flag & LOCLIKE_Z; int invZ = flag & LOCLIKE_Z_INVERT; - flag &= LOCLIKE_X | LOCLIKE_X_INVERT | LOCLIKE_OFFSET;// clear the - // other flags - // to swap - // them + // clear the other flags to swap them + flag &= LOCLIKE_X | LOCLIKE_X_INVERT | LOCLIKE_OFFSET; + flag |= y << 1; flag |= invY << 1; flag |= z >> 1; @@ -44,9 +44,9 @@ import com.jme3.scene.plugins.blender.file.Structure; @Override public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) { - if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) { - // cannot copy the location of a bone attached to its parent, - // Blender forbids that + if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null && + blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) { + // location copy does not work on bones who are connected to their parent return; } @@ -57,8 +57,7 @@ import com.jme3.scene.plugins.blender.file.Structure; Vector3f startLocation = ownerTransform.getTranslation().clone(); Vector3f offset = Vector3f.ZERO; - if ((flag & LOCLIKE_OFFSET) != 0) {// we add the original location to - // the copied location + if ((flag & LOCLIKE_OFFSET) != 0) {// we add the original location to the copied location offset = startLocation; } diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLimit.java index aff7e6b6e..615fb104b 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLimit.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionLocLimit.java @@ -4,6 +4,7 @@ import com.jme3.animation.Bone; import com.jme3.math.Transform; import com.jme3.math.Vector3f; import com.jme3.scene.plugins.blender.BlenderContext; +import com.jme3.scene.plugins.blender.animations.BoneContext; import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space; import com.jme3.scene.plugins.blender.file.Structure; @@ -55,8 +56,9 @@ import com.jme3.scene.plugins.blender.file.Structure; @Override public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) { - if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) { - // location limit does not work on bones who have parent + if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null && + blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) { + // location limit does not work on bones who are connected to their parent return; }