Skip to content

Commit

Permalink
Merge pull request #2386 from Autodesk/boudrey/MAYA-123462/pullset-re…
Browse files Browse the repository at this point in the history
…move

Boudrey/maya 123462/pullset remove
  • Loading branch information
seando-adsk authored May 30, 2022
2 parents 7356012 + a69e149 commit bd2e08f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,8 @@ bool PrimUpdaterManager::mergeToUsd(
}
}

discardPullSetIfEmpty();

// Some updaters (like MayaReference) may be writing and changing the variant during merge.
// This will change the hierarchy around pulled prim. Grab hierarchy from the parent.
auto ufeUsdItem = Ufe::Hierarchy::createItem(pulledPath.pop());
Expand Down Expand Up @@ -1156,6 +1158,8 @@ bool PrimUpdaterManager::discardPrimEdits(const Ufe::Path& pulledPath)
return false;
}

discardPullSetIfEmpty();

auto ufeUsdItem = Ufe::Hierarchy::createItem(pulledPath);
auto hier = Ufe::Hierarchy::hierarchy(ufeUsdItem);
if (TF_VERIFY(hier)) {
Expand Down Expand Up @@ -1205,6 +1209,31 @@ bool PrimUpdaterManager::discardOrphanedEdits(const MDagPath& dagPath)
return true;
}

void PrimUpdaterManager::discardPullSetIfEmpty()
{
// Discard of the pull set if it is empty.
//
// Note: do not use the MFnSet API to discard it as it clears the redo stack
// and thus prevents redo.
MObject pullSetObj;
MStatus status = UsdMayaUtil::GetMObjectByName(kPullSetName, pullSetObj);
if (status == MStatus::kSuccess) {
MFnSet fnPullSet(pullSetObj);
MSelectionList members;
const bool flatten = true;
fnPullSet.getMembers(members, flatten);

if (members.length() == 0) {
MString deleteSetCmd;
deleteSetCmd.format(
"lockNode -lock off \"^1s\";delete \"^1s\";", kPullSetName.asChar());
MDGModifier& dgMod = MDGModifierUndoItem::create("Discard edits pull set removal");
dgMod.commandToExecute(deleteSetCmd);
dgMod.doIt();
}
}
}

bool PrimUpdaterManager::duplicate(
const Ufe::Path& srcPath,
const Ufe::Path& dstPath,
Expand Down
1 change: 1 addition & 0 deletions lib/mayaUsd/fileio/primUpdaterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class PrimUpdaterManager : public PXR_NS::TfWeakBase

bool discardPrimEdits(const Ufe::Path& path);
bool discardOrphanedEdits(const MDagPath& dagPath);
void discardPullSetIfEmpty();

void onProxyContentChanged(const MayaUsdProxyStageObjectsChangedNotice& notice);

Expand Down

0 comments on commit bd2e08f

Please sign in to comment.