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-623 edit as Maya multiple variants #3342

Closed

Conversation

pierrebai-adsk
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk commented Sep 21, 2023

This change adds support to edit-as-Maya a prim that is under a variant, with
each variation having a different Maya reference. That is, a single prim can
now be edited-as-Maya multiple times in parallel. This required major changes
on how those edited prim are tracked.

Edit-as-Maya authors data in the session layer related to the edited prim.
Previously, this data was authored outside any variant, which caused problems
when a prim had multiple variants. Now these data are authored inside the same
variant as the prim itself.

Additional helper functions:

  • Add the getEditTargetForVariants function helper function to create the USD edit target targeting all the variants that affect a given prim.
  • Add variant-specific pull info metadata in the pull-info helper functions.

Change to the orphan manager:

  • Use the variant-targeting helper function when authoring the Maya reference custom attribute that holds the name of the Maya reference node.
  • Support having multiple entries for a given UFE path.
  • To differentiate between entries, the corresponding root Maya DAG path must be given in all functions to figure out which version of the prim we are dealing with.
  • Fortunately, all callers always have on hand the DAG path of the root Maya node.
  • Change all implementation function to iterate over these variations.
  • Change the orphaned nodes serialization to support the extra data.
  • Make the serialization format backward compatible by special-casing the usual case of having a single variation at a given edited UFE path.
  • Add a log to tell the user when an edited prim is orphaned.

Changes to the prim updater manager:

  • Ignore edited prim that are orphaned when determining if a prim has edited descendants.
  • Adapt to changes to the orphaned manager by passing the Maya DAG path to the root of the edited nodes.

Changes to Maya reference translator (importer from USD to Maya):

  • Use the variant-targeting helper function when authoring the pulled-prim metadata.
  • Make many functions be purely in the implementation instead of declared private in the class.
  • This allows better hiding of the implementation.
  • This was also necessary to make the function callable from internal implementation functions.
  • Renamed LoadMayaReference to CreateMayaReference to better reflect what the function does.
  • Split the long update function into multiple function for clarity.
  • When trying to reuse Maya reference nodes, verify that the referenced file is the one that was expected.
  • This allows two prim with the same USD path but different references to work alongside each other.
  • This happens when one prim with two variants each contain a Maya reference.
  • Add more comments in the code to explain what is going on.
  • Add a log to tell the user when a reference does not have the expected file path.

@pierrebai-adsk pierrebai-adsk force-pushed the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch 3 times, most recently from ce6f68d to 41bfa0f Compare September 22, 2023 15:18
@pierrebai-adsk pierrebai-adsk added bug Something isn't working adsk Related to Autodesk plugin labels Sep 22, 2023
@pierrebai-adsk pierrebai-adsk force-pushed the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch 4 times, most recently from 9576926 to 4608c30 Compare September 25, 2023 19:22
This change adds support to edit-as-Maya a prim that is under a variant, with
each variation having a different Maya reference. That is, a single prim can
now be edited-as-Maya multiple times in parallel. This required major changes
on how those edited prim are tracked.

Edit-as-Maya authors data in the session layer related to the edited prim.
Previously, this data was authored outside any variant, which caused problems
when a prim had multiple variants. Now these data are authored inside the same
variant as the prim itself.

Add overloads of the helper functions to write and remove pull informations and
metadata. The overloads take and explicit USD edit target. These are necessary
because when the orphnaed node manager tries to remove or write the
information, the stage might not be in the current state of variants might not
be the same as when the prim was initially edited-as-Maya. So we must use the
cache variant selection information instead to build the correct target.

Additional variant-related helper functions:
- Add the getEditTargetForVariants function helper function to create the USD edit target targeting all the variants that affect a given prim.
- Ensure getEditTargetForVariants works in more complex scenarios spanning payloads and references.
- Add the getVariantPath helper function to create a USD path containing a variant selection.

Additional pull information helper functions:
- Add variant-specific pull info metadata in the pull-info helper functions.
- Add overloads of the pull information helper functions, taking an explicit edit target.
- Refactor the existing overload to call the new functions.
- Warn when we fail to remove pull information.

Change to the orphan manager:
- Use the variant-targeting helper function when authoring the Maya reference custom attribute that holds the name of the Maya reference node.
- Support having multiple entries for a given UFE path.
- To differentiate between entries, the corresponding root Maya DAG path must be given in all functions to figure out which version of the prim we are dealing with.
- Fortunately, all callers always have on hand the DAG path of the root Maya node.
- Change all implementation function to iterate over these variations.
- Change the orphaned nodes serialization to support the extra data.
- Make the serialization format backward compatible by special-casing the usual case of having a single variation at a given edited UFE path.
- Add a log to tell the user when an edited prim is orphaned.
- Add a has function in the orphaned node manager to check if a prim is already edited.
- Use it to avoid editing a prim variant twice.
- Added debug log to be removed later.
- Refactor the orphaned node manager to use the helper passing an explicit edit target.
- Make the orphaned node manager build an explicit USD edit target for the exact variant selections that were active when the prim was edited.
- Fix how the orphaned manager handles notifications to determine orphans.
- In particular, handle deactvated prims correctly: when switching variants, the order of the consequences is not deterministc, so the handling must not assume that edited prims are active.

Changes to the prim updater manager:
- Ignore edited prim that are orphaned when determining if a prim has edited descendants.
- Adapt to changes to the orphaned manager by passing the Maya DAG path to the root of the edited nodes.
- When merging to USD, when removing the pull information, use the helper function.
- Remove the pull information before calling the prim updaters since they might change the active variant.

Changes to Maya reference translator (importer from USD to Maya):
- Use the variant-targeting helper function when authoring the pulled-prim metadata.
- Make many functions be purely in the implementation instead of declared private in the class.
- This allows better hiding of the implementation.
- This was also necessary to make the function callable from internal implementation functions.
- Renamed LoadMayaReference to CreateMayaReference to better reflect what the function does.
- Split the long update function into multiple function for clarity.
- When trying to reuse Maya reference nodes, verify that the referenced file is the one that was expected.
- This allows two prim with the same USD path but different references to work alongside each other.
- This happens when one prim with two variants each contain a Maya reference.
- Add more comments in the code to explain what is going on.
- Add a log to tell the user when a reference does not have the expected file path.

Fix unit tests:
- Some tests were re-using prims that had become invalid and needed to be refetched.
- Some tests were checking if prims were accessible when they should not, since merging a Maya reference with variants change to those variants.
- It used to work because there were some left-overs in the session layer.
@pierrebai-adsk pierrebai-adsk force-pushed the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch from 4608c30 to 559b96a Compare September 25, 2023 20:01
@pierrebai-adsk pierrebai-adsk deleted the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch September 25, 2023 20:02
@pierrebai-adsk pierrebai-adsk restored the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch September 25, 2023 20:03
@pierrebai-adsk pierrebai-adsk deleted the bailp/EMSUSD-623/variants-vs-multi-maya-refs branch September 25, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants