-
Notifications
You must be signed in to change notification settings - Fork 202
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
Conversation
pierrebai-adsk
commented
Feb 8, 2022
- 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 |
There was a problem hiding this comment.
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
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
There was a problem hiding this 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.
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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.