[Bf-blender-cvs] [63c23971717] blender2.8: T54643-Multi-Object EditMesh: MESH_OT_select_nth

Luc Revardel noreply at git.blender.org
Mon May 14 14:07:16 CEST 2018


Commit: 63c23971717d8a578e737c26796b92479c160f23
Author: Luc Revardel
Date:   Mon May 14 13:57:17 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB63c23971717d8a578e737c26796b92479c160f23

T54643-Multi-Object EditMesh: MESH_OT_select_nth

With changes by Dalai Felinto:
* Move WM_operator.* outside for loop.
* Update error message to handle Mesh and Meshes.
* Skip main functionality when no vert/edge/face is selected.

Maniphest Tasks: T54643
Differential Revision: https://developer.blender.org/D3371

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

M	source/blender/editors/mesh/editmesh_select.c

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

diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 0f25624a1f9..a232deed688 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -3728,18 +3728,39 @@ static bool edbm_deselect_nth(BMEditMesh *em, const struct CheckerIntervalParams
 
 static int edbm_select_nth_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);
 	struct CheckerIntervalParams op_params;
-
 	WM_operator_properties_checker_interval_from_op(op, &op_params);
+	bool found_active_elt = false;
 
-	if (edbm_deselect_nth(em, &op_params) == false) {
-		BKE_report(op->reports, RPT_ERROR, "Mesh has no active vert/edge/face");
-		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 ((em->bm->totvertsel == 0) &&
+		    (em->bm->totedgesel == 0) &&
+		    (em->bm->totfacesel == 0))
+		{
+			continue;
+		}
+
+		if (edbm_deselect_nth(em, &op_params) == true) {
+			found_active_elt = true;
+			EDBM_update_generic(em, false, false);
+		}
 	}
+	MEM_SAFE_FREE(objects);
 
-	EDBM_update_generic(em, false, false);
+	if (!found_active_elt) {
+		BKE_report(op->reports, RPT_ERROR,
+		           (objects_len == 1 ?
+		            "Mesh has no active vert/edge/face" :
+		            "Meshes have no active vert/edge/face"));
+		return OPERATOR_CANCELLED;
+	}
 
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list