From d7ff4e320d849e28fe8ff7122770f1e32b9e6bcf Mon Sep 17 00:00:00 2001 From: debloip Date: Thu, 4 Jul 2024 12:46:39 -0400 Subject: [PATCH] HYDRA-1058 : Handle build support for USD < 2403 --- lib/mayaHydra/mayaPlugin/renderOverride.cpp | 6 ++++++ lib/mayaHydra/mayaPlugin/viewCommand.cpp | 9 +++++++++ scripts/mayaHydra_GeomSubsetsPickMode.mel | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/mayaHydra/mayaPlugin/renderOverride.cpp b/lib/mayaHydra/mayaPlugin/renderOverride.cpp index f49e580a23..bb1ddeaa00 100644 --- a/lib/mayaHydra/mayaPlugin/renderOverride.cpp +++ b/lib/mayaHydra/mayaPlugin/renderOverride.cpp @@ -465,6 +465,7 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase { UsdPickHandler(MtohRenderOverride& renderOverride) : PickHandlerBase(renderOverride) {} +#if PXR_VERSION >= 2403 std::vector resolveGeomSubsetsPicking( HdSceneIndexBaseConstRefPtr sceneIndex, const SdfPath& basePrimPath, @@ -501,6 +502,7 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase { } return pickedGeomSubsets; } +#endif // Return the closest path and the instance index in the scene index scene // that corresponds to the pick hit. If the pick hit is not an instance, @@ -563,6 +565,7 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase { std::vector hitPaths; +#if PXR_VERSION >= 2403 if (GetGeomSubsetsPickMode() == GeomSubsetsPickModeTokens->Faces) { auto geomSubsetsHitPaths = resolveGeomSubsetsPicking( renderIndex()->GetTerminalSceneIndex(), @@ -580,6 +583,9 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase { } else { hitPaths.push_back(resolvePrimAndInstancePicking(*renderIndex(), pickInput.pickHit)); } +#else + hitPaths.push_back(resolvePrimAndInstancePicking(*renderIndex(), pickInput.pickHit)); +#endif size_t nbSelectedUfeItems = 0; for (const auto& [pickedUsdPath, instanceNdx] : hitPaths) { diff --git a/lib/mayaHydra/mayaPlugin/viewCommand.cpp b/lib/mayaHydra/mayaPlugin/viewCommand.cpp index 75dad64369..960c517b9f 100644 --- a/lib/mayaHydra/mayaPlugin/viewCommand.cpp +++ b/lib/mayaHydra/mayaPlugin/viewCommand.cpp @@ -28,6 +28,8 @@ #include #include +#include + PXR_NAMESPACE_USING_DIRECTIVE namespace MAYAHYDRA_NS_DEF { @@ -92,6 +94,9 @@ constexpr auto _gitCommitLong = "-gitCommit"; constexpr auto _gitBranchLong = "-gitBranch"; constexpr auto _buildDateLong = "-buildDate"; +constexpr auto _usdVersion = "-uv"; +constexpr auto _usdVersionLong = "-usdVersion"; + constexpr auto _rendererId = "-r"; constexpr auto _rendererIdLong = "-renderer"; @@ -181,6 +186,8 @@ MSyntax MtohViewCmd::createSyntax() syntax.addFlag(_gitBranch, _gitBranchLong); syntax.addFlag(_buildDate, _buildDateLong); + syntax.addFlag(_usdVersion, _usdVersionLong); + return syntax; } @@ -303,6 +310,8 @@ MStatus MtohViewCmd::doIt(const MArgList& args) setResult(MhBuildInfo::gitBranch()); } else if (db.isFlagSet(_buildDate)) { setResult(MhBuildInfo::buildDate()); + } else if (db.isFlagSet(_usdVersion)) { + setResult(PXR_VERSION); } return MS::kSuccess; } diff --git a/scripts/mayaHydra_GeomSubsetsPickMode.mel b/scripts/mayaHydra_GeomSubsetsPickMode.mel index 0bf1dca278..561e27da78 100644 --- a/scripts/mayaHydra_GeomSubsetsPickMode.mel +++ b/scripts/mayaHydra_GeomSubsetsPickMode.mel @@ -62,6 +62,10 @@ global proc mayaHydra_GeomSubsetsPickMode_SetMode(string $mode) { // Main entry point to create the GeomSubsets UI global proc mayaHydra_GeomSubsetsPickMode_SetupUI() { + if (`mayaHydra -usdVersion` < 2403) { + return; + } + mayaHydra_GeomSubsetsPickMode_SetupRuntimeCommands; global string $gMainSelectMenu; // Maya's "Select" menu $callbackExists = hasMenuCallback($gMainSelectMenu, "mayaHydra_GeomSubsetsPickModeMenu_SelectMenuOpenedCallback"); @@ -72,6 +76,10 @@ global proc mayaHydra_GeomSubsetsPickMode_SetupUI() { // Main entry point to delete the GeomSubsets UI global proc mayaHydra_GeomSubsetsPickMode_TeardownUI() { + if (`mayaHydra -usdVersion` < 2403) { + return; + } + global string $gMainSelectMenu; // Maya's "Select" menu removeMenuCallback($gMainSelectMenu, "mayaHydra_GeomSubsetsPickModeMenu_SelectMenuOpenedCallback");