diff --git a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp index 63ee6ab859..7210f1bc8f 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/basisCurves.cpp @@ -1475,11 +1475,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); @@ -1493,8 +1489,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 78d43826c8..716fdc8013 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp @@ -320,6 +320,21 @@ 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); + +#ifdef MAYA_HAS_RENDER_ITEM_HIDE_ON_PLAYBACK_API + renderItem->setHideOnPlayback(_hideOnPlayback); +#endif +} + /*! \brief Create render item for bbox repr. */ MHWRender::MRenderItem* MayaUsdRPrim::_CreateBoundingBoxRenderItem( @@ -336,18 +351,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 +384,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 +413,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 b5989a558d..1f158b0f8e 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h @@ -234,6 +234,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 3261b3263c..cc2cf92c3c 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2535,11 +2535,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); @@ -2557,8 +2553,6 @@ HdVP2DrawItem::RenderItemData& HdVP2Mesh::_CreateSmoothHullRenderItem( renderItem->setDefaultMaterialHandling(MRenderItem::SkipWhenDefaultMaterialActive); #endif - _SetWantConsolidation(*renderItem, true); - _delegate->GetVP2ResourceRegistry().EnqueueCommit( [&subSceneContainer, renderItem]() { subSceneContainer.add(renderItem); }); @@ -2580,18 +2574,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 2281896116..cc2ffc0ada 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/points.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/points.cpp @@ -1091,11 +1091,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); @@ -1109,8 +1105,6 @@ MHWRender::MRenderItem* HdVP2Points::_CreateFatPointsRenderItem(const MString& n renderItem->setObjectTypeExclusionFlag(MHWRender::MFrameContext::kExcludeNParticles); #endif - _SetWantConsolidation(*renderItem, true); - return renderItem; }