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-105322 - No undo support for viewport selections of USD objects #940

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#include <mayaUsd/ufe/UsdSceneItem.h>

#include <ufe/globalSelection.h>
#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
#include <ufe/namedSelection.h>
#endif
#include <ufe/observableSelection.h>
#include <ufe/runTimeMgr.h>
#include <ufe/scene.h>
Expand Down Expand Up @@ -755,7 +758,9 @@ bool ProxyRenderDelegate::getInstancedSelectionPath(
// each intersection.
#if defined(MAYA_ENABLE_UPDATE_FOR_SELECTION)
const TfToken& selectionKind = _selectionKind;
#if UFE_PREVIEW_VERSION_NUM < 2027 // #ifndef UFE_V2_FEATURES_AVAILABLE
const MGlobal::ListAdjustment& listAdjustment = _globalListAdjustment;
#endif
Comment on lines +761 to +763
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't this need var anymore with the new named selection code.

#else
const TfToken selectionKind = GetSelectionKind();
const MGlobal::ListAdjustment listAdjustment = GetListAdjustment();
Expand Down Expand Up @@ -783,6 +788,10 @@ bool ProxyRenderDelegate::getInstancedSelectionPath(
return false;
}

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
auto ufeSel = Ufe::NamedSelection::get("MayaSelectTool");
ufeSel->append(si);
#else
Comment on lines +791 to +794
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We simply append any items to select to this named selection. Maya takes care of the replace/toggle/add/deselect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same changes in all the plugins.

auto globalSelection = Ufe::GlobalSelection::get();

switch (listAdjustment) {
Expand All @@ -802,6 +811,7 @@ bool ProxyRenderDelegate::getInstancedSelectionPath(
break;
default: TF_WARN("Unexpected MGlobal::ListAdjustment enum for selection."); break;
}
#endif
#else
dagPath = _proxyShapeData->ProxyDagPath();
#endif
Expand All @@ -812,7 +822,7 @@ bool ProxyRenderDelegate::getInstancedSelectionPath(
//! \brief Notify of selection change.
void ProxyRenderDelegate::SelectionChanged() { _selectionChanged = true; }

//! \brief Polulate lead and active selection for Rprims under the proxy shape.
//! \brief Populate lead and active selection for Rprims under the proxy shape.
void ProxyRenderDelegate::_PopulateSelection()
{
#if defined(WANT_UFE_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/ufe/UsdStageMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void UsdStageMap::addItem(const Ufe::Path& path, UsdStageWeakPtr stage)
{
// We expect a path to the proxy shape node, therefore a single segment.
auto nbSegments =
#ifdef UFE_V0_2_6_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2006
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed this ifdef as I noticed it was wrong.

path.nbSegments();
#else
path.getSegments().size();
Expand Down
11 changes: 11 additions & 0 deletions lib/usd/hdMaya/delegates/proxyDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

#if WANT_UFE_BUILD
#include <ufe/globalSelection.h>
#if UFE_PREVIEW_VERSION_NUM >= 2027
#include <ufe/namedSelection.h>
#endif
#include <ufe/observableSelection.h>
#include <ufe/rtid.h>
#include <ufe/runTimeMgr.h>
Expand Down Expand Up @@ -373,7 +376,11 @@ void HdMayaProxyDelegate::PopulateSelectionList(
if (handler == nullptr)
return;

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
auto ufeSel = Ufe::NamedSelection::get("MayaSelectTool");
#else
const MGlobal::ListAdjustment listAdjustment = GetListAdjustment();
#endif

std::lock_guard<std::mutex> lock(_allAdaptersMutex);

Expand Down Expand Up @@ -410,6 +417,9 @@ void HdMayaProxyDelegate::PopulateSelectionList(
break;
}

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
ufeSel->append(si);
#else
auto globalSelection = Ufe::GlobalSelection::get();

switch (listAdjustment) {
Expand All @@ -429,6 +439,7 @@ void HdMayaProxyDelegate::PopulateSelectionList(
break;
default: TF_WARN("Unexpected MGlobal::ListAdjustment enum for selection."); break;
}
#endif

break;
}
Expand Down
11 changes: 11 additions & 0 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyDrawOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include "AL/usdmaya/TypeIDs.h"
#include "ufe/globalSelection.h"
#include "ufe/log.h"
#if UFE_PREVIEW_VERSION_NUM >= 2027
#include <ufe/namedSelection.h>
#endif
#include "ufe/observableSelection.h"
#include "ufe/runTimeMgr.h"
#include "ufe/sceneItem.h"
Expand Down Expand Up @@ -691,7 +694,11 @@ bool ProxyDrawOverride::userSelect(
}

if (paths.size()) {
#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
auto ufeSel = Ufe::NamedSelection::get("MayaSelectTool");
#else
auto globalSelection = Ufe::GlobalSelection::get();
#endif

for (const auto& it : paths) {
// Build a path segment of the USD picked object
Expand All @@ -701,6 +708,9 @@ bool ProxyDrawOverride::userSelect(
const Ufe::SceneItem::Ptr& si { handler->createItem(
proxyShape->ufePath() + ps_usd) };

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
ufeSel->append(si);
#else
switch (listAdjustment) {
case MGlobal::kReplaceList:
// The list has been cleared before viewport selection runs, so we
Expand All @@ -721,6 +731,7 @@ bool ProxyDrawOverride::userSelect(
UFE_LOG("UFE does not support prepend to selection.");
break;
}
#endif
}
}
} else {
Expand Down
13 changes: 13 additions & 0 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "ufe/globalSelection.h"
#include "ufe/hierarchyHandler.h"
#include "ufe/log.h"
#if UFE_PREVIEW_VERSION_NUM >= 2027
#include <ufe/namedSelection.h>
#endif
#include "ufe/observableSelection.h"
#include "ufe/runTimeMgr.h"
#include "ufe/sceneItem.h"
Expand Down Expand Up @@ -509,8 +512,12 @@ bool ProxyShapeUI::select(
return false;
}

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
auto ufeSel = Ufe::NamedSelection::get("MayaSelectTool");
#else
Ufe::Selection dstSelection; // Only used for kReplaceList
// Get the paths
#endif
if (paths.size()) {
for (const auto& it : paths) {
// Build a path segment of the USD picked object
Expand All @@ -520,6 +527,9 @@ bool ProxyShapeUI::select(
const Ufe::SceneItem::Ptr& si { handler->createItem(
proxyShape->ufePath() + ps_usd) };

#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE
ufeSel->append(si);
#else
auto globalSelection = Ufe::GlobalSelection::get();

switch (mode) {
Expand All @@ -545,12 +555,15 @@ bool ProxyShapeUI::select(
UFE_LOG("UFE does not support prepend to selection.");
} break;
}
#endif
}

#if UFE_PREVIEW_VERSION_NUM < 2027 // #ifndef UFE_V2_FEATURES_AVAILABLE
if (mode == MGlobal::kReplaceList) {
// Add to Global selection
Ufe::GlobalSelection::get()->replaceWith(dstSelection);
}
#endif
}
} else {
#endif
Expand Down