Skip to content

Commit

Permalink
Merge pull request #3515 from Autodesk/gamaj/LOOKDEVX-1625/metadata_s…
Browse files Browse the repository at this point in the history
…upport_for_color_space

LOOKDEVX-1625 - Use proper API to set color space in USD
  • Loading branch information
seando-adsk authored Dec 14, 2023
2 parents 407029b + 36b9ee4 commit 1a83777
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/mayaUsd/ufe/UsdAttributeHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ Ufe::Value UsdAttributeHolder::getMetadata(const std::string& key) const
}
#endif
return Ufe::Value(niceName);
} else if (key == SdfFieldKeys->ColorSpace) {
const auto csValue = _usdAttr.GetColorSpace();
return !csValue.IsEmpty() ? Ufe::Value(csValue.GetString()) : Ufe::Value();
}
PXR_NS::VtValue v;
if (_usdAttr.GetMetadata(tok, &v)) {
Expand Down Expand Up @@ -451,9 +454,17 @@ Ufe::Value UsdAttributeHolder::getMetadata(const std::string& key) const

bool UsdAttributeHolder::setMetadata(const std::string& key, const Ufe::Value& value)
{
if (isValid())
if (isValid()) {
if (key == SdfFieldKeys->ColorSpace) {
if (!value.empty() && value.isType<std::string>()) {
const AttributeEditRouterContext ctx(_usdAttr.GetPrim(), _usdAttr.GetName());
_usdAttr.SetColorSpace(TfToken(value.get<std::string>()));
return true;
}
return false;
}
return setUsdAttrMetadata(_usdAttr, key, value);
else {
} else {
return false;
}
}
Expand Down Expand Up @@ -481,6 +492,10 @@ bool UsdAttributeHolder::clearMetadata(const std::string& key)
if (key == Ufe::Attribute::kLocked) {
return _usdAttr.ClearMetadata(MayaUsdMetadata->Lock);
}

if (key == SdfFieldKeys->ColorSpace) {
return _usdAttr.ClearColorSpace();
}
return _usdAttr.ClearMetadata(tok);
} else {
return true;
Expand Down

0 comments on commit 1a83777

Please sign in to comment.