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:
authorMiika Hamalainen <blender@miikah.org>2011-10-04 15:42:44 +0400
committerMiika Hamalainen <blender@miikah.org>2011-10-04 15:42:44 +0400
commite8bb972f3c04b00f6e813b61332c53213c12e8c4 (patch)
tree5d05e7c8421c5af4e034ff3a01ebe34a2d94b9ec /source/blender/editors/space_view3d/drawmesh.c
parent9e9b26b8ba54227f79f97acc87893611d61b9831 (diff)
parent019dca9c54289136b34c688a048ee009e2e852ee (diff)
Merge with trunk r40782
Diffstat (limited to 'source/blender/editors/space_view3d/drawmesh.c')
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index f827d9323ac..adfae71b5ad 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -362,7 +362,7 @@ static void draw_textured_end(void)
glPopMatrix();
}
-static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
+static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
{
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
int validtexture=0;
@@ -377,7 +377,7 @@ static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
} else if (ma && ma->shade_flag&MA_OBCOLOR) {
glColor3ubv(Gtexdraw.obcol);
return 2; /* Don't set color */
- } else if (!mcol) {
+ } else if (!has_mcol) {
if (tface) glColor3f(1.0, 1.0, 1.0);
else {
if(ma) {
@@ -394,12 +394,14 @@ static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
return 1; /* Set color from mcol */
}
}
+
static int draw_mcol__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
{
if (mcol) return 1;
else return 2;
}
-static int draw_tface__set_draw(MTFace *tface, MCol *mcol, int matnr)
+
+static int draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
{
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
@@ -409,7 +411,7 @@ static int draw_tface__set_draw(MTFace *tface, MCol *mcol, int matnr)
return 2; /* Don't set color */
} else if (tface && tface->mode&TF_OBCOL) {
return 2; /* Don't set color */
- } else if (!mcol) {
+ } else if (!has_mcol) {
return 1; /* Don't set color */
} else {
return 1; /* Set color from mcol */
@@ -496,38 +498,34 @@ static int draw_tface_mapped__set_draw(void *userData, int index)
Mesh *me = (Mesh*)userData;
MTFace *tface = (me->mtface)? &me->mtface[index]: NULL;
MFace *mface = &me->mface[index];
- MCol *mcol = (me->mcol)? &me->mcol[index]: NULL;
const int matnr = mface->mat_nr;
if (mface->flag & ME_HIDE) return 0;
- return draw_tface__set_draw(tface, mcol, matnr);
+ return draw_tface__set_draw(tface, (me->mcol != NULL), matnr);
}
static int draw_em_tf_mapped__set_draw(void *userData, int index)
{
- EditMesh *em = userData;
+ struct {EditMesh *em; short has_mcol; short has_mtface;} *data = userData;
+ EditMesh *em = data->em;
EditFace *efa= EM_get_face_for_index(index);
MTFace *tface;
- MCol *mcol;
int matnr;
if (efa->h)
return 0;
- tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
+ tface = data->has_mtface ? CustomData_em_get(&em->fdata, efa->data, CD_MTFACE) : NULL;
matnr = efa->mat_nr;
- return draw_tface__set_draw_legacy(tface, mcol, matnr);
+ return draw_tface__set_draw_legacy(tface, data->has_mcol, matnr);
}
static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r)
{
Mesh *me = (Mesh*)userData;
- if (me->mface) {
- short matnr= me->mface[index].mat_nr;
- Material *ma= me->mat[matnr];
-
+ if (me->mat && me->mface) {
+ Material *ma= me->mat[me->mface[index].mat_nr];
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) {
return 0;
}
@@ -637,7 +635,13 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
glColor4f(1.0f,1.0f,1.0f,1.0f);
if(ob->mode & OB_MODE_EDIT) {
- dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
+ struct {EditMesh *em; short has_mcol; short has_mtface;} data;
+
+ data.em= me->edit_mesh;
+ data.has_mcol= CustomData_has_layer(&me->edit_mesh->fdata, CD_MCOL);
+ data.has_mtface= CustomData_has_layer(&me->edit_mesh->fdata, CD_MTFACE);
+
+ dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, &data);
}
else if(draw_flags & DRAW_IS_PAINT_SEL) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)