From 8c55c4c2234e5f1a701c97a141714ea056770abf Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Wed, 8 May 2024 15:49:17 -0400 Subject: [PATCH] Update from 24.03 to 24.05. --- .../sceneIndex/mayaHydraSceneIndexUtils.h | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndexUtils.h b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndexUtils.h index 19329a7651..ab884521d8 100644 --- a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndexUtils.h +++ b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndexUtils.h @@ -28,11 +28,12 @@ PXR_NAMESPACE_OPEN_SCOPE -#if PXR_VERSION > 2311 -static bool -_ConvertHdMaterialNetworkToHdDataSources( - const HdMaterialNetworkMap &hdNetworkMap, - HdContainerDataSourceHandle *result) +#if PXR_VERSION >= 2405 + +static +HdContainerDataSourceHandle +_ToMaterialNetworkSchema( + const HdMaterialNetworkMap& hdNetworkMap) { HD_TRACE_FUNCTION(); @@ -91,7 +92,8 @@ _ConvertHdMaterialNetworkToHdDataSources( .SetValue( HdRetainedTypedSampledDataSource::New( item.second.value)) - .SetColorSpace(item.second.colorSpace.IsEmpty() + .SetColorSpace( + item.second.colorSpace.IsEmpty() ? nullptr : HdRetainedTypedSampledDataSource::New( item.second.colorSpace)) @@ -108,7 +110,7 @@ _ConvertHdMaterialNetworkToHdDataSources( TfSmallVector cValues; for (const HdMaterialRelationship &rel : hdNetwork.relationships) { - if (rel.outputId == node.path) { + if (rel.outputId == node.path) { TfToken outputPath = rel.inputId.GetToken(); TfToken outputName = TfToken(rel.inputName.GetString()); @@ -171,22 +173,30 @@ _ConvertHdMaterialNetworkToHdDataSources( HdContainerDataSourceHandle nodesDefaultContext = HdRetainedContainerDataSource::New( - nodeNames.size(), + nodeNames.size(), nodeNames.data(), nodeValues.data()); HdContainerDataSourceHandle terminalsDefaultContext = HdRetainedContainerDataSource::New( - terminalsNames.size(), + terminalsNames.size(), terminalsNames.data(), terminalsValues.data()); - // Create the material network, potentially one per network selector - HdDataSourceBaseHandle network = HdMaterialNetworkSchema::Builder() + return HdMaterialNetworkSchema::Builder() .SetNodes(nodesDefaultContext) .SetTerminals(terminalsDefaultContext) .Build(); - +} + +static bool +_ConvertHdMaterialNetworkToHdDataSources( + const HdMaterialNetworkMap &hdNetworkMap, + HdContainerDataSourceHandle *result) +{ + // Create the material network, potentially one per network selector + HdDataSourceBaseHandle network = _ToMaterialNetworkSchema(hdNetworkMap); + TfToken defaultContext = HdMaterialSchemaTokens->universalRenderContext; *result = HdMaterialSchema::BuildRetained( 1, @@ -195,7 +205,9 @@ _ConvertHdMaterialNetworkToHdDataSources( return true; } + #else + static bool _ConvertHdMaterialNetworkToHdDataSources( const HdMaterialNetworkMap &hdNetworkMap,