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:
authorCampbell Barton <ideasman42@gmail.com>2011-09-23 22:29:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-23 22:29:45 +0400
commita189b71a28d3eddc6b85948ab1063be0a032cde4 (patch)
tree6b2d55b13122fa22ab6d4016a43399353fef6d9f /source/blender/editors/space_view3d/drawmesh.c
parent120895fd240590f428fd68dda4bb4bd5c844cfc3 (diff)
some speedup for drawing mesh in texture mode.
- only pass if the mesh has vertex colors to drawParams() rather then the mcol its self, this saves a lookup on the color. - drawing textures in editmode with no vertex colors would still lookup vertex colors on each face, instead cache this info for all faces.
Diffstat (limited to 'source/blender/editors/space_view3d/drawmesh.c')
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index b6e76885719..bf4bd7f1d93 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,7 +394,7 @@ static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
return 1; /* Set color from mcol */
}
}
-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);
@@ -404,7 +404,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 */
@@ -491,28 +491,26 @@ 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)
@@ -632,7 +630,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(faceselect) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)