diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-05-08 11:48:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-05-08 12:09:35 +0300 |
commit | 63951bc98712b6dbaf684dfcfba4ee1dcf7e706f (patch) | |
tree | ddd2f85b409779e7281f9b7885016f006b23a1d5 /source/blender | |
parent | fdc967e616132448e71101fd875101cbb53ebb9e (diff) |
Edit Mesh: multi-object reverse_uvs support by Pablo Dobarro
Maniphest Tasks: T54643
Differential Revision: https://developer.blender.org/D3220
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 676e9cc8c5d..0ac8d840b1f 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2361,23 +2361,33 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op) { - Object *ob = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(ob); - BMOperator bmop; + 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, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); - /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "reverse_uvs faces=%hf", BM_ELEM_SELECT); + if (em->bm->totfacesel == 0) { + continue; + } - /* execute the operator */ - BMO_op_exec(em->bm, &bmop); + BMOperator bmop; - /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, true)) { - return OPERATOR_CANCELLED; - } + /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ + EDBM_op_init(em, &bmop, op, "reverse_uvs faces=%hf", BM_ELEM_SELECT); - EDBM_update_generic(em, false, false); + /* execute the operator */ + BMO_op_exec(em->bm, &bmop); + /* finish the operator */ + if (!EDBM_op_finish(em, &bmop, op, true)) { + continue; + } + EDBM_update_generic(em, false, false); + } + + MEM_freeN(objects); return OPERATOR_FINISHED; } |