-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Instancing Selection : Selecting a hidden/invisible/disabled instance #1461
Comments
Filed as internal issue #USD-6583 |
For other USD folks, this is a sphere native instanced 5 times, with one of those invisible. It highlights properly in usdview. William: there's been a bit of churn in the selection API recently, which I apologize for, but it should be pretty robust in the latest version. There are essentially two ways to use them: 1.) HdxPickTask gives you a (hydra prim, hydra instance index) pair. This would look like (/root/group/ball_01.proto_mesh_id0, 3). If you call PopulateSelection(/root/group/ball_01.proto_mesh_id0, 3), you'll highlight the same object you picked. Note that although it's an SdfPath and an int, this pair means nothing to USD (at least, not necessarily). 2.) You can go the extra step of converting to USD addressing (with the caveat that USD can't address nested point instances as well as hydra can, but that's irrelevant in your case). To do this, you take the results of HdxPickTask and call GetScenePrimPath. This looks like GetScenePrimPath(/root/group/ball_01.proto_mesh_id0, 3) = /root/group/ball_03. If you then call PopulateSelection(/root/group/ball_03, -1), I'd expect the right highlight to show, just on the single instance. 2a.) Just for the sake of completeness, if /PointInstancer instances /PointInstancer/ball 4 times, and you pick one of the balls, I'd expect HdxPickTask to give you (/PointInstancer.proto_ball_id0, 2). GetScenePrimPath(/PointInstancer.proto_ball_id0, 2) would then give you (/PointInstancer/ball), plus instancer context { (/PointInstancer, 2) }. If you called PopulateSelection(/PointInstancer/ball, ), all the balls would be highlighted, but if you called PopulateSelection(/PointInstancer, 2), the precise ball you picked would be highlighted. Likewise for PopulateSelection(/PointInstancer.proto_ball_id0, 2). Note in cases of nested instancing the instance index for hydra addressing (with the ".") and USD addressing might not match. I'm not well versed enough in the vp2 code to tell what's happening between picking and selection but hopefully that's enough breadcrumbs for you to figure it out. Let me know if you have further questions, or if the functions aren't behaving like I'm describing! |
Thanks for getting back to me Tom. I read your answer quickly and I have a follow up: In Vp2RenderDelegate Maya is doing the picking and using Ufe to tell the plugin what is selected, so I don't have an HdxPickTask. Instead I have a Ufe::SceneItem::Ptr which is the output of the pick in Maya or running the select command in Maya or clicking on the object in Maya's outliner. I think that the details here are not relevant to the issue, but I would be happy to share more here if you think that would be valuable. Where I think the issue occurs is, based on my UFE selection I end up with a selection which converted to USD addressing is /root/group/ball_02 (the hidden instance). I pass that into PopulateSelection(/root/group/ball_02, -1), and I do not get the desired result. The PrimSelectionState I get back from USD has path /root/group/ball_01.proto_mesh_id0, and fullySelected is true. At that point USD is telling me all the instances are selected, so I have to draw them all selected. I would expect to get back (/root/group/ball_02) or (/root/group/ball_01.protot_mesh_id0, 2). Let me know if I have misunderstood part of your answer or if there is anything else I can add to clarify the situation. |
Ok, I see this on my end. If I select /root/group/ball 01, 03, 04, or 05 in the browser I get the expected selection highlight, but if I select 02 in the browser everything highlights. I'll follow up on that one internally. Are you having trouble with the instances being offset still? (Like selecting 03 in the browser highlights ball #4?) |
I will double check on the offset instances issue and get back to you tomorrow. I believe that the offset instances was a problem on our side and that it is either resolved or we're expecting to be able to resolve it soon, but I will verify that. |
I checked today & the offset instances issue has been resolved. Selecting any of the visible instances works as expected, we only have a problem when the invisible instance is selected. |
Today I validated that in USD v21.05 we now have the correct behavior when selecting a hidden instance. |
Thanks, @williamkrick - @tcauchois will be happy to hear that! |
Description of Issue
I'm working on the MayaUSD issue Autodesk/maya-usd#900, and I believe that there is an underlying issue with USD which is causing a part of this problem.
In USD 20.11 and later, when I tell USD that I am selecting an instance which is not visible by calling UsdImagingDelegate::PopulateSelection() with a path to the hidden instance then the HdSelection::PrimSelectionState I get back is not correct. The output selection state tells me that the whole instancer is selected, and so in all the other instances which are visible draw selected when they should not.
In USD 20.08 and earlier, when I tell USD my selection in the same way the PrimSelectionState I get back seems to be correct. Vp2RenderDelegate draws the wrong thing in these cases because of a Vp2RenderDelegate defect that I'm going to address. I think that once the problem in newer versions of USD is resolved, this incorrect behavior will come back to Vp2RenderDelegate.
Steps to Reproduce
I will provide some code pointers to where I am interacting with USD. The simplest place to see the issue is in the PopulateSelection function in vp2RenderDelegate/proxyRenderDelegate.cpp.
Here we make a call to UsdImagingDelegate::PopulateSelection() where the usdPath is /root/group/ball_02 (using the example scene in issue 900 as a concrete example) and instanceIndex is -1. When the desired path is hidden the resulting PrimSelectionState has path /root/group/ball_01.proto_mesh_id0, and fullySelected is true.
If I make a different selection of /root/group/ball_01, then the resulting PrimSelectionState is still /root/group/ball_01.proto_mesh_id0, but not fullySelected is false and I have a value in instanceIndices which is correct.
I do have another question, which is what is the purpose of the instanceIndex parameter of UsdImagingDelegate::PopulateSelection(). It seems to be ignored how I'm calling the function, but I am passing -1 in which is ALL_INSTANCES and maybe that is confusing things. Is there a way for me to convert from a path to a specific instance to the path of the instancer + the instance index? Kind of like an inverse GetSecenePrimPath() method. Otherwise I don't really see how I am meant to use that instanceIndex parameter. In any case, when the instance is not hidden everything works fine even though I'm passing -1 as the instanceIndex, so I think it should still work fine when a hidden instance is selected.
System Information (OS, Hardware)
Windows 10, I don't think it'll be relevant here I can provide all the information if it is necessary.
Package Versions
Build Flags
The text was updated successfully, but these errors were encountered: