[Bf-blender-cvs] [ee1327a84cd] blender2.8: Multi-Object-Mode: EditLattice Select All

Campbell Barton noreply at git.blender.org
Tue May 22 08:11:29 CEST 2018


Commit: ee1327a84cd5d76f58d40df28d8f8b30f7674d4a
Author: Campbell Barton
Date:   Tue May 22 08:11:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBee1327a84cd5d76f58d40df28d8f8b30f7674d4a

Multi-Object-Mode: EditLattice Select All

D3164 by @ranjian0

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

M	source/blender/blenkernel/BKE_lattice.h
M	source/blender/blenkernel/intern/lattice.c
M	source/blender/editors/lattice/editlattice_select.c

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

diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index d5c241d43e4..b722b7da6a0 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -92,6 +92,8 @@ void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]);
 void BKE_lattice_translate(struct Lattice *lt, float offset[3], bool do_keys);
 void BKE_lattice_transform(struct Lattice *lt, float mat[4][4], bool do_keys);
 
+bool BKE_lattice_is_any_selected(const struct Lattice *lt);
+
 int  BKE_lattice_index_from_uvw(struct Lattice *lt, const int u, const int v, const int w);
 void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index, int *r_u, int *r_v, int *r_w);
 int  BKE_lattice_index_flip(struct Lattice *lt, const int index,
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index d7105d3423f..2a60bd94d10 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1229,6 +1229,22 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
 	}
 }
 
+bool BKE_lattice_is_any_selected(const Lattice *lt)
+{
+	/* Intentionally don't handle 'lt->editlatt' (caller must do this). */
+	const BPoint *bp = lt->def;
+	int a = lt->pntsu * lt->pntsv * lt->pntsw;
+	while (a--) {
+		if (bp->hide == 0) {
+			if (bp->f1 & SELECT) {
+				return true;
+			}
+		}
+		bp++;
+	}
+	return false;
+}
+
 /* **** Depsgraph evaluation **** */
 
 void BKE_lattice_eval_geometry(struct Depsgraph *UNUSED(depsgraph),
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index ccf90452b0f..2ba1dde243b 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -366,51 +366,55 @@ void ED_lattice_flags_set(Object *obedit, int flag)
 
 static int lattice_select_all_exec(bContext *C, wmOperator *op)
 {
-	Object *obedit = CTX_data_edit_object(C);
-	Lattice *lt = obedit->data;
-	BPoint *bp;
-	int a;
+	ViewLayer *view_layer = CTX_data_view_layer(C);
 	int action = RNA_enum_get(op->ptr, "action");
 
+	uint objects_len = 0;
+	Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
 	if (action == SEL_TOGGLE) {
 		action = SEL_SELECT;
-
-		bp = lt->editlatt->latt->def;
-		a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
-		while (a--) {
-			if (bp->hide == 0) {
-				if (bp->f1 & SELECT) {
-					action = SEL_DESELECT;
-					break;
-				}
+		for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+			Object *obedit = objects[ob_index];
+			Lattice *lt = obedit->data;
+			if (BKE_lattice_is_any_selected(lt->editlatt->latt)) {
+				action = SEL_DESELECT;
+				break;
 			}
-			bp++;
 		}
 	}
 
-	switch (action) {
-		case SEL_SELECT:
-			ED_lattice_flags_set(obedit, 1);
-			break;
-		case SEL_DESELECT:
-			ED_lattice_flags_set(obedit, 0);
-			break;
-		case SEL_INVERT:
-			bp = lt->editlatt->latt->def;
-			a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-			lt->editlatt->latt->actbp = LT_ACTBP_NONE;
-
-			while (a--) {
-				if (bp->hide == 0) {
-					bp->f1 ^= SELECT;
+	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+		Object *obedit = objects[ob_index];
+		Lattice *lt;
+		BPoint *bp;
+		int a;
+
+		switch (action) {
+			case SEL_SELECT:
+				ED_lattice_flags_set(obedit, 1);
+				break;
+			case SEL_DESELECT:
+				ED_lattice_flags_set(obedit, 0);
+				break;
+			case SEL_INVERT:
+				lt = obedit->data;
+				bp = lt->editlatt->latt->def;
+				a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+				lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
+				while (a--) {
+					if (bp->hide == 0) {
+						bp->f1 ^= SELECT;
+					}
+					bp++;
 				}
-				bp++;
-			}
-			break;
+				break;
+		}
+		WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
 	}
+	MEM_freeN(objects);
 
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
 
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list