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-121513 add undo support to add Maya reference #2079

Merged
merged 5 commits into from
Feb 15, 2022

Conversation

pierrebai-adsk
Copy link
Collaborator

  • Correct the discard edits to not try to delete nodes in the reference.
  • Create the correct prim updater when discarding edits on maya references.
  • Prevent flush of undo when loading and unloading references as much as we can.
  • Allow undo when calling the mel function.
  • Add USD undo block in Python.
  • Add TODO to remind to investigate possible problem with namespace.

- Correct the discard edits to not try to delete nodes in the reference.
- Create the correct prim updater when discarding edits on maya references.
- Prevent flush of undo when loading and unloading references as much as we can.
- Allow undo when calling the mel function.
- Add USD undo block in Python.
- Add TODO to remind to investigate possible problem with namespace.
auto registryItem = UsdMayaPrimUpdaterRegistry::FindOrFallback(mayaTypeName);
const Ufe::Path path = MayaUsd::ufe::dagPathToPathSegment(curDagPath);

// The root of the pulled hierarchy is crucial for determining push
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 comments and inspiration for code was taken from line 542

@@ -871,7 +871,7 @@ Ufe::UndoableCommand::Ptr UsdContextOps::doOpCmd(const ItemPath& itemPath)
} else if (itemPath[0] == kAddMayaReferenceItem) {
MString script;
script.format("addMayaReferenceToUsd \"^1s\"", Ufe::PathString::string(path()).c_str());
MString result = MGlobal::executeCommandStringResult(script);
MString result = MGlobal::executeCommandStringResult(script, false, true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The final flag enables undo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put that in as a code comment, e.g.
MString result = MGlobal::executeCommandStringResult(script, /* display = / false, / undoable = */ true);

Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

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

LGTM, just the discard edits traversal pruning capability that we discussed.

@@ -871,7 +871,7 @@ Ufe::UndoableCommand::Ptr UsdContextOps::doOpCmd(const ItemPath& itemPath)
} else if (itemPath[0] == kAddMayaReferenceItem) {
MString script;
script.format("addMayaReferenceToUsd \"^1s\"", Ufe::PathString::string(path()).c_str());
MString result = MGlobal::executeCommandStringResult(script);
MString result = MGlobal::executeCommandStringResult(script, false, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put that in as a code comment, e.g.
MString result = MGlobal::executeCommandStringResult(script, /* display = / false, / undoable = */ true);

MFnDependencyNode depNode(objectToDelete);
if (!depNode.isFromReferencedFile()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed, I think we should introduce pruning to the discardEdits traversal, like we did for mergeToUsd. Otherwise, we'll needlessly traverse referenced nodes trying to discard their edits, when the edits to be discarded are in the Maya reference node itself.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Because of time constraints, we will do this later.

MFnDependencyNode depNode(objectToDelete);
if (!depNode.isFromReferencedFile()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because of time constraints, we will do this later.

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Feb 15, 2022
@kxl-adsk kxl-adsk merged commit cf5f97a into dev Feb 15, 2022
@kxl-adsk kxl-adsk deleted the t_bailp/MAYA-121513/add-maya-reference-undo branch February 15, 2022 19:04
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants