Skip to content

Commit

Permalink
USD-42 | Fixes MTLX split string array parsing. (PixarAnimationStudio…
Browse files Browse the repository at this point in the history
…s#292)

* USD-42 | Fixes MTLX split string array parsing. Splits on only commas
instead of commas and spaces. Also removes leading and trailing
whitespace.
  • Loading branch information
feldstj authored and seando-adsk committed Feb 29, 2024
1 parent d2a1074 commit 031a7f3
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 031a7f3

Please sign in to comment.