diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-23 08:07:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-23 08:08:23 +0300 |
commit | 44b593ae2d08c5294116a473328b741ec3fc0224 (patch) | |
tree | 5d78a2dd05efa10b18eeb35f5e9916629c72968f /source | |
parent | b51f730b0c215b56c8b946e404403c0caaae1efb (diff) |
Add BM_vert_edge_pair utility function
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 22 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 0c5f51b2b87..5ed8ab20b69 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -775,6 +775,28 @@ bool BM_vert_is_edge_pair(const BMVert *v) } /** + * Access a verts 2 connected edges. + * + * \return true when only 2 verts are found. + */ +bool BM_vert_edge_pair(BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b) +{ + BMEdge *e_a = v->e; + if (e_a) { + BMEdge *e_b = BM_DISK_EDGE_NEXT(e_a, v); + if ((e_b != e_a) && (BM_DISK_EDGE_NEXT(e_b, v) == e_a)) { + *r_e_a = e_a; + *r_e_b = e_b; + return true; + } + } + + *r_e_a = NULL; + *r_e_b = NULL; + return false; +} + +/** * Returns the number of edges around this vertex. */ int BM_vert_edge_count(const BMVert *v) diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 257743be3dd..a1322360729 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -85,6 +85,7 @@ int BM_vert_face_count(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_vert_is_edge_pair(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +bool BM_vert_edge_pair(BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b); bool BM_vert_face_check(BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_vert_is_wire(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 2ea18d509f0..57c77fb99fd 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -756,10 +756,10 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 if (bm_mesh_verts_select_get_n(em->bm, &v, 1) == 1) { copy_v3_v3(normal, v->no); + BMEdge *e_pair[2]; - if (BM_vert_is_edge_pair(v)) { + if (BM_vert_edge_pair(v, &e_pair[0], &e_pair[1])) { bool v_pair_swap = false; - BMEdge *e_pair[2] = {v->e, BM_DISK_EDGE_NEXT(v->e, v)}; BMVert *v_pair[2] = {BM_edge_other_vert(e_pair[0], v), BM_edge_other_vert(e_pair[1], v)}; float dir_pair[2][3]; |