diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-09-04 18:18:59 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-09-04 18:21:01 +0300 |
commit | 577d35ef2cc5e023939b4c2d880b1434ae72e66b (patch) | |
tree | aecabe6553c5e233a1b1857aba5934716eed3231 /source/blender/editors/uvedit | |
parent | 2dff0c99c08cae80baa14f7f4b1e5d443765e273 (diff) |
Multi-Objects: UV_OT_select_split
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 70aa1153076..ccd4817ba2f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2634,67 +2634,76 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot) static int uv_select_split_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); ToolSettings *ts = scene->toolsettings; Image *ima = CTX_data_edit_image(C); - Object *obedit = CTX_data_edit_object(C); - BMesh *bm = BKE_editmesh_from_object(obedit)->bm; BMFace *efa; BMLoop *l; BMIter iter, liter; MLoopUV *luv; - bool changed = false; - - const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); if (ts->uv_flag & UV_SYNC_SELECTION) { BKE_report(op->reports, RPT_ERROR, "Cannot split selection when sync selection is enabled"); return OPERATOR_CANCELLED; } + bool changed_multi = false; + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len); - BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { - bool is_sel = false; - bool is_unsel = false; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMesh *bm = BKE_editmesh_from_object(obedit)->bm; - if (!uvedit_face_visible_test(scene, obedit, ima, efa)) - continue; + bool changed = false; - /* are we all selected? */ - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - if (luv->flag & MLOOPUV_VERTSEL) { - is_sel = true; - } - else { - is_unsel = true; - } + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { + bool is_sel = false; + bool is_unsel = false; - /* we have mixed selection, bail out */ - if (is_sel && is_unsel) { - break; + if (!uvedit_face_visible_test(scene, obedit, ima, efa)) { + continue; } - } - if (is_sel && is_unsel) { + /* are we all selected? */ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - luv->flag &= ~MLOOPUV_VERTSEL; + + if (luv->flag & MLOOPUV_VERTSEL) { + is_sel = true; + } + else { + is_unsel = true; + } + + /* we have mixed selection, bail out */ + if (is_sel && is_unsel) { + break; + } } - changed = true; + if (is_sel && is_unsel) { + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + luv->flag &= ~MLOOPUV_VERTSEL; + } + + changed = true; + } } - } - if (changed) { - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); - return OPERATOR_FINISHED; - } - else { - return OPERATOR_CANCELLED; + if (changed) { + changed_multi = true; + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); + } } + MEM_freeN(objects); + + return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } |