[Bf-blender-cvs] [bdd02cc082e] blender2.8: UV_OT_unwrap: Error messages

Dalai Felinto noreply at git.blender.org
Fri Oct 19 14:15:18 CEST 2018


Commit: bdd02cc082e5f16935f2ed9fbafe63f8aed2822a
Author: Dalai Felinto
Date:   Fri Oct 19 09:13:59 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBbdd02cc082e5f16935f2ed9fbafe63f8aed2822a

UV_OT_unwrap: Error messages

Make sure a message is not reported multiple times when working with
multi-objects. Like in 2.7x we may have two infos coming from the same operator.

In 2.7 we could report non-uniform xor non-scaled, and subsurface.
Now we can report each one of those errors separately.

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

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 2e3ff5a5065..538ca9afafa 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -1417,6 +1417,11 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel, const bool pa
 	param_delete(handle);
 }
 
+enum {
+	UNWRAP_ERROR_NONUNIFORM = (1 << 0),
+	UNWRAP_ERROR_NEGATIVE = (1 << 1),
+};
+
 static int unwrap_exec(bContext *C, wmOperator *op)
 {
 	ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1425,8 +1430,10 @@ static int unwrap_exec(bContext *C, wmOperator *op)
 	const bool fill_holes = RNA_boolean_get(op->ptr, "fill_holes");
 	const bool correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
 	const bool use_subsurf = RNA_boolean_get(op->ptr, "use_subsurf_data");
-	float obsize[3];
 	bool implicit = false;
+	int reported_errors = 0;
+	/* We will report an error unless at least one object has the subsurf modifier in the right place. */
+	bool subsurf_error = use_subsurf;
 
 	uint objects_len = 0;
 	Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
@@ -1439,29 +1446,47 @@ static int unwrap_exec(bContext *C, wmOperator *op)
 	/* add uvs if they don't exist yet */
 	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 		Object *obedit = objects[ob_index];
+		float obsize[3];
 		bool use_subsurf_final;
 
 		if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
 			continue;
 		}
 
+		if (subsurf_error) {
+			/* Double up the check here but better keep ED_unwrap_lscm interface simple and not
+			 * pass operator for warning append. */
+			modifier_unwrap_state(obedit, scene, &use_subsurf_final);
+			if (use_subsurf_final) {
+				subsurf_error = false;
+			}
+		}
+
+		if (reported_errors & (UNWRAP_ERROR_NONUNIFORM | UNWRAP_ERROR_NEGATIVE)) {
+			continue;
+		}
+
 		mat4_to_size(obsize, obedit->obmat);
-		if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f))
-			BKE_report(op->reports, RPT_INFO,
-			           "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh");
-		else if (is_negative_m4(obedit->obmat))
-			BKE_report(op->reports, RPT_INFO,
-			           "Object has negative scale, unwrap will operate on a non-flipped version of the mesh");
-
-
-		/* double up the check here but better keep ED_unwrap_lscm interface simple and not
-		 * pass operator for warning append */
-		modifier_unwrap_state(obedit, scene, &use_subsurf_final);
-		if (use_subsurf != use_subsurf_final) {
-			BKE_report(op->reports, RPT_INFO, "Subdivision Surface modifier needs to be first to work with unwrap");
+		if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f)) {
+			if ((reported_errors & UNWRAP_ERROR_NONUNIFORM) == 0) {
+				BKE_report(op->reports, RPT_INFO,
+				          "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh");
+				reported_errors |= UNWRAP_ERROR_NONUNIFORM;
+			}
+		}
+		else if (is_negative_m4(obedit->obmat)) {
+			if ((reported_errors & UNWRAP_ERROR_NEGATIVE) == 0) {
+				BKE_report(op->reports, RPT_INFO,
+				           "Object has negative scale, unwrap will operate on a non-flipped version of the mesh");
+				reported_errors |= UNWRAP_ERROR_NEGATIVE;
+			}
 		}
 	}
 
+	if (subsurf_error) {
+		BKE_report(op->reports, RPT_INFO, "Subdivision Surface modifier needs to be first to work with unwrap");
+	}
+
 	/* remember last method for live unwrap */
 	if (RNA_struct_property_is_set(op->ptr, "method"))
 		scene->toolsettings->unwrapper = method;



More information about the Bf-blender-cvs mailing list