diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 29 |
2 files changed, 14 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 8c62fdf81a7..c4def539c10 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -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]; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index fb2d9af7c35..6d11eebe7dc 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -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); } } |