[Bf-blender-cvs] [36b516c] master: Fix T47249: Wrong edit-mesh material color w/ hidden faces

Campbell Barton noreply at git.blender.org
Wed Feb 3 05:14:12 CET 2016


Commit: 36b516cb979cfb809f5943a062fb35b8b2ffe911
Author: Campbell Barton
Date:   Wed Feb 3 15:01:50 2016 +1100
Branches: master
https://developer.blender.org/rB36b516cb979cfb809f5943a062fb35b8b2ffe911

Fix T47249: Wrong edit-mesh material color w/ hidden faces

Regression in 700c40e2

Also avoid unnecessary flushes with material changes with hidden faces.

===================================================================

M	source/blender/blenkernel/intern/editderivedmesh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index bf6669c..96bdfe8 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);
-				}
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list