diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-10 11:54:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-10 11:56:02 +0300 |
commit | 3756f920f4894c9ec748c0ece5f63e1bc9c616df (patch) | |
tree | 9c75009e8998407a72b51e03328aa59f6c30a81a /source/blender/bmesh/intern/bmesh_query.c | |
parent | 7efac2b0b09d9e76d9fc573ec7936a1c6440c067 (diff) |
BMesh: backport minor changes from 2.8
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_query.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index 540888ac0b9..6e69ba48baf 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -1678,6 +1678,40 @@ float BM_edge_calc_face_angle(const BMEdge *e) } /** +* \brief BMESH EDGE/FACE ANGLE +* +* Calculates the angle between two faces in world space. +* Assumes the face normals are correct. +* +* \return angle in radians +*/ +float BM_edge_calc_face_angle_with_imat3_ex(const BMEdge *e, float imat3[3][3], const float fallback) +{ + if (BM_edge_is_manifold(e)) { + const BMLoop *l1 = e->l; + const BMLoop *l2 = e->l->radial_next; + float no1[3], no2[3]; + copy_v3_v3(no1, l1->f->no); + copy_v3_v3(no2, l2->f->no); + + mul_transposed_m3_v3(imat3, no1); + mul_transposed_m3_v3(imat3, no2); + + normalize_v3(no1); + normalize_v3(no2); + + return angle_normalized_v3v3(no1, no2); + } + else { + return fallback; + } +} +float BM_edge_calc_face_angle_with_imat3(const BMEdge *e, float imat3[3][3]) +{ + return BM_edge_calc_face_angle_with_imat3_ex(e, imat3, DEG2RADF(90.0f)); +} + +/** * \brief BMESH EDGE/FACE ANGLE * * Calculates the angle between two faces. |