From 4f47afa705c9b202f25ed12872c3c87b3455a6c8 Mon Sep 17 00:00:00 2001 From: Sean Donnelly <23455376+seando-adsk@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:18:26 -0500 Subject: [PATCH 1/2] MAYA-105322 - No undo support for viewport selections of USD objects * Use new Ufe::NamedSelection "MayaSelectTool" for viewport selection, rather than modifying UFE global selection directly. --- .../vp2RenderDelegate/proxyRenderDelegate.cpp | 12 +++++++++++- lib/mayaUsd/ufe/UsdStageMap.cpp | 2 +- lib/usd/hdMaya/delegates/proxyDelegate.cpp | 11 +++++++++++ .../AL/usdmaya/nodes/ProxyDrawOverride.cpp | 11 +++++++++++ .../AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp | 13 +++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index 39b6c3ed06..f829566eb1 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -49,6 +49,9 @@ #include #include +#if UFE_PREVIEW_VERSION_NUM >= 2027 // #ifdef UFE_V2_FEATURES_AVAILABLE +#include +#endif #include #include #include @@ -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 #else const TfToken selectionKind = GetSelectionKind(); const MGlobal::ListAdjustment listAdjustment = GetListAdjustment(); @@ -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 auto globalSelection = Ufe::GlobalSelection::get(); switch (listAdjustment) { @@ -802,6 +811,7 @@ bool ProxyRenderDelegate::getInstancedSelectionPath( break; default: TF_WARN("Unexpected MGlobal::ListAdjustment enum for selection."); break; } +#endif #else dagPath = _proxyShapeData->ProxyDagPath(); #endif @@ -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) diff --git a/lib/mayaUsd/ufe/UsdStageMap.cpp b/lib/mayaUsd/ufe/UsdStageMap.cpp index 84171f1307..2641a5ca27 100644 --- a/lib/mayaUsd/ufe/UsdStageMap.cpp +++ b/lib/mayaUsd/ufe/UsdStageMap.cpp @@ -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 path.nbSegments(); #else path.getSegments().size(); diff --git a/lib/usd/hdMaya/delegates/proxyDelegate.cpp b/lib/usd/hdMaya/delegates/proxyDelegate.cpp index 606584cb7e..a32c776901 100644 --- a/lib/usd/hdMaya/delegates/proxyDelegate.cpp +++ b/lib/usd/hdMaya/delegates/proxyDelegate.cpp @@ -38,6 +38,9 @@ #if WANT_UFE_BUILD #include +#if UFE_PREVIEW_VERSION_NUM >= 2027 +#include +#endif #include #include #include @@ -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 lock(_allAdaptersMutex); @@ -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) { @@ -429,6 +439,7 @@ void HdMayaProxyDelegate::PopulateSelectionList( break; default: TF_WARN("Unexpected MGlobal::ListAdjustment enum for selection."); break; } +#endif break; } diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyDrawOverride.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyDrawOverride.cpp index 248272d4a9..624aeccc42 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyDrawOverride.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyDrawOverride.cpp @@ -35,6 +35,9 @@ #include "AL/usdmaya/TypeIDs.h" #include "ufe/globalSelection.h" #include "ufe/log.h" +#if UFE_PREVIEW_VERSION_NUM >= 2027 +#include +#endif #include "ufe/observableSelection.h" #include "ufe/runTimeMgr.h" #include "ufe/sceneItem.h" @@ -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 @@ -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 @@ -721,6 +731,7 @@ bool ProxyDrawOverride::userSelect( UFE_LOG("UFE does not support prepend to selection."); break; } +#endif } } } else { diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp index e80ed52fde..b07d5f651e 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp @@ -33,6 +33,9 @@ #include "ufe/globalSelection.h" #include "ufe/hierarchyHandler.h" #include "ufe/log.h" +#if UFE_PREVIEW_VERSION_NUM >= 2027 +#include +#endif #include "ufe/observableSelection.h" #include "ufe/runTimeMgr.h" #include "ufe/sceneItem.h" @@ -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 @@ -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) { @@ -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 From 5bff7dd00b99d7e72e1cb82f72ed10b0f2583674 Mon Sep 17 00:00:00 2001 From: Sean Donnelly <23455376+seando-adsk@users.noreply.github.com> Date: Tue, 24 Nov 2020 13:15:08 -0500 Subject: [PATCH 2/2] MAYA-105322 - No undo support for viewport selections of USD objects * Fixing build error (unused function). --- lib/usd/hdMaya/delegates/proxyDelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/usd/hdMaya/delegates/proxyDelegate.cpp b/lib/usd/hdMaya/delegates/proxyDelegate.cpp index a32c776901..9f6feda517 100644 --- a/lib/usd/hdMaya/delegates/proxyDelegate.cpp +++ b/lib/usd/hdMaya/delegates/proxyDelegate.cpp @@ -142,7 +142,7 @@ void SetupPluginCallbacks() TF_VERIFY(status, "Could not set pluginUnloaded callback"); } -#if MAYA_API_VERSION >= 20210000 && WANT_UFE_BUILD +#if (MAYA_API_VERSION >= 20210000) && WANT_UFE_BUILD && (UFE_PREVIEW_VERSION_NUM < 2027) MGlobal::ListAdjustment GetListAdjustment() { // Keyboard modifiers can be queried from QApplication::keyboardModifiers()