Skip to content

Commit

Permalink
Fixes MTLX split string array parsing.
Browse files Browse the repository at this point in the history
Fixes #2268
  • Loading branch information
feldstj committed Feb 14, 2023
1 parent 1d2f18b commit 7488ecc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit 7488ecc

Please sign in to comment.