[Bf-blender-cvs] [f4f5f3b] master: Addition/correction to previous commit:

Antony Riakiotakis noreply at git.blender.org
Thu Nov 27 20:13:00 CET 2014


Commit: f4f5f3b209e1f1309966ca007370225a06ef86fe
Author: Antony Riakiotakis
Date:   Thu Nov 27 20:12:46 2014 +0100
Branches: master
https://developer.blender.org/rBf4f5f3b209e1f1309966ca007370225a06ef86fe

Addition/correction to previous commit:

subsurf needs the same modifications in its derived mesh function or
materials don't get updated at all anymore.

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/editors/space_view3d/drawmesh.c

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 99164b8..da4fcb4 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -147,7 +147,7 @@ typedef int (*DMSetMaterial)(int mat_nr, void *attribs);
 typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_index);
 typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
 typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
-typedef DMDrawOption (*DMSetDrawOptionsMappedTex)(void *userData, int origindex, 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 enum DMDrawFlag {
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 5226171..7f49fc6 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -880,11 +880,11 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
 							draw_option = DM_DRAW_OPTION_NORMAL;
 						}
 						else if (drawParamsMapped) {
-							draw_option = drawParamsMapped(userData, orig, actualFace);
+							draw_option = drawParamsMapped(userData, orig, mf[actualFace].mat_nr);
 						}
 					}
 					else if (drawParamsMapped) {
-						draw_option = drawParamsMapped(userData, actualFace, actualFace);
+						draw_option = drawParamsMapped(userData, actualFace, mf[actualFace].mat_nr);
 					}
 				}
 
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 482c046..455c254 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2361,7 +2361,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
 		if (drawParams)
 			draw_option = drawParams(tf, (mcol != NULL), mat_nr);
 		else if (index != ORIGINDEX_NONE)
-			draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index, i) : DM_DRAW_OPTION_NORMAL;
+			draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index, mat_nr) : DM_DRAW_OPTION_NORMAL;
 		else
 			draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
 
@@ -2586,6 +2586,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
 	DMFlagMat *faceFlags = ccgdm->faceFlags;
 	int useColors = flag & DM_DRAW_USE_COLORS;
 	int gridFaces = gridSize - 1, totface;
+	int prev_mat_nr = -1;
 
 	CCG_key_top_level(&key, ss);
 
@@ -2626,9 +2627,16 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
 		{
 			DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
 
-			if (index == ORIGINDEX_NONE)
-				draw_option = setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1, NULL);  /* XXX, no faceFlags no material */
-			else if (setDrawOptions)
+			if (setMaterial) {
+				int mat_nr = faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1;
+				
+				if (mat_nr != prev_mat_nr) {
+					setMaterial(mat_nr, NULL);  /* XXX, no faceFlags no material */
+					prev_mat_nr = mat_nr;
+				}
+			}
+			
+			if (setDrawOptions && (index != ORIGINDEX_NONE))
 				draw_option = setDrawOptions(userData, index);
 
 			if (draw_option != DM_DRAW_OPTION_SKIP) {
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index a09dd84..408b417 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -668,7 +668,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
 	}
 }
 
-static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, int UNUSED(index))
+static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, int UNUSED(mat_nr))
 {
 	Mesh *me = ((drawTFace_userData *)userData)->me;
 
@@ -693,7 +693,7 @@ static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, i
 	}
 }
 
-static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, int index)
+static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, int mat_nr)
 {
 	drawEMTFMapped_userData *data = userData;
 	BMEditMesh *em = data->em;
@@ -709,7 +709,7 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, i
 	}
 	else {
 		MTFace mtf = {{{0}}};
-		int matnr = (data->mf) ? data->mf[index].mat_nr : efa->mat_nr;
+		int matnr = (mat_nr != -1) ? mat_nr : efa->mat_nr;
 
 		if (data->has_mtface) {
 			MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);




More information about the Bf-blender-cvs mailing list