Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-05-11 09:08:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-11 09:08:01 +0300
commit266638d7832b7794a315fff0c6cec347fc917602 (patch)
tree68a7a8ba56fcd8a4fc8440adb6eec4f660468bd8
parente161c51e7f12c1c9bff3be33c1483844df3c7db6 (diff)
EditMesh: multi-object recalculate normals
D3298 by @leonlg
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 8a277b20d3a..735b5ad8d8a 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2017,19 +2017,28 @@ void MESH_OT_reveal(wmOperatorType *ot)
static int edbm_normals_make_consistent_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);
- /* doflip has to do with bmesh_rationalize_normals, it's an internal
- * thing */
- if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf", BM_ELEM_SELECT))
- return OPERATOR_CANCELLED;
+ 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 (RNA_boolean_get(op->ptr, "inside")) {
- EDBM_op_callf(em, op, "reverse_faces faces=%hf flip_multires=%b", BM_ELEM_SELECT, true);
- }
+ if (em->bm->totfacesel == 0) {
+ continue;
+ }
- EDBM_update_generic(em, true, false);
+ if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf", BM_ELEM_SELECT)) {
+ continue;
+ }
+ if (RNA_boolean_get(op->ptr, "inside")) {
+ EDBM_op_callf(em, op, "reverse_faces faces=%hf flip_multires=%b", BM_ELEM_SELECT, true);
+ }
+
+ EDBM_update_generic(em, true, false);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}