[Bf-blender-cvs] [d791f3522e1] blender-v2.79b-release: Fix T54348: Bone dissolve gives invalid hierarchy

Campbell Barton noreply at git.blender.org
Thu Mar 22 09:39:20 CET 2018


Commit: d791f3522e15ed37aeae33c07ad0290210cc1b0d
Author: Campbell Barton
Date:   Thu Mar 22 07:50:58 2018 +0100
Branches: blender-v2.79b-release
https://developer.blender.org/rBd791f3522e15ed37aeae33c07ad0290210cc1b0d

Fix T54348: Bone dissolve gives invalid hierarchy

Disconnected bones weren't handled correctly.

===================================================================

M	source/blender/editors/armature/armature_edit.c
M	source/blender/editors/armature/armature_utils.c
M	source/blender/editors/include/ED_armature.h

===================================================================

diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 8b2f6b458d3..605754b76db 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -1458,7 +1458,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
 			ebone->parent->rad_tail = ebone->rad_tail;
 			SET_FLAG_FROM_TEST(ebone->parent->flag, ebone->flag & BONE_TIPSEL, BONE_TIPSEL);
 
-			ED_armature_edit_bone_remove(arm, ebone);
+			ED_armature_edit_bone_remove_ex(arm, ebone, false);
 			changed = true;
 		}
 	}
@@ -1467,9 +1467,8 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
 		for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
 			if (ebone->parent &&
 			    ebone->parent->temp.ebone &&
-			    (ebone->flag & BONE_CONNECTED) == 0)
+			    (ebone->flag & BONE_CONNECTED))
 			{
-				ebone->flag |= BONE_CONNECTED;
 				ebone->rad_head = ebone->parent->rad_tail;
 			}
 		}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index a3b439536b7..0cebae96230 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -133,7 +133,10 @@ void bone_free(bArmature *arm, EditBone *bone)
 	BLI_freelinkN(arm->edbo, bone);
 }
 
-void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
+/**
+ * \param clear_connected: When false caller is responsible for keeping the flag in a valid state.
+ */
+void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
 {
 	EditBone *curBone;
 
@@ -141,13 +144,20 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
 	for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
 		if (curBone->parent == exBone) {
 			curBone->parent = exBone->parent;
-			curBone->flag &= ~BONE_CONNECTED;
+			if (clear_connected) {
+				curBone->flag &= ~BONE_CONNECTED;
+			}
 		}
 	}
 
 	bone_free(arm, exBone);
 }
 
+void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
+{
+	ED_armature_edit_bone_remove_ex(arm, exBone, true);
+}
+
 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
 {
 	for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 6b8943421bd..2eb9c7d11df 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -144,6 +144,8 @@ void ED_armature_validate_active(struct bArmature *arm);
 
 EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
 EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
+
+void ED_armature_edit_bone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected);
 void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
 
 bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);



More information about the Bf-blender-cvs mailing list