diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-11-14 19:57:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-11-14 20:01:35 +0300 |
commit | 77ba1ed5db4754af6788e5ac4e3110d4b81cad0e (patch) | |
tree | cee1675c5f2fd344fa97dbc8e2b0501d2178d6ef | |
parent | d3919c22b04e7e93ded2c45cdc924897ebd4631a (diff) |
BMesh: fix edge-rotate with w/ flipped faces
Edge-rotate would randomly flip one of the faces to match the other.
Also maintain active-face when rotating the edge.
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index bd2bc54d85f..03165beb329 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -979,6 +979,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f BMLoop *l1, *l2; BMFace *f; BMEdge *e_new = NULL; + char f_active_prev = 0; char f_hflag_prev_1; char f_hflag_prev_2; @@ -1029,6 +1030,16 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f f_hflag_prev_1 = l1->f->head.hflag; f_hflag_prev_2 = l2->f->head.hflag; + /* maintain active face */ + if (bm->act_face == l1->f) { + f_active_prev = 1; + } + else if (bm->act_face == l2->f) { + f_active_prev = 2; + } + + const bool is_flipped = !BM_edge_is_contiguous(e); + /* don't delete the edge, manually remove the edge after so we can copy its attributes */ f = BM_faces_join_pair(bm, BM_face_edge_share_loop(l1->f, e), BM_face_edge_share_loop(l2->f, e), true); @@ -1050,6 +1061,22 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f if (BM_edge_face_pair(e_new, &fa, &fb)) { fa->head.hflag = f_hflag_prev_1; fb->head.hflag = f_hflag_prev_2; + + if (f_active_prev == 1) { + bm->act_face = fa; + } + else if (f_active_prev == 2) { + bm->act_face = fb; + } + + if (is_flipped) { + BM_face_normal_flip(bm, fb); + + if (ccw) { + /* needed otherwise ccw toggles direction */ + e_new->l = e_new->l->radial_next; + } + } } } else { |