Autodesk / maya-usd

A common USD (Universal Scene Description) plugin for Autodesk Maya
760 stars 202 forks source link

[MAYA-114247] Selection Highlight doesn't update when changing selection with USD 21.11 #1752

Closed dj-mcg closed 2 years ago

dj-mcg commented 2 years ago

Describe the bug If building against the USD dev branch (which will become 21.11 shortly), selection highlighting does not update when selection changes. As soon as you poke metadata on the item in the AE (instanceable, kind, etc), selection highlight will update correctly.

Steps to reproduce Steps to reproduce the behavior:

  1. Create a new USD Scene
  2. Verify your USD Selection Mode is set appropriately to select individual prims
  3. Add a USD cube and a USD sphere
  4. Translate them so they are in different positions
  5. Change selection from cube to sphere and back again in either the Outliner or the Viewport
  6. Observe that selection highlight does not update
  7. Poke the Instanceable metadata checkbox for the selected prim in the AE
  8. Observe selection highlight updates correctly
  9. Try changing selection again
  10. Observe the broken behavior

Expected behavior Selection highlight appropriately updates when selection changes.

Specs (if applicable):

Additional context It appears the VP2 Render Delegate is expecting Hydra to resync upon selection change, since the actual highlight logic appears to be within some hydra sync callbacks. There has been recent changes to the Hydra resync logic, and with the latest version, Hydra doesn't think there is any reason to resync upon selection change. Changing metadata WILL force hydra to sync, which calls into the callback and updates selection highlight properly.

We may want to manage the selection logic ourselves so we aren't depending on syncing, similar to USDView - see examples here:

Selection Update Calls: pxr/usdImaging/usdviewq/stageView.py Selection Management and Rendering: pxr/usdImaging/usdImagingGL/engine.cpp Selection Tracking: pxr/imaging/hdx/selectionTracker.cpp

dj-mcg commented 2 years ago

shapes.tar.gz

dj-mcg commented 2 years ago

Just for tracking purposes, this is internal Pixar Jira MAYA-3120

williamkrick commented 2 years ago

@dj-mcg I've created a pull request to fix selection for vp2RenderDelegate. I had to take a different approach than Hydra Storm does. We don't really have a simple way to integrate that selection tracker idea into our draw pipeline. Instead I've tried to restore the old behavior of Sync-ing rprims which have selection changed. I do this by directly setting a dirty bit on selected/deselected prims, and then having the rest of the code work the same way.

Please let me know if this works for you.

dj-mcg commented 2 years ago

Thanks @williamkrick - I'll sync to your branch today and let you know

gracekumagai commented 2 years ago

Hey @williamkrick - thanks for the fix!

I'm testing with the branch that @dj-mcg built and so far, with "Smooth Shade All" shading, it seems to be working as expected.

However, when flipping to "Wireframe" or "Wireframe on shaded", the selection higlight starts sticking and drawing incorrectly again.

For example, the selection highlight will remain in the previous location:

  1. Open a new file in Maya 2022
  2. Navigate to Create -> Universal Scene Description (USD) -> Stage with new layer
  3. Right click on the proxy shape -> Add new prim -> Capsule
  4. Right click on the proxy shape -> Add new prim -> Cube
  5. Toggle the shading from "Smooth Shade All" to "Wireframe" and back to "Smooth Shade All" (I can sometimes reproduce this error without this step).
  6. Move the cube
  7. Toggle the shading back to "Wireframe"

You will notice that the wireframe draws around the original position of the cube and not at it's new position. It will update if you move the cube in the particular mode. The same drawing issue occurs when moving the cube in "Wireframe" and toggling back to "Smooth Shade All." selectionHighlight_smoothToWire

For example, the selection highlight will not update as you change selection:

  1. Open a new file in Maya 2022
  2. Navigate to Create -> Universal Scene Description (USD) -> Stage with new layer
  3. Right click on the proxy shape -> Add new prim -> Capsule
  4. Right click on the proxy shape -> Add new prim -> Cube
  5. Toggle the shading from "Smooth Shade All" to "Wireframe" (or "Wireframe on shaded")
  6. Move the cube
  7. Unselect the cube

You will notice that even though the cube is not selected, the wireframe is green. If you select the capsule, it will not update the wireframes. If you move the capsule, it will highlight, however, the cube's wireframe remains green. There are a few more observations in the gif: selectionHighlight_stuckWireframe

Let me know if you think this is a separate issue and I can file a separate ticket! Thank you so much!

williamkrick commented 2 years ago

@gracekumagai I will try to reproduce this and either re-open this one or log a new one on Thursday.

williamkrick commented 2 years ago

Re-opening while I work on a fix for the issues with wireframe and wireframe on shaded.

williamkrick commented 2 years ago

@gracekumagai I believe this is working correctly now, please let us know if you find more issues!