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.
This commit is contained in:
Lukas Tönne
2014-05-29 10:00:21 +02:00
parent 47bf77951a
commit 34ca8fe82a
2 changed files with 23 additions and 12 deletions

View File

@@ -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 **** */

View File

@@ -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);