Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-15 13:03:04 +0300
committerCampbell Barton <campbell@blender.org>2022-03-16 06:48:25 +0300
commit5e5285baf621a0c225cb5fc06fcec6ffed8302d7 (patch)
treefcdc655a6b063d32a7630b648e126c20ade295f2 /source/blender/editors/metaball
parent9a763d24f2b50ad38d22cad0a23d7344afe5f1c7 (diff)
View 3D: move picking arguments into a struct & minor refactor
- Add SelectPick_Params struct to make picking logic more straightforward and easier to extend. - Use `eSelectOp` instead of booleans (extend, deselect, toggle) which were used to represent 4 states (which wasn't obvious). - Handle deselect_all when pocking instead of view3d_select_exec, de-duplicate de-selection which was already needed in when replacing the selection in picking functions. - Handle outliner update & notifiers in the picking functions instead of view3d_select_exec. - Fix particle select deselect_all option which did nothing.
Diffstat (limited to 'source/blender/editors/metaball')
-rw-r--r--source/blender/editors/metaball/mball_edit.c59
1 files changed, 39 insertions, 20 deletions
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 136d0d46c68..a19e2761394 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -736,7 +736,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
/** \name Select Pick Utility
* \{ */
-bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
+bool ED_mball_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
static MetaElem *startelem = NULL;
@@ -744,6 +744,8 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
int a, hits;
GPUSelectResult buffer[MAXPICKELEMS];
rcti rect;
+ bool changed = false;
+ bool found = false;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
@@ -822,7 +824,9 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
/* When some metaelem was found, then it is necessary to select or deselect it. */
if (ml_act) {
- if (!extend && !deselect && !toggle) {
+ found = true;
+
+ if (params->sel_op == SEL_OP_SET) {
uint objects_len;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
vc.view_layer, vc.v3d, &objects_len);
@@ -840,26 +844,36 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
MEM_freeN(objects);
}
- if (extend) {
- ml_act->flag |= SELECT;
- }
- else if (deselect) {
- ml_act->flag &= ~SELECT;
- }
- else if (toggle) {
- if (ml_act->flag & SELECT) {
+ switch (params->sel_op) {
+ case SEL_OP_ADD: {
+ ml_act->flag |= SELECT;
+ break;
+ }
+ case SEL_OP_SUB: {
ml_act->flag &= ~SELECT;
+ break;
}
- else {
- ml_act->flag |= SELECT;
+ case SEL_OP_XOR: {
+ if (ml_act->flag & SELECT) {
+ ml_act->flag &= ~SELECT;
+ }
+ else {
+ ml_act->flag |= SELECT;
+ }
+ break;
}
- }
- else {
- /* Deselect all existing metaelems */
- BKE_mball_deselect_all(mb);
+ case SEL_OP_SET: {
+ /* Deselect all existing metaelems */
+ BKE_mball_deselect_all(mb);
- /* Select only metaelem clicked on */
- ml_act->flag |= SELECT;
+ /* Select only metaelem clicked on */
+ ml_act->flag |= SELECT;
+ break;
+ }
+ case SEL_OP_AND: {
+ BLI_assert_unreachable(); /* Doesn't make sense for picking. */
+ break;
+ }
}
mb->lastelem = ml_act;
@@ -871,13 +885,18 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
ED_object_base_activate(C, base);
}
- return true;
+ changed = true;
}
}
}
FOREACH_BASE_IN_EDIT_MODE_END;
- return false;
+ if (params->deselect_all && !found) {
+ ED_mball_deselect_all_multi(C);
+ changed = true;
+ }
+
+ return changed || found;
}
/** \} */