[Bf-blender-cvs] [df36e1c5dd3] blender-v2.82-release: Fix T71091: Object restrict selection conflicts with pose selection

Campbell Barton noreply at git.blender.org
Wed Jan 15 07:15:26 CET 2020


Commit: df36e1c5dd3c5843bcdc58a7021c6defc25d56ad
Author: Campbell Barton
Date:   Wed Jan 15 16:56:06 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rBdf36e1c5dd3c5843bcdc58a7021c6defc25d56ad

Fix T71091: Object restrict selection conflicts with pose selection

Support pose bone selection when the object has hide_select enabled.

This is consistent with how all other modes work.

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

M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/space_view3d/view3d_select.c

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

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 3174edb0c05..2fbb0a740cf 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2254,6 +2254,10 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
       FOREACH_OBJECT_IN_MODE_END;
     }
     else {
+      /* When selecting pose-bones in pose mode, check for visibility not select-ability
+       * as pose-bones have their own selection restriction flag. */
+      const bool use_pose_exception = (DST.draw_ctx.object_pose != NULL);
+
       const int object_type_exclude_select = (v3d->object_type_exclude_viewport |
                                               v3d->object_type_exclude_select);
       bool filter_exclude = false;
@@ -2261,8 +2265,19 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
         if (!BKE_object_is_visible_in_viewport(v3d, ob)) {
           continue;
         }
-        if ((ob->base_flag & BASE_SELECTABLE) &&
-            (object_type_exclude_select & (1 << ob->type)) == 0) {
+
+        if (use_pose_exception && (ob->mode & OB_MODE_POSE)) {
+          if ((ob->base_flag & BASE_VISIBLE_VIEWLAYER) == 0) {
+            continue;
+          }
+        }
+        else {
+          if ((ob->base_flag & BASE_SELECTABLE) == 0) {
+            continue;
+          }
+        }
+
+        if ((object_type_exclude_select & (1 << ob->type)) == 0) {
           if (object_filter_fn != NULL) {
             if (ob->base_flag & BASE_FROM_DUPLI) {
               /* pass (use previous filter_exclude value) */
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 85e9a2d7680..89baf60bd8c 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1785,7 +1785,13 @@ static int mixed_bones_object_selectbuffer_extended(ViewContext *vc,
   return hits;
 }
 
-/* returns basact */
+/**
+ * \param has_bones: When true, skip non-bone hits, also allow bases to be used
+ * that are visible but not select-able,
+ * since you may be in pose mode with an an unselect-able object.
+ *
+ * \return the active base or NULL.
+ */
 static Base *mouse_select_eval_buffer(ViewContext *vc,
                                       const uint *buffer,
                                       int hits,
@@ -1827,7 +1833,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc,
 
     base = FIRSTBASE(view_layer);
     while (base) {
-      if (BASE_SELECTABLE(v3d, base)) {
+      if (has_bones ? BASE_VISIBLE(v3d, base) : BASE_SELECTABLE(v3d, base)) {
         if (base->object->runtime.select_id == selcol) {
           break;
         }
@@ -1844,7 +1850,8 @@ static Base *mouse_select_eval_buffer(ViewContext *vc,
     while (base) {
       /* skip objects with select restriction, to prevent prematurely ending this loop
        * with an un-selectable choice */
-      if ((base->flag & BASE_SELECTABLE) == 0) {
+      if (has_bones ? (base->flag & BASE_VISIBLE_VIEWLAYER) == 0 :
+                      (base->flag & BASE_SELECTABLE) == 0) {
         base = base->next;
         if (base == NULL) {
           base = FIRSTBASE(view_layer);
@@ -1854,7 +1861,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc,
         }
       }
 
-      if (BASE_SELECTABLE(v3d, base)) {
+      if (has_bones ? BASE_VISIBLE(v3d, base) : BASE_SELECTABLE(v3d, base)) {
         for (a = 0; a < hits; a++) {
           if (has_bones) {
             /* skip non-bone objects */



More information about the Bf-blender-cvs mailing list