Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYDRA-1058/HYDRA-970 : GeomSubsets picking filter + Fix multi-selection when single-picking #143

Merged
merged 76 commits into from
Jul 9, 2024

Conversation

debloip-adsk
Copy link
Collaborator

@debloip-adsk debloip-adsk commented Jul 5, 2024

This PR adds GeomSubsets picking functionality, and extends the "USD Selection Mode" menu with a GeomSubsets section. Bundled with it is a fix for the HYDRA-970 issue where doing a single click could select more than one prim (the fix was required to properly implement the following behavior from HYDRA-1058 : "A single pick selects either a GeomSubset, or if the picked object is not a GeomSubset, the parent prim is selected").


// Clear any registered callbacks
MGlobal::executeCommand("callbacks -cc mayaHydra;");
MGlobal::executeCommand("callbacks -cc -owner mayaHydra;");
Copy link
Collaborator Author

@debloip-adsk debloip-adsk Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the following error that was raised when trying to unload mayaHydra : When clearing callbacks, the owner must be specified. Note that mayaHydra still doesn't unload properly (and already didn't before this PR, even with this fix), but at least that's one issue down.


const HdxPickHit& pickHit;
const MHWRender::MSelectionInfo& pickInfo;
const bool isSolePickHit;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to differentiate/handle the following behaviors from HYDRA-1058 :

  • Marquee select only selects GeomSubsets, never the parent prims
  • A single pick selects either a GeomSubset, or if the picked object is not a GeomSubset, the parent prim is selected

@@ -450,15 +464,54 @@ class UsdPickHandler : public MtohRenderOverride::PickHandlerBase {

UsdPickHandler(MtohRenderOverride& renderOverride) :
PickHandlerBase(renderOverride) {}

#if PXR_VERSION >= 2403
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeomSubset Hydra prims were only added in USD 24.03

// numeric path components are not allowed by SdfPath. Do so
// here with Ufe::Path, which has no such restriction.
return pickedMayaPath + std::to_string(instanceNdx);
std::vector<HitPath> hitPaths;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now handle multiple paths, since a given component (e.g. face) of a mesh can be in more than one GeomSubset.

Comment on lines +1865 to +1871
pickParams.pickTarget = HdxPickTokens->pickPrimsAndInstances;
pickParams.resolveMode = singlePick ? HdxPickTokens->resolveNearestToCenter : HdxPickTokens->resolveUnique;
pickParams.doUnpickablesOcclude = false;
pickParams.viewMatrix.Set(viewMatrix.matrix);
pickParams.projectionMatrix.Set(adjustedProjMatrix.matrix);
pickParams.resolveMode = HdxPickTokens->resolveUnique;
pickParams.collection = _renderCollection;
pickParams.outHits = &outHits;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Reorganized the params configuration to explicitly set the default values first, and then override them based on special behaviors afterwards.
  • The resolveMode is now different if singlePick is true : the resolveNearestToCenter mode will only return the prim that is closest to the center of the selection. This fixes HYDRA-970.
  • Explicitly set doUnpickablesOcclude to false, as it was the default value and our existing behavior, to avoid unforeseen surprises if the default value ever changes.

@@ -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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use PXR_VERSION to conditionally compile the GeomSubsets pick resolution code; since the feature can't be made available when building with earlier USD versions, we also need to not show the GeomSubsets pick filter UI in such cases. However, we had no way of determining what USD version the plugin was built with from MEL/Python; this added flag to the mayaHydra command does just that.

// object is returned. Therefore test that the expected selected path is
// in the selection.
ASSERT_GE(sn->size(), 1u);
ASSERT_EQ(sn->size(), 1u);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted since we should no longer have more than one prim selected when single-clicking.

Comment on lines +43 to +44
cmds.setAttr('persp.translate', 15, 15, 10, type='float3')
cmds.setAttr('persp.rotate', -40, 60, 0, type='float3')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the tests previously clicked on the boundary between two prims, but was closer to the wrong prim than the correct one, and with the fix for HYDRA-970, this made the test fail. Adjusted the camera angle slightly so that the mouse click is on the correct prim.

Comment on lines +58 to +80
def Xform "CubeUpperHalfMarker"
{
double3 xformOp:translate = (-2, 0.5, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}

def Xform "CubeLowerHalfMarker"
{
double3 xformOp:translate = (-2, -0.5, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}

def Xform "SphereInstanceUpperHalfMarker"
{
double3 xformOp:translate = (2, 0.5, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}

def Xform "SphereInstanceLowerHalfMarker"
{
double3 xformOp:translate = (2, -0.5, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}
Copy link
Collaborator Author

@debloip-adsk debloip-adsk Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markers are used for pointing the test mouse clicks at the right spots, as by default just using a prim's transform will point to its center, but we want to click at slightly different offsets from the center, and we can't use screen-space offsets, since viewport sizes can differ.

@debloip-adsk debloip-adsk self-assigned this Jul 5, 2024
@debloip-adsk debloip-adsk requested a review from lanierd-adsk July 5, 2024 21:50
@debloip-adsk debloip-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jul 8, 2024
@lilike-adsk lilike-adsk merged commit 214f104 into dev Jul 9, 2024
10 checks passed
@lilike-adsk lilike-adsk deleted the debloip/HYDRA-1058/geomsubset-picking branch July 9, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants