Addition/correction to previous commit:

subsurf needs the same modifications in its derived mesh function or
materials don't get updated at all anymore.
This commit is contained in:
Antony Riakiotakis
2014-11-27 20:12:46 +01:00
parent 2e8ba179f7
commit f4f5f3b209
4 changed files with 18 additions and 10 deletions

View File

@@ -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 {

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -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);