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:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-12-01 16:12:39 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-12-01 16:12:39 +0400
commitf6f7e270e30946d0bb3ea4d5c556c994125e590f (patch)
tree4e77f43a26d834d0eed6917ec20bfa1bdb6d9902 /source/blender/editors/space_view3d/drawmesh.c
parentc74f6a51b66485eb2158ad1efc79be1eca5c5949 (diff)
Slight refactor of VBO code to deal with multiple textures.
Added compareDrawSettings callback to driver mesh's callbacks which are drawing textured faces (mapped and not mapped). This new callback checks if two faces are drawing with the same settings (testures, shading etc) and if they not, flush of faces happens into ogl using glDrawArrays and next face would be drawn with it's own settings. Currently implemented compareDrawSettings is used to resolve issue from bug report only, probably there are extra places where this callback is needed, but haven't seen configuration where current logic will fail, so it should be ok. Also reordered arguments passing to drawMappedFaces DM's callbacks, so now all drawing callback are accepting list of callbacks and then userData, instead of using mixed order of callbacks and userData which was a bit confusing to work with. This commit fixes: - #26410: VBO & multitexture doesnt work - #29464: VBO enabled causes UV coruption
Diffstat (limited to 'source/blender/editors/space_view3d/drawmesh.c')
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 1bc55b8d73f..690694cb7d9 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -180,7 +180,7 @@ static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* dull unselected faces so as not to get in the way of seeing color */
glColor4ub(96, 96, 96, 64);
- dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, (void*)me);
+ dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, (void*)me);
glDisable(GL_BLEND);
}
@@ -629,6 +629,21 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
ddm->release(ddm);
}
+static int compareDrawOptions(void *userData, int cur_index, int next_index)
+{
+ Mesh *me= (Mesh*) userData;
+ MFace *mf= CustomData_get_layer(&me->fdata, CD_MFACE);
+ MTFace *tf= CustomData_get_layer(&me->fdata, CD_MTFACE);
+
+ if(mf[cur_index].mat_nr != mf[next_index].mat_nr)
+ return 0;
+
+ if(tf[cur_index].tpage != tf[next_index].tpage)
+ return 0;
+
+ return 1;
+}
+
void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
{
Mesh *me= ob->data;
@@ -649,26 +664,26 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
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);
+ dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, NULL, &data);
}
else if(draw_flags & DRAW_FACE_SELECT) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me, 1);
else
- dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me);
+ dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, NULL, me);
}
else {
if(GPU_buffer_legacy(dm)) {
if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)
- dm->drawFacesTex(dm, draw_mcol__set_draw_legacy);
+ dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL);
else
- dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
+ dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL);
}
else {
if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL))
add_tface_color_layer(dm);
- dm->drawFacesTex(dm, draw_tface__set_draw);
+ dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, ob->data);
}
}
@@ -806,7 +821,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
int useColors= 1;
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions,
- ob->data, useColors, GPU_enable_material, NULL);
+ GPU_enable_material, NULL, ob->data, useColors);
}
else {
Mesh *me= ob->data;