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-128513 implement code wrapper handler #3102

Merged
merged 3 commits into from
Jun 1, 2023

Conversation

pierrebai-adsk
Copy link
Collaborator

Implement a code wrapper handler to support edit routing for composite commands:

  • Make the batch-ops handler derive from the correct class depending on which feature is supported in UFE.
  • Implement a code wrapper handler derived from the batch ops handler.
  • This code wrapper handler creates edit-routing wrappers for composite commands.

Implement a code wrapper that does the edit routing:

  • The code wrapper cache the stage and layer used when first executing a composite command.
  • This allows using the same values when undoing.
  • This is necessary because the original prim that was used when executing the command might not exist anymore once the command executed.
  • In particular, this is true for the group command, the original prim no longer exists.

Make the group command work with edit routing. Note that the Maya group command is implemented in term of the insert-child UFE command. That is why we are modifying the insert-child command.

  • Use the generic undo/redo support to record the changes, undo and redo them.
  • Don't assume that the current edit target is where the source prim has opinion.
  • Instead, apply the child-insertion to the layer that have opinion about the moving prim.
  • The command restrictions already ensure that we only affect prims that have a single opinion.
  • (But with these changes, the code will be ready if we support multi-layers command later on.)
  • The problem was that the command restrictions were correctly looking at where the prim was authored, but the command execution was assuming that the source opinion was on the target layer.
  • When routing commands, that can obviously be false: the target might not be where the original opinions were.
  • We do the right thing using similar code as when affecting the session layer, except the target layer is the layer where the command was routed.
  • By default, when no routing is registered, that is the current edit target.
  • Fix load rules duplication: the Load rules are not part of the USD data that gets restore by automatic USD undo block, so we need to duplicate them explicitly. Also, the UFE reparent notification need to be triggered during undo and redo.

Fix unit tests:

  • The unit tests were tied to some subtle behavior of the implementation. Now that we use "perfect" undo/redo, the order of items is also preserved, so the testGroupCmd assertions had to be fixed. Similarly, the parent command was assuming the parent prim was passed to the edit router. It was also creating the parent prims, which is not necessary. (The problem was fixed before, but the fix was hidden due to the exact timing of the edit routing call.)
  • Also made the parent unit test for edit routing properly unregister the router even when the test fails. Otherwise, the subsequent test crashes due to the invalid edit router being left behind.
  • Added a unit test for the Maya group composite command.
  • Made sure the code wrapper unit test is not run when the API is not available.
  • Made text filtering ignore all white spaces at the start and end of lines to avoid to have to write the exact indentations.

@pierrebai-adsk pierrebai-adsk added adsk Related to Autodesk plugin ufe Related to UFE component in Maya labels May 17, 2023
Implement a code wrapper handler to support edit routing for composite commands:

- Make the batch-ops handler derive from the correct class depending on which feature is supported in UFE.
- Implement a code wrapper handler derived from the batch ops handler.
- This code wrapper handler creates edit-routing wrappers for composite commands.

Implement a code wrapper that does the edit routing:

- The code wrapper cache the stage and layer used when first executing a composite command.
- This allows using the same values when undoing.
- This is necessary because the original prim that was used when executing the command might not exist anymore once the command executed.
- In particular, this is true for the group command, the original prim no longer exists.

Make the group command work with edit routing. Note that the Maya group command is implemented in term of the insert-child UFE command. That is why we are modifying the insert-child command.

- Use the generic undo/redo support to record the changes, undo and redo them.
- Don't assume that the current edit target is where the source prim has opinion.
- Instead, apply the child-insertion to the layer that have opinion about the moving prim.
- The command restrictions already ensure that we only affect prims that have a single opinion.
- (But with these changes, the code will be ready if we support multi-layers command later on.)
- The problem was that the command restrictions were correctly looking at where the prim was authored, but the command execution was assuming that the source opinion was on the target layer.
- When routing commands, that can obviously be false: the target might not be where the original opinions were.
- We do the right thing using similar code as when affecting the session layer, except the target layer is the layer where the command was routed.
- By default, when no routing is registered, that is the current edit target.
- Fix load rules duplication: the Load rules are not part of the USD data that gets restore by automatic USD undo block, so we need to duplicate them explicitly. Also, the UFE reparent notification need to be triggered during undo and redo.

Fix unit tests:

- The unit tests were tied to some subtle behavior of the implementation. Now that we use "perfect" undo/redo, the order of items is also preserved, so the testGroupCmd assertions had to be fixed. Similarly, the parent command was assuming the parent prim was passed to the edit router. It was also creating the parent prims, which is not necessary. (The problem was fixed before, but the fix was hidden due to the exact timing of the edit routing call.)
- Also made the parent unit test for edit routing properly unregister the router even when the test fails. Otherwise, the subsequent test crashes due to the invalid edit router being left behind.
- Added a unit test for the Maya group composite command.
- Made sure the code wrapper unit test is not run when the API is not available.
- Made text filtering ignore all white spaces at the start and end of lines to avoid to have to write the exact indentations.
@pierrebai-adsk pierrebai-adsk force-pushed the bailp/MAYA-128513/composite-command-handler branch from a183bf5 to e03935a Compare May 25, 2023 20:24
@pierrebai-adsk pierrebai-adsk added enhancement New feature or request ufe-usd Related to UFE-USD plugin in Maya-Usd labels May 29, 2023
@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label May 29, 2023
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.

Overall the changes look good. Great work. Just a few minor things to fix.

- Fix some incorrect ifdef in Global.cpp. They were currently harmless because all UFE V4 if were always satisfied simultaneously, but the code was still not theoretically  correct.
- Fix some useUfe vs mayaUSD include issues.
- Move an anonymous namespace.
- Remove a debug print in a test.
- Return the stage pointer by value.
- Remove old UFE version check.
@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label May 31, 2023
@seando-adsk seando-adsk merged commit 4994a90 into dev Jun 1, 2023
@seando-adsk seando-adsk deleted the bailp/MAYA-128513/composite-command-handler branch June 1, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin enhancement New feature or request ready-for-merge Development process is finished, PR is ready for merge ufe Related to UFE component in Maya 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