diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-19 10:54:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-19 11:00:19 +0300 |
commit | eb05e87e16147554284d7b8d6b1a7184f9310719 (patch) | |
tree | 6e796fb5a93cb36ad930fe30e9f1d72dbf631e5e /source/blender/blenkernel | |
parent | da34136de1093e7da9bc10881d11e2f553f4d8d0 (diff) |
BMesh: editmode drawing set every faces material
Check for changes in material (as other drawing code already does)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 24 |
2 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e4a5dbb9d24..3feea12f017 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -793,7 +793,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, else { /* we need to check if the next material changes */ int next_actualFace = dm->drawObject->triangle_to_mface[0]; - int prev_mat_nr = -1; + short prev_mat_nr = -1; for (i = 0; i < tottri; i++) { //int actualFace = dm->drawObject->triangle_to_mface[i]; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 5230634fe4c..90decfde30f 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -521,8 +521,6 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, GLenum poly_prev = GL_ZERO; GLenum shade_prev = GL_ZERO; - (void)setMaterial; /* UNUSED */ - /* currently unused -- each original face is handled separately */ (void)compareDrawOptions; @@ -539,6 +537,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, } if (bmdm->vertexCos) { + short prev_mat_nr = -1; + /* add direct access */ const float (*vertexCos)[3] = bmdm->vertexCos; const float (*vertexNos)[3]; @@ -569,8 +569,14 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, setDrawOptions(userData, BM_elem_index_get(efa))); if (draw_option != DM_DRAW_OPTION_SKIP) { const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ - if (setMaterial) - setMaterial(efa->mat_nr + 1, NULL); + + if (efa->mat_nr != prev_mat_nr) { + if (setMaterial) { + setMaterial(efa->mat_nr + 1, NULL); + } + prev_mat_nr = efa->mat_nr; + } + if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); @@ -645,6 +651,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, } } else { + short prev_mat_nr = -1; + BM_mesh_elem_index_ensure(bm, lnors ? BM_FACE | BM_LOOP : BM_FACE); for (i = 0; i < tottri; i++) { @@ -661,8 +669,12 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, if (draw_option != DM_DRAW_OPTION_SKIP) { const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ - if (setMaterial) - setMaterial(efa->mat_nr + 1, NULL); + if (efa->mat_nr != prev_mat_nr) { + if (setMaterial) { + setMaterial(efa->mat_nr + 1, NULL); + } + prev_mat_nr = efa->mat_nr; + } if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ |