Explorar o código

Bugfix: fixed a bug that caused models to be heavily spoiled if they had armatures with identical bones' names.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10926 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl %!s(int64=11) %!d(string=hai) anos
pai
achega
17a0554897

+ 7 - 4
engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java

@@ -529,15 +529,18 @@ public class BlenderContext {
     /**
      * Returns bone by given name.
      * 
+     * @param skeletonOMA the OMA of the skeleton where the bone will be searched
      * @param name
      *            the name of the bone
      * @return found bone or null if none bone of a given name exists
      */
-    public BoneContext getBoneByName(String name) {
+    public BoneContext getBoneByName(Long skeletonOMA, String name) {
         for (Entry<Long, BoneContext> entry : boneContexts.entrySet()) {
-            Bone bone = entry.getValue().getBone();
-            if (bone != null && name.equals(bone.getName())) {
-                return entry.getValue();
+            if(entry.getValue().getArmatureObjectOMA().equals(skeletonOMA)) {
+                Bone bone = entry.getValue().getBone();
+                if (bone != null && name.equals(bone.getName())) {
+                    return entry.getValue();
+                }
             }
         }
         return null;

+ 2 - 2
engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java

@@ -221,7 +221,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
         boolean isArmature = blenderContext.getMarkerValue(ArmatureHelper.ARMATURE_NODE_MARKER, feature) != null;
         if (isArmature) {
             blenderContext.getSkeleton(oma).updateWorldVectors();
-            BoneContext targetBoneContext = blenderContext.getBoneByName(subtargetName);
+            BoneContext targetBoneContext = blenderContext.getBoneByName(oma, subtargetName);
             Bone bone = targetBoneContext.getBone();
             
             if(bone.getParent() == null && (space == Space.CONSTRAINT_SPACE_LOCAL || space == Space.CONSTRAINT_SPACE_PARLOCAL)) {
@@ -298,7 +298,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
         boolean isArmature = blenderContext.getMarkerValue(ArmatureHelper.ARMATURE_NODE_MARKER, feature) != null;
         if (isArmature) {
             Skeleton skeleton = blenderContext.getSkeleton(oma);
-            BoneContext targetBoneContext = blenderContext.getBoneByName(subtargetName);
+            BoneContext targetBoneContext = blenderContext.getBoneByName(oma, subtargetName);
             Bone bone = targetBoneContext.getBone();
             
             if(bone.getParent() == null && (space == Space.CONSTRAINT_SPACE_LOCAL || space == Space.CONSTRAINT_SPACE_PARLOCAL)) {