fix for fix, ugh!, vertex slide with concave/convex ngons & normal flipping should...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 29 Jan 2013 05:18:30 +0000 (05:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 29 Jan 2013 05:18:30 +0000 (05:18 +0000)
... somehow I managed to make test-cases that worked in previous commits but failed in other cases.

source/blender/blenlib/intern/math_vector_inline.c
source/blender/editors/transform/transform.c

index 8c62fdf..c4def53 100644 (file)
@@ -528,6 +528,7 @@ MINLINE float cross_v2v2(const float a[2], const float b[2])
 
 MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
 {
+       BLI_assert(r != a && r != b);
        r[0] = a[1] * b[2] - a[2] * b[1];
        r[1] = a[2] * b[0] - a[0] * b[2];
        r[2] = a[0] * b[1] - a[1] * b[0];
index fb2d9af..6d11eeb 100644 (file)
@@ -4917,23 +4917,20 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                                len_v3_ensure(vec_accum, vec_accum_len / (float)i);
                        }
                        else {
-                               /* When there is no edge to slide along,
-                                * we must slide along the vector defined by the face we're attach to */
-                               float e_dir_prev[3], e_dir_next[3], tvec[3];
+                               BMLoop *l_tmp = BM_face_vert_share_loop(l_first->f, v);
 
-                               sub_v3_v3v3(e_dir_prev, BM_edge_other_vert(e_prev, v)->co, v->co);
-                               sub_v3_v3v3(e_dir_next, BM_edge_other_vert(e_next, v)->co, v->co);
-
-                               cross_v3_v3v3(tvec, l->f->no, e_dir_prev);
-                               cross_v3_v3v3(vec_accum, e_dir_next, l->f->no);
-
-                               mid_v3_v3v3(vec_accum, vec_accum, tvec);
-
-                               /* check if we need to flip
-                                * (compare the normal defines by the edges with the face normal) */
-                               cross_v3_v3v3(tvec, e_dir_prev, e_dir_next);
-                               if ((dot_v3v3(tvec, l->f->no) < 0.0f) == BM_loop_is_convex(l)) {
-                                       negate_v3(vec_accum);
+                               if (ELEM(l_tmp->e, e_prev, e_next) && ELEM(l_tmp->prev->e, e_prev, e_next)) {
+                                       float tvec[3];
+                                       BM_loop_calc_face_tangent(l_tmp, vec_accum);
+                                       if (!BM_loop_is_convex(l_tmp)) {
+                                               negate_v3(vec_accum);
+                                       }
+                                       cross_v3_v3v3(tvec, vec_accum, l_tmp->f->no);
+                                       cross_v3_v3v3(vec_accum, l_tmp->f->no, tvec);
+                                       len_v3_ensure(vec_accum, (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f);
+                               }
+                               else {
+                                       BLI_assert(0);
                                }
                        }