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

EMSUSD-626: As a layout artist, I'd like to toggle visibility of multiple prims #3417

Merged
merged 5 commits into from
Oct 31, 2023

Conversation

seando-adsk
Copy link
Collaborator

EMSUSD-626: As a layout artist, I'd like to toggle visibility of multiple prims

  • Added bulk edit menu support to base UsdContextOps class.
  • Override in MayaUsdContextOps to add Maya specific menu items.
  • Assign New Material / Assign Existing Material - both of these now only work on single prim if context item is not in selection.
  • Fix contextOps unit test because of spec change with material context menu items and selection.
  • Added unit test for bulk edit contextOps.

…iple prims

* Added bulk edit menu support to base UsdContextOps class.
* Override in MayaUsdContextOps to add Maya specific menu items.
* Assign New Material / Assign Existing Material - both of these now only work on
  single prim if context item is not in selection.
* Fix contextOps unit test because of spec change with material
  context menu items and selection.
* Added unit test for bulk edit contextOps.
@@ -422,7 +432,7 @@ void UsdUndoAssignNewMaterialCommand::execute()
}
// There might be some unassignable items in the selection list. Skip and warn.
// We know there is at least one assignable item found in the ContextOps resolver.
if (!BindMaterialUndoableCommand::CompatiblePrim(parentItem)) {
if (!BindMaterialUndoableCommand::CompatiblePrim(parentItem) || isDefPrim(parentItem)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nat wanted "Def" prims to have the same error (since they are incompatible).

Comment on lines +921 to +927
# Select all three objects.
ufe.GlobalSelection.get().append(capsuleItem)
ufe.GlobalSelection.get().append(cubeItem)
ufe.GlobalSelection.get().append(sphereItem)

# Apply the new material on the unselected object. This object should also receive the new material binding,
# in addition to the two selected objects.
# Apply the new material one of the selected objects, so we are operating in
# bulk mode. All the selected objects should receive the new material binding.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As per design from Nat, I changed the behavior of "Assign New Material" to only work on selection (and not selection + context item).

void UsdContextOps::setItem(const UsdSceneItem::Ptr& item) { fItem = item; }
void UsdContextOps::setItem(const UsdSceneItem::Ptr& item)
{
_item = item;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When setting the item, check for (and setup) the bulk edit.

static constexpr char kUSDDeactivatePrimLabel[] = "Deactivate Prim";
static constexpr char kUSDToggleInstanceableStateItem[] = "Toggle Instanceable State";
static constexpr char kUSDMarkAsInstancebaleLabel[] = "Mark as Instanceable";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed typo in kXXXLabel variable name.

@@ -417,6 +465,61 @@ Ufe::ContextOps::Items UsdContextOps::getItems(const Ufe::ContextOps::ItemPath&
return items;
}

// Adds the special Bulk Edit header as the first item.
void UsdContextOps::addBulkEditHeader(Ufe::ContextOps::Items& items) const
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Helper function so that it can be called from LookdevX plugin which also overrides contextOps and sometimes uses only their context menu (not calling ours).

}
#endif

inline bool sceneItemSupportsShading(const Ufe::SceneItem::Ptr& sceneItem)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one was already here, I just made it inline and removed if (now just single return line).

Comment on lines +115 to +116
UsdSceneItem::Ptr _item;
bool _isAGatewayType { false };
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed member var names according to coding standard.

Comment on lines +736 to +738
// In single context item mode, only assign material to the context item.
return std::make_shared<InsertChildAndSelectCommand>(
UsdUndoAssignNewMaterialCommand::create(_item, itemPath[2]));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to new spec from Nat, only apply this command to single context item (not plus selection). New bulk menu is for selection.

Comment on lines +743 to +744
// In single context item mode, only assign material to the context item.
return std::make_shared<BindMaterialUndoableCommand>(_item->path(), SdfPath(itemPath[2]));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to new spec from Nat, only apply this command to single context item (not plus selection). New bulk menu is for selection.

Comment on lines 762 to 771
#ifdef DEBUG
auto DEBUG_OUTPUT = [&compositeCmd](const Ufe::Selection& bulkItems) {
TF_STATUS(
"Performing bulk edit on %d prims (%d selected)",
compositeCmd->cmdsList().size(),
bulkItems.size());
};
#else
#define DEBUG_OUTPUT(x) (void)0
#endif
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Helpful debugging output to show how many bulk items there were and how many the menu action was applied to. Only outputs in debug builds.

@seando-adsk seando-adsk added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Oct 27, 2023
…iple prims

* Fix compiler errors for prior Maya builds.
…iple prims

* Fix compiler error and unit test.
…iple prims

* Fix compiler error (linux/osx) - related to unused ufe v4 function.
@seando-adsk seando-adsk force-pushed the donnels/EMSUSD-626/contextops_bulk_edit_support branch from b3d83b2 to 90ab805 Compare October 31, 2023 17:08
@seando-adsk seando-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Oct 31, 2023
@seando-adsk seando-adsk merged commit 91959b1 into dev Oct 31, 2023
11 checks passed
@seando-adsk seando-adsk deleted the donnels/EMSUSD-626/contextops_bulk_edit_support branch October 31, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants