From 7f089afc8bc0b25007c072838944fcdc6106544c Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 22 May 2014 21:35:41 -0300 Subject: [PATCH] Bake-API: relaxing in the check for scale uniformity It still warns the user that there may be an error, but the baking goes on. Also using the new is_uniform_scaled_m4() instead of float comparison. Reported and fix suggested by Campbell Barton as a concern over 2bfc3deb --- source/blender/blenlib/BLI_math_matrix.h | 1 + source/blender/blenlib/intern/math_matrix.c | 11 +++++++++-- source/blender/editors/object/object_bake_api.c | 8 +++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 7cfc8948baa..8ce78e5be63 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -145,6 +145,7 @@ bool is_orthonormal_m3(float mat[3][3]); bool is_orthonormal_m4(float mat[4][4]); bool is_uniform_scaled_m3(float mat[3][3]); +bool is_uniform_scaled_m4(float m[4][4]); void adjoint_m2_m2(float R[2][2], float A[2][2]); void adjoint_m3_m3(float R[3][3], float A[3][3]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 4cbe1a76f58..f375a5c01ed 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1059,10 +1059,17 @@ bool is_uniform_scaled_m3(float m[3][3]) fabsf(l5 - l1) <= eps && fabsf(l6 - l1) <= eps) { - return 1; + return true; } - return 0; + return false; +} + +bool is_uniform_scaled_m4(float m[4][4]) +{ + float t[3][3]; + copy_m3_m4(t, m); + return is_uniform_scaled_m3(t); } void normalize_m3(float mat[3][3]) diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 57e29b1b992..95bddd2d109 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -508,14 +508,12 @@ static int bake( if (ob_iter == ob_low) continue; - if (ob_iter->size[0] != ob_iter->size[1] || ob_iter->size[1] != ob_iter->size[2]) { - BKE_reportf(reports, RPT_ERROR, - "Selected objects need to have uniform scale. Apply Scale to object \"%s\"", + if (!is_uniform_scaled_m4(ob_iter->obmat)){ + BKE_reportf(reports, RPT_INFO, + "Selected objects must have uniform scale. Apply scale to object \"%s\" for correct results", ob_iter->id.name + 2); - goto cleanup; } - tot_highpoly ++; }