fix for incorrect edge slide interpolation at loop endpoings with ngons.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2013 10:04:23 +0000 (10:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2013 10:04:23 +0000 (10:04 +0000)
source/blender/bmesh/intern/bmesh_queries.c
source/blender/editors/transform/transform.c

index f61c63ee6c52dff8a2d70b22add6d0c2f490808f..a4ddc0cbba443569880ea1e1d3d3d6408e0f950d 100644 (file)
@@ -959,6 +959,7 @@ bool BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2)
  */
 BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2)
 {
+       BLI_assert(e1 != e2);
        if (BM_vert_in_edge(e2, e1->v1)) {
                return e1->v1;
        }
index 41bd375089fffd8accff9d96f23d669e13b40523..e9e9e9208531149ccd55566fc2e7b93a7d913a86 100644 (file)
@@ -5285,15 +5285,35 @@ static int createEdgeSlideVerts(TransInfo *t)
                l_a = e->l;
                l_b = e->l->radial_next;
 
+               /* regarding e_next, use get_next_loop()'s improved interpolation where possible */
                {
-                       BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
-                       sub_v3_v3v3(vec_a, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                       BMEdge *e_next = get_other_edge(v, e);
+                       if (e_next) {
+                               get_next_loop(v, l_a, e, e_next, vec_a);
+                       }
+                       else {
+                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
+                               if (BM_vert_edge_count_nonwire(v) == 2)
+                                       get_next_loop(v, l_a, e, l_tmp->e, vec_a);
+                               else
+                                       sub_v3_v3v3(vec_a, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                       }
                }
 
                /* !BM_edge_is_boundary(e); */
                if (l_b != l_a) {
-                       BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
-                       sub_v3_v3v3(vec_b, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                       BMEdge *e_next = get_other_edge(v, e);
+                       if (e_next) {
+                               get_next_loop(v, l_b, e, e_next, vec_b);
+                       }
+                       else {
+                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
+                               if (BM_vert_edge_count_nonwire(v) == 2)
+                                       get_next_loop(v, l_b, e, l_tmp->e, vec_b);
+                               else
+                                       sub_v3_v3v3(vec_b, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+
+                       }
                }
                else {
                        l_b = NULL;
@@ -5345,13 +5365,23 @@ static int createEdgeSlideVerts(TransInfo *t)
                                if (l_a) {
                                        BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
                                        sv->v_a = BM_edge_other_vert(l_tmp->e, v);
-                                       sub_v3_v3v3(sv->dir_a, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                                       if (BM_vert_edge_count_nonwire(v) == 2) {
+                                               get_next_loop(v, l_a, e_prev, l_tmp->e, sv->dir_a);
+                                       }
+                                       else {
+                                               sub_v3_v3v3(sv->dir_a, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                                       }
                                }
 
                                if (l_b) {
                                        BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
                                        sv->v_b = BM_edge_other_vert(l_tmp->e, v);
-                                       sub_v3_v3v3(sv->dir_b, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                                       if (BM_vert_edge_count_nonwire(v) == 2) {
+                                               get_next_loop(v, l_b, e_prev, l_tmp->e, sv->dir_b);
+                                       }
+                                       else {
+                                               sub_v3_v3v3(sv->dir_b, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                                       }
                                }
 
                                BM_elem_flag_disable(v, BM_ELEM_TAG);