-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
@@ -70,6 +70,9 @@ const std::string selectionHighlightMirrorTag = "_SelectionHighlight"; | |||
|
|||
SdfPath _GetSelectionHighlightMirrorPathFromOriginal(const SdfPath& originalPath) | |||
{ | |||
if (originalPath == SdfPath::AbsoluteRootPath()) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
…ou changed it in the UI.
…omponents picking mode on nodes
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
MVertexBuffer* verts = mvb; | ||
const unsigned int originalVertexCount = verts->vertexCount(); |
There was a problem hiding this comment.
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();
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
PxOsdOpenSubdivTokens | ||
->none, // For the OGS normals vertex buffer to be used, we need to use | ||
// PxOsdOpenSubdivTokens->none |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
_tokens | ||
->MayaFacesSelectionMaterial); // Is an absolute path, not linked to a scene index |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
//Maya ASCII 2026ff01 scene | ||
//Name: componentsPicking.ma | ||
//Last modified: Wed, Jun 19, 2024 06:08:46 PM | ||
//Codeset: 1252 | ||
requires maya "2026ff01"; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
// 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)){ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
//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 | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 :
-
- You can be in components picking mode, this setting is global.This is detected in the function "isInComponentsPickingMode(selectInfo)"
-
- 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.
*/
//Maya ASCII 2026ff01 scene | ||
//Name: componentsPicking.ma | ||
//Last modified: Wed, Jun 19, 2024 06:08:46 PM | ||
//Codeset: 1252 | ||
requires maya "2026ff01"; |
There was a problem hiding this comment.
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
MVertexBuffer* verts = mvb; | ||
const unsigned int originalVertexCount = verts->vertexCount(); |
There was a problem hiding this comment.
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 :)
No description provided.