[Bf-blender-cvs] [0918461] master: Move from MTFace to MTexPoly w/ texture checks

Campbell Barton noreply at git.blender.org
Tue Jul 14 14:41:22 CEST 2015


Commit: 0918461d61127f5d7e9dd7d81441a77b4bdd962d
Author: Campbell Barton
Date:   Tue Jul 14 22:27:25 2015 +1000
Branches: master
https://developer.blender.org/rB0918461d61127f5d7e9dd7d81441a77b4bdd962d

Move from MTFace to MTexPoly w/ texture checks

Part of moving away from MFace.

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/editderivedmesh.c
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/gpu/GPU_draw.h
M	source/blender/gpu/intern/gpu_draw.c
M	source/gameengine/Converter/BL_BlenderDataConversion.cpp
M	source/gameengine/Ketsji/BL_Material.cpp
M	source/gameengine/Ketsji/BL_Material.h
M	source/gameengine/Ketsji/KX_BlenderMaterial.cpp
M	source/gameengine/Ketsji/KX_BlenderMaterial.h
M	source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
M	source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
M	source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
M	source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 70ae9cd..984147d 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -142,7 +142,7 @@ typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_inde
 typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
 typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
 typedef DMDrawOption (*DMSetDrawOptionsMappedTex)(void *userData, int origindex, int mat_nr);
-typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
+typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTexPoly *mtexpoly, const bool has_vcol, int matnr);
 
 typedef enum DMDrawFlag {
 	DM_DRAW_USE_COLORS          = (1 << 0),
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index d60c5a5..b03024c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -471,7 +471,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
 {
 	CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
 	const MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
-	MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+	MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
 	MCol *mcol;
 	int i, orig;
 	int colType, startFace = 0;
@@ -539,12 +539,14 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
 		if (i != tottri - 1)
 			next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
 		
+		orig = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace) : ORIGINDEX_NONE;
+
 		if (drawParams) {
-			draw_option = drawParams(use_tface && tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr);
+			MTexPoly *tp = (use_tface && mtexpoly && orig != ORIGINDEX_NONE) ? &mtexpoly[orig] : NULL;
+			draw_option = drawParams(tp, (mcol != NULL), mf[actualFace].mat_nr);
 		}
 		else {
 			if (index_mf_to_mpoly) {
-				orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace);
 				if (orig == ORIGINDEX_NONE) {
 					/* XXX, this is not really correct
 							 * it will draw the previous faces context for this one when we don't know its settings.
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 63cec62..58f2517 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -833,19 +833,15 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
 		for (i = 0; i < em->tottri; i++) {
 			BMLoop **ltri = looptris[i];
 			MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
-			MTFace mtf = {{{0}}};
 			/*unsigned char *cp = NULL;*/ /*UNUSED*/
 			int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
 			DMDrawOption draw_option;
 
 			efa = ltri[0]->f;
 
-			if (cd_poly_tex_offset != -1) {
-				ME_MTEXFACE_CPY(&mtf, tp);
+			if (drawParams) {
+				draw_option = drawParams(tp, has_vcol, efa->mat_nr);
 			}
-
-			if (drawParams)
-				draw_option = drawParams(&mtf, has_vcol, efa->mat_nr);
 			else if (drawParamsMapped)
 				draw_option = drawParamsMapped(userData, BM_elem_index_get(efa), efa->mat_nr);
 			else
@@ -902,19 +898,14 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
 		for (i = 0; i < em->tottri; i++) {
 			BMLoop **ltri = looptris[i];
 			MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
-			MTFace mtf = {{{0}}};
 			/*unsigned char *cp = NULL;*/ /*UNUSED*/
 			int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
 			DMDrawOption draw_option;
 
 			efa = ltri[0]->f;
 
-			if (cd_poly_tex_offset != -1) {
-				ME_MTEXFACE_CPY(&mtf, tp);
-			}
-
 			if (drawParams)
-				draw_option = drawParams(&mtf, has_vcol, efa->mat_nr);
+				draw_option = drawParams(tp, has_vcol, efa->mat_nr);
 			else if (drawParamsMapped)
 				draw_option = drawParamsMapped(userData, BM_elem_index_get(efa), efa->mat_nr);
 			else
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 3b2cad6..cc68022 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2291,8 +2291,13 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
 			gridOffset += gridFaces * gridFaces * numVerts;
 		}
 
-		if (drawParams)
-			draw_option = drawParams(tf, (mcol != NULL), mat_nr);
+		if (drawParams) {
+			MTexPoly tpoly;
+			if (tf) {
+				ME_MTEXFACE_CPY(&tpoly, tf);
+			}
+			draw_option = drawParams(tf ? &tpoly : NULL, (mcol != NULL), mat_nr);
+		}
 		else if (index != ORIGINDEX_NONE)
 			draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index, mat_nr) : DM_DRAW_OPTION_NORMAL;
 		else
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 96ea5d8..35e2ca8 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -79,7 +79,7 @@ typedef struct drawMeshFaceSelect_userData {
 typedef struct drawEMTFMapped_userData {
 	BMEditMesh *em;
 	bool has_mcol;
-	bool has_mtface;
+	int cd_poly_tex_offset;
 	MFace *mf;
 	MTFace *tf;
 } drawEMTFMapped_userData;
@@ -236,11 +236,11 @@ static struct TextureDrawState {
 	bool texpaint_material; /* use material slots for texture painting */
 } Gtexdraw = {NULL, NULL, NULL, false, 0, 0, 0, false, {0, 0, 0, 0}, false, false};
 
-static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw)
+static bool set_draw_settings_cached(int clearcache, MTexPoly *texface, Material *ma, struct TextureDrawState gtexdraw)
 {
 	static Material *c_ma;
 	static int c_textured;
-	static MTFace c_texface;
+	static MTexPoly c_texface;
 	static int c_backculled;
 	static bool c_badtex;
 	static int c_lit;
@@ -264,7 +264,7 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
 
 	if (clearcache) {
 		c_textured = c_lit = c_backculled = -1;
-		memset(&c_texface, 0, sizeof(MTFace));
+		memset(&c_texface, 0, sizeof(c_texface));
 		c_badtex = false;
 		c_has_texface = -1;
 		c_ma = NULL;
@@ -534,7 +534,7 @@ static void draw_textured_end(void)
 	glPopMatrix();
 }
 
-static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mcol, int matnr)
+static DMDrawOption draw_tface__set_draw_legacy(MTexPoly *mtexpoly, const bool has_mcol, int matnr)
 {
 	Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
 	bool invalidtexture = false;
@@ -542,9 +542,9 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
 	if (ma && (ma->game.flag & GEMAT_INVISIBLE))
 		return DM_DRAW_OPTION_SKIP;
 
-	invalidtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
+	invalidtexture = set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw);
 
-	if (tface && invalidtexture) {
+	if (mtexpoly && invalidtexture) {
 		glColor3ub(0xFF, 0x00, 0xFF);
 		return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
 	}
@@ -553,7 +553,7 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
 		return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
 	}
 	else if (!has_mcol) {
-		if (tface) {
+		if (mtexpoly) {
 			glColor3f(1.0, 1.0, 1.0);
 		}
 		else {
@@ -575,14 +575,14 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
 	}
 }
 
-static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(has_mcol), int matnr)
+static DMDrawOption draw_tface__set_draw(MTexPoly *mtexpoly, const bool UNUSED(has_mcol), int matnr)
 {
 	Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
 
 	if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return DM_DRAW_OPTION_SKIP;
 
-	if (tface || Gtexdraw.is_texpaint)
-		set_draw_settings_cached(0, tface, ma, Gtexdraw);
+	if (mtexpoly || Gtexdraw.is_texpaint)
+		set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw);
 
 	/* always use color from mcol, as set in update_tface_color_layer */
 	return DM_DRAW_OPTION_NORMAL;
@@ -590,7 +590,7 @@ static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(has_mc
 
 static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
 {
-	MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE);
+	MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
 	MFace *mface = dm->getTessFaceArray(dm);
 	MCol *finalCol;
 	int i, j;
@@ -624,7 +624,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
 					finalCol[i * 4 + j].r = 255;
 				}
 		}
-		else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
+		else if (mtexpoly && set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw)) {
 			for (j = 0; j < 4; j++) {
 				finalCol[i * 4 + j].b = 255;
 				finalCol[i * 4 + j].g = 0;
@@ -639,7 +639,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
 			}
 		}
 		else if (!mcol) {
-			if (tface) {
+			if (mtexpoly) {
 				for (j = 0; j < 4; j++) {
 					finalCol[i * 4 + j].b = 255;
 					finalCol[i * 4 + j].g = 255;
@@ -691,14 +691,9 @@ static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, i
 	}
 	else {
 		MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[origindex] : NULL;
-		MTFace mtf = {{{0}}};
 		int matnr = mpoly->mat_nr;
-
-		if (tpoly) {
-			ME_MTEXFACE_CPY(&mtf, tpoly);
-		}
 		
-		return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr);
+		return draw_tface__set_draw(tpoly, (me->mloopcol != NULL), matnr);
 	}
 }
 
@@ -717,16 +712,11 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, i
 		return DM_DRAW_OPTION_SKIP;
 	}
 	else {
-		MTFace mtf = {{{0}}};
+		MTexPoly *mtexpoly = (data->cd_poly_tex_offset != -1) ?
+		        BM_ELEM_CD_GET_VOID_P(efa, data->cd_poly_tex_offset) : NULL;
 		int matnr = (mat_nr != -1) ? mat_nr : efa->mat_nr;
 
-		if (data->has_mtface) {
-			MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pda

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list