Skip to content

Commit

Permalink
Merge pull request #4044 from Autodesk/bailp/EMSUSD-1917/lock-layer-s…
Browse files Browse the repository at this point in the history
…election

EMSUSD_1917 lock layer should preserve the selection
  • Loading branch information
seando-adsk authored Dec 11, 2024
2 parents 6337dbb + 163165a commit c25a8fe
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions lib/mayaUsd/commands/layerEditorCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,6 @@ class LockLayer : public BaseCmd
if (!stage)
return false;

saveSelection();

std::set<PXR_NS::SdfLayerRefPtr> layersToUpdate;
if (_includeSublayers) {
// If _includeSublayers is True, we attempt to refresh the system lock status of all
Expand Down Expand Up @@ -896,7 +894,6 @@ class LockLayer : public BaseCmd
_proxyShapePath, _layers[layerIndex], _previousStates[layerIndex], true);
}
}
restoreSelection();

if (_updateEditTarget) {
updateEditTarget(stage);
Expand All @@ -919,36 +916,6 @@ class LockLayer : public BaseCmd
return stage;
}

void saveSelection()
{
// Make a copy of the global selection, to restore it on unlock.
auto globalSn = Ufe::GlobalSelection::get();
_savedSn.replaceWith(*globalSn);
// Filter the global selection, removing items below our proxy shape.
// We know the path to the proxy shape has a single segment. Not
// using Ufe::PathString::path() for UFE v1 compatibility, which
// unfortunately reveals leading "world" path component implementation
// detail.
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
globalSn->replaceWith(UsdUfe::removeDescendants(_savedSn, path));
}

void restoreSelection()
{
// Restore the saved selection to the global selection. If a saved
// selection item started with the proxy shape path, re-create it.
// We know the path to the proxy shape has a single segment. Not
// using Ufe::PathString::path() for UFE v1 compatibility, which
// unfortunately reveals leading "world" path component implementation
// detail.
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
auto globalSn = Ufe::GlobalSelection::get();
globalSn->replaceWith(UsdUfe::recreateDescendants(_savedSn, path));
}

Ufe::Selection _savedSn;
std::vector<MayaUsd::LayerLockType> _previousStates;
SdfLayerHandleVector _layers;
};
Expand Down

0 comments on commit c25a8fe

Please sign in to comment.