[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60259] trunk/blender/source/blender/ editors/object/object_bake.c: Images didn' t get clear when using multires baker from python script

Sergey Sharybin sergey.vfx at gmail.com
Fri Sep 20 12:14:58 CEST 2013


Revision: 60259
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60259
Author:   nazgul
Date:     2013-09-20 10:14:58 +0000 (Fri, 20 Sep 2013)
Log Message:
-----------
Images didn't get clear when using multires baker from python script

Seems to be a regression since BMesh merge.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_bake.c

Modified: trunk/blender/source/blender/editors/object/object_bake.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_bake.c	2013-09-20 10:14:54 UTC (rev 60258)
+++ trunk/blender/source/blender/editors/object/object_bake.c	2013-09-20 10:14:58 UTC (rev 60259)
@@ -269,9 +269,8 @@
 } ClearFlag;
 
 
-static void clear_images(MTFace *mtface, int totface, ClearFlag flag)
+static void clear_single_image(Image *image, ClearFlag flag)
 {
-	int a;
 	const float vec_alpha[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 	const float vec_solid[4] = {0.0f, 0.0f, 0.0f, 1.0f};
 	const float nor_alpha[4] = {0.5f, 0.5f, 1.0f, 0.0f};
@@ -279,30 +278,54 @@
 	const float disp_alpha[4] = {0.5f, 0.5f, 0.5f, 0.0f};
 	const float disp_solid[4] = {0.5f, 0.5f, 0.5f, 1.0f};
 
-	for (a = 0; a < totface; a++)
+	if ((image->id.flag & LIB_DOIT) == 0) {
+		ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
+
+		if (flag == CLEAR_TANGENT_NORMAL)
+			IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
+		else if (flag == CLEAR_DISPLACEMENT)
+			IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid);
+		else
+			IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+
+		image->id.flag |= LIB_DOIT;
+
+		BKE_image_release_ibuf(image, ibuf, NULL);
+	}
+}
+
+static void clear_images(MTFace *mtface, int totface, ClearFlag flag)
+{
+	int a;
+
+	for (a = 0; a < totface; a++) {
 		mtface[a].tpage->id.flag &= ~LIB_DOIT;
+	}
 
 	for (a = 0; a < totface; a++) {
-		Image *ima = mtface[a].tpage;
+		clear_single_image(mtface[a].tpage, flag);
+	}
 
-		if ((ima->id.flag & LIB_DOIT) == 0) {
-			ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
+	for (a = 0; a < totface; a++) {
+		mtface[a].tpage->id.flag &= ~LIB_DOIT;
+	}
+}
 
-			if (flag == CLEAR_TANGENT_NORMAL)
-				IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
-			else if (flag == CLEAR_DISPLACEMENT)
-				IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid);
-			else
-				IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+static void clear_images_poly(MTexPoly *mtpoly, int totpoly, ClearFlag flag)
+{
+	int a;
 
-			ima->id.flag |= LIB_DOIT;
+	for (a = 0; a < totpoly; a++) {
+		mtpoly[a].tpage->id.flag &= ~LIB_DOIT;
+	}
 
-			BKE_image_release_ibuf(ima, ibuf, NULL);
-		}
+	for (a = 0; a < totpoly; a++) {
+		clear_single_image(mtpoly[a].tpage, flag);
 	}
 
-	for (a = 0; a < totface; a++)
-		mtface[a].tpage->id.flag &= ~LIB_DOIT;
+	for (a = 0; a < totpoly; a++) {
+		mtpoly[a].tpage->id.flag &= ~LIB_DOIT;
+	}
 }
 
 static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
@@ -331,6 +354,7 @@
 			}
 
 			clear_images(me->mtface, me->totface, clear_flag);
+			clear_images_poly(me->mtpoly, me->totpoly, clear_flag);
 		}
 		CTX_DATA_END;
 	}




More information about the Bf-blender-cvs mailing list