Fix T49864: EnvMap baking crashes 2.78 if 'Full Sample' checked in AA
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 May 2017 10:40:04 +0000 (12:40 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 May 2017 10:40:04 +0000 (12:40 +0200)
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/render/intern/source/envmap.c

index 89e796fb7ee6ad5fe7c82c7376b50ebb58aaae17..29332a5c8997d1888e16854602d84b4ffd5a14dd 100644 (file)
@@ -1026,15 +1026,16 @@ void IMB_exr_set_channel(void *handle, const char *layname, const char *passname
        ExrChannel *echan;
        char name[EXR_TOT_MAXNAME + 1];
 
-       if (layname) {
+       if (layname && layname[0] != '\0') {
                char lay[EXR_LAY_MAXNAME + 1], pass[EXR_PASS_MAXNAME + 1];
                BLI_strncpy(lay, layname, EXR_LAY_MAXNAME);
                BLI_strncpy(pass, passname, EXR_PASS_MAXNAME);
 
                BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass);
        }
-       else
+       else {
                BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1);
+       }
 
        echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
 
@@ -1043,8 +1044,9 @@ void IMB_exr_set_channel(void *handle, const char *layname, const char *passname
                echan->ystride = ystride;
                echan->rect = rect;
        }
-       else
+       else {
                printf("IMB_exr_set_channel error %s\n", name);
+       }
 }
 
 float  *IMB_exr_channel_rect(void *handle, const char *layname, const char *passname, const char *viewname)
index b100c4f66bc44ebce4c295909a56205be14e100c..156b42159923953dae19b0262dc55affc1316d96 100644 (file)
@@ -61,6 +61,7 @@
 #include "renderpipeline.h"
 #include "texture.h"
 #include "zbuf.h"
+#include "render_result.h"
 
 /* ------------------------------------------------------------------------- */
 
@@ -493,11 +494,18 @@ static void render_envmap(Render *re, EnvMap *env)
                env_rotate_scene(envre, tmat, 0);
 
                if (re->test_break(re->tbh) == 0) {
-                       RenderLayer *rl = envre->result->layers.first;
                        int y;
                        float *alpha;
                        float *rect;
 
+                       if (envre->result->do_exr_tile) {
+                               BLI_rw_mutex_lock(&envre->resultmutex, THREAD_LOCK_WRITE);
+                               render_result_exr_file_end(envre);
+                               BLI_rw_mutex_unlock(&envre->resultmutex);
+                       }
+
+                       RenderLayer *rl = envre->result->layers.first;
+
                        /* envmap is rendered independently of multiview  */
                        rect = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, "");
                        ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat);