Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-02-03 07:01:50 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-02-03 07:01:50 +0300
commit36b516cb979cfb809f5943a062fb35b8b2ffe911 (patch)
treed6e7936afce601a5c2b3717c2093838491475001 /source/blender/blenkernel/intern/editderivedmesh.c
parent9045cf88a58292b72fb4349d6beee2b4eed4f258 (diff)
Fix T47249: Wrong edit-mesh material color w/ hidden faces
Regression in 700c40e2 Also avoid unnecessary flushes with material changes with hidden faces.
Diffstat (limited to 'source/blender/blenkernel/intern/editderivedmesh.c')
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index bf6669c39a6..96bdfe88722 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -889,9 +889,8 @@ static void emDM_drawMappedFaces(
BMFace *efa;
struct BMLoop *(*looptris)[3] = bmdm->em->looptris;
const int tottri = bmdm->em->tottri;
- const int lasttri = tottri - 1; /* compare agasint this a lot */
DMDrawOption draw_option;
- int i, flush;
+ int i;
const int skip_normals = !(flag & DM_DRAW_NEED_NORMALS);
const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
@@ -904,6 +903,7 @@ static void emDM_drawMappedFaces(
/* GL_ZERO is used to detect if drawing has started or not */
GLenum poly_prev = GL_ZERO;
GLenum shade_prev = GL_ZERO;
+ DMDrawOption draw_option_prev = DM_DRAW_OPTION_SKIP;
/* call again below is ok */
if (has_vcol_preview) {
@@ -952,8 +952,22 @@ static void emDM_drawMappedFaces(
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 (draw_option_prev != draw_option) {
+ if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) {
+ if (poly_prev != GL_ZERO) glEnd();
+ poly_prev = GL_ZERO; /* force glBegin */
+
+ GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
+ }
+ draw_option_prev = draw_option;
+ }
+
+
if (efa->mat_nr != prev_mat_nr) {
if (setMaterial) {
+ if (poly_prev != GL_ZERO) glEnd();
+ poly_prev = GL_ZERO; /* force glBegin */
+
setMaterial(efa->mat_nr + 1, NULL);
}
prev_mat_nr = efa->mat_nr;
@@ -1018,17 +1032,6 @@ static void emDM_drawMappedFaces(
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
}
-
- flush = (draw_option == DM_DRAW_OPTION_STIPPLE);
- if (!skip_normals && !flush && (i != lasttri))
- flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */
-
- if (flush) {
- glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
}
}
}
@@ -1051,8 +1054,21 @@ static void emDM_drawMappedFaces(
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 (draw_option_prev != draw_option) {
+ if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) {
+ if (poly_prev != GL_ZERO) glEnd();
+ poly_prev = GL_ZERO; /* force glBegin */
+
+ GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
+ }
+ draw_option_prev = draw_option;
+ }
+
if (efa->mat_nr != prev_mat_nr) {
if (setMaterial) {
+ if (poly_prev != GL_ZERO) glEnd();
+ poly_prev = GL_ZERO; /* force glBegin */
+
setMaterial(efa->mat_nr + 1, NULL);
}
prev_mat_nr = efa->mat_nr;
@@ -1118,18 +1134,6 @@ static void emDM_drawMappedFaces(
glVertex3fv(ltri[2]->v->co);
}
}
-
- flush = (draw_option == DM_DRAW_OPTION_STIPPLE);
- if (!skip_normals && !flush && (i != lasttri)) {
- flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */
- }
-
- if (flush) {
- glEnd();
- poly_prev = GL_ZERO; /* force glBegin */
-
- GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- }
}
}
}