-
Notifications
You must be signed in to change notification settings - Fork 201
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
MAYA-106477 selection and point snapping support for mtoh #776
Conversation
@marsupial can you review this change since you reported the missing API? I can't set you as a reviewer. |
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.
Overall, good to see some movement here.
I'm curious how the point-snapping and collection API is going to play with renderers other than Storm.
|
||
SdfPath usdPath = objectId.ReplacePrefix(delegateId, SdfPath::AbsoluteRootPath()); | ||
|
||
printf("usdPath: %s\n", usdPath.GetText()); |
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.
Should get commented out.
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 should have been removed by commit 9afde83.
{ | ||
if (selectInfo.pointSnapping()) { | ||
for (const HdxPickHit& hit : hits) { | ||
std::lock_guard<std::mutex> lock(_allAdaptersMutex); |
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.
Can the lock be acquired outside the for loop, or a comment stating why not.
const SdfPath& objectId = hit.objectId; | ||
const int instanceIndex = hit.instanceIndex; | ||
|
||
std::lock_guard<std::mutex> lock(_allAdaptersMutex); |
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.
Can the lock be moved out of the for-loop? There's very-likely little contention for it, but avoiding the lock/unlock cycle for every hit seems better for code triggered from UI.
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.
Good catch! I think it is better to move it outside of the for loop.
@kxl-adsk Can you confirm?
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.
Of course, this makes perfect sense.
Good question. I tested HdStorm and HdEmbree, which also helps me understand the responsibility of each component.
|
I'm not sure 2. is accurate (or maybe it's just a semantic point), the Hydra pick-task is different between Storm & EverythingElse, but delegates don't really implement it...they push buffers compatible with what the Hydra pick-task would like. That said, if Embree is doing what you want already, it's a pretty good sign. Waiting to get 119 installed so can check this out further. |
I didn't dig into how the pick task is implemented inside Hydra and/or render delegates, so 2. is more of a high-level concept. |
@marsupial Do you plan to test before approving the PR? |
I don't think I am an approver anyway, but starting to build/test now. |
Thanks. I see you are in the reviewers list, which is confusing. |
@marsupial see my earlier comment - #776 (comment) |
Overall working great. There is an issue with instances though, what I wound up doing was replacing these lines: maya-usd/lib/usd/hdMaya/delegates/proxyDelegate.cpp Lines 306 to 315 in e031614
With the following (the HdMayaProxyAdapter::delegate() method would need to be added as well):
@pmolodo might have more info, but the original code was probably an older version of USD where instance-selection was much less robust then it currently is. We've been using the PopulateSelection() call in this place for months, and should work for > 20.x (hopefully 19.11 too). |
Two outstanding issues related to selection (which I don't think should hold this up):
|
@marsupial Thanks for pointing out the selection highlight issue and providing the code. I just pushed a new commit that follows your suggestion. For the two outstanding issues, our priority for this task is to fix the blocking part, which is the missing API in maya for selection. For legacy issues and feature improvement, we will most likely rely on partners to do it. Hope it makes sense. |
Yes, the function has also been used in VP2RenderDelegate since last August. |
As noted, not an approver, but LGTM! |
@marsupial Re minimalizing duplicated efforts. We have no plans in near future to work on select by kind support in mtoh. If I understood your second point correctly, you are talking about draw override integration of Storm (not mtoh). This is a legacy drawing routine and we are not investing in it. We are focusing on VP2RenderDelegate which removes a number of limitations like shadows across two data models, screen-space effects, etc. In which scenarios you are using this legacy rendering mode? |
@kxl-adsk: The 'legacy' rendering mode is the fallback for us. The VP2RenderDelegate is still quite a ways off from being useable. From prior conversations and the file we sent you:
|
@marsupial Many materials problem you reported is next in line to look at. Good to know that it's the only adoption blocker you 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.
Looks good. I think we might make situationally better use of the resolveMode
, but I suppose that falls more under the class of an optimization.
pickParams.resolution.Set(view_w, view_h); | ||
pickParams.viewMatrix.Set(viewMatrix.matrix); | ||
pickParams.projectionMatrix.Set(projMatrix.matrix); | ||
pickParams.resolveMode = HdxPickTokens->resolveUnique; |
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 think we probably want to vary this depending on what selectInfo.singleSelection
and selectInfo.selectClosest
return. resolveUnique
makes sense for a marquee-selection scenario (within the limits under discussion here), but probably doesn't for single select.
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.
Maybe, but I haven't seen issue for single selection when testing the code. With the code merged, I am sure there are still some improvements in the plugin side as we iterate over time. So maybe something for future?
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.
Well, like I said, this falls more under the class of an optimization. It's a pretty easy check to make, and you'd then be able to skip the ResolveUniqueHits_Workaround
if you were doing resolveNearestToCenter
or resolveNearestToCamera
... but you're likely also right, in that it may not be noticeable for single select, since the pick region is generally going to be pretty small. So your call.
@@ -175,6 +184,11 @@ class MtohRenderOverride : public MHWRender::MRenderOverride { | |||
HdRprimCollection _selectionCollection{ | |||
HdReprTokens->wire, HdReprSelector(HdReprTokens->wire) | |||
}; | |||
HdRprimCollection _pointSnappingCollection{ |
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.
Might be worth also hiding this one behind a 20210000
version guard, since it's only used there.
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.
Good point.
@kxl-adsk Please merge. Thanks. |
The change requires new Maya APIs and needs to be merged after Maya PR119 is published.