Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-05-01 15:01:24 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-05-01 15:01:24 +0400
commit6527f42b6bd1b918c5e7b0c865024c14806ac1ae (patch)
tree998ee6e8fb73602bb34dce34949754559ee4a5b9 /source/blender/blenlib/intern/math_matrix.c
parent3ee136910d1c6b70e7c99ebb40798d1706c13d9e (diff)
Fix #31193: Normals don't have any Z component
Issue was caused by heavily non-uniform scale applied on object. Run scale correction on face and vertex normals draw if there's non-uniform scale.
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r--source/blender/blenlib/intern/math_matrix.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index bb0b8897b15..b3b58dca1a6 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -866,6 +866,35 @@ int is_orthonormal_m4(float m[][4])
return 0;
}
+int is_uniform_scaled_m3(float m[][3])
+{
+ const float eps = 1e-7;
+ float t[3][3];
+ float l1, l2, l3, l4, l5, l6;
+
+ copy_m3_m3(t, m);
+ transpose_m3(t);
+
+ l1 = len_squared_v3(m[0]);
+ l2 = len_squared_v3(m[1]);
+ l3 = len_squared_v3(m[2]);
+
+ l4 = len_squared_v3(t[0]);
+ l5 = len_squared_v3(t[1]);
+ l6 = len_squared_v3(t[2]);
+
+ if (fabsf(l2 - l1) <= eps &&
+ fabsf(l3 - l1) <= eps &&
+ fabsf(l4 - l1) <= eps &&
+ fabsf(l5 - l1) <= eps &&
+ fabsf(l6 - l1) <= eps)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
void normalize_m3(float mat[][3])
{
normalize_v3(mat[0]);