[Bf-blender-cvs] [9f1857002e2] blender2.8: Multi-Objects: LATTICE_OT_select_more/less

Dalai Felinto noreply at git.blender.org
Wed Oct 24 01:41:39 CEST 2018


Commit: 9f1857002e2b28dfd71e9237b2e92b873f87d082
Author: Dalai Felinto
Date:   Tue Oct 23 20:38:30 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB9f1857002e2b28dfd71e9237b2e92b873f87d082

Multi-Objects: LATTICE_OT_select_more/less

Note: Those operators are yet to be added to the menu.

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

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

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

diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index 5ff8ae76c3d..8ab0dc3f6b8 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -266,43 +266,53 @@ static bool lattice_test_bitmap_uvw(Lattice *lt, BLI_bitmap *selpoints, int u, i
 
 static int lattice_select_more_less(bContext *C, const bool select)
 {
-	Object *obedit = CTX_data_edit_object(C);
-	Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
-	BPoint *bp;
-	const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
-	int u, v, w;
-	BLI_bitmap *selpoints;
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	uint objects_len;
+	bool changed = false;
 
-	lt->actbp = LT_ACTBP_NONE;
+	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];
+		Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+		BPoint *bp;
+		const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
+		int u, v, w;
+		BLI_bitmap *selpoints;
 
-	selpoints = BLI_BITMAP_NEW(tot, __func__);
-	BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
+		lt->actbp = LT_ACTBP_NONE;
+
+		selpoints = BLI_BITMAP_NEW(tot, __func__);
+		BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
 
-	bp = lt->def;
-	for (w = 0; w < lt->pntsw; w++) {
-		for (v = 0; v < lt->pntsv; v++) {
-			for (u = 0; u < lt->pntsu; u++) {
-				if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) {
-					if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) ||
-					    lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) ||
-					    lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) ||
-					    lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) ||
-					    lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) ||
-					    lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select))
-					{
-						SET_FLAG_FROM_TEST(bp->f1, select, SELECT);
+		bp = lt->def;
+		for (w = 0; w < lt->pntsw; w++) {
+			for (v = 0; v < lt->pntsv; v++) {
+				for (u = 0; u < lt->pntsu; u++) {
+					if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) {
+						if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) ||
+							lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) ||
+							lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) ||
+							lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) ||
+							lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) ||
+							lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select))
+						{
+							SET_FLAG_FROM_TEST(bp->f1, select, SELECT);
+						}
 					}
+					bp++;
 				}
-				bp++;
 			}
 		}
-	}
 
-	MEM_freeN(selpoints);
+		MEM_freeN(selpoints);
 
-	DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
-	return OPERATOR_FINISHED;
+		changed = true;
+		DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+		WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+	}
+	MEM_freeN(objects);
+
+	return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
 static int lattice_select_more_exec(bContext *C, wmOperator *UNUSED(op))



More information about the Bf-blender-cvs mailing list