diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-05-29 12:00:21 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-05-29 12:00:21 +0400 |
commit | 34ca8fe82a3a5fbd339d2292f2cc3599673a0c23 (patch) | |
tree | b696e2c4065f70a36fcb09c9a42e2e4e7f0d802c /source/blender/compositor/intern | |
parent | 47bf77951a69d1b817f5201525e62e9e496f1359 (diff) |
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.
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r-- | source/blender/compositor/intern/COM_NodeGraph.cpp | 32 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_NodeGraph.h | 3 |
2 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp index 5c3de84f13c..21b88797233 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 81799d76e1d..67f94bf3465 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); |