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

Fixes MTLX split string array parsing. #2278

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pxr/usd/usdMtlx/testenv/testUsdMtlxParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_NodeParser(self):
self.assertEqual(input.GetLabel(), "UI Vector")
self.assertEqual(input.GetPage(), "UI Page")
self.assertEqual(input.GetOptions(),
[("X", "1, 0, 0"), ("Y", "0, 1, 0"), ("Z", "0, 0, 1")])
[("X Label", "1, 0, 0"), ("Y Label", "0, 1, 0"), ("Z Label", "0, 0, 1")])

node = Sdr.Registry().GetShaderNodeByIdentifier(
'UsdMtlxTestNamespace:nd_float')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<output name="out" type="string" />
</nodedef>
<nodedef name="nd_vector" node="UsdMtlxTestNode" doc="Vector help">
<input name="in" type="vector3" enum="X,Y,Z" enumvalues="1,0,0, 0,1,0, 0,0,1" doc="Property help" uiname="UI Vector" uifolder="UI Page" />
<input name="in" type="vector3" enum="X Label, Y Label, Z Label" enumvalues="1,0,0, 0,1,0, 0,0,1" doc="Property help" uiname="UI Vector" uifolder="UI Page" />
<input name="note" type="string" value="" uniform="true" />
<output name="out" type="vector3" />
</nodedef>
Expand Down
8 changes: 7 additions & 1 deletion pxr/usd/usdMtlx/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ TF_DEFINE_PUBLIC_TOKENS(UsdMtlxTokens, USD_MTLX_TOKENS);

namespace {

const std::string _CommaSeparator = ",";

using DocumentCache = std::map<std::string, mx::DocumentPtr>;

static
Expand Down Expand Up @@ -586,7 +588,11 @@ UsdMtlxGetPackedUsdValues(const std::string& values, const std::string& type)
std::vector<std::string>
UsdMtlxSplitStringArray(const std::string& s)
{
return mx::splitString(s, mx::ARRAY_VALID_SEPARATORS);
std::vector<std::string> strs = mx::splitString(s, _CommaSeparator);
for (size_t i=0; i<strs.size(); ++i) {
strs[i] = mx::trimSpaces(strs[i]);
}
return strs;
}

PXR_NAMESPACE_CLOSE_SCOPE