[Bf-blender-cvs] [e026a3b0167] blender2.8: Multi-Objects: UV_OT_average_islands_scale

Alan noreply at git.blender.org
Tue Sep 4 19:22:31 CEST 2018


Commit: e026a3b0167435b9515e07316490033eef9d991b
Author: Alan
Date:   Tue Sep 4 14:06:54 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBe026a3b0167435b9515e07316490033eef9d991b

Multi-Objects: UV_OT_average_islands_scale

Changes from reviewer (Dalai Felinto):
* Skip loop if sync selection and no vertex selected.

https://developer.blender.org/D3406

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

M	source/blender/editors/uvedit/uvedit_unwrap_ops.c

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

diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 52409dc2a1f..fea835aa2b2 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -885,23 +885,37 @@ void UV_OT_pack_islands(wmOperatorType *ot)
 static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene = CTX_data_scene(C);
-	Object *obedit = CTX_data_edit_object(C);
-	BMEditMesh *em = BKE_editmesh_from_object(obedit);
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	ToolSettings *ts = scene->toolsettings;
+	const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
+	const bool implicit = true;
 	ParamHandle *handle;
-	bool implicit = true;
 
-	if (!uvedit_have_selection(scene, em, implicit)) {
+	uint objects_len = 0;
+	Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+
+	if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
+		MEM_freeN(objects);
 		return OPERATOR_CANCELLED;
 	}
 
-	handle = construct_param_handle(scene, obedit, em->bm, implicit, 0, 1, 1);
+	handle = construct_param_handle_multi(scene, objects, objects_len, implicit, false, true, true);
 	param_average(handle);
 	param_flush(handle);
 	param_delete(handle);
 
-	DEG_id_tag_update(obedit->data, 0);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+		Object *obedit = objects[ob_index];
+		BMEditMesh *em = BKE_editmesh_from_object(obedit);
+
+		if (synced_selection && (em->bm->totvertsel == 0)) {
+			continue;
+		}
 
+		DEG_id_tag_update(obedit->data, 0);
+		WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	}
+	MEM_freeN(objects);
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list