[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50730] trunk/blender/source/blender: Fix #31539, painting in image editor while in object mode does not update mipmaps.

Antony Riakiotakis kalast at gmail.com
Tue Sep 18 17:58:07 CEST 2012


Revision: 50730
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50730
Author:   psy-fi
Date:     2012-09-18 15:58:07 +0000 (Tue, 18 Sep 2012)
Log Message:
-----------
Fix #31539, painting in image editor while in object mode does not update mipmaps. 

While we could disable/enable mipmaps on stroke begin/end, it is a bit hacky (but worthy of consideration for later) for my taste just to paint in the image editor. Instead we generate mipmaps on the fly. Since we can update texture levels below the first only with GPU mipmapping, partial update when painting in the image editor will actually work only with GPU mipmapping from now on (which is fast enough I hope not to get any lags!).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/gpu/GPU_draw.h
    trunk/blender/source/blender/gpu/intern/gpu_draw.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2012-09-18 15:13:45 UTC (rev 50729)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2012-09-18 15:58:07 UTC (rev 50730)
@@ -4265,7 +4265,7 @@
 		int w = imapaintpartial.x2 - imapaintpartial.x1;
 		int h = imapaintpartial.y2 - imapaintpartial.y1;
 		/* Testing with partial update in uv editor too */
-		GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint);
+		GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); //!texpaint);
 	}
 }
 

Modified: trunk/blender/source/blender/gpu/GPU_draw.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_draw.h	2012-09-18 15:13:45 UTC (rev 50729)
+++ trunk/blender/source/blender/gpu/GPU_draw.h	2012-09-18 15:58:07 UTC (rev 50730)
@@ -119,7 +119,7 @@
 /* Image updates and free
  * - these deal with images bound as opengl textures */
 
-void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int mipmap);
+void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
 void GPU_update_images_framechange(void);
 int GPU_update_image_time(struct Image *ima, double time);
 int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int ncd);

Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c	2012-09-18 15:13:45 UTC (rev 50729)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c	2012-09-18 15:58:07 UTC (rev 50730)
@@ -878,13 +878,13 @@
 	}
 }
 
-void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
+void GPU_paint_update_image(Image *ima, int x, int y, int w, int h)
 {
 	ImBuf *ibuf;
 	
 	ibuf = BKE_image_get_ibuf(ima, NULL);
 	
-	if (ima->repbind || (GPU_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
+	if (ima->repbind || (GPU_get_mipmap() && !GTS.gpu_mipmap) || !ima->bindcode || !ibuf ||
 	    (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
 	    (w == 0) || (h == 0))
 	{
@@ -911,8 +911,13 @@
 
 			MEM_freeN(buffer);
 
-			if (ima->tpageflag & IMA_MIPMAP_COMPLETE)
+			/* we have already accounted for the case where GTS.gpu_mipmap is false
+			 * so we will be using GPU mipmap generation here */
+			if (GPU_get_mipmap()) {
+				glGenerateMipmapEXT(GL_TEXTURE_2D);
+			} else {
 				ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+			}
 
 			return;
 		}
@@ -934,8 +939,12 @@
 		glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
 		glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
 
-		if (ima->tpageflag & IMA_MIPMAP_COMPLETE)
+		/* see comment above as to why we are using gpu mipmap generation here */
+		if (GPU_get_mipmap()) {
+			glGenerateMipmapEXT(GL_TEXTURE_2D);
+		} else {
 			ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+		}
 	}
 }
 




More information about the Bf-blender-cvs mailing list