Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_image / image_ops.c
index be91f7abf99bc0ded10883529557b3f3eb2da3b4..c42f17f2700d03fc18cd4e391d8aa390050a5179 100644 (file)
@@ -1859,6 +1859,8 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                rr = BKE_image_acquire_renderresult(scene, ima);
                bool is_mono = rr ? BLI_listbase_count_at_most(&rr->views, 2) < 2 : BLI_listbase_count_at_most(&ima->views, 2) < 2;
                bool is_exr_rr = rr && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) && RE_HasFloatPixels(rr);
+               bool is_multilayer = is_exr_rr && (imf->imtype == R_IMF_IMTYPE_MULTILAYER);
+               int layer = (is_multilayer) ? -1 : sima->iuser.layer;
 
                /* error handling */
                if (!rr) {
@@ -1890,14 +1892,14 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                /* fancy multiview OpenEXR */
                if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
                        /* save render result */
-                       ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, sima->iuser.layer);
+                       ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                        save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
                        ED_space_image_release_buffer(sima, ibuf, lock);
                }
                /* regular mono pipeline */
                else if (is_mono) {
                        if (is_exr_rr) {
-                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1);
+                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                        }
                        else {
                                colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
@@ -1925,7 +1927,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
 
                                if (is_exr_rr) {
                                        BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath);
-                                       ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, -1);
+                                       ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, layer);
                                        save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
                                }
                                else {
@@ -1960,7 +1962,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
                /* stereo (multiview) images */
                else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
                        if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
-                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1);
+                               ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
                                save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
                                ED_space_image_release_buffer(sima, ibuf, lock);
                        }