From 17a055489759c59f51d4ce97bd1a29f34f9c9e12 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sun, 1 Dec 2013 20:37:13 +0000 Subject: [PATCH] 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 --- .../jme3/scene/plugins/blender/BlenderContext.java | 11 +++++++---- .../plugins/blender/constraints/ConstraintHelper.java | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java index a85b82f82..290a578b9 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/BlenderContext.java +++ b/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 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; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java index 89846e242..ba350cc64 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java +++ b/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)) {