Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / mesh / editmesh_extrude.c
index 9467c545bbf2310e428b2e5267eb3dd609377a19..950dc92d87ced7925394eb2441f163f5adae7911 100644 (file)
@@ -35,6 +35,7 @@
 #include "BLI_math.h"
 #include "BLI_listbase.h"
 
+#include "BKE_layer.h"
 #include "BKE_context.h"
 #include "BKE_report.h"
 #include "BKE_editmesh.h"
 #include "ED_transform.h"
 #include "ED_view3d.h"
 
+
+#include "MEM_guardedalloc.h"
+
 #include "mesh_intern.h"  /* own include */
 
+#define USE_MANIPULATOR
+
+#ifdef USE_MANIPULATOR
+#endif
+
 /* -------------------------------------------------------------------- */
 /** \name Extrude Internal Utilities
  * \{ */
@@ -391,18 +400,26 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op)
 /* extrude without transform */
 static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
-       edbm_extrude_mesh(obedit, em, op);
-
-       /* This normally happens when pushing undo but modal operators
-        * like this one don't push undo data until after modal mode is
-        * done.*/
-       EDBM_mesh_normals_update(em);
+       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);
+               if (em->bm->totvertsel == 0) {
+                       continue;
+               }
 
-       EDBM_update_generic(em, true, true);
+               edbm_extrude_mesh(obedit, em, op);
+               /* This normally happens when pushing undo but modal operators
+                * like this one don't push undo data until after modal mode is
+                * done.*/
+               EDBM_mesh_normals_update(em);
 
+               EDBM_update_generic(em, true, true);
+       }
+       MEM_freeN(objects);
        return OPERATOR_FINISHED;
 }
 
@@ -432,12 +449,22 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
 
 static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+       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);
+               if (em->bm->totvertsel == 0) {
+                       continue;
+               }
 
-       edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT);
+               edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT);
 
-       EDBM_update_generic(em, true, true);
+               EDBM_update_generic(em, true, true);
+       }
+       MEM_freeN(objects);
 
        return OPERATOR_FINISHED;
 }
@@ -468,12 +495,22 @@ void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
 
 static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+       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);
+               if (em->bm->totedgesel == 0) {
+                       continue;
+               }
 
-       edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT);
+               edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT);
 
-       EDBM_update_generic(em, true, true);
+               EDBM_update_generic(em, true, true);
+       }
+       MEM_freeN(objects);
 
        return OPERATOR_FINISHED;
 }
@@ -504,12 +541,22 @@ void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
 
 static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
 {
-       Object *obedit = CTX_data_edit_object(C);
-       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+       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);
+               if (em->bm->totfacesel == 0) {
+                       continue;
+               }
 
-       edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT);
+               edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT);
 
-       EDBM_update_generic(em, true, true);
+               EDBM_update_generic(em, true, true);
+       }
+       MEM_freeN(objects);
 
        return OPERATOR_FINISHED;
 }
@@ -723,4 +770,3 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
 }
 
 /** \} */
-