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-30 : support faces picking in Hydra viewport #139

Merged
merged 7 commits into from
Jun 27, 2024
Merged

Conversation

lanierd-adsk
Copy link
Collaborator

No description provided.

@lanierd-adsk lanierd-adsk self-assigned this Jun 20, 2024
@@ -70,6 +70,9 @@ const std::string selectionHighlightMirrorTag = "_SelectionHighlight";

SdfPath _GetSelectionHighlightMirrorPathFromOriginal(const SdfPath& originalPath)
{
if (originalPath == SdfPath::AbsoluteRootPath()) {
Copy link
Collaborator Author

@lanierd-adsk lanierd-adsk Jun 24, 2024

Choose a reason for hiding this comment

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

Is a bug fix for a warning at maya startup

@@ -29,14 +30,6 @@

PXR_NAMESPACE_USING_DIRECTIVE

// An implementation for maya of the WireframeColorInterface to get the wireframe color from a prim for selection highlighting
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has been moved to mixedUtils.h to make this common to multiple cpp files

@@ -11,7 +11,7 @@ target_sources(${TARGET_NAME}
mayaHydraCameraDataSource.cpp
mayaHydraLightDataSource.cpp
mayaHydraDefaultLightDataSource.cpp
mayaHydraDefaultMaterialDataSource.cpp
mayaHydraMaterialDataSource.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mayaHydraDefaultMaterialDataSource has been converted to a generic mayaHydraMaterialDataSource class since nothing special in it was for the default material.

@@ -696,26 +740,41 @@ bool MayaHydraSceneIndex::AddPickHitToSelectionList(
const HdxPickHit& hit,
const MHWRender::MSelectionInfo& /* selectInfo */,
MSelectionList& selectionList,
MPointArray& worldSpaceHitPts)
MPointArray& worldSpaceHitPts,
bool& isOneNodeInComponentsPickingMode)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This new parameter is to handle when a node is being set in component selection

@@ -345,15 +345,27 @@ inline bool areDifferentForOneOfTheseBits(unsigned int val1, unsigned int val2,
return ((val1 & bitsToTest) != (val2 & bitsToTest));
}

inline bool isInComponentsPickingMode(const MHWRender::MSelectionInfo& selectInfo)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is used to detect the global component picking mode

@lanierd-adsk lanierd-adsk requested a review from ppt-adsk June 24, 2024 13:17
@lanierd-adsk
Copy link
Collaborator Author

@lilike-adsk @debloip-adsk

@lanierd-adsk lanierd-adsk requested review from debloip-adsk and removed request for ppt-adsk June 26, 2024 08:20
Copy link
Collaborator

@debloip-adsk debloip-adsk left a comment

Choose a reason for hiding this comment

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

Thanks for this work! Just a couple of very minor things and questions

@@ -142,7 +142,7 @@ void MayaHydraRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data
// const bool isNew = flags & MViewportScene::MVS_new; //not used yet
const bool visible = data._flags & MVS::MVS_visible;
const bool matrixChanged = data._flags & MVS::MVS_changedMatrix;
const bool geomChanged = (data._flags & MVS::MVS_changedGeometry) || positionsHaveBeenReset;
bool geomChanged = (data._flags & MVS::MVS_changedGeometry) || positionsHaveBeenReset;//Non const as we may modify it later
Copy link
Collaborator

Choose a reason for hiding this comment

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

If MAYA-134200 gets fixed, should this be const again? If so I'd probably mention the issue number here as well so we don't forget it

Comment on lines +211 to +212
MVertexBuffer* verts = mvb;
const unsigned int originalVertexCount = verts->vertexCount();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super nitpicky, but is there a reason we create a separate variable to point to the same object? As this could just be
const unsigned int originalVertexCount = mvb->vertexCount();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure what you mean ? We use the vertexCount in 2 places only in this function and keeping a variable for it wouldn't be useful IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's more that the mvb and verts variables are the same thing, so I wasn't sure why the verts variable was created when we could just re-use mvb. But it's nothing major, I'll approve the PR regardless :)

const unsigned int originalVertexCount = verts->vertexCount();
if (_positions.size() != originalVertexCount) {//Is it different ?
geomChanged = true;
vbIdx = vertexBuffercount; //Stop looping
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional/Thinking out loud : personally I would have instead gone with adding a check in the for loop's condition that checks for geomChanged not being true, i.e. for (int vbIdx = 0; vbIdx < vertexBuffercount && !geomChanged; vbIdx++).
Feels a bit closer to the intent, though it adds an extra comparison in potentially performance-sensitive code, so I don't know how much of an impact it would have.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I changed it the way you said.

Comment on lines 390 to 392
PxOsdOpenSubdivTokens
->none, // For the OGS normals vertex buffer to be used, we need to use
// PxOsdOpenSubdivTokens->none
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor autoformat nitpick, but breaking up the -> statement from its deref'd pointer feels a bit weird to me, I'd probably have the comment as a line above so autoformat doesn't split it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Comment on lines 416 to 417
_tokens
->MayaFacesSelectionMaterial); // Is an absolute path, not linked to a scene index
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same minor autoformat nitpick about breaking up the -> statement in two, I'd probably have the comment as a line above here as well

@@ -1690,22 +1700,41 @@ void MtohRenderOverride::_PopulateSelectionList(
const HdxPickHitVector& hits,
const MHWRender::MSelectionInfo& selectInfo,
MSelectionList& selectionList,
MPointArray& worldSpaceHitPts)
MPointArray& worldSpaceHitPts,
bool& isOneMayaNodeInComponentsPickingMode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Slight inconsistency : the variable is named isOneMayaNodeInComponentsPickingMode whilst the same conceptual value/variable is named isOneNodeInComponentsPickingMode elsewhere. I think it'd be clearer if everywhere else also used the Maya-explicit name as here, i.e. isOneMayaNodeInComponentsPickingMode

@@ -46,6 +46,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testDataProducerSelHighlight.py|skipOnPlatform:osx
testPassingNormalsOnMayaNative.py
testViewportFilters.py
testMayaComponentsPicking.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is an extra indent here

Comment on lines 1 to 5
//Maya ASCII 2026ff01 scene
//Name: componentsPicking.ma
//Last modified: Wed, Jun 19, 2024 06:08:46 PM
//Codeset: 1252
requires maya "2026ff01";
Copy link
Collaborator

@debloip-adsk debloip-adsk Jun 26, 2024

Choose a reason for hiding this comment

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

Maya version years need to be changed

Copy link
Collaborator

Choose a reason for hiding this comment

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

This still needs to be changed to a released Maya version, e.g. 2025

Comment on lines +1722 to +1724
// Maya does not create Hydra instances, so if the pick hit instancer
// ID isn't empty, it's not a Maya pick hit.
if (_mayaHydraSceneIndex && pickInput.pickHit.instancerId.IsEmpty() && _mayaHydraSceneIndex->IsPickedNodeInComponentsPickingMode(pickInput.pickHit)){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question : I'm assuming the instancerId check is just to accelerate things?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it was a test used by Pierre to double check this is a maya node that is being picked, I did a copy /paste of that same test

Comment on lines 1901 to 1906
//isOneNodeInComponentsPickingMode will be true if one of the picked node is in components picking mode
bool isOneNodeInComponentsPickingMode = false;
_PopulateSelectionList(outHits, selectInfo, selectionList, worldSpaceHitPts, isOneNodeInComponentsPickingMode);
if (isOneNodeInComponentsPickingMode){
return false;//When being in components picking on a node, returning false will use maya/OGS for components selection
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question : is component-picking not simply handled by the if (isInComponentsPickingMode(selectInfo)) check earlier? I think I remember a mention that there were different cases of component picking but I can't remember the other ones (other than right-click a selected object and go into component selection mode)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right that this needs clarification, so I've added the following comments to the code :
/*

  • There are 2 modes of selection picking for components in maya :
    1. You can be in components picking mode, this setting is global.This is detected in the function "isInComponentsPickingMode(selectInfo)"
    1. The second mode is when you right click on a node and choose a component to pick it (e.g : Face), this is
  • where we use the variable "isOneNodeInComponentsPickingMode" to detect that case, later in this function.
    */

@lanierd-adsk lanierd-adsk removed their assignment Jun 27, 2024
@lanierd-adsk lanierd-adsk self-assigned this Jun 27, 2024
Comment on lines 1 to 5
//Maya ASCII 2026ff01 scene
//Name: componentsPicking.ma
//Last modified: Wed, Jun 19, 2024 06:08:46 PM
//Codeset: 1252
requires maya "2026ff01";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This still needs to be changed to a released Maya version, e.g. 2025

Comment on lines +211 to +212
MVertexBuffer* verts = mvb;
const unsigned int originalVertexCount = verts->vertexCount();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's more that the mvb and verts variables are the same thing, so I wasn't sure why the verts variable was created when we could just re-use mvb. But it's nothing major, I'll approve the PR regardless :)

@lanierd-adsk lanierd-adsk removed their assignment Jun 27, 2024
@lanierd-adsk lanierd-adsk self-assigned this Jun 27, 2024
@lilike-adsk lilike-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jun 27, 2024
@lilike-adsk lilike-adsk merged commit 33857b5 into dev Jun 27, 2024
10 checks passed
@lilike-adsk lilike-adsk deleted the lanierd/HYDRA-30 branch June 27, 2024 14:54
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