diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-05-12 07:38:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-12 07:38:01 +0300 |
commit | eaa21df5051c23ca0f3e7624be5f0bb86c891e08 (patch) | |
tree | 6b08425f966114278854d4a39a9c868e890a003e /source/blender/editors/mesh/editmesh_tools.c | |
parent | 750b370c25bf2aeb016d36637381d422ca219234 (diff) |
Fix T71882: Offset Edge Slide doesn't switch selection mode
Based on D6335 with modifications.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index fd5bf006829..1d724d0b9a7 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -7081,37 +7081,17 @@ void MESH_OT_wireframe(wmOperatorType *ot) static int edbm_offset_edgeloop_exec(bContext *C, wmOperator *op) { - bool mode_change = false; const bool use_cap_endpoint = RNA_boolean_get(op->ptr, "use_cap_endpoint"); - int ret = OPERATOR_CANCELLED; - - { - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); - if (em->selectmode == SCE_SELECT_FACE) { - EDBM_selectmode_to_scene(C); - mode_change = true; - } - } - + bool changed_multi = false; + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { - Object *obedit = objects[ob_index]; + uint bases_len = 0; + Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( + view_layer, CTX_wm_view3d(C), &bases_len); + for (uint base_index = 0; base_index < bases_len; base_index++) { + Object *obedit = bases[base_index]->object; BMEditMesh *em = BKE_editmesh_from_object(obedit); - /** If in face-only select mode, switch to edge select mode so that - * an edge-only selection is not inconsistent state. - * - * We need to run this for all objects, even when nothing is selected. - * This way we keep them in sync. */ - if (mode_change) { - em->selectmode = SCE_SELECT_EDGE; - EDBM_selectmode_set(em); - } - if (em->bm->totedgesel == 0) { continue; } @@ -7131,16 +7111,26 @@ static int edbm_offset_edgeloop_exec(bContext *C, wmOperator *op) BMO_slot_buffer_hflag_enable( em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, true)) { - continue; - } - else { + if (EDBM_op_finish(em, &bmop, op, true)) { EDBM_update_generic(obedit->data, true, true); - ret = OPERATOR_FINISHED; + changed_multi = true; } } - MEM_freeN(objects); - return ret; + + if (changed_multi) { + /** If in face-only select mode, switch to edge select mode so that + * an edge-only selection is not inconsistent state. + * + * We need to run this for all objects, even when nothing is selected. + * This way we keep them in sync. */ + if (scene->toolsettings->selectmode == SCE_SELECT_FACE) { + EDBM_selectmode_disable_multi_ex(scene, bases, bases_len, SCE_SELECT_FACE, SCE_SELECT_EDGE); + } + } + + MEM_freeN(bases); + + return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void MESH_OT_offset_edge_loops(wmOperatorType *ot) |