diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-09-20 14:14:58 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-09-20 14:14:58 +0400 |
commit | 6ca12765e331a3403f8bf3f6a0c94db99937c790 (patch) | |
tree | c38539582175c6eddf4036b16058ddd0f94f0477 /source/blender/editors/object/object_bake.c | |
parent | 7617eadae43f8b21b8dc327515af54639b66c9b3 (diff) |
Images didn't get clear when using multires baker from python script
Seems to be a regression since BMesh merge.
Diffstat (limited to 'source/blender/editors/object/object_bake.c')
-rw-r--r-- | source/blender/editors/object/object_bake.c | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 6b169d2342c..376f2ed294b 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -269,9 +269,8 @@ typedef enum ClearFlag { } 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 @@ static void clear_images(MTFace *mtface, int totface, ClearFlag flag) 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 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) } clear_images(me->mtface, me->totface, clear_flag); + clear_images_poly(me->mtpoly, me->totpoly, clear_flag); } CTX_DATA_END; } |