diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-25 13:11:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-25 13:36:11 +0400 |
commit | 62a03509574eac608f3199b4fd2ad8c00e14c789 (patch) | |
tree | 43c6bdccb4ea1778a5e32eb5c252cbf12c9fef48 /source | |
parent | 436d6ec2e9f8db160c52d5442ae2bbe4aadb9424 (diff) |
Editmode drawing: avoid glBegin/End for every tri (emDM_drawMappedFacesMat,GLSL)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 63189330869..752ae293a35 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -953,20 +953,27 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, int drawSmooth; efa = ltri[0]->f; - drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) continue; new_matnr = efa->mat_nr + 1; if (new_matnr != matnr) { + if (matnr != -1) + glEnd(); + do_draw = setMaterial(matnr = new_matnr, &gattribs); if (do_draw) DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); + + glBegin(GL_TRIANGLES); } if (do_draw) { - glBegin(GL_TRIANGLES); + + /* draw face */ + drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + if (!drawSmooth) { if (vertexCos) { glNormal3fv(polyNos[BM_elem_index_get(efa)]); @@ -1000,9 +1007,12 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, } } } - glEnd(); } } + + if (matnr != -1) { + glEnd(); + } } static void emDM_drawFacesGLSL(DerivedMesh *dm, @@ -1045,7 +1055,6 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, int drawSmooth; efa = ltri[0]->f; - drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); /* face hiding */ if (setFace && !setFace(userData, BM_elem_index_get(efa))) @@ -1054,12 +1063,18 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, /* material */ new_matnr = efa->mat_nr + 1; if (new_matnr != matnr) { + if (matnr != -1) + glEnd(); + setMaterial(userData, matnr = new_matnr, &gattribs); DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); + + glBegin(GL_TRIANGLES); } - /* face */ - glBegin(GL_TRIANGLES); + /* draw face */ + drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + if (!drawSmooth) { if (vertexCos) { glNormal3fv(polyNos[BM_elem_index_get(efa)]); @@ -1093,6 +1108,9 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, } } } + } + + if (matnr != -1) { glEnd(); } } |