Skip to content

Commit b1c6b6a

Browse files
Refinements to getUIProperties
- Restore support for enumerated lists of colors and vectors. - Clarify implementation logic.
1 parent d49f7af commit b1c6b6a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

source/MaterialXRender/Util.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,27 @@ unsigned int getUIProperties(InputPtr input, const string& target, UIProperties&
133133
propertyCount++;
134134
}
135135

136-
StringVec enumerationValues = input->getTypedAttribute<StringVec>(ValueElement::ENUM_VALUES_ATTRIBUTE);
137-
if (!enumerationValues.empty())
136+
const string& enumValuesAttr = input->getAttribute(ValueElement::ENUM_VALUES_ATTRIBUTE);
137+
if (!enumValuesAttr.empty())
138138
{
139-
for (const string& val : enumerationValues)
139+
const string COMMA_SEPARATOR = ",";
140+
const TypeDesc* typeDesc = TypeDesc::get(input->getType());
141+
string valueString;
142+
size_t index = 0;
143+
for (const string& val : splitString(enumValuesAttr, COMMA_SEPARATOR))
140144
{
141-
uiProperties.enumerationValues.push_back(Value::createValueFromStrings(val, input->getType()));
145+
if (index < typeDesc->getSize() - 1)
146+
{
147+
valueString += val + COMMA_SEPARATOR;
148+
index++;
149+
}
150+
else
151+
{
152+
valueString += val;
153+
uiProperties.enumerationValues.push_back(Value::createValueFromStrings(valueString, input->getType()));
154+
valueString.clear();
155+
index = 0;
156+
}
142157
}
143158
if (uiProperties.enumeration.size() != uiProperties.enumerationValues.size())
144159
{

0 commit comments

Comments
 (0)