瀏覽代碼

Bugfix: locations of bones not connected to their parents are now properly applied if their constraints force them to

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10853 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl 12 年之前
父節點
當前提交
821d6b6aa3

+ 5 - 5
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 <b>true</b> if the bone IS of specified proeprty and <b>false</b> otherwise
      */
-    private boolean is(int flagMask) {
+    public boolean is(int flagMask) {
         return (flag & flagMask) != 0;
     }
-    
+
     @Override
     public String toString() {
         return "BoneContext: " + bone.getName();

+ 4 - 2
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;
         }
         

+ 8 - 9
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;
         }
 

+ 4 - 2
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;
         }