diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 06:46:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-07 06:46:58 +0400 |
commit | 04beeea9c9d7805b8df10c986c779f7b48a3f56f (patch) | |
tree | 465ef9c30d79c33eacb80cdabc696f2550c873d9 | |
parent | 6eb6877cdda57ed7f1442c310b0bc3e0bceba2ab (diff) |
single vertex rip wasn't finishing with the best vertex selected.
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 226a17f7cb1..022b95f542d 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -2510,11 +2510,40 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BMBVH_FreeBVH(bvhtree); #endif - /* de-select one of the sides */ - BMO_slot_buffer_hflag_disable(bm, &bmop, side ? "edgeout1" : "edgeout2", BM_ELEM_SELECT, BM_EDGE, TRUE); + if (singlesel) { + BMVert *v_best = NULL; - if (ripvert) { + /* not good enough! - original vert may not be attached to the closest edge */ +#if 0 + EDBM_flag_disable_all(em, BM_ELEM_SELECT); BM_elem_select_set(bm, ripvert, TRUE); +#else + + dist = FLT_MAX; + BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { + if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { + /* 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); + if (d < dist) { + v_best = v; + dist = d; + } + } + } + } + + if (v_best) { + BM_elem_select_set(bm, v_best, TRUE); + } +#endif + + } + else { + /* de-select one of the sides */ + BMO_slot_buffer_hflag_disable(bm, &bmop, side ? "edgeout1" : "edgeout2", BM_ELEM_SELECT, BM_EDGE, TRUE); } EDBM_selectmode_flush(em); |