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.
This commit is contained in:
parent
15d5cd961c
commit
bdd02cc082
|
@ -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,27 +1446,45 @@ 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;
|
||||
}
|
||||
|
||||
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 (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)) {
|
||||
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 */
|
||||
|
|
Loading…
Reference in New Issue