From f26799cc5c1eac0ff8c9cc9455a63ade34bd22cf Mon Sep 17 00:00:00 2001 From: Dan Englesson Date: Thu, 20 Apr 2023 12:12:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20instancing=20for=20Maya202?= =?UTF-8?q?0/2022=20and=20don't=20rename=20refs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mayaUsd/fileio/translators/translatorMayaReference.cpp | 7 ++++--- lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp | 6 ++++-- .../render/vp2RenderDelegate/proxyRenderDelegate.cpp | 2 +- lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/mayaUsd/fileio/translators/translatorMayaReference.cpp b/lib/mayaUsd/fileio/translators/translatorMayaReference.cpp index b1594d7a07..6b2c0663a8 100644 --- a/lib/mayaUsd/fileio/translators/translatorMayaReference.cpp +++ b/lib/mayaUsd/fileio/translators/translatorMayaReference.cpp @@ -145,8 +145,8 @@ const bool useLegacyMayaRefNaming(const UsdPrim& prim) { // Check if the user requested that we use the legacy behavior for AL refs. // If not, we treat all references with the new scheme. - if (!TfGetenvBool("MAYA_USD_ENABLE_MAYA_REFERENCE_LEGACY_BEHAVIOUR", false)) - return false; + if (TfGetenvBool("MAYA_USD_ENABLE_MAYA_REFERENCE_LEGACY_BEHAVIOUR", false)) + return true; // MayaReference prims are using the new behaviour, others use the legacy behaviour. const TfToken MayaReference("MayaReference"); @@ -526,9 +526,10 @@ MStatus UsdMayaTranslatorMayaReference::update(const UsdPrim& prim, MObject pare if (!useLegacyScheme) { // On reconnect, the Maya reference node is renamed to match // the prim. - MString uniqueRefNodeName + /*MString uniqueRefNodeName = getUniqueRefNodeName(prim, parentDag, tempRefFn); tempRefFn.setName(uniqueRefNodeName); + */ status = setMayaRefCustomAttribute(prim, tempRefFn); CHECK_MSTATUS_AND_RETURN_IT(status); diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp index 0490f8dbbf..cb4b39f5dc 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp @@ -2308,8 +2308,10 @@ void HdVP2Mesh::_UpdateDrawItem( // prims. In case of multiple instances, we need to disable consolidation to allow // GPU instancing to be used. else if (newInstanceCount == 1) { - bool success = renderItem->setMatrix(&(*stateToCommit._instanceTransforms)[0]); - TF_VERIFY(success); + if (stateToCommit._instanceTransforms) { + bool success = renderItem->setMatrix(&(*stateToCommit._instanceTransforms)[0]); + TF_VERIFY(success); + } } else if (newInstanceCount > 1) { _SetWantConsolidation(*renderItem, false); #endif diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index 975efce9fc..6c57eacf91 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -894,7 +894,7 @@ void ProxyRenderDelegate::_UpdateSceneDelegate() InstancePrototypePath ProxyRenderDelegate::GetPathInPrototype(const SdfPath& id) { HdInstancerContext instancerContext; - auto usdInstancePath = GetScenePrimPath(id, 0, &instancerContext); + auto usdInstancePath = GetScenePrimPath(id, UsdImagingDelegate::ALL_INSTANCES, &instancerContext); // In case of point instancer, we already have the path in prototype, return it. if (!instancerContext.empty()) { diff --git a/lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp b/lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp index 8253376321..28e4f5ed83 100644 --- a/lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp +++ b/lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp @@ -387,7 +387,7 @@ MStatus HdVP2ShaderFragments::registerFragments() } } } - +#if MAYA_API_VERSION >= 20210000 { // This is a temporary fix for Maya 2022 that is quite fragile and will need to be revisited // in the near future. It will not handle the custom color space some large scale clients @@ -535,7 +535,6 @@ MStatus HdVP2ShaderFragments::registerFragments() LINREC709_TO_SCENE_LINREC709_REC_2020); } -#if MAYA_API_VERSION >= 20210000 // Register automatic shader stage input parameters. for (const auto& input : _automaticShaderStageInputs) {