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:
authorCampbell Barton <ideasman42@gmail.com>2012-09-25 04:20:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-25 04:20:42 +0400
commitb0bf816ececfaf56281e1539577656df3c995aa0 (patch)
tree0e289fc19194472a88e08528efb9e8fb9947d9a1 /source/blender/blenlib/intern/math_rotation.c
parent687cacfdd0aec599e56f7f5e2ed69f0bf6c61b4e (diff)
fix [#32646] Duplifaces can have wrong orientation with ngons
concave ngons could flip the dupliface, now use the faces normal when calculating the dupli-face.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index e10b0b3298c..1392e88c168 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -613,13 +613,21 @@ void add_qt_qtqt(float result[4], const float quat1[4], const float quat2[4], co
result[3] = quat1[3] + t * quat2[3];
}
-void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const float v3[3])
+/* same as tri_to_quat() but takes pre-computed normal from the triangle
+ * used for ngons when we know their normal */
+void tri_to_quat_ex(float quat[4], const float v1[3], const float v2[3], const float v3[3],
+ const float no_orig[3])
{
/* imaginary x-axis, y-axis triangle is being rotated */
float vec[3], q1[4], q2[4], n[3], si, co, angle, mat[3][3], imat[3][3];
/* move z-axis to face-normal */
+#if 0
normal_tri_v3(vec, v1, v2, v3);
+#else
+ copy_v3_v3(vec, no_orig);
+ (void)v3;
+#endif
n[0] = vec[1];
n[1] = -vec[0];
@@ -659,6 +667,13 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa
mul_qt_qtqt(quat, q1, q2);
}
+void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const float v3[3])
+{
+ float vec[3];
+ normal_tri_v3(vec, v1, v2, v3);
+ tri_to_quat_ex(quat, v1, v2, v3, vec);
+}
+
void print_qt(const char *str, const float q[4])
{
printf("%s: %.3f %.3f %.3f %.3f\n", str, q[0], q[1], q[2], q[3]);