Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-03-22 09:50:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-03-22 09:50:58 +0300
commit865fbe343a9067f342c45fb2a1a63eca0f7cf2d7 (patch)
tree033f1552d92497da98e38d1fa95cd8d4cd162acb /source/blender/editors
parentce51066e47175a38fd205987b6e6acc1a805dbe0 (diff)
Fix T54348: Bone dissolve gives invalid hierarchy
Disconnected bones weren't handled correctly.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/armature_edit.c5
-rw-r--r--source/blender/editors/armature/armature_utils.c14
-rw-r--r--source/blender/editors/include/ED_armature.h2
3 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 17d60d2b4a0..9a4a0eecfcd 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -1460,7 +1460,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;
}
}
@@ -1469,9 +1469,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 0efd9cec959..3928cb2d85d 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 39e95eb9ee1..91c9a36c31f 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -146,6 +146,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);