-
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-125918 auto re-edit when merging a Maya Ref #2762
Changes from all commits
c7bf976
32fbc58
65fb980
19c143d
d063b27
cc599a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -760,6 +760,14 @@ class PushPullScope | |
} | ||
} | ||
|
||
void end() | ||
{ | ||
if (_controllingFlag) { | ||
*_controllingFlag = false; | ||
_controllingFlag = nullptr; | ||
} | ||
} | ||
|
||
private: | ||
bool* _controllingFlag { nullptr }; | ||
}; | ||
|
@@ -873,6 +881,12 @@ class RemovePullVariantInfoUndoItem : public MayaUsd::OpUndoItem | |
}; | ||
#endif | ||
|
||
void executeAdditionalCommands(const UsdMayaPrimUpdaterContext& context) | ||
{ | ||
std::shared_ptr<Ufe::CompositeUndoableCommand> cmds = context.GetAdditionalFinalCommands(); | ||
UfeCommandUndoItem::execute("Additional final commands", cmds); | ||
} | ||
|
||
} // namespace | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
@@ -922,7 +936,7 @@ bool PrimUpdaterManager::mergeToUsd( | |
MString progStr( | ||
VtDictionaryIsHolding<std::string>(userArgs, "rn_primName") ? "Caching to USD" | ||
: "Merging to USD"); | ||
MayaUsd::ProgressBarScope progressBar(10, progStr); | ||
MayaUsd::ProgressBarScope progressBar(11, progStr); | ||
PushPullScope scopeIt(_inPushPull); | ||
|
||
auto ctxArgs = VtDictionaryOver(userArgs, UsdMayaJobExportArgs::GetDefaultDictionary()); | ||
|
@@ -996,11 +1010,7 @@ bool PrimUpdaterManager::mergeToUsd( | |
// 2) Traverse the in-memory layer, creating a prim updater for each prim, | ||
// and call Push for each updater. Build a new context with the USD path | ||
// to Maya path mapping information. | ||
UsdMayaPrimUpdaterContext customizeContext( | ||
proxyShape->getTime(), | ||
proxyStage, | ||
ctxArgs, | ||
std::get<UsdPathToDagPathMapPtr>(pushCustomizeSrc)); | ||
context.SetUsdPathToDagPathMap(std::get<UsdPathToDagPathMapPtr>(pushCustomizeSrc)); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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,,,, |
||
if (!isCopy) { | ||
if (!FunctionUndoItem::execute( | ||
|
@@ -1016,7 +1026,7 @@ bool PrimUpdaterManager::mergeToUsd( | |
} | ||
progressBar.advance(); | ||
|
||
if (!pushCustomize(pulledPath, pushCustomizeSrc, customizeContext)) { | ||
if (!pushCustomize(pulledPath, pushCustomizeSrc, context)) { | ||
return false; | ||
} | ||
progressBar.advance(); | ||
|
@@ -1073,6 +1083,10 @@ bool PrimUpdaterManager::mergeToUsd( | |
} | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -1093,7 +1107,7 @@ bool PrimUpdaterManager::editAsMaya(const Ufe::Path& path, const VtDictionary& u | |
return false; | ||
} | ||
|
||
MayaUsd::ProgressBarScope progressBar(6, "Converting to Maya Data"); | ||
MayaUsd::ProgressBarScope progressBar(7, "Converting to Maya Data"); | ||
|
||
PushPullScope scopeIt(_inPushPull); | ||
|
||
|
@@ -1158,6 +1172,10 @@ bool PrimUpdaterManager::editAsMaya(const Ufe::Path& path, const VtDictionary& u | |
scene.notify(Ufe::ObjectAdd(ufeItem)); | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -1218,7 +1236,7 @@ bool PrimUpdaterManager::discardPrimEdits(const Ufe::Path& pulledPath) | |
return false; | ||
} | ||
|
||
MayaUsd::ProgressBarScope progressBar(5); | ||
MayaUsd::ProgressBarScope progressBar(6); | ||
PushPullScope scopeIt(_inPushPull); | ||
|
||
// Record all USD modifications in an undo block and item. | ||
|
@@ -1310,12 +1328,17 @@ bool PrimUpdaterManager::discardPrimEdits(const Ufe::Path& pulledPath) | |
scene.notify(Ufe::SubtreeInvalidate(hier->defaultParent())); | ||
} | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
|
||
bool PrimUpdaterManager::discardOrphanedEdits(const MDagPath& dagPath, const Ufe::Path& pulledPath) | ||
{ | ||
MayaUsd::ProgressBarScope progressBar(2); | ||
MayaUsd::ProgressBarScope progressBar(3); | ||
PushPullScope scopeIt(_inPushPull); | ||
|
||
// Unlock the pulled hierarchy, clear the pull information, and remove the | ||
|
@@ -1356,6 +1379,10 @@ bool PrimUpdaterManager::discardOrphanedEdits(const MDagPath& dagPath, const Ufe | |
} | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -1401,7 +1428,7 @@ bool PrimUpdaterManager::duplicate( | |
return false; | ||
} | ||
|
||
MayaUsd::ProgressBarScope progressBar(2, "Duplicating to Maya Data"); | ||
MayaUsd::ProgressBarScope progressBar(3, "Duplicating to Maya Data"); | ||
|
||
auto ctxArgs = VtDictionaryOver(userArgs, UsdMayaJobImportArgs::GetDefaultDictionary()); | ||
|
||
|
@@ -1427,6 +1454,11 @@ bool PrimUpdaterManager::duplicate( | |
|
||
pullImport(srcPath, srcPrim, context); | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
// Copy from DG to USD | ||
|
@@ -1437,7 +1469,7 @@ bool PrimUpdaterManager::duplicate( | |
return false; | ||
} | ||
|
||
MayaUsd::ProgressBarScope progressBar(7, "Duplicating to USD"); | ||
MayaUsd::ProgressBarScope progressBar(8, "Duplicating to USD"); | ||
|
||
auto ctxArgs = VtDictionaryOver(userArgs, UsdMayaJobExportArgs::GetDefaultDictionary()); | ||
|
||
|
@@ -1494,6 +1526,11 @@ bool PrimUpdaterManager::duplicate( | |
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(ufeItem)); | ||
} | ||
progressBar.advance(); | ||
|
||
scopeIt.end(); | ||
executeAdditionalCommands(context); | ||
progressBar.advance(); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -1573,6 +1610,8 @@ void PrimUpdaterManager::onProxyContentChanged( | |
} | ||
} | ||
} | ||
|
||
executeAdditionalCommands(context); | ||
} | ||
|
||
PrimUpdaterManager& PrimUpdaterManager::getInstance() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,6 +246,10 @@ void wrapPrimUpdaterContext() | |
"GetArgs", | ||
&UsdMayaPrimUpdaterContext::GetArgs, | ||
boost::python::return_internal_reference<>()) | ||
.def( | ||
"GetAdditionalFinalCommands", | ||
&UsdMayaPrimUpdaterContext::GetAdditionalFinalCommands, | ||
boost::python::return_internal_reference<>()) | ||
.def("MapSdfPathToDagPath", &UsdMayaPrimUpdaterContext::MapSdfPathToDagPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
|
@@ -289,6 +293,7 @@ void wrapPrimUpdater() | |
boost::python::return_value_policy<boost::python::return_by_value>()) | ||
.def("getUfePath", &This::getUfePath, boost::python::return_internal_reference<>()) | ||
.def("getUsdPrim", &This::getUsdPrim) | ||
.def("getContext", &This::getContext, boost::python::return_internal_reference<>()) | ||
.def("isAnimated", &This::isAnimated) | ||
.staticmethod("isAnimated") | ||
.def("Register", &PrimUpdaterWrapper::Register) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Copyright 2022 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "EditAsMayaCommand.h" | ||
|
||
#include <mayaUsd/fileio/primUpdaterManager.h> | ||
#include <mayaUsd/undo/OpUndoItemRecorder.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
EditAsMayaUfeCommand::Ptr EditAsMayaUfeCommand::create(const Ufe::Path& path) | ||
{ | ||
return std::make_shared<ufe::EditAsMayaUfeCommand>(path); | ||
} | ||
|
||
EditAsMayaUfeCommand::EditAsMayaUfeCommand(const Ufe::Path& path) | ||
: _path(path) | ||
{ | ||
} | ||
|
||
EditAsMayaUfeCommand::~EditAsMayaUfeCommand() { } | ||
|
||
void EditAsMayaUfeCommand::execute() | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
bool status = false; | ||
|
||
// Scope the undo item recording so we can undo on failure. | ||
{ | ||
OpUndoItemRecorder undoRecorder(_undoItemList); | ||
|
||
auto& manager = PXR_NS::PrimUpdaterManager::getInstance(); | ||
status = manager.editAsMaya(_path); | ||
} | ||
|
||
// Undo potentially partially-made edit-as-Maya on failure. | ||
if (!status) | ||
_undoItemList.undo(); | ||
} | ||
|
||
void EditAsMayaUfeCommand::undo() { _undoItemList.redo(); } | ||
|
||
void EditAsMayaUfeCommand::redo() { _undoItemList.redo(); } | ||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF |
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 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.