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

Fix USD Min build after outliner rework #2781

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Changes from 2 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
24 changes: 21 additions & 3 deletions lib/mayaUsd/ufe/UsdContextOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,29 @@ static const std::vector<MayaUsd::ufe::SchemaTypeGroup> getConcretePrimTypes(boo
}
#endif

bool sceneItemSupportsShading(const Ufe::SceneItem::Ptr& sceneItem)
{
#if PXR_VERSION >= 2108
if (MAYAUSD_NS_DEF::ufe::BindMaterialUndoableCommand::CompatiblePrim(sceneItem).IsValid()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't really use the macro here. Just "MayaUsd::"

return true;
}
#else
auto usdItem = std::dynamic_pointer_cast<MAYAUSD_NS_DEF::ufe::UsdSceneItem>(sceneItem);
if (!usdItem) {
return false;
}
if (PXR_NS::UsdShadeMaterialBindingAPI(usdItem->prim())) {
return true;
}
#endif
return false;
}

bool selectionSupportsShading()
{
if (auto globalSn = Ufe::GlobalSelection::get()) {
for (auto&& selItem : *globalSn) {
if (MAYAUSD_NS_DEF::ufe::BindMaterialUndoableCommand::CompatiblePrim(selItem)) {
if (sceneItemSupportsShading(selItem)) {
return true;
}
}
Expand Down Expand Up @@ -880,7 +898,7 @@ Ufe::ContextOps::Items UsdContextOps::getItems(const Ufe::ContextOps::ItemPath&
if (!fIsAGatewayType) {
// Top level item - Bind/unbind existing materials
bool materialSeparatorsAdded = false;
if (BindMaterialUndoableCommand::CompatiblePrim(fItem).IsValid()) {
if (sceneItemSupportsShading(fItem)) {
// Show bind menu if there is at least one bindable material in the stage.
//
// TODO: Show only materials that are inside of the asset's namespace otherwise
Expand Down Expand Up @@ -933,7 +951,7 @@ Ufe::ContextOps::Items UsdContextOps::getItems(const Ufe::ContextOps::ItemPath&
}
}
#if UFE_PREVIEW_VERSION_NUM >= 4010
if (BindMaterialUndoableCommand::CompatiblePrim(fItem).IsValid()) {
if (sceneItemSupportsShading(fItem)) {
if (!materialSeparatorsAdded) {
items.emplace_back(Ufe::ContextItem::kSeparator);
materialSeparatorsAdded = true;
Expand Down