diff options
author | Habib Gahbiche <habibgahbiche@gmail.com> | 2018-11-09 22:03:41 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-09 22:19:04 +0300 |
commit | 0c1934f3c2d3dff3bce65e2e8169866bafea04e0 (patch) | |
tree | 4b5e8baf24fe1946bcf6eb1ce76286025e8eb67d /source/blender/bmesh/intern/bmesh_query.c | |
parent | dc346c05fe32c7d90be261a2e970ef976b13c1fc (diff) |
Multi-Objects: MESH_OT_select_similar worldspace completion
This makes the operator to work 100% with worldspace similarity:
* SIMFACE_PERIMETER
* SIMFACE_AREA
* SIMEDGE_FACE_ANGLE
Note from revisor (Dalai Felinto):
I'm not sure we want to pass Object * to the bmesh api, though I
personally don't see why not. Either way I group the patches together so
we can more easily roll them back if needs be.
Maniphest Tasks: T56948
Differential Revision: D3908, D3899, D3896
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_query.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index 540888ac0b9..c51c6322136 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -31,6 +31,8 @@ * of inspecting the mesh structure directly. */ +#include "DNA_object_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -39,6 +41,7 @@ #include "BLI_utildefines_stack.h" #include "BKE_customdata.h" +#include "BKE_object.h" #include "bmesh.h" #include "intern/bmesh_private.h" @@ -1678,6 +1681,43 @@ 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_worldspace_ex(Object *ob, const BMEdge *e, 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); + + float smat[3][3]; + BKE_object_scale_to_mat3(ob, smat); + invert_m3(smat); + + mul_m3_v3(smat, no1); + mul_m3_v3(smat, no2); + normalize_v3(no1); + normalize_v3(no2); + + return angle_normalized_v3v3(no1, no2); + } + else { + return fallback; + } +} +float BM_edge_calc_face_angle_worldspace(Object *ob, const BMEdge *e) +{ + return BM_edge_calc_face_angle_worldspace_ex(ob, e, DEG2RADF(90.0f)); +} + +/** * \brief BMESH EDGE/FACE ANGLE * * Calculates the angle between two faces. |