Skip to content

Commit

Permalink
HYDRA-1058 : Handle build support for USD < 2403
Browse files Browse the repository at this point in the history
  • Loading branch information
debloip-adsk committed Jul 4, 2024
1 parent d580ab8 commit d7ff4e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/mayaHydra/mayaPlugin/renderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase {
UsdPickHandler(MtohRenderOverride& renderOverride) :
PickHandlerBase(renderOverride) {}

#if PXR_VERSION >= 2403
std::vector<HitPath> resolveGeomSubsetsPicking(
HdSceneIndexBaseConstRefPtr sceneIndex,
const SdfPath& basePrimPath,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -563,6 +565,7 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase {

std::vector<HitPath> hitPaths;

#if PXR_VERSION >= 2403
if (GetGeomSubsetsPickMode() == GeomSubsetsPickModeTokens->Faces) {
auto geomSubsetsHitPaths = resolveGeomSubsetsPicking(
renderIndex()->GetTerminalSceneIndex(),
Expand All @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions lib/mayaHydra/mayaPlugin/viewCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <maya/MGlobal.h>
#include <maya/MSyntax.h>

#include <pxr/pxr.h>

PXR_NAMESPACE_USING_DIRECTIVE

namespace MAYAHYDRA_NS_DEF {
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -181,6 +186,8 @@ MSyntax MtohViewCmd::createSyntax()
syntax.addFlag(_gitBranch, _gitBranchLong);
syntax.addFlag(_buildDate, _buildDateLong);

syntax.addFlag(_usdVersion, _usdVersionLong);

return syntax;
}

Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions scripts/mayaHydra_GeomSubsetsPickMode.mel
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");

Expand Down

0 comments on commit d7ff4e3

Please sign in to comment.