switch arg order for BM_face_other_* funcs (make face come first), and add nice ascii...
[blender.git] / source / blender / editors / mesh / loopcut.c
index 11f936a6a9f9752c3a8df6da24d399e004b07648..bbc495706ac621340afae08cd93da3e7f7f75db5 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "DNA_ID.h"
 #include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
@@ -50,7 +51,6 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_dynstr.h" /*for WM_operator_pystring */
-#include "BLI_editVert.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_blender.h"
@@ -133,8 +133,8 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
        }
 }
 
-/*given two opposite edges in a face, finds the ordering of their vertices so
-  that cut preview lines won't cross each other*/
+/* given two opposite edges in a face, finds the ordering of their vertices so
* that cut preview lines won't cross each other*/
 static void edgering_find_order(BMEditMesh *em, BMEdge *lasteed, BMEdge *eed, 
                                 BMVert *lastv1, BMVert *v[2][2])
 {
@@ -145,9 +145,9 @@ static void edgering_find_order(BMEditMesh *em, BMEdge *lasteed, BMEdge *eed,
        l = eed->l;
 
        /*find correct order for v[1]*/
-       if (!(BM_Edge_In_Face(l->f, eed) && BM_Edge_In_Face(l->f, lasteed))) {
+       if (!(BM_edge_in_face(l->f, eed) && BM_edge_in_face(l->f, lasteed))) {
                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_LOOP, l) {
-                       if (BM_Edge_In_Face(l->f, eed) && BM_Edge_In_Face(l->f, lasteed))
+                       if (BM_edge_in_face(l->f, eed) && BM_edge_in_face(l->f, lasteed))
                                break;
                }
        }
@@ -161,7 +161,7 @@ static void edgering_find_order(BMEditMesh *em, BMEdge *lasteed, BMEdge *eed,
                return;
        }
        
-       l2 = BM_OtherFaceLoop(l->e, l->f, eed->v1);
+       l2 = BM_face_other_loop(l->f, l->e, eed->v1);
        rev = (l2 == l->prev);
        while (l2->v != lasteed->v1 && l2->v != lasteed->v2) {
                l2 = rev ? l2->prev : l2->next;
@@ -200,30 +200,30 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
        }
 
        if (!lcd->extend) {
-               EDBM_clear_flag_all(lcd->em, BM_SELECT);
+               EDBM_flag_disable_all(lcd->em, BM_ELEM_SELECT);
        }
 
        if (select) {
-               BMW_Init(&walker, em->bm, BMW_EDGERING,
+               BMW_init(&walker, em->bm, BMW_EDGERING,
                         BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
                         BMW_NIL_LAY);
 
-               eed = BMW_Begin(&walker, startedge);
-               for (; eed; eed=BMW_Step(&walker)) {
-                       BM_Select(em->bm, eed, TRUE);
+               eed = BMW_begin(&walker, startedge);
+               for (; eed; eed=BMW_step(&walker)) {
+                       BM_elem_select_set(em->bm, eed, TRUE);
                }
-               BMW_End(&walker);
+               BMW_end(&walker);
 
                return;
        }
 
-       BMW_Init(&walker, em->bm, BMW_EDGERING,
+       BMW_init(&walker, em->bm, BMW_EDGERING,
                 BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
                 BMW_NIL_LAY);
 
-       eed = startedge = BMW_Begin(&walker, startedge);
+       eed = startedge = BMW_begin(&walker, startedge);
        lastv1 = NULL;
-       for (lasteed=NULL; eed; eed=BMW_Step(&walker)) {
+       for (lasteed=NULL; eed; eed=BMW_step(&walker)) {
                if (lasteed) {
                        if (lastv1) {
                                v[1][0] = v[0][0];
@@ -255,7 +255,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
                lasteed = eed;
        }
        
-       if (lasteed != startedge && BM_Edge_Share_Faces(lasteed, startedge)) {
+       if (lasteed != startedge && BM_edge_share_face_count(lasteed, startedge)) {
                v[1][0] = v[0][0];
                v[1][1] = v[0][1];
 
@@ -280,7 +280,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
                }
        }
 
-       BMW_End(&walker);
+       BMW_end(&walker);
        lcd->edges = edges;
        lcd->totedge = tot;
 }
@@ -308,9 +308,9 @@ static void ringsel_finish(bContext *C, wmOperator *op)
                edgering_sel(lcd, cuts, 1);
                
                if (lcd->do_cut) {
-                       BM_esubdivideflag(lcd->ob, em->bm, BM_SELECT, 0.0f, 
-                                         0.0f, 0, cuts, SUBDIV_SELECT_LOOPCUT, 
-                                         SUBD_PATH, 0, 0, 0);
+                       BM_mesh_esubdivideflag(lcd->ob, em->bm, BM_ELEM_SELECT, 0.0f,
+                                              0.0f, 0, cuts, SUBDIV_SELECT_LOOPCUT,
+                                              SUBD_PATH, 0, FALSE, 0);
                        
                        /* force edge slide to edge select mode in in face select mode */
                        if (em->selectmode & SCE_SELECT_FACE) {
@@ -333,9 +333,9 @@ static void ringsel_finish(bContext *C, wmOperator *op)
                        
                        /* sets as active, useful for other tools */
                        if(em->selectmode & SCE_SELECT_VERTEX)
-                               EDBM_selectmode_flush(em);
+                               EDBM_store_selection(em, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */
                        if(em->selectmode & SCE_SELECT_EDGE)
-                               EDBM_selectmode_flush(em);
+                               EDBM_store_selection(em, lcd->eed);
                        
                        EDBM_selectmode_flush(lcd->em);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, lcd->ob->data);
@@ -373,7 +373,7 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
        lcd->ar= CTX_wm_region(C);
        lcd->draw_handle= ED_region_draw_cb_activate(lcd->ar->type, ringsel_draw, lcd, REGION_DRAW_POST_VIEW);
        lcd->ob = CTX_data_edit_object(C);
-       lcd->em= ((Mesh *)lcd->ob->data)->edit_btmesh;
+       lcd->em = BMEdit_FromObject(lcd->ob);
        lcd->extend = do_cut ? 0 : RNA_boolean_get(op->ptr, "extend");
        lcd->do_cut = do_cut;
        
@@ -395,56 +395,6 @@ static int ringcut_cancel (bContext *C, wmOperator *op)
        return OPERATOR_CANCELLED;
 }
 
-/* for bmesh this tool is in bmesh_select.c */
-#if 0
-
-static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
-{
-       tringselOpData *lcd;
-       EditEdge *edge;
-       int dist = 75;
-       
-       view3d_operator_needs_opengl(C);
-
-       if (!ringsel_init(C, op, 0))
-               return OPERATOR_CANCELLED;
-       
-       lcd = op->customdata;
-       
-       if (lcd->em->selectmode == SCE_SELECT_FACE) {
-               PointerRNA props_ptr;
-               int extend = RNA_boolean_get(op->ptr, "extend");
-
-               ringsel_exit(op);
-
-               WM_operator_properties_create(&props_ptr, "MESH_OT_loop_select");
-               RNA_boolean_set(&props_ptr, "extend", extend);
-               WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, &props_ptr);
-               WM_operator_properties_free(&props_ptr);
-
-               return OPERATOR_CANCELLED;
-       }
-
-       lcd->vc.mval[0] = evt->mval[0];
-       lcd->vc.mval[1] = evt->mval[1];
-       
-       edge = findnearestedge(&lcd->vc, &dist);
-       if(!edge) {
-               ringsel_exit(op);
-               return OPERATOR_CANCELLED;
-       }
-
-       lcd->eed = edge;
-       ringsel_find_edge(lcd, 1);
-
-       ringsel_finish(C, op);
-       ringsel_exit(op);
-
-       return OPERATOR_FINISHED;
-}
-
-#endif
-
 static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 {
        Object *obedit= CTX_data_edit_object(C);