diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-08-20 23:42:36 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-08-21 02:58:20 +0300 |
commit | 753be0a2a59fb77adc179aa8502b4f9b2ee97597 (patch) | |
tree | 8794bf4e4c47714df33751d1812e2058b6d64285 /source/blender/editors/mesh/editmesh_tools.c | |
parent | 3c5365556a46a66ca06f77b5eeaf790bceb6270c (diff) |
Multi-Objects: MESH_OT_colors_reverse
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 76ba2e5c67e..cb008c376c3 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2545,22 +2545,34 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) static int edbm_reverse_colors_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); - /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "reverse_colors faces=%hf", BM_ELEM_SELECT); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *ob = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(ob); - /* execute the operator */ - BMO_op_exec(em->bm, &bmop); + if (em->bm->totfacesel == 0) { + continue; + } - /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, true)) { - return OPERATOR_CANCELLED; - } + BMOperator bmop; - EDBM_update_generic(em, false, false); + /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ + EDBM_op_init(em, &bmop, op, "reverse_colors faces=%hf", BM_ELEM_SELECT); + + /* execute the operator */ + BMO_op_exec(em->bm, &bmop); + + /* finish the operator */ + if (!EDBM_op_finish(em, &bmop, op, true)) { + return OPERATOR_CANCELLED; + } + + EDBM_update_generic(em, false, false); + } + MEM_freeN(objects); return OPERATOR_FINISHED; } |