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-114603 persist USD payload state #2226

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

pierrebai-adsk
Copy link
Collaborator

Load rules conversions

  • Add functions to convert the USD stage load rules into text and back.
  • Add function to save/load load rules on a dynamic Maya attribute.
  • Add unit tests for the text conversions.
  • Only run load rules unit test on Windows.
  • Other platforms have linker or run-time link problems with Cg and OpenMaya.

Load rules persistence

  • Add a class to handle the persistence.
  • It keeps a list of proxy shape that need to be updated before being saved
  • Listen to kBeforeSave Maya message and transfers the load rules to the proxy stage.
  • Each proxy shape registers with this class.
  • The proxy shape applies the persisted load rules on load if present.
  • Implemented the persistence using dynamic attributes.
  • Since there won't be a ton of them, use MEL as it is more robust and simpler.

Others

  • Fix a bug in UsdMayaSceneResetNotice.

Load rules conversions

- Add functions to convert the USD stage load rules into text and back.
- Add function to save/load load rules on a dynamic Maya attribute.
- Add unit tests for the text conversions.
- Only run load rules unit test on Windows.
- Other platforms have linker or un-time link problems with Cg and OpenMaya.

Load rules persistence

- Add a class to handle the persistence.
- It keeps a list of proxy shape that need to be updated before being saved
- Listen to kBeforeSave Maya message and transfers the load rules to the proxy stage.
- Each proxy shape registers with this class.
- The proxy shape applies the persisted load rules on load if present.
- Implemented the persistence using dynamic attributes.
- Since there won't be a ton of them, use MEL as it is more robest and simpler.

Others

- Fix a bug in UsdMayaSceneResetNotice.
endfunction()

if(IS_WINDOWS)
# There are link problems on Linux and OSX with C++ test using USD + Maya,
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 could not get the C++ unit test to link on Linux or run on OSX.

  • On Linux 2020, the linker would fail to find OpenSubDiv
  • On Linux 2022, execution ofthe test would fail to find libCg.so
  • On OSX master, execution would fail to find libOpenMaya.dylib

But all other platforms / versions would work... so I only kept the test on Windows. It is enough to validate during pre-flight.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@pierrebai-adsk pierrebai-adsk Mar 30, 2022

Choose a reason for hiding this comment

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

I tried yesterday this exact setup to fix it, and a few variations found elsewhere (some were also adding lib64 in Linux, other varied the number of ../..) and it did not fix anything. Not having access to an Mac or Linux made it difficult to fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please assign it to me after it is merged, I will give it a try.

@@ -0,0 +1,95 @@
//
// Copyright 2016 Pixar
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright should be Autodesk right?

@@ -0,0 +1,58 @@
//
// Copyright 2022 Pixar
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright?

{
MString nodeName = depNode.absoluteName();
MString cmd;
cmd.format("addAttr -query -exists \"^2s.^1s\"", loadRulesAttrName, nodeName);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a shame to call MEL code in c++. How hard would it be to find the proper OpenMaya call to do the same?

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 tried initially, but the code would just crash when accessing the dynamic attribute I added. Since I had prototyped it in MEl in Maya and it worked just fine, that MEL mostly never crashes even when things are not right and that I doubt people will create many stages in a single Maya file, I don't think it is worth trying to optimize it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Plus, frankly, the docs in the C++ API related to dynamic attribute is... obscure or missing. Even searching the Maya code base yielded next to zero use case examples.

@pierrebai-adsk
Copy link
Collaborator Author

The only failure is the known Linux interactive where image comparison unit tests now fail due to viewport changes.

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Mar 30, 2022
@seando-adsk seando-adsk added enhancement New feature or request workflows Related to in-context workflows labels Apr 6, 2022
@seando-adsk seando-adsk merged commit 30cddab into dev Apr 6, 2022
@seando-adsk seando-adsk deleted the t_bailp/MAYA-114603/persist-payload-state branch April 6, 2022 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready-for-merge Development process is finished, PR is ready for merge workflows Related to in-context workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants