[Bf-blender-cvs] [1cc7d71a0b2] blender2.8: Multi-Objects: LATTICE_OT_make_regular

Dalai Felinto noreply at git.blender.org
Fri Oct 26 19:10:10 CEST 2018


Commit: 1cc7d71a0b20fdea9328305e7ed59b0d64a8b8b0
Author: Dalai Felinto
Date:   Fri Oct 26 11:01:53 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB1cc7d71a0b20fdea9328305e7ed59b0d64a8b8b0

Multi-Objects: LATTICE_OT_make_regular

Committing this for the sake of completionism. I'm going to bring this
up for review, I think we may want to revert it.

Fundamentally I'm changing the behaviour of the operator both in object
mode (acting on all selected lattice objects), as well as the edit mode
(acting on all lattices in edit mode, regardless of them having any
 selected vertice).

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

M	source/blender/editors/lattice/editlattice_tools.c

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

diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c
index 4fefe05b799..01211a436a4 100644
--- a/source/blender/editors/lattice/editlattice_tools.c
+++ b/source/blender/editors/lattice/editlattice_tools.c
@@ -72,22 +72,40 @@ static bool make_regular_poll(bContext *C)
 
 static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob = CTX_data_edit_object(C);
-	Lattice *lt;
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	const bool is_editmode = CTX_data_edit_object(C) != NULL;
+
+	if (is_editmode) {
+		uint objects_len;
+		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 *ob = objects[ob_index];
+			Lattice *lt = ob->data;
+
+			if (lt->editlatt->latt == NULL) {
+				continue;
+			}
+
+			BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
 
-	if (ob) {
-		lt = ob->data;
-		BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+			DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+			WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+		}
+		MEM_freeN(objects);
 	}
 	else {
-		ob = CTX_data_active_object(C);
-		lt = ob->data;
-		BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
-	}
+		FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) {
+			if (ob->type != OB_LATTICE) {
+				continue;
+			}
 
-	DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+			Lattice *lt = ob->data;
+			BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
 
+			DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+			WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+		} FOREACH_SELECTED_OBJECT_END;
+	}
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list