[Bf-blender-cvs] [d653c70] master: Bake API: force opengl reload and mipmap recalc (fix T40055)

Dalai Felinto noreply at git.blender.org
Wed May 7 00:32:01 CEST 2014


Commit: d653c70ee65856d74aaa1712b52b51b62e7c527c
Author: Dalai Felinto
Date:   Tue May 6 19:12:31 2014 -0300
https://developer.blender.org/rBd653c70ee65856d74aaa1712b52b51b62e7c527c

Bake API: force opengl reload and mipmap recalc (fix T40055)

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

M	source/blender/editors/object/object_bake_api.c

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

diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 17f323b..72adc6c 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -69,6 +69,7 @@
 #include "ED_screen.h"
 #include "ED_uvedit.h"
 
+#include "GPU_draw.h"
 
 #include "object_intern.h"
 
@@ -175,6 +176,12 @@ static bool write_internal_bake_pixels(
 	if (ibuf->rect_float)
 		ibuf->userflags |= IB_RECT_INVALID;
 
+	/* force mipmap recalc */
+	if (ibuf->mipmap[0]) {
+		ibuf->userflags |= IB_MIPMAP_INVALID;
+		imb_freemipmapImBuf(ibuf);
+	}
+
 	BKE_image_release_ibuf(image, ibuf, NULL);
 
 	if (mask_buffer)
@@ -183,6 +190,18 @@ static bool write_internal_bake_pixels(
 	return true;
 }
 
+/* force OpenGL reload */
+static void reset_images_gpu(BakeImages *bake_images)
+{
+	int i;
+	for (i = 0; i < bake_images->size; i++) {
+		Image *ima = bake_images->data[i].image;
+		if (ima->ok == IMA_OK_LOADED) {
+			GPU_free_image(ima);
+		}
+	}
+}
+
 static bool write_external_bake_pixels(
         const char *filepath, BakePixel pixel_array[], float *buffer,
         const int width, const int height, const int margin,
@@ -793,6 +812,8 @@ static int bake(
 		}
 	}
 
+	if (is_save_internal)
+		reset_images_gpu(&bake_images);
 
 cleanup:




More information about the Bf-blender-cvs mailing list