Fix T43208 material flickering in edit mode.

Happens because material setting now occurs in the derived mesh drawing
routine as it should. However that means that it also happens during
selection and that influenced the drawing state somehow.

In 2.72 this did not occur because material setting happened during draw
setting (skip or draw) instead of after the draw setting passed (so
selection would skip it by use another draw setting function). Of course
this violated design but worked.

Made it now so backbuffer selection does not enable materials (it's
redundant in those cases anyway).

This could be ported to a possible 'a' release but as is classic with
display code there may be some other places that it could backfire.

Tested fix with texture/vertex painting and selection which use
backbuffer for both subsurf and regular meshes and it seems to work OK.
This commit is contained in:
Antony Riakiotakis 2015-01-11 21:28:30 +01:00
parent 0a5ad65512
commit 1864253db0
2 changed files with 12 additions and 11 deletions

@ -56,7 +56,6 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "GPU_extensions.h" #include "GPU_extensions.h"
#include "GPU_draw.h"
#include "GPU_glew.h" #include "GPU_glew.h"
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */ extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
@ -527,7 +526,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
setDrawOptions(userData, BM_elem_index_get(efa))); setDrawOptions(userData, BM_elem_index_get(efa)));
if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option != DM_DRAW_OPTION_SKIP) {
const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */
GPU_enable_material(efa->mat_nr + 1, NULL); if (setMaterial)
setMaterial(efa->mat_nr + 1, NULL);
if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */
if (poly_prev != GL_ZERO) glEnd(); if (poly_prev != GL_ZERO) glEnd();
@ -611,14 +611,15 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
efa = ltri[0]->f; efa = ltri[0]->f;
drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH)); drawSmooth = lnors || ((flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH));
draw_option = (!setDrawOptions ? draw_option = (setDrawOptions ?
DM_DRAW_OPTION_NORMAL : setDrawOptions(userData, BM_elem_index_get(efa)) :
setDrawOptions(userData, BM_elem_index_get(efa))); DM_DRAW_OPTION_NORMAL);
if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option != DM_DRAW_OPTION_SKIP) {
const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */
GPU_enable_material(efa->mat_nr + 1, NULL); if (setMaterial)
setMaterial(efa->mat_nr + 1, NULL);
if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */

@ -7978,7 +7978,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
cpack(0); cpack(0);
if (use_faceselect) { if (use_faceselect) {
dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, GPU_enable_material, NULL, em->bm, 0); dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, NULL, NULL, em->bm, 0);
if (check_ob_drawface_dot(scene, v3d, ob->dt)) { if (check_ob_drawface_dot(scene, v3d, ob->dt)) {
glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE)); glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
@ -7990,7 +7990,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
} }
else { else {
dm->drawMappedFaces(dm, bbs_mesh_mask__setSolidDrawOptions, GPU_enable_material, NULL, em->bm, 0); dm->drawMappedFaces(dm, bbs_mesh_mask__setSolidDrawOptions, NULL, NULL, em->bm, 0);
} }
} }
@ -8051,9 +8051,9 @@ static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
DM_update_materials(dm, ob); DM_update_materials(dm, ob);
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) if ((me->editflag & ME_EDIT_PAINT_FACE_SEL))
dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, GPU_enable_material, NULL, me, 0); dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, NULL, NULL, me, 0);
else else
dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, GPU_enable_material, NULL, me, 0); dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, NULL, NULL, me, 0);
dm->release(dm); dm->release(dm);
} }