Skip to content

Commit ec7347b

Browse files
authored
Fix 1.38 interface-bound input upgrade (#2968)
MaterialX 1.39 validates node inputs as having exactly one binding. 1.38 nodegraph implementations allowed having a default value and an interfacename on implementation inputs. During the 1.38 to 1.39 upgrade we remove the stale value if connection is present. (This is needed to use some of our Houdini 19.5 assets with MaterialX 1.39)
1 parent 834c6a2 commit ec7347b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

source/MaterialXCore/Version.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,21 @@ void Document::upgradeVersion()
10881088
}
10891089
}
10901090

1091+
// In MaterialX 1.39, each node input may have only one binding. Legacy
1092+
// 1.38 nodegraph implementations sometimes kept a default value on an
1093+
// input that was also connected to a nodegraph interface, so preserve the
1094+
// binding and let the declaration provide any default value.
1095+
for (ElementPtr elem : traverseTree())
1096+
{
1097+
InputPtr input = elem->asA<Input>();
1098+
if (input && input->getParent()->isA<Node>() && input->hasValue() &&
1099+
(input->hasNodeName() || input->hasNodeGraphString() ||
1100+
input->hasInterfaceName() || input->hasOutputString()))
1101+
{
1102+
input->removeAttribute(ValueElement::VALUE_ATTRIBUTE);
1103+
}
1104+
}
1105+
10911106
// Update all nodes.
10921107
vector<NodePtr> unusedNodes;
10931108
for (ElementPtr elem : traverseTree())

0 commit comments

Comments
 (0)