diff --git a/lib/mayaHydra/hydraExtensions/mayaHydra.h.src b/lib/mayaHydra/hydraExtensions/mayaHydra.h.src index e3f29d2e2c..e7ef2e5ad2 100644 --- a/lib/mayaHydra/hydraExtensions/mayaHydra.h.src +++ b/lib/mayaHydra/hydraExtensions/mayaHydra.h.src @@ -19,6 +19,7 @@ #define MAYAHYDRA_MAJOR_VERSION ${MAYAHYDRA_MAJOR_VERSION} #define MAYAHYDRA_MINOR_VERSION ${MAYAHYDRA_MINOR_VERSION} #define MAYAHYDRA_PATCH_LEVEL ${MAYAHYDRA_PATCH_LEVEL} +#define MAYAHYDRA_API_VERSION (MAYAHYDRA_MAJOR_VERSION * 10000 + MAYAHYDRA_MINOR_VERSION * 100 + MAYAHYDRA_PATCH_LEVEL) // MayaHydra public namespace string will never change. #define MAYAHYDRA_NS MayaHydra diff --git a/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp b/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp index 2f4ef5bd74..9c8685c04a 100644 --- a/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp +++ b/lib/mayaHydra/hydraExtensions/sceneIndex/registration.cpp @@ -163,8 +163,6 @@ bool MayaHydraSceneIndexRegistry::_RemoveSceneIndexForNode(const MObject& dagNod return false; } -constexpr char kDataSourceEntryNodePathName[] = { "object" }; -constexpr char kDataSourceEntryInterpretRprimPathName[] = { "interpretRprimPath" }; constexpr char kSceneIndexPluginSuffix[] = { "MayaNodeSceneIndexPlugin" }; // every scene index plugin compatible with the hydra viewport requires this suffix @@ -182,23 +180,29 @@ void MayaHydraSceneIndexRegistry::_AddSceneIndexForNode(MObject& dagNode) = HdSceneIndexPluginRegistry::GetInstance(); if (sceneIndexPluginRegistry.IsRegisteredPlugin(sceneIndexPluginId)) { using MayaHydraMObjectDataSource = HdRetainedTypedSampledDataSource; + using MayaHydraVersionDataSource = HdRetainedTypedSampledDataSource; // Functions retrieved from the scene index plugin using MayaHydraInterpretRprimPathDataSource = HdRetainedTypedSampledDataSource; // Create the registration record which is then added into the registry if everything // succeeds + static TfToken sDataSourceEntryNames[] { TfToken("object"), + TfToken("version"), + TfToken("interpretRprimPath") }; + constexpr int kDataSourceNumEntries = sizeof(sDataSourceEntryNames) / sizeof(TfToken); MayaHydraSceneIndexRegistrationPtr registration(new MayaHydraSceneIndexRegistration()); - - TfToken names[3] { - - TfToken(kDataSourceEntryNodePathName), TfToken(kDataSourceEntryInterpretRprimPathName) - }; - HdDataSourceBaseHandle values[2] { MayaHydraMObjectDataSource::New(dagNode), - MayaHydraInterpretRprimPathDataSource::New( - registration->interpretRprimPathFn) }; + HdDataSourceBaseHandle values[] { MayaHydraMObjectDataSource::New(dagNode), + MayaHydraVersionDataSource::New(MAYAHYDRA_API_VERSION), + MayaHydraInterpretRprimPathDataSource::New( + registration->interpretRprimPathFn) }; + static_assert( + sizeof(values) / sizeof(HdDataSourceBaseHandle) == kDataSourceNumEntries, + "Incorrect number of data source entries"); registration->pluginSceneIndex = sceneIndexPluginRegistry.AppendSceneIndex( - sceneIndexPluginId, nullptr, HdRetainedContainerDataSource::New(2, names, values)); + sceneIndexPluginId, + nullptr, + HdRetainedContainerDataSource::New(kDataSourceNumEntries, sDataSourceEntryNames, values)); if (TF_VERIFY( registration->pluginSceneIndex, "HdSceneIndexBase::AppendSceneIndex failed to create %s scene index from given "