[Bf-blender-cvs] [f4639276eea] master: Fix outliner multi-object edit-armature operations

Campbell Barton noreply at git.blender.org
Wed Mar 17 07:24:26 CET 2021


Commit: f4639276eea47f193fa0d59e8110dbe2c1af3442
Author: Campbell Barton
Date:   Wed Mar 17 16:33:45 2021 +1100
Branches: master
https://developer.blender.org/rBf4639276eea47f193fa0d59e8110dbe2c1af3442

Fix outliner multi-object edit-armature operations

Recursive restrict selection (hide/selectable flag) & renaming
edit-bones both used the active object, even when bones for another
non-active object were being operated on.

Bone renaming would rename a bone in the active object
(if that name exists).

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

M	source/blender/editors/space_outliner/outliner_draw.c

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 5b4a45f6115..278162c4338 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -133,13 +133,11 @@ static bool is_object_data_in_editmode(const ID *id, const Object *obact)
 
 /* ****************************************************** */
 
-static void restrictbutton_recursive_ebone(bContext *C,
+static void restrictbutton_recursive_ebone(bArmature *arm,
                                            EditBone *ebone_parent,
                                            int flag,
                                            bool set_flag)
 {
-  Object *obedit = CTX_data_edit_object(C);
-  bArmature *arm = obedit->data;
   EditBone *ebone;
 
   for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
@@ -198,8 +196,9 @@ static void restrictbutton_bone_select_fn(bContext *C, void *UNUSED(poin), void
   WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
 }
 
-static void restrictbutton_ebone_select_fn(bContext *C, void *UNUSED(poin), void *poin2)
+static void restrictbutton_ebone_select_fn(bContext *C, void *poin, void *poin2)
 {
+  bArmature *arm = (bArmature *)poin;
   EditBone *ebone = (EditBone *)poin2;
 
   if (ebone->flag & BONE_UNSELECTABLE) {
@@ -208,21 +207,22 @@ static void restrictbutton_ebone_select_fn(bContext *C, void *UNUSED(poin), void
 
   if (CTX_wm_window(C)->eventstate->shift) {
     restrictbutton_recursive_ebone(
-        C, ebone, BONE_UNSELECTABLE, (ebone->flag & BONE_UNSELECTABLE) != 0);
+        arm, ebone, BONE_UNSELECTABLE, (ebone->flag & BONE_UNSELECTABLE) != 0);
   }
 
   WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
 }
 
-static void restrictbutton_ebone_visibility_fn(bContext *C, void *UNUSED(poin), void *poin2)
+static void restrictbutton_ebone_visibility_fn(bContext *C, void *poin, void *poin2)
 {
+  bArmature *arm = (bArmature *)poin;
   EditBone *ebone = (EditBone *)poin2;
   if (ebone->flag & BONE_HIDDEN_A) {
     ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
   }
 
   if (CTX_wm_window(C)->eventstate->shift) {
-    restrictbutton_recursive_ebone(C, ebone, BONE_HIDDEN_A, (ebone->flag & BONE_HIDDEN_A) != 0);
+    restrictbutton_recursive_ebone(arm, ebone, BONE_HIDDEN_A, (ebone->flag & BONE_HIDDEN_A) != 0);
   }
 
   WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
@@ -663,7 +663,6 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
 {
   Main *bmain = CTX_data_main(C);
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  Object *obedit = CTX_data_edit_object(C);
   BLI_mempool *ts = space_outliner->treestore;
   TreeStoreElem *tselem = tsep;
 
@@ -740,7 +739,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
             /* restore bone name */
             BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
             BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
-            ED_armature_bone_rename(bmain, obedit->data, oldname, newname);
+            ED_armature_bone_rename(bmain, arm, oldname, newname);
             WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
           }
           break;
@@ -1347,6 +1346,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
       }
       else if (tselem->type == TSE_EBONE) {
+        bArmature *arm = (bArmature *)tselem->id;
         EditBone *ebone = (EditBone *)te->directdata;
 
         if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
@@ -1366,7 +1366,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                 0,
                                 TIP_("Restrict visibility in the 3D View\n"
                                      "* Shift to set children"));
-          UI_but_func_set(bt, restrictbutton_ebone_visibility_fn, NULL, ebone);
+          UI_but_func_set(bt, restrictbutton_ebone_visibility_fn, arm, ebone);
           UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
           UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
         }
@@ -1388,7 +1388,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                 0,
                                 TIP_("Restrict selection in the 3D View\n"
                                      "* Shift to set children"));
-          UI_but_func_set(bt, restrictbutton_ebone_select_fn, NULL, ebone);
+          UI_but_func_set(bt, restrictbutton_ebone_select_fn, arm, ebone);
           UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
           UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
         }



More information about the Bf-blender-cvs mailing list