Commit: e073a0aa0791a6ce69be4252e6673596d1a54a6d
Author: Lukas Stockner
Date:   Sun Jun 4 00:58:38 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBe073a0aa0791a6ce69be4252e6673596d1a54a6d

Fix T51587: Blender fails to interpret a specific layer in OpenEXR multilayer 
file

===================================================================

M       source/blender/compositor/nodes/COM_ImageNode.cpp
M       source/blender/nodes/composite/nodes/node_composite_image.c

===================================================================

diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp 
b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 462947f32a3..81891d853d2 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -99,6 +99,11 @@ void ImageNode::convertToOperations(NodeConverter 
&converter, const CompositorCo
                                        RenderPass *rpass = (RenderPass 
*)BLI_findstring(&rl->passes, storage->pass_name, offsetof(RenderPass, name));
                                        int view = 0;
 
+                                       if (STREQ(storage->pass_name, 
RE_PASSNAME_COMBINED) && STREQ(bnodeSocket->name, "Alpha")) {
+                                               /* Alpha output is already 
handled with the associated combined output. */
+                                               continue;
+                                       }
+
                                        /* returns the image view to use for 
the current active view */
                                        if 
(BLI_listbase_count_ex(&image->rr->views, 2) > 1) {
                                                const int view_image = 
imageuser->view;
@@ -140,16 +145,24 @@ void ImageNode::convertToOperations(NodeConverter 
&converter, const CompositorCo
                                                        
converter.addPreview(operation->getOutputSocket());
                                                }
                                                if (STREQ(rpass->name, 
RE_PASSNAME_COMBINED)) {
-                                                       BLI_assert(operation != 
NULL);
-                                                       BLI_assert(index < 
numberOfOutputs - 1);
-                                                       NodeOutput 
*outputSocket = this->getOutputSocket(index + 1);
-                                                       
SeparateChannelOperation *separate_operation;
-                                                       separate_operation = 
new SeparateChannelOperation();
-                                                       
separate_operation->setChannel(3);
-                                                       
converter.addOperation(separate_operation);
-                                                       
converter.addLink(operation->getOutputSocket(), 
separate_operation->getInputSocket(0));
-                                                       
converter.mapOutputSocket(outputSocket, separate_operation->getOutputSocket());
-                                                       index++;
+                                                       for (int alphaIndex = 
0; alphaIndex < numberOfOutputs; alphaIndex++) {
+                                                               NodeOutput 
*alphaSocket = this->getOutputSocket(alphaIndex);
+                                                               bNodeSocket 
*bnodeAlphaSocket = alphaSocket->getbNodeSocket();
+                                                               if 
(!STREQ(bnodeAlphaSocket->name, "Alpha")) {
+                                                                       
continue;
+                                                               }
+                                                               NodeImageLayer 
*alphaStorage = (NodeImageLayer *)bnodeSocket->storage;
+                                                               if 
(!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) {
+                                                                       
continue;
+                                                               }
+                                                               
SeparateChannelOperation *separate_operation;
+                                                               
separate_operation = new SeparateChannelOperation();
+                                                               
separate_operation->setChannel(3);
+                                                               
converter.addOperation(separate_operation);
+                                                               
converter.addLink(operation->getOutputSocket(), 
separate_operation->getInputSocket(0));
+                                                               
converter.mapOutputSocket(alphaSocket, separate_operation->getOutputSocket());
+                                                               break;
+                                                       }
                                                }
                                        }
 
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c 
b/source/blender/nodes/composite/nodes/node_composite_image.c
index e958ab9a3dc..a95a99449fd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -116,6 +116,10 @@ static void cmp_node_image_add_pass_output(bNodeTree 
*ntree, bNode *node,
        }
        else {
                sock = BLI_findlink(&node->outputs, sock_index);
+               NodeImageLayer *sockdata = sock->storage;
+               if(sockdata) {
+                       BLI_strncpy(sockdata->pass_name, passname, 
sizeof(sockdata->pass_name));
+               }
        }
 
        BLI_linklist_append(available_sockets, sock);
@@ -158,14 +162,11 @@ static void cmp_node_image_create_outputs(bNodeTree 
*ntree, bNode *node, LinkNod
                                        else
                                                type = SOCK_RGBA;
 
+                                       cmp_node_image_add_pass_output(ntree, 
node, rpass->name, rpass->name, -1, type, false, available_sockets, 
&prev_index);
                                        /* Special handling for the Combined 
pass to ensure compatibility. */
                                        if (STREQ(rpass->name, 
RE_PASSNAME_COMBINED)) {
-                                               
cmp_node_image_add_pass_output(ntree, node, "Image", rpass->name, -1, type, 
false, available_sockets, &prev_index);
                                                
cmp_node_image_add_pass_output(ntree, node, "Alpha", rpass->name, -1, 
SOCK_FLOAT, false, available_sockets, &prev_index);
                                        }
-                                       else {
-                                               
cmp_node_image_add_pass_output(ntree, node, rpass->name, rpass->name, -1, type, 
false, available_sockets, &prev_index);
-                                       }
                                }
                                BKE_image_release_ibuf(ima, ibuf, NULL);
                                return;
@@ -173,13 +174,10 @@ static void cmp_node_image_create_outputs(bNodeTree 
*ntree, bNode *node, LinkNod
                }
        }
 
-       cmp_node_image_add_pass_output(ntree, node, "Image", 
RE_PASSNAME_COMBINED, RRES_OUT_IMAGE, SOCK_RGBA, false, available_sockets, 
&prev_index);
-       cmp_node_image_add_pass_output(ntree, node, "Alpha", 
RE_PASSNAME_COMBINED, RRES_OUT_ALPHA, SOCK_FLOAT, false, available_sockets, 
&prev_index);
+       cmp_node_image_add_pass_output(ntree, node, "Image", 
RE_PASSNAME_COMBINED, -1, SOCK_RGBA, false, available_sockets, &prev_index);
+       cmp_node_image_add_pass_output(ntree, node, "Alpha", 
RE_PASSNAME_COMBINED, -1, SOCK_FLOAT, false, available_sockets, &prev_index);
 
        if (ima) {
-               if (!ima->rr) {
-                       cmp_node_image_add_pass_output(ntree, node, 
RE_PASSNAME_Z, RE_PASSNAME_Z, RRES_OUT_Z, SOCK_FLOAT, false, available_sockets, 
&prev_index);
-               }
                BKE_image_release_ibuf(ima, ibuf, NULL);
        }
 }
@@ -276,7 +274,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, 
bNode *node, bool rl
                        for (link = ntree->links.first; link; link = 
link->next) {
                                if (link->fromsock == sock) break;
                        }
-                       if (!link && sock_index > 30) {
+                       if (!link && (!rlayer || sock_index > 30)) {
                                MEM_freeN(sock->storage);
                                nodeRemoveSocket(ntree, node, sock);
                        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to