[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45517] trunk/blender/source/blender/ editors/space_view3d/drawmesh.c: Fix #30874: Single texture display in Edit Mode

Sergey Sharybin sergey.vfx at gmail.com
Tue Apr 10 18:28:27 CEST 2012


Revision: 45517
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45517
Author:   nazgul
Date:     2012-04-10 16:28:26 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
Fix #30874: Single texture display in Edit Mode

It was a regression since 2.62 caused by how texface is passing to drawParamsMapped
Previously it was used from CD layer but now it's getting copied from MexPoly
into a variable allocated in stack for function void emDM_drawFacesTex_common.

To set texture needed to draw particular face function set_draw_settings_cached
is used, which tries to not to copy texture into GPU when it's not needed (for
example, when drawing bunch of faces with the same texture) and one of condition
if texture should be updated in GPU was comparing address of texface passed to
this function and cached texface. But this address are exactly the sane and
points to a memory inside stack of emDM_drawFacesTex_common.

Fixed by cacheing texface content, not it's address.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawmesh.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawmesh.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawmesh.c	2012-04-10 15:56:33 UTC (rev 45516)
+++ trunk/blender/source/blender/editors/space_view3d/drawmesh.c	2012-04-10 16:28:26 UTC (rev 45517)
@@ -242,21 +242,25 @@
 {
 	static Material *c_ma;
 	static int c_textured;
-	static MTFace *c_texface;
+	static MTFace c_texface;
 	static int c_backculled;
 	static int c_badtex;
 	static int c_lit;
+	static int c_has_texface;
 
 	Object *litob = NULL; //to get mode to turn off mipmap in painting mode
 	int backculled = GEMAT_BACKCULL;
 	int alphablend = 0;
 	int textured = 0;
 	int lit = 0;
-	
+	int has_texface = texface != NULL;
+	int need_set_tpage = FALSE;
+
 	if (clearcache) {
 		c_textured = c_lit = c_backculled = -1;
-		c_texface = (MTFace *) -1;
+		memset(&c_texface, 0, sizeof(MTFace));
 		c_badtex = 0;
+		c_has_texface = -1;
 	}
 	else {
 		textured = gtexdraw.istex;
@@ -290,7 +294,12 @@
 		c_backculled = backculled;
 	}
 
-	if (textured != c_textured || texface != c_texface) {
+	/* need to re-set tpage if textured flag changed or existsment of texface changed..  */
+	need_set_tpage = textured != c_textured || has_texface != c_has_texface;
+	/* ..or if settings inside texface were changed (if texface was used) */
+	need_set_tpage |= texface && memcmp(&c_texface, texface, sizeof(c_texface));
+
+	if (need_set_tpage) {
 		if (textured) {
 			c_badtex = !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT), alphablend);
 		}
@@ -299,7 +308,9 @@
 			c_badtex = 0;
 		}
 		c_textured = textured;
-		c_texface = texface;
+		c_has_texface = has_texface;
+		if (texface)
+			memcpy(&c_texface, texface, sizeof(c_texface));
 	}
 
 	if (c_badtex) lit = 0;




More information about the Bf-blender-cvs mailing list