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

[usdShade] GetPrimvarNamesMetadataString - only append non-empty string #2131

Merged
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
10 changes: 9 additions & 1 deletion pxr/usd/usdShade/shaderDefUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,15 @@ UsdShadeShaderDefUtils::GetPrimvarNamesMetadataString(
// If there's an existing value in the definition, we must append to it.
std::vector<std::string> primvarNames;
if (metadata.count(SdrNodeMetadata->Primvars)) {
primvarNames.push_back(metadata.at(SdrNodeMetadata->Primvars));
auto& existingValue = metadata.at(SdrNodeMetadata->Primvars);
// Only append if it's non-empty - calling code may do, ie,
// metadata["primvars"] = this_function()
// ...and on some compilers / architectures, that will result in a
// default empty string being inserted into metadata BEFORE this
// function is called
if (!existingValue.empty()) {
primvarNames.push_back(existingValue);
}
}

for (auto &shdInput : shaderDef.GetInputs(/* onlyAuthored */ false)) {
Expand Down