Commit: 34ca8fe82a3a5fbd339d2292f2cc3599673a0c23
Author: Lukas Tönne
Date:   Thu May 29 10:00:21 2014 +0200
https://developer.blender.org/rB34ca8fe82a3a5fbd339d2292f2cc3599673a0c23

Fix T40414: Multiple input nodes in a group not working.

A node group can have multiple input nodes. In the compositor that means
each of the input sockets has to be connected to the linked outputs,
which is represented by a single link on the outside of the group.

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

M       source/blender/compositor/intern/COM_NodeGraph.cpp
M       source/blender/compositor/intern/COM_NodeGraph.h

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

diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp 
b/source/blender/compositor/intern/COM_NodeGraph.cpp
index 5c3de84..21b8879 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -146,17 +146,19 @@ void NodeGraph::add_bNode(const CompositorContext 
&context, bNodeTree *b_ntree,
        }
 }
 
-NodeInput *NodeGraph::find_input(const NodeRange &node_range, bNodeSocket 
*b_socket)
+NodeGraph::NodeInputs NodeGraph::find_inputs(const NodeRange &node_range, 
bNodeSocket *b_socket)
 {
+       NodeInputs result;
        for (NodeGraph::NodeIterator it = node_range.first; it != 
node_range.second; ++it) {
                Node *node = *it;
                for (int index = 0; index < node->getNumberOfInputSockets(); 
index++) {
                        NodeInput *input = node->getInputSocket(index);
-                       if (input->getbNodeSocket() == b_socket)
-                               return input;
+                       if (input->getbNodeSocket() == b_socket) {
+                               result.push_back(input);
+                       }
                }
        }
-       return NULL;
+       return result;
 }
 
 NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket 
*b_socket)
@@ -165,8 +167,9 @@ NodeOutput *NodeGraph::find_output(const NodeRange 
&node_range, bNodeSocket *b_s
                Node *node = *it;
                for (int index = 0; index < node->getNumberOfOutputSockets(); 
index++) {
                        NodeOutput *output = node->getOutputSocket(index);
-                       if (output->getbNodeSocket() == b_socket)
+                       if (output->getbNodeSocket() == b_socket) {
                                return output;
+                       }
                }
        }
        return NULL;
@@ -177,15 +180,22 @@ void NodeGraph::add_bNodeLink(const NodeRange 
&node_range, bNodeLink *b_nodelink
        /// @note: ignore invalid links
        if (!(b_nodelink->flag & NODE_LINK_VALID))
                return;
-
-       NodeInput *input = find_input(node_range, b_nodelink->tosock);
+       
+       /* Note: a DNA input socket can have multiple NodeInput in the 
compositor tree! (proxies)
+        * The output then gets linked to each one of them.
+        */
+       
        NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
-       if (!input || !output)
-               return;
-       if (input->isLinked())
+       if (!output)
                return;
        
-       add_link(output, input);
+       NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
+       for (NodeInputs::const_iterator it = inputs.begin(); it != 
inputs.end(); ++it) {
+               NodeInput *input = *it;
+               if (input->isLinked())
+                       continue;
+               add_link(output, input);
+       }
 }
 
 /* **** Special proxy node type conversions **** */
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h 
b/source/blender/compositor/intern/COM_NodeGraph.h
index 81799d7..67f94bf 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.h
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -78,6 +78,7 @@ public:
        
 protected:
        typedef std::pair<NodeIterator, NodeIterator> NodeRange;
+       typedef std::vector<NodeInput *> NodeInputs;
        
        static bNodeSocket *find_b_node_input(bNode *b_node, const char 
*identifier);
        static bNodeSocket *find_b_node_output(bNode *b_node, const char 
*identifier);
@@ -89,7 +90,7 @@ protected:
        
        void add_bNode(const CompositorContext &context, bNodeTree *b_ntree, 
bNode *b_node, bNodeInstanceKey key, bool is_active_group);
        
-       NodeInput *find_input(const NodeRange &node_range, bNodeSocket 
*b_socket);
+       NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket 
*b_socket);
        NodeOutput *find_output(const NodeRange &node_range, bNodeSocket 
*b_socket);
        void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to