Open JGamache-autodesk opened 1 month ago
USD crashes when referencing a MaterialX NodeDef/NodeGraph exposing a filename output.
usdcat ShadeTest.mtlx
usdview ShadeTest.mtlx
ShadeTest.zip
diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp index 473a359ce..ad1ef85cd 100644 --- a/pxr/usd/usdMtlx/reader.cpp +++ b/pxr/usd/usdMtlx/reader.cpp @@ -434,8 +434,12 @@ _TypeSupportsColorSpace(const mx::ConstValueElementPtr& mxElem) bool colorImageNode = false; if (type == "filename") { // verify the output is color3 or color4 - mx::ConstNodeDefPtr parentNodeDef = - _GetNodeDef(mxElem->getParent()->asA<mx::Node>()); + mx::ConstNodeDefPtr parentNodeDef; + if (mxElem->getParent()->isA<mx::Node>()) { + parentNodeDef = _GetNodeDef(mxElem->getParent()->asA<mx::Node>()); + } else if (mxElem->getParent()->isA<mx::NodeDef>()) { + parentNodeDef = mxElem->getParent()->asA<mx::NodeDef>(); + } if (parentNodeDef) { for (const mx::OutputPtr& output : parentNodeDef->getOutputs()) { const std::string &type = output->getType();
Should I open an official PR?
Filed as internal issue #USD-10085
Description of Issue
USD crashes when referencing a MaterialX NodeDef/NodeGraph exposing a filename output.
Steps to Reproduce
usdcat ShadeTest.mtlx
orusdview ShadeTest.mtlx
ShadeTest.zip
Fix:
Should I open an official PR?