svn merge -r39433:39493 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender-staging.git] / source / blender / editors / space_view3d / view3d_header.c
index 70b2a3d36282fc9ce51856c119eb694e867229b4..c85f7d3af8a3d413d6a7d019ce6b7bc2e7dc3118 100644 (file)
@@ -55,6 +55,7 @@
 #include "BKE_modifier.h"
 #include "BKE_paint.h"
 #include "BKE_screen.h"
+#include "BKE_tessmesh.h"
 
 #include "ED_mesh.h"
 #include "ED_util.h"
@@ -327,12 +328,12 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
        ScrArea *sa= CTX_wm_area(C);
        View3D *v3d= sa->spacedata.first;
        Object *obedit = CTX_data_edit_object(C);
-       EditMesh *em= NULL;
+       BMEditMesh *em= NULL;
        int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
        PointerRNA props_ptr;
        
        if(obedit && obedit->type==OB_MESH) {
-               em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+               em= ((Mesh *)obedit->data)->edit_btmesh;
        }
        /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
 
@@ -353,7 +354,7 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
                        if(shift==0 || em->selectmode==0)
                                em->selectmode= SCE_SELECT_VERTEX;
                        ts->selectmode= em->selectmode;
-                       EM_selectmode_set(em);
+                       EDBM_selectmode_set(em);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                        ED_undo_push(C, "Selectmode Set: Vertex");
                }
@@ -362,12 +363,12 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
                if(em) {
                        if(shift==0 || em->selectmode==0){
                                if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
-                                       if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
+                                       if(ctrl) EDBM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
                                }
                                em->selectmode = SCE_SELECT_EDGE;
                        }
                        ts->selectmode= em->selectmode;
-                       EM_selectmode_set(em);
+                       EDBM_selectmode_set(em);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                        ED_undo_push(C, "Selectmode Set: Edge");
                }
@@ -375,14 +376,13 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
        case B_SEL_FACE:
                if(em) {
                        if( shift==0 || em->selectmode==0){
-                               if( ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
-                                       if(ctrl)
-                                               EM_convertsel(em, (em->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
+                               if( ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
+                                       if(ctrl) EDBM_convertsel(em, (ts->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
                                }
                                em->selectmode = SCE_SELECT_FACE;
                        }
                        ts->selectmode= em->selectmode;
-                       EM_selectmode_set(em);
+                       EDBM_selectmode_set(em);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
                        ED_undo_push(C, "Selectmode Set: Face");
                }
@@ -415,9 +415,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
        default:
                break;
        }
-
-       if(obedit && obedit->type==OB_MESH)
-               BKE_mesh_end_editmesh(obedit->data, em);
 }
 
 /* Returns the icon associated with an object mode */
@@ -442,7 +439,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
        uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
 
        if(obedit && (obedit->type == OB_MESH)) {
-               EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+               BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
                uiLayout *row;
 
                row= uiLayoutRow(layout, 1);
@@ -450,8 +447,6 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
                uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
                uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
                uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
-
-               BKE_mesh_end_editmesh(obedit->data, em);
        }
 }
 
@@ -480,11 +475,17 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        uiBlockSetEmboss(block, UI_EMBOSS);
        
        /* mode */
-       if(ob)
+       if(ob) {
+               /*sanity point checkpoint, put here to avoid seeding
+                 this same code in 10 different other places.*/
+               if (!ob->mode)
+                       ob->mode = OB_MODE_OBJECT;
+
                v3d->modeselect = ob->mode;
-       else
+       } else {
                v3d->modeselect = OB_MODE_OBJECT;
-
+       }
+       
        uiBlockBeginAlign(block);
        uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
                          0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, "Mode");
@@ -542,4 +543,3 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        
        uiTemplateEditModeSelection(layout, C);
 }
-