diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-27 05:28:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-27 05:28:40 +0400 |
commit | b5d6f14290c02f17cce38e3f96594af76e0410ae (patch) | |
tree | 713c017a68f2b74b6b8a1ede041411bb44f74b58 /source/blender/editors/util | |
parent | 26133a96ae82f44de12c4952ddca07578ede752c (diff) |
Fix T38858: Crazy spaces was unpredictable with co-linear edges
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/crazyspace.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 399b0f86d5f..67b805943bf 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -62,21 +62,27 @@ BLI_INLINE void tan_calc_v3(float a[3], const float b[3], const float c[3]) a[2] = b[2] + 0.2f * (b[2] - c[2]); } +BLI_INLINE void tan_calc_quat_v3( + float r_quat[4], + const float co_1[3], const float co_2[3], const float co_3[3]) +{ + float vec_u[3], vec_v[3]; + tan_calc_v3(vec_u, co_1, co_2); + tan_calc_v3(vec_v, co_1, co_3); + if (tri_to_quat(r_quat, co_1, vec_u, vec_v) < FLT_EPSILON) { + unit_qt(r_quat); + } +} + static void set_crazy_vertex_quat( float r_quat[4], const float co_1[3], const float co_2[3], const float co_3[3], const float vd_1[3], const float vd_2[3], const float vd_3[3]) { - float vec_u[3], vec_v[3]; float q1[4], q2[4]; - tan_calc_v3(vec_u, co_1, co_2); - tan_calc_v3(vec_v, co_1, co_3); - tri_to_quat(q1, co_1, vec_u, vec_v); - - tan_calc_v3(vec_u, vd_1, vd_2); - tan_calc_v3(vec_v, vd_1, vd_3); - tri_to_quat(q2, vd_1, vec_u, vec_v); + tan_calc_quat_v3(q1, co_1, co_2, co_3); + tan_calc_quat_v3(q2, vd_1, vd_2, vd_3); sub_qt_qtqt(r_quat, q2, q1); } |