Fix #19659, #20387, #20489, part of #20565. VBO's in edit mode were not
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 8 Jan 2010 17:53:17 +0000 (17:53 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 8 Jan 2010 17:53:17 +0000 (17:53 +0000)
working well, and no one seems to be fixing it, so I've just removed the
code for this. It has to be replaced eventually for bmesh anyway.

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/editors/space_view3d/drawobject.c

index b54f90880b8219141511ba8de1c4ad266e6f7943..3ffa32c700d9a52d136ee6e9994b55e01594b497 100644 (file)
@@ -523,56 +523,14 @@ static void emDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *us
                }
                glEnd();
        } else {
-               GPUBuffer *buffer = NULL;
-               float *varray;
-
-               if(GPU_buffer_legacy(dm)==FALSE)
-                       buffer = GPU_buffer_alloc( sizeof(float)*3*2*emdm->em->totedge, 0 );
-
-               if( buffer != 0 && (varray = GPU_buffer_lock_stream( buffer )) ) {
-                       int prevdraw = 0;
-                       int numedges = 0;
-                       int draw = 0;
-                       int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_END };
-                       GPU_buffer_unlock( buffer );
-                       GPU_interleaved_setup( buffer, datatype );
-                       varray = GPU_buffer_lock_stream( buffer );
-                       for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                               if(!setDrawOptions || setDrawOptions(userData, i)) {
-                                       draw = 1;
-                               } else {
-                                       draw = 0;
-                               }
-                               if( prevdraw != draw && prevdraw != 0 && numedges > 0) {
-                                       GPU_buffer_unlock( buffer );
-                                       glDrawArrays(GL_LINES,0,numedges*2);
-                                       varray = GPU_buffer_lock_stream( buffer );
-                                       numedges = 0;
-                               }
-                               if( draw != 0 ) {
-                                       VECCOPY(&varray[numedges*6],eed->v1->co);
-                                       VECCOPY(&varray[numedges*6+3],eed->v2->co);
-                                       numedges++;
-                               }
-                               prevdraw = draw;
-                       }
-                       GPU_buffer_unlock( buffer );
-                       if( prevdraw != 0 && numedges > 0) {
-                               glDrawArrays(GL_LINES,0,numedges*2);
-                       }
-                       GPU_buffer_unbind();
-               } else {
-                       glBegin(GL_LINES);
-                       for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
-                               if(!setDrawOptions || setDrawOptions(userData, i)) {
-                                       glVertex3fv(eed->v1->co);
-                                       glVertex3fv(eed->v2->co);
-                               }
+               glBegin(GL_LINES);
+               for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
+                       if(!setDrawOptions || setDrawOptions(userData, i)) {
+                               glVertex3fv(eed->v1->co);
+                               glVertex3fv(eed->v2->co);
                        }
-                       glEnd();
                }
-               if( buffer != 0 )
-                       GPU_buffer_free( buffer, 0 );
+               glEnd();
        }
 }
 static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
@@ -733,135 +691,41 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
                        }
                }
        } else {
-               GPUBuffer *buffer = 0;
-               float *varray;
-               if( setDrawOptions == 0 ) {
-                       /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
-                       buffer = GPU_buffer_alloc( sizeof(float)*6*emdm->em->totface*3*2, 0 );
-               }
-               if( buffer != 0 && (varray = GPU_buffer_lock_stream( buffer )) ) {
-                       int prevdraw = 0;
-                       int numfaces = 0;
-                       int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_N3F, GPU_BUFFER_INTER_END };
-                       GPU_buffer_unlock( buffer );
-                       GPU_interleaved_setup( buffer, datatype );
-                       glShadeModel(GL_SMOOTH);
-                       varray = GPU_buffer_lock_stream( buffer );
-                       for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
-                               int drawSmooth = (efa->flag & ME_SMOOTH);
-                               draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
-                               if( prevdraw != draw && prevdraw != 0 && numfaces > 0) {
-                                       if( prevdraw==2 ) {
-                                               glEnable(GL_POLYGON_STIPPLE);
-                                               glPolygonStipple(stipple_quarttone);
-                                       }
-                                       GPU_buffer_unlock( buffer );
-                                       glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                                       if( prevdraw==2 ) {
-                                               glDisable(GL_POLYGON_STIPPLE);
-                                       }
-                                       varray = GPU_buffer_lock_stream( buffer );
-                                       numfaces = 0;
-                               }
-                               if( draw != 0 ) {
-                                       if(!drawSmooth) {
-                                               VECCOPY(&varray[numfaces*18],efa->v1->co);
-                                               VECCOPY(&varray[numfaces*18+3],efa->n);
-
-                                               VECCOPY(&varray[numfaces*18+6],efa->v2->co);
-                                               VECCOPY(&varray[numfaces*18+9],efa->n);
-
-                                               VECCOPY(&varray[numfaces*18+12],efa->v3->co);
-                                               VECCOPY(&varray[numfaces*18+15],efa->n);
-                                               numfaces++;
-                                               if( efa->v4 ) {
-                                                       VECCOPY(&varray[numfaces*18],efa->v3->co);
-                                                       VECCOPY(&varray[numfaces*18+3],efa->n);
-
-                                                       VECCOPY(&varray[numfaces*18+6],efa->v4->co);
-                                                       VECCOPY(&varray[numfaces*18+9],efa->n);
-
-                                                       VECCOPY(&varray[numfaces*18+12],efa->v1->co);
-                                                       VECCOPY(&varray[numfaces*18+15],efa->n);
-                                                       numfaces++;
-                                               }
-                                       }
-                                       else {
-                                               VECCOPY(&varray[numfaces*18],efa->v1->co);
-                                               VECCOPY(&varray[numfaces*18+3],efa->v1->no);
-
-                                               VECCOPY(&varray[numfaces*18+6],efa->v2->co);
-                                               VECCOPY(&varray[numfaces*18+9],efa->v2->no);
-
-                                               VECCOPY(&varray[numfaces*18+12],efa->v3->co);
-                                               VECCOPY(&varray[numfaces*18+15],efa->v3->no);
-                                               numfaces++;
-                                               if( efa->v4 ) {
-                                                       VECCOPY(&varray[numfaces*18],efa->v3->co);
-                                                       VECCOPY(&varray[numfaces*18+3],efa->v3->no);
-
-                                                       VECCOPY(&varray[numfaces*18+6],efa->v4->co);
-                                                       VECCOPY(&varray[numfaces*18+9],efa->v4->no);
-
-                                                       VECCOPY(&varray[numfaces*18+12],efa->v1->co);
-                                                       VECCOPY(&varray[numfaces*18+15],efa->v1->no);
-                                                       numfaces++;
-                                               }
-                                       }
-                               }
-                               prevdraw = draw;
-                       }
-                       GPU_buffer_unlock( buffer );
-                       if( prevdraw != 0 && numfaces > 0) {
-                               if( prevdraw==2 ) {
+               for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
+                       int drawSmooth = (efa->flag & ME_SMOOTH);
+                       draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
+                       if(draw) {
+                               if (draw==2) { /* enabled with stipple */
                                        glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(stipple_quarttone);
-                               }
-                               glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                               if( prevdraw==2 ) {
-                                       glDisable(GL_POLYGON_STIPPLE);
+                                       glPolygonStipple(stipple_quarttone);
                                }
-                       }
-                       GPU_buffer_unbind();
-               } else {
-                       for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
-                               int drawSmooth = (efa->flag & ME_SMOOTH);
-                               draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
-                               if(draw) {
-                                       if (draw==2) { /* enabled with stipple */
-                                               glEnable(GL_POLYGON_STIPPLE);
-                                               glPolygonStipple(stipple_quarttone);
-                                       }
-                                       glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
+                               glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
 
-                                       glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
-                                       if (!drawSmooth) {
-                                               glNormal3fv(efa->n);
-                                               glVertex3fv(efa->v1->co);
-                                               glVertex3fv(efa->v2->co);
-                                               glVertex3fv(efa->v3->co);
-                                               if(efa->v4) glVertex3fv(efa->v4->co);
-                                       } else {
-                                               glNormal3fv(efa->v1->no);
-                                               glVertex3fv(efa->v1->co);
-                                               glNormal3fv(efa->v2->no);
-                                               glVertex3fv(efa->v2->co);
-                                               glNormal3fv(efa->v3->no);
-                                               glVertex3fv(efa->v3->co);
-                                               if(efa->v4) {
-                                                       glNormal3fv(efa->v4->no);
-                                                       glVertex3fv(efa->v4->co);
-                                               }
+                               glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
+                               if (!drawSmooth) {
+                                       glNormal3fv(efa->n);
+                                       glVertex3fv(efa->v1->co);
+                                       glVertex3fv(efa->v2->co);
+                                       glVertex3fv(efa->v3->co);
+                                       if(efa->v4) glVertex3fv(efa->v4->co);
+                               } else {
+                                       glNormal3fv(efa->v1->no);
+                                       glVertex3fv(efa->v1->co);
+                                       glNormal3fv(efa->v2->no);
+                                       glVertex3fv(efa->v2->co);
+                                       glNormal3fv(efa->v3->no);
+                                       glVertex3fv(efa->v3->co);
+                                       if(efa->v4) {
+                                               glNormal3fv(efa->v4->no);
+                                               glVertex3fv(efa->v4->co);
                                        }
-                                       glEnd();
-                                       
-                                       if (draw==2)
-                                               glDisable(GL_POLYGON_STIPPLE);
                                }
+                               glEnd();
+                               
+                               if (draw==2)
+                                       glDisable(GL_POLYGON_STIPPLE);
                        }
                }
-               if( buffer != 0 )
-                       GPU_buffer_free( buffer, 0 );
        }
 }
 
index 66790d9b7f08bb01452a51d180f8cd725524c492..77d8ed0f24d9e49ddc81743a44b1c13ebb4bcbea 100644 (file)
 #include "GPU_draw.h"
 #include "GPU_material.h"
 #include "GPU_extensions.h"
-#include "gpu_buffers.h"
 
 #include "ED_mesh.h"
 #include "ED_particle.h"
@@ -820,6 +819,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
                circrad = 3.0f*lampsize;
                drawcircball(GL_LINE_LOOP, vec, circrad, imat);
        }
+       else
+               circrad = 0.0f;
        
        setlinestyle(3);
 
@@ -1575,82 +1576,15 @@ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *
        }
 }
 
-/* disabled because it crashes combined with e.g. subsurf modifier,
- * the derivedmesh can't be assumed to be an EditMeshDerivedMesh,
- * nor should this struct be copied around, it should be defined in
- * a single place only to avoid them getting out of sync */
-#if 0
-/* originally defined in DerivedMesh.c */
-typedef struct {
-       DerivedMesh dm;
-
-       EditMesh *em;
-       float (*vertexCos)[3];
-       float (*vertexNos)[3];
-       float (*faceNos)[3];
-} EditMeshDerivedMesh;
-#endif
-
 static void draw_dm_verts(DerivedMesh *dm, int sel, EditVert *eve_act)
 {
        struct { int sel; EditVert *eve_act; } data;
-       //GPUBuffer *buffer;
-       //float *varray;
        data.sel = sel;
        data.eve_act = eve_act;
 
-#if 0
-       /* first come the unselected vertices, then the selected */
-       buffer = GPU_buffer_legacy(dm)?0:GPU_buffer_alloc( sizeof(float)*3*dm->getNumVerts(dm)*2, 0 );
-
-       if( (varray = GPU_buffer_lock_stream( buffer )) && bglPointHack() == 0 ) {
-               EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
-               EditVert *eve;
-               int i;
-               int numverts = 0, numselected = 0;
-               int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_END };
-               GPU_buffer_unlock( buffer );
-               GPU_interleaved_setup( buffer, datatype );
-               varray = GPU_buffer_lock_stream( buffer );
-
-               glBegin(GL_POINTS);
-               for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) {
-                       if (eve->h==0 && (eve->f&SELECT)==data.sel) {
-                               if (eve==data.eve_act) {
-                                       if (emdm->vertexCos) {
-                                               VECCOPY(&varray[3*(dm->getNumVerts(dm)+numselected)],emdm->vertexCos[i]);
-                                       }
-                                       else {
-                                               VECCOPY(&varray[3*(dm->getNumVerts(dm)+numselected)],eve->co);
-                                       }
-                                       numselected++;
-                               } else {
-                                       if (emdm->vertexCos) {
-                                               VECCOPY(&varray[3*numverts],emdm->vertexCos[i]);
-                                       } else {
-                                               VECCOPY(&varray[3*numverts],eve->co);
-                                       }
-                                       numverts++;
-                               }
-                       }
-               }
-               glEnd();
-               GPU_buffer_unlock( buffer );
-               glDrawArrays(GL_POINTS,0,numverts);
-               UI_ThemeColor4(TH_EDITMESH_ACTIVE);
-               glDrawArrays(GL_POINTS,dm->getNumVerts(dm),numselected);
-               UI_ThemeColor4(data.sel?TH_VERTEX_SELECT:TH_VERTEX);
-               GPU_buffer_unbind();
-       }
-       {
-#endif
-               bglBegin(GL_POINTS);
-               dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
-               bglEnd();
-#if 0
-       }
-       GPU_buffer_free( buffer, 0 );
-#endif
+       bglBegin(GL_POINTS);
+       dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
+       bglEnd();
 }
 
        /* Draw edges with color set based on selection */
@@ -1722,55 +1656,8 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i
 static void draw_dm_edges_sel_interp(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
 {
        unsigned char *cols[2] = {baseCol, selCol};
-#if 0
-       int elemsize = sizeof(float)*3+sizeof(unsigned char)*4;
-       EditMeshDerivedMesh *emdm = (EditMeshDerivedMesh *)dm;
-       EditMesh *em= emdm->em;
-       unsigned char *varray;
-       int i;
-       GPUBuffer *buffer;
-
-       buffer = GPU_buffer_legacy(dm)?0:GPU_buffer_alloc( elemsize*em->totedge*2, 0 );
-       if( (varray = GPU_buffer_lock_stream( buffer )) ) {
-               EditEdge *eed;
-               int numedges = 0;
-               int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_C4UB, GPU_BUFFER_INTER_END };
-               GPU_buffer_unlock( buffer );
-               GPU_interleaved_setup( buffer, datatype );
-               varray = GPU_buffer_lock_stream( buffer );
-               for (i=0,eed= em->edges.first; eed; i++,eed= eed->next) {
-                       if(eed->h==0) {
-                               unsigned char *col0 = cols[(eed->v1->f&SELECT)?1:0];
-                               unsigned char *col1 = cols[(eed->v2->f&SELECT)?1:0];
-
-                               if( emdm->vertexCos ) {
-                                       VECCOPY(((float *)&varray[elemsize*numedges*2]),emdm->vertexCos[(int) eed->v1->tmp.l]);
-                               }
-                               else {
-                                       VECCOPY(((float *)&varray[elemsize*numedges*2]),eed->v1->co);
-                               }
-                               QUATCOPY(&varray[elemsize*numedges*2+sizeof(float)*3],col0);
-                               if( emdm->vertexCos ) {
-                                       VECCOPY(((float *)&varray[elemsize*numedges*2+elemsize]),emdm->vertexCos[(int) eed->v2->tmp.l]);
-                               }
-                               else {
-                                       VECCOPY(((float *)&varray[elemsize*numedges*2+elemsize]),eed->v2->co);
-                               }
-                               QUATCOPY(&varray[elemsize*numedges*2+elemsize+sizeof(float)*3],col1);
-                               numedges++;
-                       }
-               }
-               GPU_buffer_unlock( buffer );
-               glDrawArrays(GL_LINES,0,numedges*2);
-               GPU_buffer_unbind();
-       }
-       else {
-#endif
-               dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
-#if 0
-       }
-       GPU_buffer_free( buffer, 0 );
-#endif
+
+       dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
 }
 
        /* Draw only seam edges */
@@ -1824,236 +1711,12 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *dra
 static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) 
 {
        struct { unsigned char *cols[3]; EditFace *efa_act; } data;
-       //EditMeshDerivedMesh *emdm = (EditMeshDerivedMesh *)dm;
-       EditFace *efa;
-       unsigned char *col;
-       GPUBuffer *buffer;
-       unsigned char *varray;
-       unsigned char black[] = { 0, 0, 0, 0 };
-       int i, draw=0;
-       int elemsize = (sizeof(float)*6+sizeof(unsigned char)*4);
        data.cols[0] = baseCol;
        data.cols[1] = selCol;
        data.cols[2] = actCol;
        data.efa_act = efa_act;
 
-
-       buffer = GPU_buffer_legacy(dm)?0:GPU_buffer_alloc( elemsize*dm->getNumFaces(dm)*3*2, 0 );
-       if( dm->getVertCos == 0 && (varray = GPU_buffer_lock_stream( buffer )) ) {
-               int prevdraw = 0;
-               int numfaces = 0;
-               int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_N3F, GPU_BUFFER_INTER_C4UB, GPU_BUFFER_INTER_END };
-               GPU_buffer_unlock( buffer );
-               GPU_interleaved_setup( buffer, datatype );
-               glShadeModel(GL_SMOOTH);
-               varray = GPU_buffer_lock_stream( buffer );
-               for (i=0,efa= efa_act; efa; i++,efa= efa->next) {
-                       int drawSmooth = (efa->flag & ME_SMOOTH);
-                       if (efa->h==0) {
-                               if (efa == data.efa_act) {
-                                       draw = 2;
-                               } else {
-                                       col = data.cols[(efa->f&SELECT)?1:0];
-                                       if (col[3]==0) draw = 0;
-                                       else draw = 1;
-                               }
-                       }
-                       else {
-                               draw = 0;
-                       }
-                       if( prevdraw != draw && prevdraw != 0 && numfaces > 0) {
-                               if( prevdraw==2 ) {
-                                       glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(stipple_quarttone);
-                               }
-                               GPU_buffer_unlock( buffer );
-                               glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                               if( prevdraw==2 ) {
-                                       glDisable(GL_POLYGON_STIPPLE);
-                               }
-                               varray = GPU_buffer_lock_stream( buffer );
-                               numfaces = 0;
-                       }
-
-                       if( draw != 0 ) {
-                               if(!drawSmooth) {
-                                       /*if (emdm->vertexCos) {
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces],emdm->vertexCos[(int) efa->v1->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],emdm->faceNos[i]);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],emdm->vertexCos[(int) efa->v2->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],emdm->faceNos[i]);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],emdm->vertexCos[(int) efa->v3->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],emdm->faceNos[i]);
-                                       }
-                                       else {*/
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces],efa->v1->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],efa->n);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],efa->v2->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],efa->n);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],efa->v3->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],efa->n);
-                                       /*}*/
-                                       if( draw == 2 ) {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[2]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[2]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[2]);
-                                       }
-                                       else if( draw == 1 ) {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                       }
-                                       else {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],black);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],black);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],black);
-                                       }
-
-                                       numfaces++;
-                                       if( efa->v4 ) {
-                                               /*if (emdm->vertexCos) {
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces],emdm->vertexCos[(int) efa->v3->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],emdm->faceNos[i]);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],emdm->vertexCos[(int) efa->v4->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],emdm->faceNos[i]);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],emdm->vertexCos[(int) efa->v1->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],emdm->faceNos[i]);
-                                               }
-                                               else {*/
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces],efa->v3->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],efa->n);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],efa->v4->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],efa->n);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],efa->v1->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],efa->n);
-                                               /*}*/
-
-                                               if( draw == 2 ) {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[2]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[2]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[2]);
-                                               }
-                                               else if( draw == 1 ) {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               }
-                                               else {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],black);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],black);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],black);
-                                               }
-
-                                               numfaces++;
-                                       }
-                               }
-                               else {
-                                       /*if (emdm->vertexCos) {
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces],emdm->vertexCos[(int) efa->v1->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],emdm->vertexNos[(int) efa->v1->tmp.l]);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],emdm->vertexCos[(int) efa->v2->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],emdm->vertexNos[(int) efa->v2->tmp.l]);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],emdm->vertexCos[(int) efa->v3->tmp.l]);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],emdm->vertexNos[(int) efa->v3->tmp.l]);
-                                       }
-                                       else {*/
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces],efa->v1->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],efa->v1->no);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],efa->v2->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],efa->v2->no);
-
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],efa->v3->co);
-                                               VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],efa->v3->no);
-                                       /*}*/
-
-                                       if( draw == 2 ) {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[2]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[2]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[2]);
-                                       }
-                                       else if( draw == 1 ) {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                       }
-                                       else {
-                                               QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],black);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],black);
-                                               QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],black);
-                                       }
-
-                                       numfaces++;
-                                       if( efa->v4 ) {
-                                               /*if (emdm->vertexCos) {
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces],emdm->vertexCos[(int) efa->v3->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],emdm->vertexNos[(int) efa->v1->tmp.l]);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],emdm->vertexCos[(int) efa->v4->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],emdm->vertexNos[(int) efa->v2->tmp.l]);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],emdm->vertexCos[(int) efa->v1->tmp.l]);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],emdm->vertexNos[(int) efa->v3->tmp.l]);
-                                               }
-                                               else {*/
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces],efa->v3->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+sizeof(float)*3],efa->v3->no);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize],efa->v4->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize+sizeof(float)*3],efa->v4->no);
-
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2],efa->v1->co);
-                                                       VECCOPY((float *)&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*3],efa->v1->no);
-                                               /*}*/
-
-                                               if( draw == 2 ) {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[2]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[2]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[2]);
-                                               }
-                                               else if( draw == 1 ) {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],data.cols[(efa->f&SELECT)?1:0]);
-                                               }
-                                               else {
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+sizeof(float)*6],black);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize+sizeof(float)*6],black);
-                                                       QUATCOPY(&varray[elemsize*3*numfaces+elemsize*2+sizeof(float)*6],black);
-                                               }
-
-                                               numfaces++;
-                                       }
-                               }
-                       }
-                       prevdraw = draw;
-               }
-               GPU_buffer_unlock( buffer );
-               if( prevdraw != 0 && numfaces > 0) {
-                       if( prevdraw==2 ) {
-                               glEnable(GL_POLYGON_STIPPLE);
-                               glPolygonStipple(stipple_quarttone);
-                       }
-                       glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                       if( prevdraw==2 ) {
-                               glDisable(GL_POLYGON_STIPPLE);
-                       }
-               }
-               GPU_buffer_unbind();
-       } else {
-               dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0);
-       }
-       GPU_buffer_free( buffer, 0 );
+       dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0);
 }
 
 static int draw_dm_creases__setDrawOptions(void *userData, int index)
@@ -2467,114 +2130,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
                }
                else {
                        /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
-                       GPUBuffer *buffer = GPU_buffer_legacy(em->derivedFinal)?0:GPU_buffer_alloc( sizeof(float)*6*em->totface*3*2, 0 );
-                       float *varray;
-                       EditFace *efa;
-                       int i, curmat = 0, draw = 0;
-
                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
 
                        glEnable(GL_LIGHTING);
                        glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
-                       if( finalDM->getVertCos == 0 && (varray = GPU_buffer_lock_stream( buffer )) ) {
-                               int prevdraw = 0, prevmat = 0;
-                               int numfaces = 0;
-                               int datatype[] = { GPU_BUFFER_INTER_V3F, GPU_BUFFER_INTER_N3F, GPU_BUFFER_INTER_END };
-                               GPU_buffer_unlock( buffer );
-                               GPU_interleaved_setup( buffer, datatype );
-                               glShadeModel(GL_SMOOTH);
-                               varray = GPU_buffer_lock_stream( buffer );
-                               for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
-                                       int drawSmooth = (efa->flag & ME_SMOOTH);
-                                       if( efa->h == 0 ) {
-                                               curmat = efa->mat_nr+1;
-                                               draw = 1;
-                                       } 
-                                       else {
-                                               draw = 0;
-                                       }
-                                       if( ((prevdraw != draw) || (curmat != prevmat)) && prevdraw != 0 && numfaces > 0) {
-                                               if( prevdraw==2 ) {
-                                                       glEnable(GL_POLYGON_STIPPLE);
-                                                       glPolygonStipple(stipple_quarttone);
-                                               }
-                                               GPU_buffer_unlock( buffer );
-                                               GPU_enable_material(prevmat, NULL);
-                                               glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                                               if( prevdraw==2 ) {
-                                                       glDisable(GL_POLYGON_STIPPLE);
-                                               }
-                                               varray = GPU_buffer_lock_stream( buffer );
-                                               numfaces = 0;
-                                       }
-                                       if( draw != 0 ) {
-                                               if(!drawSmooth) {
-                                                       VECCOPY(&varray[numfaces*18],efa->v1->co);
-                                                       VECCOPY(&varray[numfaces*18+3],efa->n);
-
-                                                       VECCOPY(&varray[numfaces*18+6],efa->v2->co);
-                                                       VECCOPY(&varray[numfaces*18+9],efa->n);
-
-                                                       VECCOPY(&varray[numfaces*18+12],efa->v3->co);
-                                                       VECCOPY(&varray[numfaces*18+15],efa->n);
-                                                       numfaces++;
-                                                       if( efa->v4 ) {
-                                                               VECCOPY(&varray[numfaces*18],efa->v3->co);
-                                                               VECCOPY(&varray[numfaces*18+3],efa->n);
-
-                                                               VECCOPY(&varray[numfaces*18+6],efa->v4->co);
-                                                               VECCOPY(&varray[numfaces*18+9],efa->n);
-
-                                                               VECCOPY(&varray[numfaces*18+12],efa->v1->co);
-                                                               VECCOPY(&varray[numfaces*18+15],efa->n);
-                                                               numfaces++;
-                                                       }
-                                               }
-                                               else {
-                                                       VECCOPY(&varray[numfaces*18],efa->v1->co);
-                                                       VECCOPY(&varray[numfaces*18+3],efa->v1->no);
-
-                                                       VECCOPY(&varray[numfaces*18+6],efa->v2->co);
-                                                       VECCOPY(&varray[numfaces*18+9],efa->v2->no);
-
-                                                       VECCOPY(&varray[numfaces*18+12],efa->v3->co);
-                                                       VECCOPY(&varray[numfaces*18+15],efa->v3->no);
-                                                       numfaces++;
-                                                       if( efa->v4 ) {
-                                                               VECCOPY(&varray[numfaces*18],efa->v3->co);
-                                                               VECCOPY(&varray[numfaces*18+3],efa->v3->no);
-
-                                                               VECCOPY(&varray[numfaces*18+6],efa->v4->co);
-                                                               VECCOPY(&varray[numfaces*18+9],efa->v4->no);
-
-                                                               VECCOPY(&varray[numfaces*18+12],efa->v1->co);
-                                                               VECCOPY(&varray[numfaces*18+15],efa->v1->no);
-                                                               numfaces++;
-                                                       }
-                                               }
-                                       }
-                                       prevdraw = draw;
-                                       prevmat = curmat;
-                               }
-                               GPU_buffer_unlock( buffer );
-                               if( prevdraw != 0 && numfaces > 0) {
-                                       if( prevdraw==2 ) {
-                                               glEnable(GL_POLYGON_STIPPLE);
-                                               glPolygonStipple(stipple_quarttone);
-                                       }
-                                       GPU_enable_material(prevmat, NULL);
-                                       glDrawArrays(GL_TRIANGLES,0,numfaces*3);
-                                       if( prevdraw==2 ) {
-                                               glDisable(GL_POLYGON_STIPPLE);
-                                       }
-                               }
-                               GPU_buffer_unbind();
-                       }
-                       else {
-                               finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, 0, 0);
-                       }
-                       GPU_buffer_free(buffer,0);
+                       finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, 0, 0);
 
                        glFrontFace(GL_CCW);
                        glDisable(GL_LIGHTING);
@@ -6312,24 +5873,13 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh
        }
 }
 
-static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *drawSmooth_r)
-{
-       Mesh *me = userData;
-
-       if (!(me->mface[index].flag&ME_HIDE)) {
-               return 1;
-       } else {
-               return 0;
-       }
-}
-
-static int bbs_mesh_solid__setDrawOpts_legacy(void *userData, int index, int *drawSmooth_r)
+static int bbs_mesh_solid__setDrawOpts(void *userData, int index, int *drawSmooth_r)
 {
        WM_set_framebuffer_index_color(index+1);
        return 1;
 }
 
-static int bbs_mesh_solid_hide__setDrawOpts_legacy(void *userData, int index, int *drawSmooth_r)
+static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *drawSmooth_r)
 {
        Mesh *me = userData;
 
@@ -6345,43 +5895,12 @@ static void bbs_mesh_solid(Scene *scene, View3D *v3d, Object *ob)
 {
        DerivedMesh *dm = mesh_get_derived_final(scene, ob, v3d->customdata_mask);
        Mesh *me = (Mesh*)ob->data;
-       MCol *colors;
-       int i,j;
        int face_sel_mode = (me->flag & ME_EDIT_PAINT_MASK) ? 1:0;
        
        glColor3ub(0, 0, 0);
                
-       if( !GPU_buffer_legacy(dm) ) {
-               int *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
-               int ind;
-               colors = MEM_mallocN(dm->getNumFaces(dm)*sizeof(MCol)*4,"bbs_mesh_solid");
-               for(i=0;i<dm->getNumFaces(dm);i++) {
-                       ind= ( index )? index[i]: i;
-
-                       if (face_sel_mode==0 || !(me->mface[ind].flag&ME_HIDE)) {
-                               unsigned int fbindex = index_to_framebuffer(ind+1);
-                               for(j=0;j<4;j++) {
-                                       colors[i*4+j].b = ((fbindex)&0xFF);
-                                       colors[i*4+j].g = (((fbindex)>>8)&0xFF);
-                                       colors[i*4+j].r = (((fbindex)>>16)&0xFF);
-                               }
-                       }
-                       else {
-                               memset(&colors[i*4],0,sizeof(MCol)*4);
-                       }
-               }
-
-               CustomData_add_layer( &dm->faceData, CD_ID_MCOL, CD_ASSIGN, colors, dm->numFaceData );
-               GPU_buffer_free(dm->drawObject->colors,0);
-               dm->drawObject->colors = 0;
-
-               if(face_sel_mode)       dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 1);
-               else                            dm->drawMappedFaces(dm, NULL, me, 1);
-       }
-       else {
-               if(face_sel_mode)       dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts_legacy, me, 0);
-               else                            dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts_legacy, me, 0);
-       }
+       if(face_sel_mode)       dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0);
+       else                            dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0);
 
        dm->release(dm);
 }