svn merge -r39433:39493 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Wed, 24 Aug 2011 01:44:54 +0000 (01:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 24 Aug 2011 01:44:54 +0000 (01:44 +0000)
1  2 
intern/ghost/intern/GHOST_SystemSDL.cpp
source/blender/blenkernel/intern/displist.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/python/mathutils/mathutils_Vector.c

index 6f6679b8d8c02ff8339b00b8f0a3749e9d5fd927,f2cc45731fa0c5a7b2dbed0910bc9bbf71d07e8c..12669ed1a19c4900feb879d4de5b4b2dad2ed286
mode 100755,100644..100755
@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * $Id$
 + * $Id: GHOST_SystemSDL.cpp 38349 2011-07-13 00:49:22Z gsrb3d $
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -385,8 -385,26 +385,26 @@@ GHOST_SystemSDL::processEvent(SDL_Even
  
                        GHOST_TKey gkey= convertSDLKey(sdl_sub_evt.keysym.scancode);
                        /* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */
+                       /* printf("%d\n", sym); */
                        if(sym > 127) {
-                               sym= 0;
+                               switch(sym) {
+                                       case SDLK_KP_DIVIDE: sym= '/'; break;
+                                   case SDLK_KP_MULTIPLY: sym= '*'; break;
+                                   case SDLK_KP_MINUS: sym= '-'; break;
+                                   case SDLK_KP_PLUS: sym= '+'; break;
+                                   case SDLK_KP_1: sym= '1'; break;
+                                   case SDLK_KP_2: sym= '2'; break;
+                                   case SDLK_KP_3: sym= '3'; break;
+                                   case SDLK_KP_4: sym= '4'; break;
+                                   case SDLK_KP_5: sym= '5'; break;
+                                   case SDLK_KP_6: sym= '6'; break;
+                                   case SDLK_KP_7: sym= '7'; break;
+                                   case SDLK_KP_8: sym= '8'; break;
+                                   case SDLK_KP_9: sym= '9'; break;
+                                   case SDLK_KP_0: sym= '0'; break;
+                                   case SDLK_KP_PERIOD: sym= '.'; break;
+                                       default: sym= 0; break;
+                               }
                        }
                        else {
                                if(sdl_sub_evt.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) {
index 0f89533c8236f7cd7a95db66755b1ca1560f958e,c2ed64686434630805db7458968d047c192fa7eb..ec8a59d51f090d7b22d422fba153a1ded4abaf92
@@@ -438,8 -438,6 +438,8 @@@ void filldisplist(ListBase *dispbase, L
                totvert= 0;
                nextcol= 0;
                
 +              BLI_begin_edgefill();
 +              
                dl= dispbase->first;
                while(dl) {
        
@@@ -892,7 -890,7 +892,7 @@@ static void curve_calc_modifiers_post(S
  
                        if (dm) {
                                if (vertCos) {
 -                                      DerivedMesh *tdm = CDDM_copy(dm);
 +                                      DerivedMesh *tdm = CDDM_copy(dm, 0);
                                        dm->release(dm);
                                        dm = tdm;
  
  
        if (vertCos) {
                if (dm) {
 -                      DerivedMesh *tdm = CDDM_copy(dm);
 +                      DerivedMesh *tdm = CDDM_copy(dm, 0);
                        dm->release(dm);
                        dm = tdm;
  
@@@ -1371,6 -1369,11 +1371,11 @@@ void makeDispListCurveTypes(Scene *scen
        Curve *cu= ob->data;
        ListBase *dispbase;
  
+       /* The same check for duplis as in do_makeDispListCurveTypes.
+          Happens when curve used for constraint/bevel was converted to mesh.
+          check there is still needed for render displist and orco displists. */
+       if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
        freedisplist(&(ob->disp));
        dispbase= &(ob->disp);
        freedisplist(dispbase);
index ccd768d5c2aea92c5766ac662e53d8dc4b2fa4e9,f5c178267aa3cc36f9b14a990f0d3101b927a43b..06a88cd78665d36316bea91ceb175c7795b372dd
@@@ -48,7 -48,6 +48,7 @@@
  #include "DNA_world_types.h"
  #include "DNA_armature_types.h"
  
 +#include "BLI_utildefines.h"
  #include "BLI_blenlib.h"
  #include "BLI_math.h"
  #include "BLI_editVert.h"
@@@ -76,8 -75,6 +76,8 @@@
  #include "BKE_pointcache.h"
  #include "BKE_unit.h"
  
 +#include "BKE_tessmesh.h"
 +
  #include "smoke_API.h"
  
  #include "IMB_imbuf.h"
@@@ -229,7 -226,7 +229,7 @@@ static int check_material_alpha(Base *b
        if(G.f & G_PICKSEL)
                return 0;
                        
 -      if(me->edit_mesh)
 +      if(me->edit_btmesh)
                return 0;
        
        return (glsl || (base->object->dtx & OB_DRAWTRANSP));
@@@ -1637,18 -1634,16 +1637,18 @@@ static void drawlattice(Scene *scene, V
   * use the object matrix in the useual way */
  static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
  {
 -      struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
 -      EditVert *eve = EM_get_vert_for_index(index);
 +      struct { void (*func)(void *userData, BMVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } *data = userData;
 +      BMVert *eve = EDBM_get_vert_for_index(data->vc.em, index);
  
 -      if (eve->h==0) {
 +      if (!BM_TestHFlag(eve, BM_HIDDEN)) {
                short s[2]= {IS_CLIPPED, 0};
  
                if (data->clipVerts) {
                        view3d_project_short_clip(data->vc.ar, co, s, 1);
                } else {
 -                      view3d_project_short_noclip(data->vc.ar, co, s);
 +                      float co2[2];
 +                      mul_v3_m4v3(co2, data->vc.obedit->obmat, co);
 +                      project_short_noclip(data->vc.ar, co2, s);
                }
  
                if (s[0]!=IS_CLIPPED)
        }
  }
  
 -void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVert *eve, int x, int y, int index), void *userData, int clipVerts)
 +void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BMVert *eve, int x, int y, int index), void *userData, int clipVerts)
  {
 -      struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } data;
 -      DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
 +      struct { void (*func)(void *userData, BMVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
 +      DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
        
        data.vc= *vc;
        data.func = func;
        data.userData = userData;
        data.clipVerts = clipVerts;
  
 +      EDBM_init_index_arrays(vc->em, 1, 0, 0);
        if(clipVerts)
                ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
  
 -      EM_init_index_arrays(vc->em, 1, 0, 0);
        dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);
 -      EM_free_index_arrays();
 +      EDBM_free_index_arrays(vc->em);
  
        dm->release(dm);
  }
  
  static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0co, float *v1co)
  {
 -      struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
 -      EditEdge *eed = EM_get_edge_for_index(index);
 -      short s[2][2];
 +      struct { void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } *data = userData;
 +      BMEdge *eed = EDBM_get_edge_for_index(data->vc.em, index);
 +
 +      if (!BM_TestHFlag(eed, BM_HIDDEN)) {
 +              short s[2][2];
  
 -      if (eed->h==0) {
                if (data->clipVerts==1) {
                        view3d_project_short_clip(data->vc.ar, v0co, s[0], 1);
                        view3d_project_short_clip(data->vc.ar, v1co, s[1], 1);
                } else {
 -                      view3d_project_short_noclip(data->vc.ar, v0co, s[0]);
 -                      view3d_project_short_noclip(data->vc.ar, v1co, s[1]);
 +                      float v1_co[3], v2_co[3];
 +
 +                      mul_v3_m4v3(v1_co, data->vc.obedit->obmat, v0co);
 +                      mul_v3_m4v3(v2_co, data->vc.obedit->obmat, v1co);
 +
 +                      project_short_noclip(data->vc.ar, v1_co, s[0]);
 +                      project_short_noclip(data->vc.ar, v2_co, s[1]);
  
                        if (data->clipVerts==2) {
                                if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]<data->vc.ar->winx && s[0][1]<data->vc.ar->winy))
        }
  }
  
 -void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts)
 +void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts)
  {
 -      struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } data;
 -      DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
 +      struct { void (*func)(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
 +      DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
  
        data.vc= *vc;
        data.func = func;
        data.userData = userData;
        data.clipVerts = clipVerts;
  
 +      EDBM_init_index_arrays(vc->em, 0, 1, 0);
        if(clipVerts)
                ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
  
 -      EM_init_index_arrays(vc->em, 0, 1, 0);
        dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
 -      EM_free_index_arrays();
 +      EDBM_free_index_arrays(vc->em);
  
        dm->release(dm);
  }
  
  static void mesh_foreachScreenFace__mapFunc(void *userData, int index, float *cent, float *UNUSED(no))
  {
 -      struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; } *data = userData;
 -      EditFace *efa = EM_get_face_for_index(index);
 -      short s[2];
 +      struct { void (*func)(void *userData, BMFace *efa, int x, int y, int index); void *userData; ViewContext vc; float pmat[4][4], vmat[4][4]; } *data = userData;
 +      BMFace *efa = EDBM_get_face_for_index(data->vc.em, index);
 +
 +      if (efa && !BM_TestHFlag(efa, BM_HIDDEN)) {
 +              float cent2[3];
 +              short s[2];
  
 -      if (efa && efa->h==0 && efa->fgonf!=EM_FGON) {
 -              view3d_project_short_clip(data->vc.ar, cent, s, 1);
 +              mul_v3_m4v3(cent2, data->vc.obedit->obmat, cent);
 +              project_short(data->vc.ar, cent2, s);
  
 -              data->func(data->userData, efa, s[0], s[1], index);
 +              if (s[0] != IS_CLIPPED) {
 +                      data->func(data->userData, efa, s[0], s[1], index);
 +              }
        }
  }
  
 -void mesh_foreachScreenFace(ViewContext *vc, void (*func)(void *userData, EditFace *efa, int x, int y, int index), void *userData)
 +void mesh_foreachScreenFace(ViewContext *vc, void (*func)(void *userData, BMFace *efa, int x, int y, int index), void *userData)
  {
 -      struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; } data;
 -      DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
 +      struct { void (*func)(void *userData, BMFace *efa, int x, int y, int index); void *userData; ViewContext vc; float pmat[4][4], vmat[4][4]; } data;
 +      DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
  
        data.vc= *vc;
        data.func = func;
        data.userData = userData;
  
 +      EDBM_init_index_arrays(vc->em, 0, 0, 1);
        //if(clipVerts)
        ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
  
 -      EM_init_index_arrays(vc->em, 0, 0, 1);
        dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data);
 -      EM_free_index_arrays();
 +      EDBM_free_index_arrays(vc->em);
  
        dm->release(dm);
  }
@@@ -1826,53 -1810,46 +1826,53 @@@ void nurbs_foreachScreenVert(ViewContex
  
  static void draw_dm_face_normals__mapFunc(void *userData, int index, float *cent, float *no)
  {
 -      ToolSettings *ts= ((Scene *)userData)->toolsettings;
 -      EditFace *efa = EM_get_face_for_index(index);
 +      Scene *scene= ((void **)userData)[0];
 +      BMEditMesh *em = ((void **)userData)[1];
 +      BMFace *efa = EDBM_get_face_for_index(em, index);
 +      ToolSettings *ts= scene->toolsettings;
  
 -      if (efa->h==0 && efa->fgonf!=EM_FGON) {
 +      if (!BM_TestHFlag(efa, BM_HIDDEN)) {
                glVertex3fv(cent);
                glVertex3f(     cent[0] + no[0]*ts->normalsize,
                                        cent[1] + no[1]*ts->normalsize,
                                        cent[2] + no[2]*ts->normalsize);
        }
  }
 -static void draw_dm_face_normals(Scene *scene, DerivedMesh *dm) 
 +static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, DerivedMesh *dm) 
  {
 +      void *ptrs[2] = {scene, em};
 +
        glBegin(GL_LINES);
 -      dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, scene);
 +      dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, ptrs);
        glEnd();
  }
  
  static void draw_dm_face_centers__mapFunc(void *userData, int index, float *cent, float *UNUSED(no))
  {
 -      EditFace *efa = EM_get_face_for_index(index);
 -      int sel = *((int*) userData);
 -
 -      if (efa->h==0 && efa->fgonf!=EM_FGON && (efa->f&SELECT)==sel) {
 +      BMFace *efa = EDBM_get_face_for_index(((void **)userData)[0], index);
 +      int sel = *(((int **)userData)[1]);
 +      
 +      if (efa && !BM_TestHFlag(efa, BM_HIDDEN) && BM_TestHFlag(efa, BM_SELECT)==sel) {
                bglVertex3fv(cent);
        }
  }
 -static void draw_dm_face_centers(DerivedMesh *dm, int sel)
 +static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, int sel)
  {
 +      void *ptrs[2] = {em, &sel};
 +
        bglBegin(GL_POINTS);
 -      dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, &sel);
 +      dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, ptrs);
        bglEnd();
  }
  
  static void draw_dm_vert_normals__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
  {
 -      Scene *scene= (Scene *)userData;
 +      Scene *scene= ((void **)userData)[0];
        ToolSettings *ts= scene->toolsettings;
 -      EditVert *eve = EM_get_vert_for_index(index);
 +      BMEditMesh *em = ((void **)userData)[1];
 +      BMVert *eve = EDBM_get_vert_for_index(em, index);
  
 -      if (eve->h==0) {
 +      if (!BM_TestHFlag(eve, BM_HIDDEN)) {
                glVertex3fv(co);
  
                if (no_f) {
                }
        }
  }
 -static void draw_dm_vert_normals(Scene *scene, DerivedMesh *dm) 
 +static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, DerivedMesh *dm) 
  {
 +      void *ptrs[2] = {scene, em};
 +
        glBegin(GL_LINES);
 -      dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, scene);
 +      dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, ptrs);
        glEnd();
  }
  
 -      /* Draw verts with color set based on selection */
 +/* Draw verts with color set based on selection */
  static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
  {
 -      struct { int sel; EditVert *eve_act; } * data = userData;
 -      EditVert *eve = EM_get_vert_for_index(index);
 +      struct { BMEditMesh *em; int sel; BMVert *eve_act; } *data = userData;
 +      BMVert *eve = EDBM_get_vert_for_index(data->em, index);
  
 -      if (eve->h==0 && (eve->f&SELECT)==data->sel) {
 +      if (!BM_TestHFlag(eve, BM_HIDDEN) && BM_TestHFlag(eve, BM_SELECT)==data->sel) {
                /* draw active larger - need to stop/start point drawing for this :/ */
                if (eve==data->eve_act) {
                        float size = UI_GetThemeValuef(TH_VERTEX_SIZE);
        }
  }
  
 -static void draw_dm_verts(DerivedMesh *dm, int sel, EditVert *eve_act)
 +static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, int sel, BMVert *eve_act)
  {
 -      struct { int sel; EditVert *eve_act; } data;
 +      struct { BMEditMesh *em; int sel; BMVert *eve_act; } data;
        data.sel = sel;
        data.eve_act = eve_act;
 +      data.em = em;
 +      
 +      bglBegin(GL_POINTS);
 +      dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
 +      bglEnd();
  
        bglBegin(GL_POINTS);
        dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
        /* Draw edges with color set based on selection */
  static int draw_dm_edges_sel__setDrawOptions(void *userData, int index)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      BMEdge *eed;
        //unsigned char **cols = userData, *col;
 -      struct { unsigned char *baseCol, *selCol, *actCol; EditEdge *eed_act; } * data = userData;
 +      struct { BMEditMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } * data = userData;
        unsigned char *col;
  
 -      if (eed->h==0) {
 +      eed = EDBM_get_edge_for_index(data->em, index);
 +
 +      if (!BM_TestHFlag(eed, BM_HIDDEN)) {
                if (eed==data->eed_act) {
                        glColor4ubv(data->actCol);
                } else {
 -                      if (eed->f&SELECT) {
 +                      if (BM_TestHFlag(eed, BM_SELECT)) {
                                col = data->selCol;
                        } else {
                                col = data->baseCol;
                return 0;
        }
  }
 -static void draw_dm_edges_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditEdge *eed_act) 
 +static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, 
 +                            unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act) 
  {
 -      struct { unsigned char *baseCol, *selCol, *actCol; EditEdge *eed_act; } data;
 +      struct { BMEditMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } data;
        
        data.baseCol = baseCol;
        data.selCol = selCol;
        data.actCol = actCol;
 +      data.em = em;
        data.eed_act = eed_act;
        dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
  }
  
        /* Draw edges */
 -static int draw_dm_edges__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_edges__setDrawOptions(void *userData, int index)
  {
 -      return EM_get_edge_for_index(index)->h==0;
 +      return !BM_TestHFlag(EDBM_get_edge_for_index(userData, index), BM_HIDDEN);
  }
 -static void draw_dm_edges(DerivedMesh *dm) 
 +static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm) 
  {
 -      dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, NULL);
 +      dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em);
  }
  
        /* Draw edges with color interpolated based on selection */
 -static int draw_dm_edges_sel_interp__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index)
  {
 -      return EM_get_edge_for_index(index)->h==0;
 +      return !BM_TestHFlag(EDBM_get_edge_for_index(((void**)userData)[0], index), BM_HIDDEN);
  }
  static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      BMEdge *eed = EDBM_get_edge_for_index(((void**)userData)[0], index);
        unsigned char **cols = userData;
 -      unsigned char *col0 = cols[(eed->v1->f&SELECT)?1:0];
 -      unsigned char *col1 = cols[(eed->v2->f&SELECT)?1:0];
 +      unsigned char *col0 = cols[(BM_TestHFlag(eed->v1, BM_SELECT))?2:1];
 +      unsigned char *col1 = cols[(BM_TestHFlag(eed->v2, BM_SELECT))?2:1];
  
        glColor4ub(     col0[0] + (col1[0]-col0[0])*t,
                                col0[1] + (col1[1]-col0[1])*t,
                                col0[3] + (col1[3]-col0[3])*t);
  }
  
 -static void draw_dm_edges_sel_interp(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
 +static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
  {
 -      unsigned char *cols[2];
 -      cols[0]= baseCol;
 -      cols[1]= selCol;
 +      void *cols[3] = {em, baseCol, selCol};
 +
        dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
  }
  
        /* Draw only seam edges */
 -static int draw_dm_edges_seams__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_edges_seams__setDrawOptions(void *userData, int index)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      BMEdge *eed = EDBM_get_edge_for_index(userData, index);
  
 -      return (eed->h==0 && eed->seam);
 +      return !BM_TestHFlag(eed, BM_HIDDEN) && BM_TestHFlag(eed, BM_SEAM);
  }
 -static void draw_dm_edges_seams(DerivedMesh *dm)
 +
 +static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm)
  {
 -      dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, NULL);
 +      dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em);
  }
  
        /* Draw only sharp edges */
 -static int draw_dm_edges_sharp__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_edges_sharp__setDrawOptions(void *userData, int index)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      BMEdge *eed = EDBM_get_edge_for_index(userData, index);
  
 -      return (eed->h==0 && eed->sharp);
 +      return !BM_TestHFlag(eed, BM_HIDDEN) && BM_TestHFlag(eed, BM_SHARP);
  }
 -static void draw_dm_edges_sharp(DerivedMesh *dm)
 +static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm)
  {
 -      dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, NULL);
 +      dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
  }
  
  
         * return 2 for the active face so it renders with stipple enabled */
  static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r))
  {
 -      struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
 -      EditFace *efa = EM_get_face_for_index(index);
 +      struct { unsigned char *cols[3]; BMEditMesh *em; BMFace *efa_act; Mesh *me;} *data = userData;
 +      BMFace *efa = EDBM_get_face_for_index(data->em, index);
        unsigned char *col;
        
 -      if (efa->h==0) {
 +      if (!efa)
 +              return 0;
 +      
 +      if (!BM_TestHFlag(efa, BM_HIDDEN)) {
                if (efa == data->efa_act) {
                        glColor4ubv(data->cols[2]);
 +
                        return 2; /* stipple */
                } else {
 -                      col = data->cols[(efa->f&SELECT)?1:0];
 +                      col = data->cols[BM_TestHFlag(efa, BM_SELECT)?1:0];
                        if (col[3]==0) return 0;
 +
                        glColor4ubv(col);
 +
                        return 1;
                }
        }
  }
  
  /* also draws the active face */
 -static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) 
 +static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, 
 +                            unsigned char *selCol, unsigned char *actCol, BMFace *efa_act, Mesh *me) 
  {
 -      struct { unsigned char *cols[3]; EditFace *efa_act; } data;
 +      struct { unsigned char *cols[3]; BMEditMesh *em; BMFace *efa_act; Mesh *me;} data;
 +
        data.cols[0] = baseCol;
 +      data.em = em;
        data.cols[1] = selCol;
        data.cols[2] = actCol;
        data.efa_act = efa_act;
 +      data.me = me;
  
        dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material);
  }
  
 -static int draw_dm_creases__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_creases__setDrawOptions(void *userData, int index)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 -
 -      if (eed->h==0 && eed->crease != 0.0f) {
 -              UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, eed->crease);
 +      BMEditMesh *em = userData;
 +      BMEdge *eed = EDBM_get_edge_for_index(userData, index);
 +      float *crease = eed ? bm_get_cd_float(&em->bm->edata, eed->head.data, CD_CREASE) : NULL;
 +      
 +      if (!crease)
 +              return 0;
 +      
 +      if (!BM_TestHFlag(eed, BM_HIDDEN) && *crease!=0.0f) {
 +              UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease);
                return 1;
        } else {
                return 0;
        }
  }
 -static void draw_dm_creases(DerivedMesh *dm)
 +static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
  {
        glLineWidth(3.0);
 -      dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, NULL);
 +      dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, em);
        glLineWidth(1.0);
  }
  
 -static int draw_dm_bweights__setDrawOptions(void *UNUSED(userData), int index)
 +static int draw_dm_bweights__setDrawOptions(void *userData, int index)
  {
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      BMEditMesh *em = userData;
 +      BMEdge *eed = EDBM_get_edge_for_index(userData, index);
 +      float *bweight = bm_get_cd_float(&em->bm->edata, eed->head.data, CD_BWEIGHT);
  
 -      if (eed->h==0 && eed->bweight != 0.0f) {
 -              UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, eed->bweight);
 +      if (!bweight)
 +              return 0;
 +      
 +      if (!BM_TestHFlag(eed, BM_HIDDEN) && *bweight!=0.0f) {
 +              UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight);
                return 1;
        } else {
                return 0;
        }
  }
 -static void draw_dm_bweights__mapFunc(void *UNUSED(userData), int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 +static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
  {
 -      EditVert *eve = EM_get_vert_for_index(index);
 -
 -      if (eve->h==0 && eve->bweight != 0.0f) {
 -              UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, eve->bweight);
 +      BMEditMesh *em = userData;
 +      BMVert *eve = EDBM_get_vert_for_index(userData, index);
 +      float *bweight = bm_get_cd_float(&em->bm->vdata, eve->head.data, CD_BWEIGHT);
 +      
 +      if (!bweight)
 +              return;
 +      
 +      if (!BM_TestHFlag(eve, BM_HIDDEN) && *bweight!=0.0f) {
 +              UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight);
                bglVertex3fv(co);
        }
  }
 -static void draw_dm_bweights(Scene *scene, DerivedMesh *dm)
 +static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
  {
        ToolSettings *ts= scene->toolsettings;
  
        if (ts->selectmode & SCE_SELECT_VERTEX) {
                glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2);
                bglBegin(GL_POINTS);
 -              dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, NULL);
 +              dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, em);
                bglEnd();
        }
        else {
                glLineWidth(3.0);
 -              dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, NULL);
 +              dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, em);
                glLineWidth(1.0);
        }
  }
  
  /* EditMesh drawing routines*/
  
 -static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, DerivedMesh *cageDM, EditVert *eve_act)
 +static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, 
 +                              BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act)
  {
        ToolSettings *ts= scene->toolsettings;
        int sel;
                        if(ts->selectmode & SCE_SELECT_VERTEX) {
                                glPointSize(size);
                                glColor4ubv(col);
 -                              draw_dm_verts(cageDM, sel, eve_act);
 +                              draw_dm_verts(em, cageDM, sel, eve_act);
                        }
                        
                        if(check_ob_drawface_dot(scene, v3d, obedit->dt)) {
                                glPointSize(fsize);
                                glColor4ubv(fcol);
 -                              draw_dm_face_centers(cageDM, sel);
 +                              draw_dm_face_centers(em, cageDM, sel);
                        }
                        
                        if (pass==0) {
        glPointSize(1.0);
  }
  
 -static void draw_em_fancy_edges(Scene *scene, View3D *v3d, Mesh *me, DerivedMesh *cageDM, short sel_only, EditEdge *eed_act)
 +static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, 
 +                              Mesh *me, DerivedMesh *cageDM, short sel_only, 
 +                              BMEdge *eed_act)
  {
        ToolSettings *ts= scene->toolsettings;
        int pass;
                }
  
                if(ts->selectmode == SCE_SELECT_FACE) {
 -                      draw_dm_edges_sel(cageDM, wireCol, selCol, actCol, eed_act);
 +                      draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
                }       
                else if( (me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE) ) {        
                        if(cageDM->drawMappedEdgesInterp && (ts->selectmode & SCE_SELECT_VERTEX)) {
                                glShadeModel(GL_SMOOTH);
 -                              draw_dm_edges_sel_interp(cageDM, wireCol, selCol);
 +                              draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol);
                                glShadeModel(GL_FLAT);
                        } else {
 -                              draw_dm_edges_sel(cageDM, wireCol, selCol, actCol, eed_act);
 +                              draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
                        }
                }
                else {
                        if (!sel_only) {
                                glColor4ubv(wireCol);
 -                              draw_dm_edges(cageDM);
 +                              draw_dm_edges(em, cageDM);
                        }
                }
  
        }
  }     
  
 -static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, EditMesh *em, UnitSettings *unit)
 +static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, 
 +                                Object *ob, BMEditMesh *em, UnitSettings *unit)
  {
        Mesh *me= ob->data;
 -      EditEdge *eed;
 -      EditFace *efa;
 -      float v1[3], v2[3], v3[3], v4[3], vmid[3];
 -      float fvec[3];
 +      float v1[3], v2[3], v3[3], vmid[3], fvec[3];
        char val[32]; /* Stores the measurement display text here */
        const char *conv_float; /* Use a float conversion matching the grid size */
        unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */
        const int do_global= v3d->flag & V3D_GLOBAL_STATS;
        const int do_moving= G.moving;
  
 +      BMIter iter;
 +      int i;
 +
        /* make the precision of the pronted value proportionate to the gridsize */
  
        if (grid < 0.01f)               conv_float= "%.6g";
        if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f);
        
        if(me->drawflag & ME_DRAWEXTRA_EDGELEN) {
 +              BMEdge *eed;
 +
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
  
 -              for(eed= em->edges.first; eed; eed= eed->next) {
 -                      /* draw non fgon edges, or selected edges, or edges next to selected verts while draging */
 -                      if((eed->h != EM_FGON) && ((eed->f & SELECT) || (do_moving && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT)) ))) {
 +              eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
 +              for(; eed; eed=BMIter_Step(&iter)) {
 +                      /* draw selected edges, or edges next to selected verts while draging */
 +                      if(BM_TestHFlag(eed, BM_SELECT) ||
 +                              (do_moving && (BM_TestHFlag(eed->v1, BM_SELECT) || BM_TestHFlag(eed->v2, BM_SELECT) ))) {
 +
                                copy_v3_v3(v1, eed->v1->co);
                                copy_v3_v3(v2, eed->v2->co);
  
        }
  
        if(me->drawflag & ME_DRAWEXTRA_FACEAREA) {
 -// XXX                extern int faceselectedOR(EditFace *efa, int flag);             // editmesh.h shouldn't be in this file... ok for now?
 +              /* would be nice to use BM_face_area, but that is for 2d faces
 +              so instead add up tessalation triangle areas */
 +              BMFace *f;
 +              int n;
 +
 +#define DRAW_EM_MEASURE_STATS_FACEAREA(void)\
 +              if (BM_TestHFlag(f, BM_SELECT)) {\
 +                      mul_v3_fl(vmid, 1.0/n);\
 +                      if(unit->system)\
 +                              bUnit_AsString(val, sizeof(val), area*unit->scale_length,\
 +                                      3, unit->system, B_UNIT_LENGTH, do_split, FALSE);\
 +                      else\
 +                              sprintf(val, conv_float, area);\
 +                      view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col);\
 +              }
 +
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
                
 -              for(efa= em->faces.first; efa; efa= efa->next) {
 -                      if((efa->f & SELECT)) { // XXX || (do_moving && faceselectedOR(efa, SELECT)) ) {
 -                              copy_v3_v3(v1, efa->v1->co);
 -                              copy_v3_v3(v2, efa->v2->co);
 -                              copy_v3_v3(v3, efa->v3->co);
 -                              if (efa->v4) {
 -                                      copy_v3_v3(v4, efa->v4->co);
 -                              }
 -                              if(do_global) {
 -                                      mul_mat3_m4_v3(ob->obmat, v1);
 -                                      mul_mat3_m4_v3(ob->obmat, v2);
 -                                      mul_mat3_m4_v3(ob->obmat, v3);
 -                                      if (efa->v4) mul_mat3_m4_v3(ob->obmat, v4);
 -                              }
 -                              
 -                              if (efa->v4)
 -                                      area=  area_quad_v3(v1, v2, v3, v4);
 -                              else
 -                                      area = area_tri_v3(v1, v2, v3);
 -
 -                              if(unit->system)
 -                                      bUnit_AsString(val, sizeof(val), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA
 -                              else
 -                                      sprintf(val, conv_float, area);
 -
 -                              view3d_cached_text_draw_add(efa->cent, val, 0, V3D_CACHE_TEXT_ASCII, col);
 +              f = NULL;
 +              area = 0.0;
 +              zero_v3(vmid);
 +              n = 0;
 +              for(i = 0; i < em->tottri; i++) {
 +                      BMLoop **l = em->looptris[i];
 +                      if(f && l[0]->f != f) {
 +                              DRAW_EM_MEASURE_STATS_FACEAREA();
 +                              zero_v3(vmid);
 +                              area = 0.0;
 +                              n = 0;
                        }
 -              }
 -      }
  
 -      if(me->drawflag & ME_DRAWEXTRA_FACEANG) {
 -              EditEdge *e1, *e2, *e3, *e4;
 -              UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
 -              for(efa= em->faces.first; efa; efa= efa->next) {
 -                      copy_v3_v3(v1, efa->v1->co);
 -                      copy_v3_v3(v2, efa->v2->co);
 -                      copy_v3_v3(v3, efa->v3->co);
 -                      if(efa->v4) {
 -                              copy_v3_v3(v4, efa->v4->co); 
 -                      }
 -                      else {
 -                              copy_v3_v3(v4, v3);
 -                      }
 +                      f = l[0]->f;
 +                      copy_v3_v3(v1, l[0]->v->co);
 +                      copy_v3_v3(v2, l[1]->v->co);
 +                      copy_v3_v3(v3, l[2]->v->co);
                        if(do_global) {
                                mul_mat3_m4_v3(ob->obmat, v1);
                                mul_mat3_m4_v3(ob->obmat, v2);
                                mul_mat3_m4_v3(ob->obmat, v3);
 -                              mul_mat3_m4_v3(ob->obmat, v4); /* intentionally executed even for tri's */
 -                      }
 -                      
 -                      e1= efa->e1;
 -                      e2= efa->e2;
 -                      e3= efa->e3;
 -                      if(efa->e4) e4= efa->e4; else e4= e3;
 -                      
 -                      /* Calculate the angles */
 -                              
 -                      if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) {
 -                              /* Vec 1 */
 -                              sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v4, v1, v2)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
 -                      }
 -                      if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) {
 -                              /* Vec 2 */
 -                              sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
                        }
 -                      if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) {
 -                              /* Vec 3 */
 -                              if(efa->v4) 
 -                                      sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v4)));
 -                              else
 -                                      sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v1)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
 -                      }
 -                              /* Vec 4 */
 -                      if(efa->v4) {
 -                              if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) {
 -                                      sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v3, v4, v1)));
 -                                      interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f);
 +                      area += area_tri_v3(v1, v2, v3);
 +                      add_v3_v3(vmid, v1);
 +                      add_v3_v3(vmid, v2);
 +                      add_v3_v3(vmid, v3);
 +                      n += 3;
 +              }
 +
 +              if(f){
 +                      DRAW_EM_MEASURE_STATS_FACEAREA();
 +              }
 +#undef DRAW_EM_MEASURE_STATS_FACEAREA
 +      }
 +
 +      if(me->drawflag & ME_DRAWEXTRA_FACEANG) {
 +              BMFace *efa;
 +
 +              UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
 +
 +
 +              for(efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL);
 +                  efa; efa=BMIter_Step(&iter)) {
 +                      BMIter liter;
 +                      BMLoop *loop;
 +
 +                      BM_Compute_Face_Center(em->bm, efa, vmid);
 +
 +                      for(loop = BMIter_New(&liter, em->bm, BM_LOOPS_OF_FACE, efa);
 +                          loop; loop = BMIter_Step(&liter)) {
 +
 +                              float v1[3], v2[3], v3[3];
 +
 +                              copy_v3_v3(v1, loop->prev->v->co);
 +                              copy_v3_v3(v2, loop->v->co);
 +                              copy_v3_v3(v3, loop->next->v->co);
 +
 +                              if(do_global){
 +                                      mul_mat3_m4_v3(ob->obmat, v1);
 +                                      mul_mat3_m4_v3(ob->obmat, v2);
 +                                      mul_mat3_m4_v3(ob->obmat, v3);
 +                              }
 +
 +                              if(BM_TestHFlag(efa, BM_SELECT) ||
 +                                      (do_moving && BM_TestHFlag(loop->v, BM_SELECT))){
 +                                      sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
 +                                      interp_v3_v3v3(fvec, vmid, v2, 0.8f);
                                        view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
                                }
                        }
                }
        }
 -      
 +
        if(v3d->zbuf) {
                glEnable(GL_DEPTH_TEST);
                bglPolygonOffset(rv3d->dist, 0.0f);
        }
  }
  
 -static int draw_em_fancy__setFaceOpts(void *UNUSED(userData), int index, int *UNUSED(drawSmooth_r))
 +static int draw_em_fancy__setFaceOpts(void *userData, int index, int *UNUSED(drawSmooth_r))
  {
 -      EditFace *efa = EM_get_face_for_index(index);
 +      BMFace *efa = EDBM_get_face_for_index(userData, index);
  
 -      if (efa->h==0) {
 +      if (efa && !BM_TestHFlag(efa, BM_HIDDEN)) {
                GPU_enable_material(efa->mat_nr+1, NULL);
                return 1;
        }
                return 0;
  }
  
 -static int draw_em_fancy__setGLSLFaceOpts(void *UNUSED(userData), int index)
 +static int draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
  {
 -      EditFace *efa = EM_get_face_for_index(index);
 +      BMFace *efa = EDBM_get_face_for_index(userData, index);
  
 -      return (efa->h==0);
 +      return !BM_TestHFlag(efa, BM_HIDDEN);
  }
  
 -static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, EditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
 +static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob,
 +                        BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
 +
  {
        Mesh *me = ob->data;
 -      EditFace *efa_act = EM_get_actFace(em, 0); /* annoying but active faces is stored differently */
 -      EditEdge *eed_act = NULL;
 -      EditVert *eve_act = NULL;
 +      BMFace *efa_act = EDBM_get_actFace(em, 0); /* annoying but active faces is stored differently */
 +      BMEdge *eed_act = NULL;
 +      BMVert *eve_act = NULL;
        
 -      if (em->selected.last) {
 -              EditSelection *ese = em->selected.last;
 +      if (em->bm->selected.last) {
 +              BMEditSelection *ese = em->bm->selected.last;
                /* face is handeled above */
                /*if (ese->type == EDITFACE ) {
                        efa_act = (EditFace *)ese->data;
                } else */ if ( ese->type == EDITEDGE ) {
 -                      eed_act = (EditEdge *)ese->data;
 +                      eed_act = (BMEdge *)ese->data;
                } else if ( ese->type == EDITVERT ) {
 -                      eve_act = (EditVert *)ese->data;
 +                      eve_act = (BMVert *)ese->data;
                }
        }
        
 -      EM_init_index_arrays(em, 1, 1, 1);
 +      EDBM_init_index_arrays(em, 1, 1, 1);
  
        if(dt>OB_WIRE) {
                if(CHECK_OB_DRAWTEXTURE(v3d, dt)) {
                                glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
  
                                finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
 -                                      draw_em_fancy__setGLSLFaceOpts, NULL);
 +                                      draw_em_fancy__setGLSLFaceOpts, em);
                                GPU_disable_material();
  
                                glFrontFace(GL_CCW);
  
                        glEnable(GL_LIGHTING);
                        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 -
 -                      finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material);
 +                      finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, me->edit_btmesh, 0, GPU_enable_material);
  
                        glFrontFace(GL_CCW);
                        glDisable(GL_LIGHTING);
                if CHECK_OB_DRAWTEXTURE(v3d, dt)
                        col1[3] = 0;
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act, me);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                glEnable(GL_BLEND);
                glDepthMask(0);         // disable write in zbuffer, needed for nice transp
                
 -              draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
 +              draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act, me);
  
                glDisable(GL_BLEND);
                glDepthMask(1);         // restore write in zbuffer
                /* we are drawing textures and 'ME_DRAWEDGES' is disabled, dont draw any edges */
                
                /* only draw selected edges otherwise there is no way of telling if a face is selected */
 -              draw_em_fancy_edges(scene, v3d, me, cageDM, 1, eed_act);
 +              draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act);
                
        } else {
                if(me->drawflag & ME_DRAWSEAMS) {
                        UI_ThemeColor(TH_EDGE_SEAM);
                        glLineWidth(2);
        
 -                      draw_dm_edges_seams(cageDM);
 +                      draw_dm_edges_seams(em, cageDM);
        
                        glColor3ub(0,0,0);
                        glLineWidth(1);
                        UI_ThemeColor(TH_EDGE_SHARP);
                        glLineWidth(2);
        
 -                      draw_dm_edges_sharp(cageDM);
 +                      draw_dm_edges_sharp(em, cageDM);
        
                        glColor3ub(0,0,0);
                        glLineWidth(1);
                }
        
 -              if(me->drawflag & ME_DRAWCREASES) {
 -                      draw_dm_creases(cageDM);
 +              if(me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) {
 +                      draw_dm_creases(em, cageDM);
                }
                if(me->drawflag & ME_DRAWBWEIGHTS) {
 -                      draw_dm_bweights(scene, cageDM);
 +                      draw_dm_bweights(em, scene, cageDM);
                }
 -      
 -              draw_em_fancy_edges(scene, v3d, me, cageDM, 0, eed_act);
 +
 +              draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
        }
        if(em) {
  // XXX                retopo_matrix_update(v3d);
  
 -              draw_em_fancy_verts(scene, v3d, ob, cageDM, eve_act);
 +              draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act);
  
                if(me->drawflag & ME_DRAWNORMALS) {
                        UI_ThemeColor(TH_NORMAL);
 -                      draw_dm_face_normals(scene, cageDM);
 +                      draw_dm_face_normals(em, scene, cageDM);
                }
                if(me->drawflag & ME_DRAW_VNORMALS) {
                        UI_ThemeColor(TH_VNORMAL);
 -                      draw_dm_vert_normals(scene, cageDM);
 +                      draw_dm_vert_normals(em, scene, cageDM);
                }
  
                if(me->drawflag & (ME_DRAWEXTRA_EDGELEN|ME_DRAWEXTRA_FACEAREA|ME_DRAWEXTRA_FACEANG) && !((v3d->flag2 & V3D_RENDER_OVERRIDE)))
                GPU_disable_material();
        }
  
 -      EM_free_index_arrays();
 +      EDBM_free_index_arrays(em);
  }
  
  /* Mesh drawing routines */
@@@ -2676,7 -2608,7 +2676,7 @@@ static void draw_mesh_fancy(Scene *scen
        
        /* totvert = dm->getNumVerts(dm); */ /*UNUSED*/
        totedge = dm->getNumEdges(dm);
 -      totface = dm->getNumFaces(dm);
 +      totface = dm->getNumTessFaces(dm);
        
        /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
        if(dt!=OB_SHADED)
@@@ -2898,7 -2830,7 +2898,7 @@@ static int draw_mesh_object(Scene *scen
        Object *ob= base->object;
        Object *obedit= scene->obedit;
        Mesh *me= ob->data;
 -      EditMesh *em= me->edit_mesh;
 +      BMEditMesh *em= me->edit_btmesh;
        int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha;
        
        if(obedit && ob!=obedit && ob->data==obedit->data) {
                DerivedMesh *finalDM, *cageDM;
                
                if (obedit!=ob)
 -                      finalDM = cageDM = editmesh_get_derived_base(ob, em);
 +                      finalDM = cageDM = editbmesh_get_derived_base(ob, em);
                else
 -                      cageDM = editmesh_get_derived_cage_and_final(scene, ob, em, &finalDM,
 +                      cageDM = editbmesh_get_derived_cage_and_final(scene, ob, em, &finalDM,
                                                                                        scene->customdata_mask);
  
                if(dt>OB_WIRE) {
@@@ -5545,7 -5477,7 +5545,7 @@@ static void drawObjectSelect(Scene *sce
                }
        }
        else if(ob->type==OB_ARMATURE) {
-               if(!(ob->mode & OB_MODE_POSE))
+               if(!(ob->mode & OB_MODE_POSE && base == scene->basact))
                        draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, TRUE);
        }
  
@@@ -6441,51 -6373,44 +6441,51 @@@ void draw_object(Scene *scene, ARegion 
  
  static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
  {
 -      int offset = (intptr_t) userData;
 -      EditVert *eve = EM_get_vert_for_index(index);
 +      void **ptrs = userData;
 +      int offset = (intptr_t) ptrs[0];
 +      BMVert *eve = EDBM_get_vert_for_index(ptrs[1], index);
  
 -      if (eve->h==0) {
 +      if (!BM_TestHFlag(eve, BM_HIDDEN)) {
                WM_set_framebuffer_index_color(offset+index);
                bglVertex3fv(co);
        }
  }
 -static void bbs_mesh_verts(DerivedMesh *dm, int offset)
 +static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
  {
 +      void *ptrs[2] = {(void*)(intptr_t) offset, em};
 +
        glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) );
        bglBegin(GL_POINTS);
 -      dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, (void*)(intptr_t) offset);
 +      dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, ptrs);
        bglEnd();
        glPointSize(1.0);
  }             
  
  static int bbs_mesh_wire__setDrawOptions(void *userData, int index)
  {
 -      int offset = (intptr_t) userData;
 -      EditEdge *eed = EM_get_edge_for_index(index);
 +      void **ptrs = userData;
 +      int offset = (intptr_t) ptrs[0];
 +      BMEdge *eed = EDBM_get_edge_for_index(ptrs[1], index);
  
 -      if (eed->h==0) {
 +      if (!BM_TestHFlag(eed, BM_HIDDEN)) {
                WM_set_framebuffer_index_color(offset+index);
                return 1;
        } else {
                return 0;
        }
  }
 -static void bbs_mesh_wire(DerivedMesh *dm, int offset)
 +static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
  {
 -      dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, (void*)(intptr_t) offset);
 +      void *ptrs[2] = {(void*)(intptr_t) offset, em};
 +      dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs);
  }             
  
  static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r))
  {
 -      if (EM_get_face_for_index(index)->h==0) {
 -              if (userData) {
 +      BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index);
 +      
 +      if (efa && !BM_TestHFlag(efa, BM_HIDDEN)) {
 +              if (((void**)userData)[1]) {
                        WM_set_framebuffer_index_color(index+1);
                }
                return 1;
        }
  }
  
 -static void bbs_mesh_solid__drawCenter(void *UNUSED(userData), int index, float *cent, float *UNUSED(no))
 +static void bbs_mesh_solid__drawCenter(void *userData, int index, float *cent, float *UNUSED(no))
  {
 -      EditFace *efa = EM_get_face_for_index(index);
 +      BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index);
  
 -      if (efa->h==0 && efa->fgonf!=EM_FGON) {
 +      if (!BM_TestHFlag(efa, BM_HIDDEN)) {
                WM_set_framebuffer_index_color(index+1);
  
                bglVertex3fv(cent);
  }
  
  /* two options, facecolors or black */
 -static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol)
 +static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
 +                            Object *ob, DerivedMesh *dm, int facecol)
  {
 +      void *ptrs[2] = {em, NULL}; //second one being null means to draw black
        cpack(0);
  
        if (facecol) {
 -              dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material);
 +              ptrs[1] = (void*)(intptr_t) 1;
 +              dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, ptrs, 0, GPU_enable_material);
  
                if(check_ob_drawface_dot(scene, v3d, ob->dt)) {
                        glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
                
                        bglBegin(GL_POINTS);
 -                      dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, NULL);
 +                      dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, ptrs);
                        bglEnd();
                }
  
        } else {
 -              dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material);
 +              dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, ptrs, 0, GPU_enable_material);
        }
  }
  
@@@ -6574,36 -6496,36 +6574,36 @@@ void draw_object_backbufsel(Scene *scen
        {
                if(ob->mode & OB_MODE_EDIT) {
                        Mesh *me= ob->data;
 -                      EditMesh *em= me->edit_mesh;
 +                      BMEditMesh *em= me->edit_btmesh;
  
 -                      DerivedMesh *dm = editmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
 +                      DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
  
 -                      EM_init_index_arrays(em, 1, 1, 1);
 +                      EDBM_init_index_arrays(em, 1, 1, 1);
  
 -                      bbs_mesh_solid_EM(scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE);
 +                      bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE);
                        if(ts->selectmode & SCE_SELECT_FACE)
 -                              em_solidoffs = 1+em->totface;
 +                              bm_solidoffs = 1+em->bm->totface;
                        else
 -                              em_solidoffs= 1;
 +                              bm_solidoffs= 1;
                        
                        bglPolygonOffset(rv3d->dist, 1.0);
                        
                        // we draw edges always, for loop (select) tools
 -                      bbs_mesh_wire(dm, em_solidoffs);
 -                      em_wireoffs= em_solidoffs + em->totedge;
 +                      bbs_mesh_wire(em, dm, bm_solidoffs);
 +                      bm_wireoffs= bm_solidoffs + em->bm->totedge;
                        
                        // we draw verts if vert select mode or if in transform (for snap).
                        if(ts->selectmode & SCE_SELECT_VERTEX || G.moving & G_TRANSFORM_EDIT) {
 -                              bbs_mesh_verts(dm, em_wireoffs);
 -                              em_vertoffs= em_wireoffs + em->totvert;
 +                              bbs_mesh_verts(em, dm, bm_wireoffs);
 +                              bm_vertoffs= bm_wireoffs + em->bm->totvert;
                        }
 -                      else em_vertoffs= em_wireoffs;
 +                      else bm_vertoffs= bm_wireoffs;
                        
                        bglPolygonOffset(rv3d->dist, 0.0);
  
                        dm->release(dm);
  
 -                      EM_free_index_arrays();
 +                      EDBM_free_index_arrays(em);
                }
                else bbs_mesh_solid(scene, ob);
        }
@@@ -6629,7 -6551,7 +6629,7 @@@ static void draw_object_mesh_instance(S
        int glsl;
        
        if(ob->mode & OB_MODE_EDIT)
 -              edm= editmesh_get_derived_base(ob, me->edit_mesh);
 +              edm= editbmesh_get_derived_base(ob, me->edit_btmesh);
        else 
                dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
  
index 117528114c6b782747a884056fbe29992388291e,70b2a3d36282fc9ce51856c119eb694e867229b4..c85f7d3af8a3d413d6a7d019ce6b7bc2e7dc3118
@@@ -55,7 -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"
@@@ -282,31 -281,32 +282,32 @@@ static char *view3d_modeselect_pup(Scen
        str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA);
        
        if(ob==NULL || ob->data==NULL) return string;
-       if(ob->id.lib || ((ID *)ob->data)->lib) return string;
+       if(ob->id.lib) return string;
        
-       /* if active object is editable */
-       if ( ((ob->type == OB_MESH)
-               || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
-               || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
-               
-               str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
-       }
-       else if (ob->type == OB_ARMATURE) {
-               if (ob->mode & OB_MODE_POSE)
-                       str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
-               else
+       if(!((ID *)ob->data)->lib) {
+               /* if active object is editable */
+               if ( ((ob->type == OB_MESH)
+                       || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
+                       || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
+                       
                        str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
-       }
+               }
+               else if (ob->type == OB_ARMATURE) {
+                       if (ob->mode & OB_MODE_POSE)
+                               str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
+                       else
+                               str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
+               }
  
-       if (ob->type == OB_MESH) {
+               if (ob->type == OB_MESH) {
  
-               str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
-               str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
-               str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
-               str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
+                       str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
+                       str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
+                       str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
+                       str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
+               }
        }
-       
+               
        /* if active object is an armature */
        if (ob->type==OB_ARMATURE) {
                str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT);
@@@ -327,12 -327,12 +328,12 @@@ static void do_view3d_header_buttons(bC
        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 */
  
                        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");
                }
                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");
                }
        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");
                }
        default:
                break;
        }
 -
 -      if(obedit && obedit->type==OB_MESH)
 -              BKE_mesh_end_editmesh(obedit->data, em);
  }
  
  /* Returns the icon associated with an object mode */
@@@ -438,7 -442,7 +439,7 @@@ void uiTemplateEditModeSelection(uiLayo
        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);
                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);
        }
  }
  
@@@ -474,17 -480,11 +475,17 @@@ void uiTemplateHeader3D(uiLayout *layou
        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");
        
        uiTemplateEditModeSelection(layout, C);
  }
 -
index 29d7b66f27f22776747ae511064890cca2ad26a9,86112a42d994974145c200f7c38786b265c09e63..652682a2257d38da48ac212c80e609fc65acf8f4
@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * $Id$
 + * $Id: view3d_select.c 35106 2011-02-23 10:52:22Z jesterking $
   *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
@@@ -57,7 -57,7 +57,7 @@@
  #include "BKE_context.h"
  #include "BKE_paint.h"
  #include "BKE_armature.h"
 -
 +#include "BKE_tessmesh.h"
  
  #include "BIF_gl.h"
  #include "BIF_glutil.h"
@@@ -156,63 -156,57 +156,63 @@@ void view3d_get_transformation(ARegion 
  
  /* local prototypes */
  
 -static void EM_backbuf_checkAndSelectVerts(EditMesh *em, int select)
 +static void EDBM_backbuf_checkAndSelectVerts(BMEditMesh *em, int select)
  {
 -      EditVert *eve;
 -      int index= em_wireoffs;
 -
 -      for(eve= em->verts.first; eve; eve= eve->next, index++) {
 -              if(eve->h==0) {
 -                      if(EM_check_backbuf(index)) {
 -                              eve->f = select?(eve->f|1):(eve->f&~1);
 +      BMVert *eve;
 +      BMIter iter;
 +      int index= bm_wireoffs;
 +
 +      eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
 +      for ( ; eve; eve=BMIter_Step(&iter), index++) {
 +              if(!BM_TestHFlag(eve, BM_HIDDEN)) {
 +                      if(EDBM_check_backbuf(index)) {
 +                              BM_Select_Vert(em->bm, eve, select);
                        }
                }
        }
  }
  
 -static void EM_backbuf_checkAndSelectEdges(EditMesh *em, int select)
 +static void EDBM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select)
  {
 -      EditEdge *eed;
 -      int index= em_solidoffs;
 -
 -      for(eed= em->edges.first; eed; eed= eed->next, index++) {
 -              if(eed->h==0) {
 -                      if(EM_check_backbuf(index)) {
 -                              EM_select_edge(eed, select);
 +      BMEdge *eed;
 +      BMIter iter;
 +      int index= bm_solidoffs;
 +
 +      eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
 +      for ( ; eed; eed=BMIter_Step(&iter), index++) {
 +              if(!BM_TestHFlag(eed, BM_HIDDEN)) {
 +                      if(EDBM_check_backbuf(index)) {
 +                              BM_Select_Edge(em->bm, eed, select);
                        }
                }
        }
  }
  
 -static void EM_backbuf_checkAndSelectFaces(EditMesh *em, int select)
 +static void EDBM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select)
  {
 -      EditFace *efa;
 +      BMFace *efa;
 +      BMIter iter;
        int index= 1;
  
 -      for(efa= em->faces.first; efa; efa= efa->next, index++) {
 -              if(efa->h==0) {
 -                      if(EM_check_backbuf(index)) {
 -                              EM_select_face_fgon(em, efa, select);
 +      efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL);
 +      for ( ; efa; efa=BMIter_Step(&iter), index++) {
 +              if(!BM_TestHFlag(efa, BM_HIDDEN)) {
 +                      if(EDBM_check_backbuf(index)) {
 +                              BM_Select_Face(em->bm, efa, select);
                        }
                }
        }
  }
  
 -static void EM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
 +static void EDBM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
  {
 -      MFace *mface = me->mface;
 +      MPoly *mpoly = me->mpoly;
        int a;
  
 -      if (mface) {
 -              for(a=1; a<=me->totface; a++, mface++) {
 -                      if(EM_check_backbuf(a)) {
 -                              mface->flag = select?(mface->flag|ME_FACE_SEL):(mface->flag&~ME_FACE_SEL);
 +      if (mpoly) {
 +              for(a=1; a<=me->totpoly; a++, mpoly++) {
 +                      if(EDBM_check_backbuf(a)) {
 +                              mpoly->flag = select?(mpoly->flag|ME_FACE_SEL):(mpoly->flag&~ME_FACE_SEL);
                        }
                }
        }
@@@ -432,39 -426,39 +432,39 @@@ static void lasso_select_boundbox(rcti 
        }
  }
  
 -static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
 +static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
  {
        struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
  
        if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) {
 -              eve->f = data->select?(eve->f|1):(eve->f&~1);
 +              BM_Select(data->vc.em->bm, eve, data->select);
        }
  }
 -static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index)
 +static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index)
  {
        struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
  
 -      if (EM_check_backbuf(em_solidoffs+index)) {
 +      if (EDBM_check_backbuf(bm_solidoffs+index)) {
                if (data->pass==0) {
                        if (    edge_fully_inside_rect(data->rect, x0, y0, x1, y1)  &&
                                        lasso_inside(data->mcords, data->moves, x0, y0) &&
                                        lasso_inside(data->mcords, data->moves, x1, y1)) {
 -                              EM_select_edge(eed, data->select);
 +                              BM_Select(data->vc.em->bm, eed, data->select);
                                data->done = 1;
                        }
                } else {
                        if (lasso_inside_edge(data->mcords, data->moves, x0, y0, x1, y1)) {
 -                              EM_select_edge(eed, data->select);
 +                              BM_Select(data->vc.em->bm, eed, data->select);
                        }
                }
        }
  }
 -static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
 +static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
  {
        struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData;
  
        if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) {
 -              EM_select_face_fgon(data->vc.em, efa, data->select);
 +              BM_Select(data->vc.em->bm, efa, data->select);
        }
  }
  
@@@ -478,7 -472,7 +478,7 @@@ static void do_lasso_select_mesh(ViewCo
        lasso_select_boundbox(&rect, mcords, moves);
        
        /* set editmesh */
 -      vc->em= ((Mesh *)vc->obedit->data)->edit_mesh;
 +      vc->em= ((Mesh *)vc->obedit->data)->edit_btmesh;
  
        data.vc= *vc;
        data.rect = &rect;
        data.pass = 0;
  
        if (extend == 0 && select)
 -              EM_deselect_all(vc->em);
 +              EDBM_clear_flag_all(vc->em, BM_SELECT);
  
         /* for non zbuf projections, dont change the GL state */
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
  
        glLoadMatrixf(vc->rv3d->viewmat);
 -      bbsel= EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 +      bbsel= EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
        
        if(ts->selectmode & SCE_SELECT_VERTEX) {
                if (bbsel) {
 -                      EM_backbuf_checkAndSelectVerts(vc->em, select);
 +                      EDBM_backbuf_checkAndSelectVerts(vc->em, select);
                }
                else {
                        mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, 1);
        
        if(ts->selectmode & SCE_SELECT_FACE) {
                if (bbsel) {
 -                      EM_backbuf_checkAndSelectFaces(vc->em, select);
 +                      EDBM_backbuf_checkAndSelectFaces(vc->em, select);
                }
                else {
                        mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data);
                }
        }
        
 -      EM_free_backbuf();
 -      EM_selectmode_flush(vc->em);    
 +      EDBM_free_backbuf();
 +      EDBM_selectmode_flush(vc->em);  
  }
  
  #if 0
@@@ -745,14 -739,14 +745,14 @@@ static void do_lasso_select_paintface(V
        if(extend==0 && select)
                paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */
  
 -      em_vertoffs= me->totface+1;     /* max index array */
 +      bm_vertoffs= me->totpoly+1;     /* max index array */
  
        lasso_select_boundbox(&rect, mcords, moves);
 -      EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 +      EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
        
 -      EM_backbuf_checkAndSelectTFaces(me, select);
 +      EDBM_backbuf_checkAndSelectTFaces(me, select);
  
 -      EM_free_backbuf();
 +      EDBM_free_backbuf();
  
        paintface_flush_flags(ob);
  }
@@@ -1341,9 -1335,9 +1341,9 @@@ static int mouse_select(bContext *C, co
                        if(oldbasact != basact) {
                                ED_base_object_activate(C, basact); /* adds notifier */
                        }
-                       WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
                }
+               WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
        }
  
        return retval;
@@@ -1444,37 -1438,37 +1444,37 @@@ static int do_lattice_box_select(ViewCo
        return OPERATOR_FINISHED;
  }
  
 -static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
 +static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
  {
        struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
  
        if (BLI_in_rcti(data->rect, x, y)) {
 -              eve->f = data->select?(eve->f|1):(eve->f&~1);
 +              BM_Select(data->vc.em->bm, eve, data->select);
        }
  }
 -static void do_mesh_box_select__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index)
 +static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index)
  {
        struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
  
 -      if(EM_check_backbuf(em_solidoffs+index)) {
 +      if(EDBM_check_backbuf(bm_solidoffs+index)) {
                if (data->pass==0) {
                        if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) {
 -                              EM_select_edge(eed, data->select);
 +                              BM_Select(data->vc.em->bm, eed, data->select);
                                data->done = 1;
                        }
                } else {
                        if (edge_inside_rect(data->rect, x0, y0, x1, y1)) {
 -                              EM_select_edge(eed, data->select);
 +                              BM_Select(data->vc.em->bm, eed, data->select);
                        }
                }
        }
  }
 -static void do_mesh_box_select__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
 +static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
  {
        struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData;
  
        if (BLI_in_rcti(data->rect, x, y)) {
 -              EM_select_face_fgon(data->vc.em, efa, data->select);
 +              BM_Select(data->vc.em->bm, efa, data->select);
        }
  }
  static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend)
        data.done = 0;
  
        if (extend == 0 && select)
 -              EM_deselect_all(vc->em);
 +              EDBM_clear_flag_all(vc->em, BM_SELECT);
  
        /* for non zbuf projections, dont change the GL state */
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
  
        glLoadMatrixf(vc->rv3d->viewmat);
 -      bbsel= EM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
 +      bbsel= EDBM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
  
        if(ts->selectmode & SCE_SELECT_VERTEX) {
                if (bbsel) {
 -                      EM_backbuf_checkAndSelectVerts(vc->em, select);
 +                      EDBM_backbuf_checkAndSelectVerts(vc->em, select);
                } else {
                        mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, 1);
                }
        
        if(ts->selectmode & SCE_SELECT_FACE) {
                if(bbsel) {
 -                      EM_backbuf_checkAndSelectFaces(vc->em, select);
 +                      EDBM_backbuf_checkAndSelectFaces(vc->em, select);
                } else {
                        mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data);
                }
        }
        
 -      EM_free_backbuf();
 +      EDBM_free_backbuf();
                
 -      EM_selectmode_flush(vc->em);
 +      EDBM_selectmode_flush(vc->em);
        
        return OPERATOR_FINISHED;
  }
@@@ -1761,7 -1755,7 +1761,7 @@@ static int view3d_borderselect_exec(bCo
        if(vc.obedit) {
                switch(vc.obedit->type) {
                case OB_MESH:
 -                      vc.em= ((Mesh *)vc.obedit->data)->edit_mesh;
 +                      vc.em= ((Mesh *)vc.obedit->data)->edit_btmesh;
                        ret= do_mesh_box_select(&vc, &rect, select, extend);
  //                    if (EM_texFaceCheck())
                        if(ret & OPERATOR_FINISHED) {
@@@ -1847,8 -1841,8 +1847,8 @@@ static int view3d_select_invoke(bContex
        int     retval = 0;
  
        view3d_operator_needs_opengl(C);
-       
-       if(obedit) {
+       if(obedit && center==FALSE) {
                if(obedit->type==OB_MESH)
                        retval = mouse_mesh(C, event->mval, extend);
                else if(obedit->type==OB_ARMATURE)
@@@ -1895,39 -1889,39 +1895,39 @@@ void VIEW3D_OT_select(wmOperatorType *o
        
        /* properties */
        RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first.");
-       RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting (object mode only).");
+       RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection.");
        RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only).");
  }
  
  
  /* -------------------- circle select --------------------------------------------- */
  
 -static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
 +static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index))
  {
        struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
        int mx = x - data->mval[0], my = y - data->mval[1];
        float r = sqrt(mx*mx + my*my);
  
        if (r<=data->radius) {
 -              eve->f = data->select?(eve->f|1):(eve->f&~1);
 +              BM_Select(data->vc->em->bm, eve, data->select);
        }
  }
 -static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index))
 +static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index))
  {
        struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
  
        if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) {
 -              EM_select_edge(eed, data->select);
 +              BM_Select(data->vc->em->bm, eed, data->select);
        }
  }
 -static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index))
 +static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index))
  {
        struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData;
        int mx = x - data->mval[0], my = y - data->mval[1];
        float r = sqrt(mx*mx + my*my);
        
        if (r<=data->radius) {
 -              EM_select_face_fgon(data->vc->em, efa, data->select);
 +              BM_Select(data->vc->em->bm, efa, data->select);
        }
  }
  
@@@ -1937,10 -1931,10 +1937,10 @@@ static void mesh_circle_select(ViewCont
        int bbsel;
        struct {ViewContext *vc; short select; int mval[2]; float radius; } data;
        
 -      bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f));
 +      bbsel= EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0));
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
  
 -      vc->em= ((Mesh *)vc->obedit->data)->edit_mesh;
 +      vc->em= ((Mesh *)vc->obedit->data)->edit_btmesh;
  
        data.vc = vc;
        data.select = select;
  
        if(ts->selectmode & SCE_SELECT_VERTEX) {
                if(bbsel) {
 -                      EM_backbuf_checkAndSelectVerts(vc->em, select==LEFTMOUSE);
 +                      EDBM_backbuf_checkAndSelectVerts(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, 1);
                }
  
        if(ts->selectmode & SCE_SELECT_EDGE) {
                if (bbsel) {
 -                      EM_backbuf_checkAndSelectEdges(vc->em, select==LEFTMOUSE);
 +                      EDBM_backbuf_checkAndSelectEdges(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, 0);
                }
        
        if(ts->selectmode & SCE_SELECT_FACE) {
                if(bbsel) {
 -                      EM_backbuf_checkAndSelectFaces(vc->em, select==LEFTMOUSE);
 +                      EDBM_backbuf_checkAndSelectFaces(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data);
                }
        }
  
 -      EM_free_backbuf();
 -      EM_selectmode_flush(vc->em);
 +      EDBM_free_backbuf();
 +      EDBM_selectmode_flush(vc->em);
  }
  
  static void paint_facesel_circle_select(ViewContext *vc, int select, const int mval[2], float rad)
        int bbsel;
  
        if (me) {
 -              em_vertoffs= me->totface+1;     /* max index array */
 +              bm_vertoffs= me->totpoly+1;     /* max index array */
  
 -              bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f));
 -              EM_backbuf_checkAndSelectTFaces(me, select==LEFTMOUSE);
 -              EM_free_backbuf();
 +              bbsel= EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0));
 +              EDBM_backbuf_checkAndSelectTFaces(me, select==LEFTMOUSE);
 +              EDBM_free_backbuf();
        }
  }
  
index 54c12f568c7040ccba98f5d1ac49af410c7ed677,56c1334ecaca31fc6b78d732c7e80c0c9f6ae27b..695cbc25b27738a37c6b43621a54dca8ff69be44
@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * $Id$
 + * $Id: mathutils_Vector.c 38409 2011-07-15 04:01:47Z campbellbarton $
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -37,8 -37,6 +37,6 @@@
  #include "BLI_math.h"
  #include "BLI_utildefines.h"
  
- extern void PyC_LineSpit(void);
  #define MAX_DIMENSIONS 4
  
  /* Swizzle axes get packed into a single value that is used as a closure. Each
@@@ -1161,28 -1159,18 +1159,18 @@@ static PyObject *Vector_mul(PyObject *v
        }
        else if (vec1) {
                if (MatrixObject_Check(v2)) {
-                       extern void PyC_LineSpit(void);
-                       /* VEC * MATRIX */
-                       /* this is deprecated!, use the reverse instead */
-                       float tvec[MAX_DIMENSIONS];
  
  /* ------ to be removed ------*/
- #ifndef MATH_STANDALONE
- #ifdef WITH_ASSERT_ABORT
+ #if 1
                        PyErr_SetString(PyExc_ValueError,
                                        "(Vector * Matrix) is now removed, reverse the "
                                        "order (promoted to an Error for Debug builds)");
                        return NULL;
  #else
-                       printf("Warning: (Vector * Matrix) is now deprecated, "
-                              "reverse the multiplication order in the script.\n");
-                       PyC_LineSpit();
- #endif
- #endif                /* ifndef MATH_STANDALONE */
- /* ------ to be removed ------*/
  
+                       /* VEC * MATRIX */
+                       /* this is deprecated!, use the reverse instead */
+                       float tvec[MAX_DIMENSIONS];
  
                        if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
                                return NULL;
                        }
  
                        return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1));
+ #endif
+ /* ------ to be removed ------*/
                }
                else if (QuaternionObject_Check(v2)) {
                        /* VEC * QUAT */
+ /* ------ to be removed ------*/
+ #if 1
+                       PyErr_SetString(PyExc_ValueError,
+                                       "(Vector * Quat) is now removed, reverse the "
+                                       "order (promoted to an Error for Debug builds)");
+                       return NULL;
+ #else
                        QuaternionObject *quat2 = (QuaternionObject*)v2;
                        float tvec[3];
  
                                return NULL;
                        }
  
- /* ------ to be removed ------*/
- #ifndef MATH_STANDALONE
- #ifdef WITH_ASSERT_ABORT
-                       PyErr_SetString(PyExc_ValueError,
-                                       "(Vector * Quat) is now removed, reverse the "
-                                       "order (promoted to an Error for Debug builds)");
-                       return NULL;
- #else
-                       printf("Warning: (Vector * Quat) is now deprecated, "
-                              "reverse the multiplication order in the script.\n");
-                       PyC_LineSpit();
- #endif
- #endif                /* ifndef MATH_STANDALONE */
- /* ------ to be removed ------*/
                        copy_v3_v3(tvec, vec1->vec);
                        mul_qt_v3(quat2->quat, tvec);
                        return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1));
+ #endif
+ /* ------ to be removed ------*/
                }
                else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC * FLOAT */
                        return vector_mul_float(vec1, scalar);
@@@ -1260,6 -1242,14 +1242,14 @@@ static PyObject *Vector_imul(PyObject *
        /* only support vec*=float and vec*=mat
           vec*=vec result is a float so that wont work */
        if (MatrixObject_Check(v2)) {
+ /* ------ to be removed ------*/
+ #if 1
+               PyErr_SetString(PyExc_ValueError,
+                                               "(Vector *= Matrix) is now removed, reverse the "
+                                               "order (promoted to an Error for Debug builds) "
+                                               "and uses the non in-place multiplication.");
+               return NULL;
+ #else
                float rvec[MAX_DIMENSIONS];
                if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
                        return NULL;
                if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1)
                        return NULL;
  
- /* ------ to be removed ------*/
- #ifndef MATH_STANDALONE
- #ifdef WITH_ASSERT_ABORT
-                       PyErr_SetString(PyExc_ValueError,
-                                                       "(Vector *= Matrix) is now removed, reverse the "
-                                                       "order (promoted to an Error for Debug builds) "
-                                       "and uses the non in-place multiplication.");
-                       return NULL;
- #else
-                       printf("Warning: (Vector *= Matrix) is now deprecated, "
-                                  "reverse the (non in-place) multiplication order in the script.\n");
-                       PyC_LineSpit();
+               memcpy(vec->vec, rvec, sizeof(float) * vec->size);
  #endif
- #endif                /* ifndef MATH_STANDALONE */
  /* ------ to be removed ------*/
-               memcpy(vec->vec, rvec, sizeof(float) * vec->size);
        }
        else if (QuaternionObject_Check(v2)) {
                /* VEC *= QUAT */
+ /* ------ to be removed ------*/
+ #if 1
+               PyErr_SetString(PyExc_ValueError,
+                                               "(Vector *= Quat) is now removed, reverse the "
+                                               "order (promoted to an Error for Debug builds) "
+                                               "and uses the non in-place multiplication.");
+               return NULL;
+ #else
                QuaternionObject *quat2 = (QuaternionObject*)v2;
  
                if(vec->size != 3) {
                        return NULL;
                }
  
- /* ------ to be removed ------*/
- #ifndef MATH_STANDALONE
- #ifdef WITH_ASSERT_ABORT
-                       PyErr_SetString(PyExc_ValueError,
-                                                       "(Vector *= Quat) is now removed, reverse the "
-                                                       "order (promoted to an Error for Debug builds) "
-                                       "and uses the non in-place multiplication.");
-                       return NULL;
- #else
-                       printf("Warning: (Vector *= Quat) is now deprecated, "
-                                  "reverse the (non in-place) multiplication order in the script.\n");
-                       PyC_LineSpit();
+               mul_qt_v3(quat2->quat, vec->vec);
  #endif
- #endif                /* ifndef MATH_STANDALONE */
  /* ------ to be removed ------*/
-               mul_qt_v3(quat2->quat, vec->vec);
        }
        else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */
                mul_vn_fl(vec->vec, vec->size, scalar);