Skip to content

Commit

Permalink
Consider defaultgeomprop when validating an input.
Browse files Browse the repository at this point in the history
Fix validation ordering for graph to avoid errors due to the fact the libraries are not loaded before validation occurs.
  • Loading branch information
kwokcb committed Jun 23, 2023
1 parent 9aa9b3a commit 2bfb093
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,16 @@ bool Input::validate(string* message) const
{
bool hasValueBinding = hasValue();
bool hasConnection = hasNodeName() || hasNodeGraphString() || hasOutputString() || hasInterfaceName();
validateRequire(hasValueBinding || hasConnection, res, message, "Node input binds no value or connection");
bool hasDefaultGeomProp = false;
if (!hasConnection && !hasValueBinding)
{
ConstNodePtr node = parent->asA<Node>();
ConstNodeDefPtr nodeDef = node->getNodeDef();
InputPtr input = nodeDef ? nodeDef->getInput(getName()) : nullptr;
if (input && input->hasDefaultGeomPropString())
hasDefaultGeomProp = true;
}
validateRequire(hasValueBinding || hasConnection || hasDefaultGeomProp, res, message, "Node input binds no value or connection");
}
else if (parent->isA<NodeGraph>())
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ mx::DocumentPtr Graph::loadDocument(mx::FilePath filename)
};

mx::DocumentPtr doc = mx::createDocument();
doc->importLibrary(_stdLib);
try
{
if (!filename.isEmpty())
Expand Down Expand Up @@ -4047,7 +4048,6 @@ void Graph::drawGraph(ImVec2 mousePos)
std::string graphName = fileName.getBaseName();
_currGraphName.push_back(graphName.substr(0, graphName.length() - 5));
_graphDoc = loadDocument(fileName);
_graphDoc->importLibrary(_stdLib);

_initial = true;
buildUiBaseGraph(_graphDoc);
Expand Down

0 comments on commit 2bfb093

Please sign in to comment.