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

MAYA-127045 Add reparenting rules for Shaders, NodeGraphs and Materials. #2811

Merged
merged 3 commits into from
Jan 16, 2023

Conversation

frohnej-adsk
Copy link
Collaborator

MAYA-127045 Add reparenting rules for UsdShadeShader, UsdShadeNodeGraph and UsdShadeMaterial.

Users are able to reparent USD items in the Outliner. However, in some cases, reparenting does not make sense and can lead to problematic situations in LookdevX. The following rules are established, when a user tries to reparent items in the Outliner:

  • UsdShadeShader can only have UsdShadeNodeGraph/UsdShadeMaterial as parent.
  • UsdShadeNodeGraph can only have a UsdShadeNodeGraph/UsdShadeMaterial as parent.
  • UsdShadeMaterial cannot have UsdShadeShader/UsdShadeNodeGraph/UsdShadeMaterial as parent.

If one of the rules is broken, reparenting is prevented.

…ph and UsdShadeMaterial.

Users are able to reparent USD items in the Outliner. However, in some cases, reparenting does not
make sense and can lead to problematic situations in LookdevX. The following rules are established,
when a user tries to reparent items in the Outliner:

- UsdShadeShader can only have UsdShadeNodeGraph/UsdShadeMaterial as parent.
- UsdShadeNodeGraph can only have a UsdShadeNodeGraph/UsdShadeMaterial as parent.
- UsdShadeMaterial can not have UsdShadeShader/UsdShadeNodeGraph/UsdShadeMaterial as parent.

If one of the rules is broken, reparenting is prevented.
@JGamache-autodesk
Copy link
Collaborator

You are actually implementing rules that are defined in USD.
The documentation for NodeGraph is here. The reason for this encapsulation is documented here.

Copy link
Collaborator

@seando-adsk seando-adsk left a comment

Choose a reason for hiding this comment

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

This requires a unit test, similar to this one that tests the existing gprim restriction:
https://github.com/Autodesk/maya-usd/blob/dev/test/lib/ufe/testParentCmd.py#L1045

…rials.

- Add tests for the new reparenting rules of UsdShadeShader, UsdShadeNodeGraph and UsdShadeMaterial.
- Adjust the `testUnparentMultiStage` test to not break the new reparenting rules.
…erials for Maya2023 and later.

In Maya 2022, reparenting something to a Material results in:
```
RuntimeError: Object [path/to/material] does not support parenting and therefore cannot be a parent.
```
@frohnej-adsk
Copy link
Collaborator Author

@seando-adsk I changed one of the existing tests that was unparenting a Shader, which is no longer allowed. I also added tests for the new reparenting rules.

I made the new tests only run for Maya2023 and later, because reparenting something to a Material in Maya2022 results in a runtime error for some reason:

RuntimeError: Object [path/to/material] does not support parenting and therefore cannot be a parent.

If you approve of my changes, the PR is ready for merge.

@frohnej-adsk frohnej-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 16, 2023
@seando-adsk seando-adsk added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Jan 16, 2023
@seando-adsk seando-adsk merged commit 5230c46 into dev Jan 16, 2023
@seando-adsk seando-adsk deleted the frohnej/MAYA-127045/reparentingRules branch January 16, 2023 15:26
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.

4 participants