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

Add UFE path handling and utilities to support paths that identify point instances of a PointInstancer #1027

Conversation

mattyjams
Copy link
Contributor

This PR represents all of the plumbing necessary to work with UFE paths that identify individual instances of a PointInstancer prim. It was distilled from #936 as well as some offline discussion. This PR stops short of making the Viewport 2.0 render delegate point instance selection-aware. That and manipulation will be added in subsequent PRs.

The path to a point instance is constructed by simply appending the instance's instanceIndex as a final component of the USD Ufe::PathSegment, for example: /PointInstancer/12345. This is a valid path in UFE, but it is not a valid SdfPath, since all elements of an SdfPath need to be C identifiers and cannot start with a digit. We take advantage of this fact to quickly identify Ufe::Paths to point instances and avoid having to do too much string manipulation. Utilities were added and wrapped to Python to handle adding or stripping the instanceIndex component when necessary. All of the path manipulation specifics about how point instance paths are constructed or parsed should be consolidated in lib/mayaUsd/ufe/Utils.cpp, so if we choose to change the path representation or apply a similar pattern to other prim component types (e.g. individual points/edges/faces of a Mesh prim), we should hopefully only have one place we'll need to change it.

Test USD files and Maya scenes with proxies that use them were added at three different scales: 14 instances, 7,000 instances, and 70,000 instances. The test added in this PR only makes use of the 14 instance sample, but the imaging and manipulation tests to be added in subsequent PRs will also use the large scale samples.

@mattyjams mattyjams added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Dec 22, 2020
@mattyjams mattyjams force-pushed the pr/ufe_path_handling_and_utilities_for_point_instances branch from b458b52 to 5d6e227 Compare December 23, 2020 01:09
@kxl-adsk kxl-adsk requested a review from ppt-adsk January 4, 2021 13:38
@mattyjams mattyjams force-pushed the pr/ufe_path_handling_and_utilities_for_point_instances branch from 5d6e227 to 7aebebd Compare January 7, 2021 00:29
@mattyjams
Copy link
Contributor Author

Just rebased to resolve conflicts from the merge of #1039.

Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks simple enough! There are most likely some things where I don't completely understand the UFE parenting model for point instancer instances (pointed out in code comments), but otherwise seems like a good data model place to start!

lib/mayaUsd/ufe/Utils.cpp Outdated Show resolved Hide resolved
lib/mayaUsd/ufe/Utils.cpp Show resolved Hide resolved
lib/mayaUsd/ufe/wrapUtils.cpp Outdated Show resolved Hide resolved
lib/mayaUsd/ufe/wrapUtils.cpp Outdated Show resolved Hide resolved
lib/mayaUsd/ufe/UsdHierarchy.cpp Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Outdated Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Outdated Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Outdated Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Outdated Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Outdated Show resolved Hide resolved
@mattyjams mattyjams force-pushed the pr/ufe_path_handling_and_utilities_for_point_instances branch from 7aebebd to 32299f7 Compare January 15, 2021 22:43
@mattyjams mattyjams force-pushed the pr/ufe_path_handling_and_utilities_for_point_instances branch from 32299f7 to 9c50995 Compare January 19, 2021 21:18
Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one change where you can add a point instancer and point instance UFE data model section to UsdSceneItem, and I think we're done!

lib/mayaUsd/ufe/UsdHierarchy.cpp Show resolved Hide resolved
test/lib/ufe/testPointInstances.py Show resolved Hide resolved
…nd accessor for retrieving it

Additional class documentation was added to describe the handling of point
instances generated by PointInstancer prims, and how their semantics differ
between USD and UFE.
…for a USD path

If an instanceIndex is provided, the path segment for a point instance with
that USD path and index is returned.
Because of the conflicting Python bindings between USD and UFE, we cannot
return an instance of Ufe::PathSegment and instead must return the path segment
as a string.
…ePathToPrim()

This will become relevant when the Viewport 2.0 render delegate appends an
instance index path component to the UFE paths of PointInstancer prims in order
to uniquely identify point instances. Trying to get the PointInstancer prim
using the full path would fail, since the path includes the instance index
component.
For UFE versions before version 2, the work that was previously local to
ufePathToPrim() to turn a std::string into a Ufe::Path was broken out into a
helper function so that it could be shared between ufePathToPrim() and
ufePathToInstanceIndex().
Because of the conflicting Python bindings between USD and UFE, we cannot
receive or return instances of Ufe::Path and instead must use strings.
When a scene item represents a point instance, its Ufe::Path will end with a
path component that is all digits representing the instance index (e.g.
".../PointInstancer/12345"). Point instances are generated by a PointInstancer
prim based on data members on the PointInstancer and the prototype being
instanced. There is otherwise no direct mapping of a point instance to any
location in USD namespace.

As a result, we treat point instances as child-less in UFE. For the same reason,
point instances don't really have a "parent" in USD either, but in UFE we
consider the PointInstancer prim the "parent" of a point instance it generated.
This allows pick-walking from a point instance up to the PointInstancer prim
that generated it. Note that the reverse is *not* true. The point instances
generated by a PointInstancer cannot be retrieved by querying the
PointInstancer for its children.
@mattyjams mattyjams force-pushed the pr/ufe_path_handling_and_utilities_for_point_instances branch from 9c50995 to e9de85a Compare January 21, 2021 20:16
@kxl-adsk kxl-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 21, 2021
@kxl-adsk kxl-adsk merged commit 8510159 into Autodesk:dev Jan 21, 2021
@mattyjams mattyjams deleted the pr/ufe_path_handling_and_utilities_for_point_instances branch January 22, 2021 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants