Commit: 42c5c20e54f3686b31411144a8e09421f8580be4
Author: Campbell Barton
Date:   Fri May 4 19:16:43 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB42c5c20e54f3686b31411144a8e09421f8580be4

Edit Mesh: Multi object color reverse

D3173 by @la10

===================================================================

M       source/blender/editors/mesh/editmesh_tools.c

===================================================================

diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index c375e4c26de..ff52f6294fd 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2321,26 +2321,38 @@ static int edbm_reverse_uvs_exec(bContext *C, 
wmOperator *op)
 
 static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
 {
-       Object *ob = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(ob);
-       BMOperator bmop;
-
-       /* get the direction from RNA */
+               /* get the direction from RNA */
        const bool use_ccw = RNA_boolean_get(op->ptr, "use_ccw");
 
-       /* initialize the bmop using EDBM api, which does various ui error 
reporting and other stuff */
-       EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf use_ccw=%b", 
BM_ELEM_SELECT, use_ccw);
+       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);
 
-       /* execute the operator */
-       BMO_op_exec(em->bm, &bmop);
+       for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+               Object *ob = objects[ob_index];
+               BMEditMesh *em = BKE_editmesh_from_object(ob);
+               if (em->bm->totfacesel == 0) {
+                       continue;
+               }
 
-       /* finish the operator */
-       if (!EDBM_op_finish(em, &bmop, op, true)) {
-               return OPERATOR_CANCELLED;
+               BMOperator bmop;
+
+               /* initialize the bmop using EDBM api, which does various ui 
error reporting and other stuff */
+               EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf 
use_ccw=%b", BM_ELEM_SELECT, use_ccw);
+
+               /* execute the operator */
+               BMO_op_exec(em->bm, &bmop);
+
+               /* finish the operator */
+               if (!EDBM_op_finish(em, &bmop, op, true)) {
+                       continue;
+               }
+
+               /* dependencies graph and notification stuff */
+               EDBM_update_generic(em, false, false);
        }
 
-       /* dependencies graph and notification stuff */
-       EDBM_update_generic(em, false, false);
+       MEM_freeN(objects);
 
        return OPERATOR_FINISHED;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to