Fixed missing display buffer and mipmaps invalidation in cases only

few of selected objects failed to bake.
This commit is contained in:
Sergey Sharybin
2012-10-14 06:59:01 +00:00
parent 643f331cb5
commit 76e2706b30
3 changed files with 17 additions and 13 deletions

View File

@@ -900,7 +900,7 @@ static void finish_images(MultiresBakeRender *bkr)
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;;
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
if (ibuf->rect_float)
ibuf->userflags |= IB_RECT_INVALID;
@@ -1366,20 +1366,23 @@ static void finish_bake_internal(BakeRender *bkr)
if (bkr->prev_r_raytrace == 0)
bkr->scene->r.mode &= ~R_RAYTRACE;
/* force OpenGL reload and mipmap recalc */
for (ima = G.main->image.first; ima; ima = ima->id.next) {
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
if (bkr->result == BAKE_RESULT_OK) {
if (ima->ok == IMA_OK_LOADED) {
if (ibuf) {
if (ibuf->userflags & IB_BITMAPDIRTY) {
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
GPU_free_image(ima);
imb_freemipmapImBuf(ibuf);
}
/* some of the images could have been changed during bake,
* so recreate mipmaps regardless bake result status
*/
if (ima->ok == IMA_OK_LOADED) {
if (ibuf) {
if (ibuf->userflags & IB_BITMAPDIRTY) {
GPU_free_image(ima);
imb_freemipmapImBuf(ibuf);
}
/* invalidate display buffers for changed images */
if (ibuf->userflags & IB_BITMAPDIRTY)
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
}

View File

@@ -1822,7 +1822,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
if (global_tot_display)
ibuf->display_buffer_flags = MEM_callocN(sizeof(unsigned int) * global_tot_display, "imbuf display_buffer_flags");
}
else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
/* all display buffers were marked as invalid from other areas,
* now propagate this flag to internal color management routines
*/

View File

@@ -2513,7 +2513,9 @@ static int get_next_bake_face(BakeShade *bs)
/* clear image */
if (R.r.bake_flag & R_BAKE_CLEAR)
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
/* might be read by UI to set active image for display */
R.bakebuf= ima;
}
@@ -2733,7 +2735,6 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, re->r.bake_filter);
ibuf->userflags |= IB_BITMAPDIRTY;
if (ibuf->rect_float) IMB_rect_from_float(ibuf);
}
}