Merged changes in the trunk up to revision 46045.
[blender-staging.git] / source / blender / editors / mesh / editmesh_select.c
index 228c29cb4a0e867884504ef9c006e51ac41a40d1..6af8f82ec1a9dfa1260f5f2c8353f98570b47e59 100644 (file)
@@ -1051,10 +1051,10 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
                                /* TODO: would be nice if the edge vertex chosen here
                                 * was the one closer to the selection pointer, instead
                                 * of arbitrarily selecting the first one */
-                               EDBM_editselection_store(em, &eed->v1->head);
+                               BM_select_history_store(em->bm, eed->v1);
                        }
                        else if (em->selectmode & SCE_SELECT_EDGE) {
-                               EDBM_editselection_store(em, &eed->head);
+                               BM_select_history_store(em->bm, eed);
                        }
                        /* TODO: would be nice if the nearest face that
                         * belongs to the selected edge could be set to
@@ -1346,7 +1346,7 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
 /* ******************* mesh shortest path select, uses prev-selected edge ****************** */
 
 /* since you want to create paths with multiple selects, it doesn't have extend option */
-static void mouse_mesh_shortest_path(bContext *C, int mval[2])
+static int mouse_mesh_shortest_path(bContext *C, int mval[2])
 {
        ViewContext vc;
        BMEditMesh *em;
@@ -1371,7 +1371,7 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2])
                                e_act = (BMEdge *)ese->ele;
                                if (e_act != e) {
                                        if (edgetag_shortest_path(vc.scene, em, e_act, e)) {
-                                               EDBM_editselection_remove(em, &e_act->head);
+                                               BM_select_history_remove(em->bm, e_act);
                                                path = 1;
                                        }
                                }
@@ -1386,9 +1386,9 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2])
 
                /* even if this is selected it may not be in the selection list */
                if (edgetag_context_check(vc.scene, em, e) == 0)
-                       EDBM_editselection_remove(em, &e->head);
+                       BM_select_history_remove(em->bm, e);
                else
-                       EDBM_editselection_store(em, &e->head);
+                       BM_select_history_store(em->bm, e);
        
                /* force drawmode for mesh */
                switch (CTX_data_tool_settings(C)->edge_mode) {
@@ -1412,6 +1412,11 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2])
                }
                
                EDBM_update_generic(C, em, FALSE);
+
+               return TRUE;
+       }
+       else {
+               return FALSE;
        }
 }
 
@@ -1421,11 +1426,24 @@ static int edbm_shortest_path_select_invoke(bContext *C, wmOperator *UNUSED(op),
        
        view3d_operator_needs_opengl(C);
 
-       mouse_mesh_shortest_path(C, event->mval);
-       
-       return OPERATOR_FINISHED;
+       if (mouse_mesh_shortest_path(C, event->mval)) {
+               return OPERATOR_FINISHED;
+       }
+       else {
+               return OPERATOR_PASS_THROUGH;
+       }
 }
-       
+
+static int edbm_shortest_path_select_poll(bContext *C)
+{
+       if (ED_operator_editmesh_region_view3d(C)) {
+               Object *obedit = CTX_data_edit_object(C);
+               BMEditMesh *em = BMEdit_FromObject(obedit);
+               return (em->selectmode & SCE_SELECT_EDGE) != 0;
+       }
+       return 0;
+}
+
 void MESH_OT_select_shortest_path(wmOperatorType *ot)
 {
        /* identifiers */
@@ -1435,7 +1453,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke = edbm_shortest_path_select_invoke;
-       ot->poll = ED_operator_editmesh;
+       ot->poll = edbm_shortest_path_select_poll;
        
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1468,31 +1486,31 @@ int mouse_mesh(bContext *C, const int mval[2], short extend)
                        BM_active_face_set(vc.em->bm, efa);
                        
                        if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
-                               EDBM_editselection_store(vc.em, &efa->head);
+                               BM_select_history_store(vc.em->bm, efa);
                                BM_face_select_set(vc.em->bm, efa, TRUE);
                        }
                        else if (extend) {
-                               EDBM_editselection_remove(vc.em, &efa->head);
+                               BM_select_history_remove(vc.em->bm, efa);
                                BM_face_select_set(vc.em->bm, efa, FALSE);
                        }
                }
                else if (eed) {
                        if (!BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
-                               EDBM_editselection_store(vc.em, &eed->head);
+                               BM_select_history_store(vc.em->bm, eed);
                                BM_edge_select_set(vc.em->bm, eed, TRUE);
                        }
                        else if (extend) {
-                               EDBM_editselection_remove(vc.em, &eed->head);
+                               BM_select_history_remove(vc.em->bm, eed);
                                BM_edge_select_set(vc.em->bm, eed, FALSE);
                        }
                }
                else if (eve) {
                        if (!BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
-                               EDBM_editselection_store(vc.em, &eve->head);
+                               BM_select_history_store(vc.em->bm, eve);
                                BM_vert_select_set(vc.em->bm, eve, TRUE);
                        }
                        else if (extend) {
-                               EDBM_editselection_remove(vc.em, &eve->head);
+                               BM_select_history_remove(vc.em->bm, eve);
                                BM_vert_select_set(vc.em->bm, eve, FALSE);
                        }
                }
@@ -1504,7 +1522,7 @@ int mouse_mesh(bContext *C, const int mval[2], short extend)
                        vc.obedit->actcol = efa->mat_nr + 1;
                        vc.em->mat_nr = efa->mat_nr;
 
-                       WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL);
+                       WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, NULL);
 
                }
 
@@ -1907,7 +1925,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
                }
                BMW_end(&walker);
        }
-       else  {
+       else {
                BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
                        if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
                                BM_elem_flag_enable(v, BM_ELEM_TAG);
@@ -2299,7 +2317,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
                BLI_array_empty(stack);
                i = 1;
 
-               BLI_array_growone(stack);
+               BLI_array_grow_one(stack);
                stack[i - 1] = f;
 
                while (i) {
@@ -2322,7 +2340,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
 
                                        /* invalidate: edge too sharp */
                                        if (angle < sharp) {
-                                               BLI_array_growone(stack);
+                                               BLI_array_grow_one(stack);
                                                stack[i] = l2->f;
                                                i++;
                                        }