diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 08:20:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 08:20:30 +0400 |
commit | b563870fd992ec2539a0332e024ba4eda72a6d6e (patch) | |
tree | 5e186967445f57a44cf0563fba4eeb2643e20c44 | |
parent | 0c7487d1ebe35d3221e129252835667892e5a8a4 (diff) |
use a better method if picking the rip vertex to use, rather then finding the edge closest to the mouse, find the face corner attached to the vert - thats closest to the mouse, this way ripping gives predictable outcome.
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index baaf4309c64..ae48eadd9cc 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -2341,7 +2341,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BMesh *bm = em->bm; BMOperator bmop; BMOIter siter; - BMIter iter, eiter; + BMIter iter, eiter, liter; BMLoop *l; BMEdge *e, *e2; BMVert *v, *ripvert = NULL; @@ -2512,6 +2512,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) if (singlesel) { BMVert *v_best = NULL; + float l_prev_co[3], l_next_co[3], l_corner_co[3]; + float scale; /* not good enough! - original vert may not be attached to the closest edge */ #if 0 @@ -2525,8 +2527,20 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) /* disable by default, re-enable winner at end */ BM_elem_select_set(bm, v, FALSE); - BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) { - d = mesh_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval); + BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) { + /* calculate a point in the face, rather then calculate the middle, + * make a vector pointing between the 2 edges attached to this loop */ + sub_v3_v3v3(l_prev_co, l->prev->v->co, l->v->co); + sub_v3_v3v3(l_next_co, l->next->v->co, l->v->co); + + scale = normalize_v3(l_prev_co) + normalize_v3(l_next_co); + mul_v3_fl(l_prev_co, scale); + mul_v3_fl(l_next_co, scale); + + add_v3_v3v3(l_corner_co, l_prev_co, l_next_co); + add_v3_v3(l_corner_co, l->v->co); + + d = mesh_rip_edgedist(ar, projectMat, l->v->co, l_corner_co, fmval); if (d < dist) { v_best = v; dist = d; |