diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-08-21 17:19:31 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-08-21 17:19:31 +0400 |
commit | be4ac3a860723af7d176aeabb1dba112a1594bd3 (patch) | |
tree | 3394152dfcd93f8fc9829958ec067d4a3a470c8d /source/blender/editors/mesh/editmesh_tools.c | |
parent | 4bcae5fb076cad3a9ca312a6ba881b5645be76e7 (diff) |
Fix #32355: select vertex path not working when vertices are selected with e.g.
border select. There was a fix before bmesh where it would require exactly two
vertices to be selected, but this was not ported over, and it also wasn't quite
correct.
This case should also work: click on two vertices, selected the path between
them, and then click on a 3rd vertex and select path, to extend the path further
from the 2nd to the 3rd vertex.
Now both use cases should work.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4b8edb920a1..3de945fb06c 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2122,23 +2122,49 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; + BMIter iter; + BMVert *eve = NULL, *svert = NULL, *evert = NULL; BMEditSelection *sv, *ev; /* get the type from RNA */ int type = RNA_enum_get(op->ptr, "type"); + /* first try to find vertices in edit selection */ sv = em->bm->selected.last; - if (sv != NULL) + if (sv != NULL) { ev = sv->prev; - else return OPERATOR_CANCELLED; - if (ev == NULL) - return OPERATOR_CANCELLED; - if ((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) + if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) { + svert = (BMVert *)sv->ele; + evert = (BMVert *)ev->ele; + } + } + + /* if those are not found, because vertices where selected by e.g. + border or circle select, find two selected vertices */ + if (svert == NULL) { + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) + continue; + + if (svert == NULL) svert = eve; + else if (evert == NULL) evert = eve; + else { + /* more than two vertices are selected, + show warning message and cancel operator */ + svert = evert = NULL; + break; + } + } + } + + if (svert == NULL || evert == NULL) { + BKE_report(op->reports, RPT_WARNING, "Path Selection requires that two vertices be selected"); return OPERATOR_CANCELLED; + } /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type); + EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", svert, evert, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); |