Revision: 50084
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50084
Author:   blendix
Date:     2012-08-21 13:19:31 +0000 (Tue, 21 Aug 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c  2012-08-21 
11:53:09 UTC (rev 50083)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c  2012-08-21 
13:19:31 UTC (rev 50084)
@@ -2122,23 +2122,49 @@
        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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to