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-125918 auto re-edit when merging a Maya Ref #2762

Merged
merged 6 commits into from
Dec 13, 2022

Conversation

pierrebai-adsk
Copy link
Collaborator

This required many fixes and improvements.

The main challenges were:

  • The fact that a given prim is a Maya reference is the knowledge of custom prim update manager.
  • Some things were not available as UFE commands.
  • It is possible to edit multiple Maya Ref at the same time in a single edit session (for example two ref as child of an edited prim)
  • Many small bugs or limitations that had to be fixed.

The first item was addressed by having the possibility for prim updater to add extra work to be done once an operation (edit-as-Maya, merge-to-USD, etc) is done successfully:

  • Add a composite UFE command to the prim updater context.
  • This command contains sub-commands that are executed at the end of a prim updater operation.
  • The prim updater customization classes can thus add final work that need to be done after the edit-as-Maya or merge-to-USD is done.

Augment the updater undo items to support UFE commands:

  • Added execute to OpUndoItem because UFE and Maya commands sometimes do things differently in execute vs redo.
  • Added a UfeCommandUndoItem to execute UFE commands in the prim updater manager undo item system.

Add commands for edit and switching variants:

  • Added Edit-as-Maya UFE command.
  • Added Set-Variant-Selection UFE command.
  • Change context op to use the new commands.

Modify the Maya ref prim updater to use this:

  • Made the Maya Ref prim updater automatically switch to the Maya Ref variant when merge-to-USD ends.
  • This uses the new prim updater context additional command system.
  • This trigger an edit due to the existing code to edit when switching variant on auto-edit Maya Ref.
  • (That code is in the prim updater manager, listening to scene notifications.)

Small fixes to make things work:

  • Made the USD path to DAG path map settable on the context to avoid recreating the context multiple times.
  • (Recreating the context caused the additional commands to be lost...)
  • Fixed the code that check if commands and property changes, etc are allowed when one layer is invalid (null).

Testing:

  • Add a unit test.

This required many fixes and improvements.

The main challenges were:
- The fact that a given prim is a Maya reference is the knowledge of custom prim update manager.
- Some things were not available as UFE commands.
- It is possible to edit multiple Maya Ref at the same time in a single edit session (for example two ref as child of an edited prim)
- Many small bugs or limitations that had to be fixed.

The first item was addressed by having the possibility for prim updater to add extra work to be done once an operation (edit-as-Maya, merge-to-USD, etc) is done successfully:
- Add a composite UFE command to the prim updater context.
- This command contains sub-commands that are executed at the end of a prim updater operation.
- The prim updater customization classes can thus add final work that need to be done after the edit-as-Maya or merge-to-USD is done.

Augment the updater undo items to support UFE commands:
- Added execute to OpUndoItem because UFE and Maya commands sometimes do things differently in execute vs redo.
- Added a UfeCommandUndoItem to execute UFE commands in the prim updater manager undo item system.

Add commands for edit and switching variants:
- Added Edit-as-Maya UFE command.
- Added Set-Variant-Selection UFE command.
- Change context op to use the new commands.

Modify the Maya ref prim updater to use this:
- Made the Maya Ref prim updater automatically switch to the Maya Ref variant when merge-to-USD ends.
- This uses the new prim updater context additional command system.
- This trigger an edit due to the existing code to edit when switching variant on auto-edit Maya Ref.
- (That code is in the prim updater manager, listening to scene notifications.)

Small fixes to make things work:
- Made the USD path to DAG path map settable on the context to avoid recreating the context multiple times.
- (Recreating the context  caused the additional commands to be lost...)
- Fixed the code that check if commands and property changes, etc are allowed when one layer is invalid (null).

Testing:
- Add a unit test.
_controllingFlag = nullptr;
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This allows resetting the "in-push-pull" flag early because otherwise it would interfere with the auto-edit mechanism that is triggered by the final additional command when merging to USD a Maya Ref with auto-edit on.

proxyStage,
ctxArgs,
std::get<UsdPathToDagPathMapPtr>(pushCustomizeSrc));
context.SetUsdPathToDagPathMap(std::get<UsdPathToDagPathMapPtr>(pushCustomizeSrc));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Avoid re-creating the context since it would interfere with having additional commands. The command would be added in the context, but a new one would be used afterward,,,,

.def(
"GetAdditionalFinalCommands",
&UsdMayaPrimUpdaterContext::GetAdditionalFinalCommands,
boost::python::return_internal_reference<>())
.def("MapSdfPathToDagPath", &UsdMayaPrimUpdaterContext::MapSdfPathToDagPath);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, calling this currently fails in Python because UFE does not expose the UndoableCommand and CompositeUndoableCommand to Python. Not a blocker until someone wants to add additional commands from aprim updater in Python.

/// \brief execute a single sub-operation. By default calls redo.
MAYAUSD_CORE_PUBLIC
virtual bool execute() { return redo(); }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As explained, the old design assumed redo == execute, but this not the case for some UFE commands.

EditAsMayaUfeCommand::~EditAsMayaUfeCommand() { }

void EditAsMayaUfeCommand::execute()
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In case you're wondering: there was already a EditAsMayaCommand class... but it is a Maya Command (MPxCommand) not a UFE command (Ufe::UndoableCommand). So I had to use a more specific name to disambiguate.

Also fix two tests that changed behavior now that we respect auto-edit and that chaning variant is checked at execution.
vlasovi
vlasovi previously approved these changes Dec 2, 2022
Copy link
Collaborator

@vlasovi vlasovi left a comment

Choose a reason for hiding this comment

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

Overall looks good. However, it's a big change and I would propose to wait and not merge it for the next release so that QA had enough time to identify any regressions

@pierrebai-adsk
Copy link
Collaborator Author

it's a big change and I would propose to wait and not merge it for the next release so that QA had enough time to identify any regressions

We can ask QA what they prefer next week.

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.

Looks great. Just one minor comment about the using macro.

@pierrebai-adsk pierrebai-adsk added adsk Related to Autodesk plugin ready-for-merge Development process is finished, PR is ready for merge labels Dec 8, 2022
@seando-adsk seando-adsk added the workflows Related to in-context workflows label Dec 13, 2022
@seando-adsk seando-adsk merged commit c37e181 into dev Dec 13, 2022
@seando-adsk seando-adsk deleted the bailp/MAYA-125918/auto-edit-maya-ref branch December 13, 2022 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin 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