diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-03 16:35:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-03 16:35:37 +0400 |
commit | 9c18ade898fb613321bf2eb73232a74de7186aab (patch) | |
tree | 802da6fd569ba897b9649659e4dab5f6da004f46 /source/blender/bmesh/intern/bmesh_queries.c | |
parent | 9d49fa0e6373d78c794e8472ed3f527392dfabcd (diff) |
bmesh edge rotate
* improve check to see if edge rotate can be done,
was checking if both edges verts have an edge count of 2, which is really a meaningless test since the verts can have stray edges connected and the result wont work right.
instead check if the next verts in both faces share a vertex.
* add utility function BM_face_other_vert_loop() which gets the next loop in a face.
* add convenience function BM_edge_face_pair() which returns 2 faces for edges that have exactly 2 face users. (saves ugly e->l->radial_next ... in code) and is more readable.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_queries.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index e597145a54c..ad7300e1c21 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -65,7 +65,7 @@ int BM_vert_in_edge(BMEdge *e, BMVert *v) /** * \brief BMESH OTHER EDGE IN FACE SHARING A VERTEX * - * Finds the other loop that shares 'v' with 'e's loop in 'f'. + * Finds the other loop that shares \a v with \a e loop in \a f. */ BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v) { @@ -84,6 +84,50 @@ BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v) } /** + * \brief BMESH NEXT LOOP IN FACE SHARING A VERTEX + * + * Finds the other loop in a face. + * + * This function returns a loop in \a f that shares an edge with \v + * The direction is defined by \a v_prev, where the return value is + * the loop of what would be 'v_next' + * + * \note \a v_prev and \a v _implicitly_ define an edge. + */ +BMLoop *BM_face_other_vert_loop(BMVert *v_prev, BMFace *f, BMVert *v) +{ + BMIter liter; + BMLoop *l_iter; + + BLI_assert(BM_edge_exists(v_prev, v) != NULL); + + BM_ITER(l_iter, &liter, NULL, BM_LOOPS_OF_VERT, v) { + if (l_iter->f == f) { + break; + } + } + + if (l_iter) { + if (l_iter->prev->v == v_prev) { + return l_iter->next; + } + else if (l_iter->next->v == v_prev) { + return l_iter->prev; + } + else { + /* invalid args */ + BLI_assert(0); + return NULL; + } + } + else { + /* invalid args */ + BLI_assert(0); + return NULL; + } +} + +/** * Returns TRUE if the vertex is used in a given face. */ @@ -191,6 +235,31 @@ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v) } /** + * Utility function, since enough times we have an edge + * and want to access 2 connected faces. + * + * \return TRUE when only 2 faces are found. + */ +int BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb) +{ + BMLoop *la, *lb; + + if ((la = e->l) && + (lb = la->radial_next) && + (lb->radial_next == la)) + { + *r_fa = la->f; + *r_fb = lb->f; + return TRUE; + } + else { + *r_fa = NULL; + *r_fb = NULL; + return FALSE; + } +} + +/** * Returns the number of edges around this vertex. */ int BM_vert_edge_count(BMVert *v) |