diff options
Diffstat (limited to 'source/blender/editors/lattice/editlattice_select.c')
-rw-r--r-- | source/blender/editors/lattice/editlattice_select.c | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index d1635078126..883476aed7d 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -616,49 +616,63 @@ static BPoint *findnearestLattvert(ViewContext *vc, int sel, Base **r_base) return data.bp; } -bool ED_lattice_select_pick( - bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) +bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; BPoint *bp = NULL; Base *basact = NULL; + bool changed = false; ED_view3d_viewcontext_init(C, &vc, depsgraph); vc.mval[0] = mval[0]; vc.mval[1] = mval[1]; bp = findnearestLattvert(&vc, true, &basact); - if (bp) { - ED_view3d_viewcontext_init_object(&vc, basact->object); - Lattice *lt = ((Lattice *)vc.obedit->data)->editlatt->latt; + const bool found = (bp != NULL); - if (!extend && !deselect && !toggle) { - 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) && (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); } + MEM_freeN(objects); + changed = true; + } - if (extend) { - bp->f1 |= SELECT; - } - else if (deselect) { - bp->f1 &= ~SELECT; - } - else if (toggle) { - bp->f1 ^= SELECT; /* swap */ - } - else { - ED_lattice_flags_set(vc.obedit, 0); - bp->f1 |= SELECT; + if (found) { + ED_view3d_viewcontext_init_object(&vc, basact->object); + Lattice *lt = ((Lattice *)vc.obedit->data)->editlatt->latt; + + switch (params->sel_op) { + case SEL_OP_ADD: { + bp->f1 |= SELECT; + break; + } + case SEL_OP_SUB: { + bp->f1 &= ~SELECT; + break; + } + case SEL_OP_XOR: { + bp->f1 ^= SELECT; /* swap */ + break; + } + case SEL_OP_SET: { + ED_lattice_flags_set(vc.obedit, 0); + bp->f1 |= SELECT; + break; + } + case SEL_OP_AND: { + BLI_assert_unreachable(); /* Doesn't make sense for picking. */ + break; + } } if (bp->f1 & SELECT) { @@ -675,10 +689,10 @@ bool ED_lattice_select_pick( DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); - return true; + changed = true; } - return false; + return changed || found; } /** \} */ |