[Bf-blender-cvs] [8bf7ca9fe31] master: Fix T72310: Separate bones creates empty armatures

Campbell Barton noreply at git.blender.org
Mon Dec 9 20:59:38 CET 2019


Commit: 8bf7ca9fe31c438c68e6765666ce890a192ad765
Author: Campbell Barton
Date:   Tue Dec 10 06:12:08 2019 +1100
Branches: master
https://developer.blender.org/rB8bf7ca9fe31c438c68e6765666ce890a192ad765

Fix T72310: Separate bones creates empty armatures

Armatures that didn't contain any selected bones were still
creating armatures.

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

M	source/blender/editors/armature/armature_relations.c

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

diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index b60c8ce4592..e98deeb970e 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -631,6 +631,31 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
     Base *base_iter = bases[base_index];
     Object *obedit = base_iter->object;
 
+    {
+      bArmature *arm_old = obedit->data;
+      bool has_selected_bone = false;
+      bool has_selected_any = false;
+      for (EditBone *ebone = arm_old->edbo->first; ebone; ebone = ebone->next) {
+        if (EBONE_VISIBLE(arm_old, ebone)) {
+          if (ebone->flag & BONE_SELECTED) {
+            has_selected_bone = true;
+            break;
+          }
+          else if (ebone->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
+            has_selected_any = true;
+          }
+        }
+        if (has_selected_bone == false) {
+          if (has_selected_any) {
+            /* Without this, we may leave head/tail selected
+             * which isn't expected after separating. */
+            ED_armature_edit_deselect_all(obedit);
+          }
+          continue;
+        }
+      }
+    }
+
     Object *oldob, *newob;
     Base *oldbase, *newbase;



More information about the Bf-blender-cvs mailing list