Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multioutput connection edits #1506

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,33 @@ void Graph::AddLink(ed::PinId inputPinId, ed::PinId outputPinId)
{
if (uiUpNode->getNode())
{
pin->_input->setConnectedNode(uiUpNode->getNode());
mx::NodePtr upstreamNode = _graphNodes[upNode]->getNode();
mx::NodeDefPtr upstreamNodeDef = upstreamNode->getNodeDef();
bool isMultiOutput = upstreamNodeDef ? upstreamNodeDef->getOutputs().size() > 1 : false;

// This is purely to avoid adding a reference to an update node only 1 output,
// as currently validation consides adding this an error. Otherwise
// it will add an "output" attribute all the time.
if (!isMultiOutput)
{
pin->_input->setConnectedNode(uiUpNode->getNode());
}
else
{
for (UiPinPtr outPin : _graphNodes[upNode]->outputPins)
{
// set pin connection to correct output
if (outPin->_pinId == inputPinId)
{
mx::OutputPtr outputs = uiUpNode->getNode()->getOutput(outPin->_name);
if (!outputs)
{
outputs = uiUpNode->getNode()->addOutput(outPin->_name, pin->_input->getType());
}
pin->_input->setConnectedOutput(outputs);
}
}
}
}
else if (uiUpNode->getNodeGraph())
{
Expand Down Expand Up @@ -2716,6 +2742,9 @@ void Graph::deleteLinkInfo(int startAttr, int endAttr)
setDefaults(_graphNodes[upNode]->getInput());
}

// Remove any output reference
pin->_input->removeAttribute(mx::PortElement::OUTPUT_ATTRIBUTE);

pin->setConnected(false);
// if a value exists update the input with it
if (val)
Expand Down