[Bf-blender-cvs] [1d88aeb95fc] master: View 3D: support for select passthrough when picking selected items

Campbell Barton noreply at git.blender.org
Thu Mar 17 04:44:20 CET 2022


Commit: 1d88aeb95fc40771be7ef3a835af4206c845aa9b
Author: Campbell Barton
Date:   Thu Mar 17 14:37:20 2022 +1100
Branches: master
https://developer.blender.org/rB1d88aeb95fc40771be7ef3a835af4206c845aa9b

View 3D: support for select passthrough when picking selected items

Currently this isn't used in the key-map, it will eventually
allow the 3D viewports tweak tool to match the behavior of other
editors that support tweaking a selection without first de-selecting
all other elements.

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

M	source/blender/editors/armature/armature_select.c
M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/include/ED_select_utils.h
M	source/blender/editors/lattice/editlattice_select.c
M	source/blender/editors/mesh/editface.c
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/metaball/mball_edit.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/space_view3d/view3d_select.c
M	source/blender/windowmanager/intern/wm_operator_props.c

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

diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index d1a5c128c35..08d5d6558e0 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -965,14 +965,20 @@ bool ED_armature_edit_select_pick_bone(bContext *C,
     }
   }
 
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    /* Deselect everything. */
-    uint bases_len = 0;
-    Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
-        view_layer, v3d, &bases_len);
-    ED_armature_edit_deselect_all_multi_ex(bases, bases_len);
-    MEM_freeN(bases);
-    changed = true;
+  if (params->sel_op == SEL_OP_SET) {
+    if ((found && params->select_passthrough) &&
+        (ED_armature_ebone_selectflag_get(ebone) & selmask)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      uint bases_len = 0;
+      Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
+          view_layer, v3d, &bases_len);
+      ED_armature_edit_deselect_all_multi_ex(bases, bases_len);
+      MEM_freeN(bases);
+      changed = true;
+    }
   }
 
   if (found) {
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 1cf56389580..8790a10f3e5 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -136,19 +136,25 @@ bool ED_armature_pose_select_pick_bone(ViewLayer *view_layer,
     }
   }
 
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    /* Don't use 'BKE_object_pose_base_array_get_unique'
-     * because we may be selecting from object mode. */
-    FOREACH_VISIBLE_BASE_BEGIN (view_layer, v3d, base_iter) {
-      Object *ob_iter = base_iter->object;
-      if ((ob_iter->type == OB_ARMATURE) && (ob_iter->mode & OB_MODE_POSE)) {
-        if (ED_pose_deselect_all(ob_iter, SEL_DESELECT, true)) {
-          ED_pose_bone_select_tag_update(ob_iter);
+  if (params->sel_op == SEL_OP_SET) {
+    if ((found && params->select_passthrough) && (bone->flag & BONE_SELECTED)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      /* Don't use 'BKE_object_pose_base_array_get_unique'
+       * because we may be selecting from object mode. */
+      FOREACH_VISIBLE_BASE_BEGIN (view_layer, v3d, base_iter) {
+        Object *ob_iter = base_iter->object;
+        if ((ob_iter->type == OB_ARMATURE) && (ob_iter->mode & OB_MODE_POSE)) {
+          if (ED_pose_deselect_all(ob_iter, SEL_DESELECT, true)) {
+            ED_pose_bone_select_tag_update(ob_iter);
+          }
         }
       }
+      FOREACH_VISIBLE_BASE_END;
+      changed = true;
     }
-    FOREACH_VISIBLE_BASE_END;
-    changed = true;
   }
 
   if (found) {
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 1c1783669c3..5ff63e767f6 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4740,23 +4740,29 @@ bool ED_curve_editnurb_select_pick(bContext *C,
   ED_view3d_viewcontext_init(C, &vc, depsgraph);
   copy_v2_v2_int(vc.mval, mval);
 
-  const bool found = ED_curve_pick_vert(&vc, 1, &nu, &bezt, &bp, &hand, &basact);
+  bool found = ED_curve_pick_vert(&vc, 1, &nu, &bezt, &bp, &hand, &basact);
 
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    /* Deselect everything. */
-    uint objects_len = 0;
-    Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
-        vc.view_layer, vc.v3d, &objects_len);
-    for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
-      Object *ob_iter = objects[ob_index];
+  if (params->sel_op == SEL_OP_SET) {
+    if ((found && params->select_passthrough) &&
+        (((bezt ? (&bezt->f1)[hand] : bp->f1) & SELECT) != 0)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      uint objects_len = 0;
+      Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+          vc.view_layer, vc.v3d, &objects_len);
+      for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+        Object *ob_iter = objects[ob_index];
 
-      ED_curve_deselect_all(((Curve *)ob_iter->data)->editnurb);
+        ED_curve_deselect_all(((Curve *)ob_iter->data)->editnurb);
 
-      DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
-      WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+        DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
+        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+      }
+      MEM_freeN(objects);
+      changed = true;
     }
-    MEM_freeN(objects);
-    changed = true;
   }
 
   if (found) {
diff --git a/source/blender/editors/include/ED_select_utils.h b/source/blender/editors/include/ED_select_utils.h
index c24c9168fe8..b9ef5c283aa 100644
--- a/source/blender/editors/include/ED_select_utils.h
+++ b/source/blender/editors/include/ED_select_utils.h
@@ -82,6 +82,12 @@ struct SelectPick_Params {
   eSelectOp sel_op;
   /** Deselect all, even when there is nothing found at the cursor location. */
   bool deselect_all;
+  /**
+   * When selecting an element that is already selected, do nothing (passthrough).
+   * don't even make it active.
+   * Use to implement tweaking to move the selection without first de-selecting.
+   */
+  bool select_passthrough;
 };
 
 /**
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index bc3bca248a4..ea99c6e23ff 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -623,22 +623,27 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectP
   vc.mval[1] = mval[1];
 
   bp = findnearestLattvert(&vc, true, &basact);
-  const bool found = (bp != NULL);
+  bool found = (bp != NULL);
 
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    /* Deselect everything. */
-    uint objects_len = 0;
-    Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
-        vc.view_layer, vc.v3d, &objects_len);
-    for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
-      Object *ob = objects[ob_index];
-      if (ED_lattice_flags_set(ob, 0)) {
-        DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
-        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+  if (params->sel_op == SEL_OP_SET) {
+    if ((found && params->select_passthrough) && (bp->f1 & SELECT)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      uint objects_len = 0;
+      Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+          vc.view_layer, vc.v3d, &objects_len);
+      for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+        Object *ob = objects[ob_index];
+        if (ED_lattice_flags_set(ob, 0)) {
+          DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
+          WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+        }
       }
+      MEM_freeN(objects);
+      changed = true;
     }
-    MEM_freeN(objects);
-    changed = true;
   }
 
   if (found) {
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 9832f7ba9cf..a5c6adaa43e 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -389,8 +389,14 @@ bool paintface_mouse_select(struct bContext *C,
     }
   }
 
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    changed |= paintface_deselect_all_visible(C, ob, SEL_DESELECT, false);
+  if (params->sel_op == SEL_OP_SET) {
+    if ((found && params->select_passthrough) && (mpoly_sel->flag & ME_FACE_SEL)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      changed |= paintface_deselect_all_visible(C, ob, SEL_DESELECT, false);
+    }
   }
 
   if (found) {
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index fba6838fd99..9c8c5c45cb7 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -2034,19 +2034,24 @@ bool EDBM_select_pick(bContext *C, const int mval[2], const struct SelectPick_Pa
   Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
 
   bool changed = false;
-  const bool found = unified_findnearest(
-      &vc, bases, bases_len, &base_index_active, &eve, &eed, &efa);
-
-  if ((params->sel_op == SEL_OP_SET) && (found || params->deselect_all)) {
-    /* Deselect everything. */
-    for (uint base_index = 0; base_index < bases_len; base_index++) {
-      Base *base_iter = bases[base_index];
-      Object *ob_iter = base_iter->object;
-      EDBM_flag_disable_all(BKE_editmesh_from_object(ob_iter), BM_ELEM_SELECT);
-      DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
-      WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+  bool found = unified_findnearest(&vc, bases, bases_len, &base_index_active, &eve, &eed, &efa);
+
+  if (params->sel_op == SEL_OP_SET) {
+    BMElem *ele = efa ? (BMElem *)efa : (eed ? (BMElem *)eed : (BMElem *)eve);
+    if ((found && params->select_passthrough) && BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+      found = false;
+    }
+    else if (found || params->deselect_all) {
+      /* Deselect everything. */
+      for (uint base_index = 0; base_index < bases_len; base_index++) {
+        Base *base_iter = bases[base_index];
+        Object *ob_iter = base_iter->object;
+        EDBM_flag_disable_all(BKE_editmesh_from_object(ob_iter), BM_ELEM_SELECT);
+        DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
+        WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+      }
+      changed = 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list