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

T bailp/maya 112769/usd prim selectability #1673

Merged
merged 9 commits into from
Aug 31, 2021

Conversation

pierrebai-adsk
Copy link
Collaborator

Add control over the selectability of USD prims in the Maya viewport. The
selectability is controlled by a metadata USD token on the prim, named
"mayaSelectability". The name was chosen to display nicely in teh attribute editor which will convert it to "Maya Selectability".

The metadata can have three states: "on", off" or "inherit". If the metadata is
missing, the default is "inherit". The reason to have an explicit "inherit"
state is to allow a USD layer to override the setting on a prim.

A prim is selectable if "on" or "inherit" under an "on" ancestor. Similarly, it
is unselectable if "off" or if inheriting "off" from an ancestor. An explicit
state always override ancestors, so a prim can be selectable under and
unselectable prim.

Using these names for the states makes them generic in case we want to add
other inheritable metadata. They will be able to follow the same naming
convention.

The selectability computation is kept in its own C++ file and class:
"selectability.h", "selectability.cpp" and Selectability. The class provides three static functions:
prepareForSelection(), isSelectable() and getLocalState(). The first is called before doing multiple
calls to isSelectable(). The function isSelectable() is the core of the
functionality and returns true or false for a given prim. The getLocalState()
function gets the state on a given prim without checking inheritance. The
Selectability class also declares a selectability state enum and the metadata
and value tokens.

The Selectability class is used in the Maya USD proxy render delegate class, in the render library.
The metadata is registered via plugInfo.json, registered at plugin
initialization. The plugInfo.json file in under the utils library.

Internally, a cache is used to speed up the computation of multiple calls to isSelectable(), since
most prim will be in the "inherit" state and will have to check their parent
prim. This cache is cleared when preprareForSelection() is called. The cache
accelerates the verification of selectability in big scenes of thousands of
prims, for example when they are all being selected. Throwing away the cache at
the beginning of each batch of selections does not costs much performance and
avoids the always thorny problem of cache invalidation.

There are units tests for:

  • a single prim having different selectability in different USD layers and that the result is correct.
  • various selectability scenarios for a single prim.
  • instances and instancers,

- If set to "unselectable" then it is not selectable.
- Per-prim, sub-prim can be selected.
- Metadata is registered via plugInfo.json, registered at plugin initialization.

- place the plugInfo.json in the render library.
- Moved selectability code to its own file.
- Declared selectability state enum.
- Declared the metadata and value tokens.
- Added C++ functions to get and compute selectability.
- Use it in the proxy render delegate.
Add tests for a single prim having different selectability in different USD layers and that the result is correct.
…bility state names

The cache is cleared at the beginning of each selection to avoid the always thorny problem of cache invalidation.
The cache accelerate the verification of selectability in bug scene of thousands of prims being all region-selected.

Change "selectable" to "on", Change "unselectable" to "off".
This makes the state more generic in case we ant to add other inheritable metadata. They will be able to follow the same naming convention: metadata-name = "on" | off" | "inherit"
This makes teh name more compatible with how the Maya Attribute Editor convert metadata names to UI labels. It removes underscores but adds a space before uppercase letter. Thus the new name result in a UI label "Maya Selectability" which is more readable than "mayaselectability".
Move the code and metadata declarations in the utils folder. Use correct ifdef in the header file.
@pierrebai-adsk pierrebai-adsk added core Related to core library enhancement New feature or request vp2renderdelegate Related to VP2RenderDelegate labels Aug 31, 2021
@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Aug 31, 2021
@kxl-adsk kxl-adsk merged commit ad02547 into dev Aug 31, 2021
@kxl-adsk kxl-adsk deleted the t_bailp/MAYA-112769/usd-prim-selectability branch August 31, 2021 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to core library enhancement New feature or request ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants