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

Add contextual menu to bind materials #2287

Merged
merged 5 commits into from
Apr 21, 2022

Conversation

JGamache-autodesk
Copy link
Collaborator

  • Adds a bind/unbind contextual menu to the outliner. The menu lists
    available materials to bind.
  • Extends the create reference menu to list all asset types that can
    be referenced. Includes MaterialX and Alembic files.

- Adds a bind/unbind contextual menu to the outliner. The menu lists
  available materials to bind.
- Extends the create reference menu to list all asset types that can
  be referenced. Includes MaterialX and Alembic files.
//
// TODO: Show only materials that are inside of the asset's namespace otherwise there
// will be "refers to a path outside the scope" errors. See
// https://groups.google.com/g/usd-interest/c/dmjV5bQBKIo/m/LeozZ3k6BAAJ
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any idea how to do this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Afraid not.

@@ -48,6 +48,9 @@ Ufe::ConstAttributeDefs getAttrs(const PXR_NS::SdrShaderNodeConstPtr& shaderNode
for (const PXR_NS::TfToken& name : names) {
PXR_NS::SdrShaderPropertyConstPtr property
= input ? shaderNodeDef->GetShaderInput(name) : shaderNodeDef->GetShaderOutput(name);
if (!property) {
continue;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have third-party shaders crashing here. They registered the input names, but did not register a SdrShaderProperty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be a great code comment.

ppt-adsk
ppt-adsk previously approved these changes Apr 14, 2022
Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just minor comments. Material discovery traversals are a bit worrisome, I will say, especially if this is used in a context where UI must be displayed synchronously, but I will assume that you feel the typical scene hierarchy where this will be used will not cause performance problems.

//
// TODO: Show only materials that are inside of the asset's namespace otherwise there
// will be "refers to a path outside the scope" errors. See
// https://groups.google.com/g/usd-interest/c/dmjV5bQBKIo/m/LeozZ3k6BAAJ
Copy link
Collaborator

Choose a reason for hiding this comment

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

Afraid not.

// TODO: Introduce material binding via collections API
//
auto stage = fItem->prim().GetStage();
for (UsdPrim currentPrim : stage->TraverseAll()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How expensive can this traversal end up being?

@@ -48,6 +48,9 @@ Ufe::ConstAttributeDefs getAttrs(const PXR_NS::SdrShaderNodeConstPtr& shaderNode
for (const PXR_NS::TfToken& name : names) {
PXR_NS::SdrShaderPropertyConstPtr property
= input ? shaderNodeDef->GetShaderInput(name) : shaderNodeDef->GetShaderOutput(name);
if (!property) {
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be a great code comment.

- Traversing large scenes is not an option. Instead we traverse the
  selection to find materials either directly selected, or under a
  selected parent (Looks section).

The workflow is now:
 - Select the materials or the looks section
 - Navigate in the outliner to the geometry you want to bind, and
   activate the context menu (this does not change selection).
 - If materials are found in the selection, they will be offered in a
   Bind Material context menu item.

In UX terms, this forces you to pre-select the "object" before right
clicking on the "subject" to get the Bind "verb" as an option. This is far
from perfect, so I am open to any other solution that does not process the
whole stage to find materials.
ppt-adsk
ppt-adsk previously approved these changes Apr 20, 2022
feldstj
feldstj previously approved these changes Apr 20, 2022
@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Apr 21, 2022
@seando-adsk seando-adsk merged commit 4249ce4 into dev Apr 21, 2022
@seando-adsk seando-adsk deleted the t_gamaj/LOOKDEVX-610/bind_unbind_context_menu branch April 21, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
materials outliner Features affecting Maya's Outliner ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants