From 798afc2fdf010c2faf83293136cb2c780c45df27 Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Wed, 27 Jul 2022 14:49:25 -0400 Subject: [PATCH 1/2] - Set HideOnPlayback flag to all new render items - Minor refactoring --- .../render/vp2RenderDelegate/basisCurves.cpp | 8 +--- .../vp2RenderDelegate/mayaPrimCommon.cpp | 37 ++++++++----------- .../render/vp2RenderDelegate/mayaPrimCommon.h | 2 + lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 16 +------- .../render/vp2RenderDelegate/points.cpp | 8 +--- 5 files changed, 22 insertions(+), 49 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp index 5e8f6cd1bd..af46d75d47 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp @@ -1460,11 +1460,7 @@ MHWRender::MRenderItem* HdVP2BasisCurves::_CreatePatchRenderItem(const MString& renderItem->castsShadows(false); renderItem->receivesShadows(false); renderItem->setShader(_delegate->Get3dSolidShader(kOpaqueGray)); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #ifdef MAYA_NEW_POINT_SNAPPING_SUPPORT MSelectionMask selectionMask(MSelectionMask::kSelectNurbsCurves); @@ -1478,8 +1474,6 @@ MHWRender::MRenderItem* HdVP2BasisCurves::_CreatePatchRenderItem(const MString& renderItem->setObjectTypeExclusionFlag(MHWRender::MFrameContext::kExcludeNurbsCurves); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp index c94b42d6b9..7428f9d98c 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp @@ -320,6 +320,19 @@ void MayaUsdRPrim::_PropagateDirtyBitsCommon(HdDirtyBits& bits, const ReprVector } } +void MayaUsdRPrim::_InitRenderItemCommon(MHWRender::MRenderItem* renderItem) const +{ +#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT + auto* const param = static_cast(_delegate->GetRenderParam()); + ProxyRenderDelegate& drawScene = param->GetDrawScene(); + drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); +#endif + + _SetWantConsolidation(*renderItem, true); + + renderItem->setHideOnPlayback(_hideOnPlayback); +} + /*! \brief Create render item for bbox repr. */ MHWRender::MRenderItem* MayaUsdRPrim::_CreateBoundingBoxRenderItem( @@ -336,18 +349,12 @@ MHWRender::MRenderItem* MayaUsdRPrim::_CreateBoundingBoxRenderItem( renderItem->receivesShadows(false); renderItem->setShader(_delegate->Get3dSolidShader(color)); renderItem->setSelectionMask(selectionMask); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #if MAYA_API_VERSION >= 20220000 renderItem->setObjectTypeExclusionFlag(exclusionFlag); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } @@ -375,18 +382,12 @@ MHWRender::MRenderItem* MayaUsdRPrim::_CreateWireframeRenderItem( #else renderItem->setSelectionMask(selectionMask); #endif -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #if MAYA_API_VERSION >= 20220000 renderItem->setObjectTypeExclusionFlag(exclusionFlag); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } @@ -410,18 +411,12 @@ MHWRender::MRenderItem* MayaUsdRPrim::_CreatePointsRenderItem( MSelectionMask selectionMasks(selectionMask); selectionMasks.addMask(MSelectionMask::kSelectPointsForGravity); renderItem->setSelectionMask(selectionMasks); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #if MAYA_API_VERSION >= 20220000 renderItem->setObjectTypeExclusionFlag(exclusionFlag); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } #endif diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h index e53fe218eb..6d513ddbeb 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h @@ -227,6 +227,8 @@ class MayaUsdRPrim //! Helper utility function to adapt Maya API changes. static void _SetWantConsolidation(MHWRender::MRenderItem& renderItem, bool state); + void _InitRenderItemCommon(MHWRender::MRenderItem* renderItem) const; + MHWRender::MRenderItem* _CreateWireframeRenderItem( const MString& name, const MColor& color, diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index fd2238d01d..5b3dd42ecc 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2509,11 +2509,7 @@ HdVP2DrawItem::RenderItemData& HdVP2Mesh::_CreateSmoothHullRenderItem( renderItem->castsShadows(true); renderItem->receivesShadows(true); renderItem->setShader(_delegate->GetFallbackShader(kOpaqueGray)); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #ifdef MAYA_NEW_POINT_SNAPPING_SUPPORT MSelectionMask selectionMask(MSelectionMask::kSelectMeshes); @@ -2531,8 +2527,6 @@ HdVP2DrawItem::RenderItemData& HdVP2Mesh::_CreateSmoothHullRenderItem( renderItem->setDefaultMaterialHandling(MRenderItem::SkipWhenDefaultMaterialActive); #endif - _SetWantConsolidation(*renderItem, true); - _delegate->GetVP2ResourceRegistry().EnqueueCommit( [&subSceneContainer, renderItem]() { subSceneContainer.add(renderItem); }); @@ -2554,18 +2548,12 @@ MHWRender::MRenderItem* HdVP2Mesh::_CreateSelectionHighlightRenderItem(const MSt renderItem->receivesShadows(false); renderItem->setShader(_delegate->Get3dSolidShader(kOpaqueBlue)); renderItem->setSelectionMask(MSelectionMask()); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #if MAYA_API_VERSION >= 20220000 renderItem->setObjectTypeExclusionFlag(MHWRender::MFrameContext::kExcludeMeshes); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } diff --git a/lib/mayaUsd/render/vp2RenderDelegate/points.cpp b/lib/mayaUsd/render/vp2RenderDelegate/points.cpp index f24a8899ed..9ae245f584 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/points.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/points.cpp @@ -1072,11 +1072,7 @@ MHWRender::MRenderItem* HdVP2Points::_CreateFatPointsRenderItem(const MString& n renderItem->castsShadows(false); renderItem->receivesShadows(false); renderItem->setShader(_delegate->GetPointsFallbackShader(MColor())); -#ifdef MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT - auto* const param = static_cast(_delegate->GetRenderParam()); - ProxyRenderDelegate& drawScene = param->GetDrawScene(); - drawScene.setUfeIdentifiers(*renderItem, _PrimSegmentString); -#endif + _InitRenderItemCommon(renderItem); #ifdef MAYA_NEW_POINT_SNAPPING_SUPPORT MSelectionMask selectionMask(MSelectionMask::kSelectParticleShapes); @@ -1090,8 +1086,6 @@ MHWRender::MRenderItem* HdVP2Points::_CreateFatPointsRenderItem(const MString& n renderItem->setObjectTypeExclusionFlag(MHWRender::MFrameContext::kExcludeNParticles); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; } From 83a5648fe0430f16732e9114afcb098cbc240656 Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Thu, 28 Jul 2022 07:58:27 -0400 Subject: [PATCH 2/2] Compilation fix --- lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp index 7428f9d98c..8f18feacc1 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp @@ -330,7 +330,9 @@ void MayaUsdRPrim::_InitRenderItemCommon(MHWRender::MRenderItem* renderItem) con _SetWantConsolidation(*renderItem, true); +#ifdef MAYA_HAS_RENDER_ITEM_HIDE_ON_PLAYBACK_API renderItem->setHideOnPlayback(_hideOnPlayback); +#endif } /*! \brief Create render item for bbox repr.