[Bf-blender-cvs] [c08ef9c] blender-v2.73-release: Fix T43208 material flickering in edit mode.

Antony Riakiotakis noreply at git.blender.org
Tue Jan 20 10:23:29 CET 2015


Commit: c08ef9c62ad74e2c223831c2cd03f1b67d91a8ff
Author: Antony Riakiotakis
Date:   Sun Jan 11 21:28:30 2015 +0100
Branches: blender-v2.73-release
https://developer.blender.org/rBc08ef9c62ad74e2c223831c2cd03f1b67d91a8ff

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.

===================================================================

M	source/blender/blenkernel/intern/editderivedmesh.c
M	source/blender/editors/space_view3d/drawobject.c

===================================================================

diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 9168954..6294b49 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -56,7 +56,6 @@
 #include "MEM_guardedalloc.h"
 
 #include "GPU_extensions.h"
-#include "GPU_draw.h"
 #include "GPU_glew.h"
 
 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)));
 			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 */
-				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 (poly_prev != GL_ZERO) glEnd();
@@ -609,16 +609,17 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
 			int drawSmooth;
 
 			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 ?
-			               DM_DRAW_OPTION_NORMAL :
-			               setDrawOptions(userData, BM_elem_index_get(efa)));
+			draw_option = (setDrawOptions ?
+			                   setDrawOptions(userData, BM_elem_index_get(efa)) :
+			                   DM_DRAW_OPTION_NORMAL);
 
 			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 */
 
-				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 */
 
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 6c2d9db..55b621d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7978,7 +7978,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
 	cpack(0);
 
 	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)) {
 			glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
@@ -7990,7 +7990,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
 
 	}
 	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);
 
 	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
-		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);
 }




More information about the Bf-blender-cvs mailing list