[Bf-blender-cvs] [064c4396c79] soc-2019-outliner: Outliner: Sync edit and pose bone selection state

Nathan Craddock noreply at git.blender.org
Wed Jul 3 03:47:53 CEST 2019


Commit: 064c4396c79bd300f90180357795e3f20af03b4a
Author: Nathan Craddock
Date:   Tue Jul 2 19:45:25 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB064c4396c79bd300f90180357795e3f20af03b4a

Outliner: Sync edit and pose bone selection state

Syncs selection to and from outliner for bones in both modes.

The code for pose bones is acceptable, but edit bones is quite
the mess. Something more intelligent needs to be thought of here.

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

M	source/blender/editors/armature/armature_select.c
M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/object/object_select.c
M	source/blender/editors/space_outliner/outliner_sync.c
M	source/blender/editors/space_sequencer/sequencer_select.c
M	source/blender/editors/space_view3d/view3d_select.c

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

diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 23ddf77e63d..9b901ae50a9 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -46,6 +46,7 @@
 
 #include "ED_armature.h"
 #include "ED_object.h"
+#include "ED_outliner.h"
 #include "ED_screen.h"
 #include "ED_select_utils.h"
 #include "ED_view3d.h"
@@ -356,6 +357,8 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
     }
   }
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   ED_armature_edit_sync_selection(arm->edbo);
 
   WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object);
@@ -1027,6 +1030,8 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
   }
   CTX_DATA_END;
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
 
   return OPERATOR_FINISHED;
@@ -1148,6 +1153,8 @@ static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op))
     WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
   }
   MEM_freeN(objects);
+
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
   return OPERATOR_FINISHED;
 }
 
@@ -1178,6 +1185,8 @@ static int armature_de_select_less_exec(bContext *C, wmOperator *UNUSED(op))
     WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
   }
   MEM_freeN(objects);
+
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
   return OPERATOR_FINISHED;
 }
 
@@ -1569,6 +1578,8 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op)
 
 #undef STRUCT_SIZE_AND_OFFSET
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   return OPERATOR_FINISHED;
 }
 
@@ -1663,6 +1674,8 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   ED_armature_edit_sync_selection(arm->edbo);
 
   WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
@@ -1748,6 +1761,8 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op)
       arm->act_edbone = ebone_mirror_act;
     }
 
+    sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
     ED_armature_edit_sync_selection(arm->edbo);
 
     WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
@@ -1876,6 +1891,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
 
   if (changed) {
     arm->act_edbone = ebone_dst;
+    sync_select_dirty_flag = SYNC_SELECT_REPLACE;
     ED_armature_edit_sync_selection(arm->edbo);
     WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
 
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index e9ea49aaf03..a27426261c0 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -53,6 +53,7 @@
 #include "ED_keyframing.h"
 #include "ED_mesh.h"
 #include "ED_object.h"
+#include "ED_outliner.h"
 #include "ED_screen.h"
 #include "ED_select_utils.h"
 #include "ED_view3d.h"
@@ -87,6 +88,8 @@ static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode)
       }
       break;
   }
+
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
 }
 
 void ED_pose_bone_select_tag_update(Object *ob)
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 8908fd2da93..7e114412bc5 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -1272,6 +1272,8 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
   }
   CTX_DATA_END;
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   /* undo? */
   DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
   WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index 4cac7d5b104..096ebc5a649 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 
+#include "DNA_armature_types.h"
 #include "DNA_layer_types.h"
 #include "DNA_outliner_types.h"
 #include "DNA_screen_types.h"
@@ -36,6 +37,7 @@
 
 #include "DEG_depsgraph.h"
 
+#include "ED_armature.h"
 #include "ED_object.h"
 #include "ED_outliner.h"
 
@@ -93,6 +95,33 @@ static void outliner_sync_selection_from_outliner(bContext *C, ListBase *tree)
         }
       }
     }
+    else if (tselem->type == TSE_EBONE) {
+      printf("\t\tSyncing an editbone: %s\n", te->name);
+      EditBone *ebone = (EditBone *)te->directdata;
+
+      if (tselem->flag & TSE_SELECTED) {
+        ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+      }
+      else {
+        ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+      }
+    }
+    else if (tselem->type == TSE_POSE_CHANNEL) {
+      printf("\t\tSyncing a posebone: %s\n", te->name);
+      Object *ob = (Object *)tselem->id;
+      bArmature *arm = ob->data;
+      bPoseChannel *pchan = (bPoseChannel *)te->directdata;
+
+      if (tselem->flag & TSE_SELECTED) {
+        pchan->bone->flag |= BONE_SELECTED;
+      }
+      else {
+        pchan->bone->flag &= ~BONE_SELECTED;
+      }
+
+      DEG_id_tag_update(&arm->id, ID_RECALC_SELECT);
+      WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+    }
     else if (tselem->type == TSE_SEQUENCE) {
       printf("\t\tSyncing a sequence: %s\n", te->name);
 
@@ -146,9 +175,31 @@ static void outliner_sync_selection_to_outliner(const bContext *C,
         }
       }
     }
+    else if (tselem->type == TSE_EBONE) {
+      printf("\t\tSyncing an editbone: %s\n", te->name);
+      EditBone *ebone = (EditBone *)te->directdata;
+
+      if (ebone->flag & BONE_SELECTED) {
+        tselem->flag |= TSE_SELECTED;
+      }
+      else {
+        tselem->flag &= ~TSE_SELECTED;
+      }
+    }
+    else if (tselem->type == TSE_POSE_CHANNEL) {
+      printf("\t\tSyncing a posebone: %s\n", te->name);
+      bPoseChannel *pchan = (bPoseChannel *)te->directdata;
+      Bone *bone = pchan->bone;
+
+      if (bone->flag & BONE_SELECTED) {
+        tselem->flag |= TSE_SELECTED;
+      }
+      else {
+        tselem->flag &= ~TSE_SELECTED;
+      }
+    }
     else if (tselem->type == TSE_SEQUENCE) {
       printf("\t\tSyncing a sequence: %s\n", te->name);
-
       Sequence *seq = (Sequence *)tselem->id;
 
       if (seq == seq_act) {
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 3ab9df74ead..4a1d7f6819f 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -51,7 +51,7 @@
 /* own include */
 #include "sequencer_intern.h"
 
-static void sequencer_sync_selection()
+static void sequencer_sync_selection(void)
 {
   sync_select_dirty_flag = SYNC_SELECT_REPLACE;
 }
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 3ff97cdd59a..9b1288e241f 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -88,6 +88,7 @@
 #include "ED_particle.h"
 #include "ED_mesh.h"
 #include "ED_object.h"
+#include "ED_outliner.h"
 #include "ED_screen.h"
 #include "ED_select_buffer_utils.h"
 #include "ED_select_utils.h"
@@ -1482,6 +1483,9 @@ static bool view3d_lasso_select(
           break;
         case OB_ARMATURE:
           changed = do_lasso_select_armature(vc, mcords, moves, sel_op);
+          if (changed) {
+            sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+          }
           break;
         case OB_MBALL:
           changed = do_lasso_select_meta(vc, mcords, moves, sel_op);
@@ -2482,6 +2486,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
       if (!retval && deselect_all) {
         retval = ED_armature_edit_deselect_all_visible_multi(C);
       }
+      sync_select_dirty_flag = SYNC_SELECT_REPLACE;
     }
     else if (obedit->type == OB_LATTICE) {
       retval = ED_lattice_select_pick(C, location, extend, deselect, toggle);
@@ -3118,6 +3123,8 @@ static bool do_armature_box_select(ViewContext *vc, const rcti *rect, const eSel
     }
   }
 
+  sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+
   MEM_freeN(bases);
 
   return changed;
@@ -4038,6 +4045,9 @@ static bool obedit_circle_select(ViewContext *vc,
       break;
     case OB_ARMATURE:
       changed = armature_circle_select(vc, sel_op, mval, rad);
+      if (changed) {
+        sync_select_dirty_flag = SYNC_SELECT_REPLACE;
+      }
       break;
     case OB_MBALL:
       changed = mball_circle_select(vc, sel_op, mval, rad);



More information about the Bf-blender-cvs mailing list