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

HYDRA-845 : Selection highlighting for point instancing of meshes #132

Merged
Merged
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
a0a4797
Working point instancer highlighting with the different nested/propag…
debloip-adsk May 15, 2024
fe6f344
Add PrimsRemoved support
debloip-adsk May 23, 2024
73e9fa1
Refactor SceneIndexPath method to return multiple selections + instances
debloip-adsk May 23, 2024
f014fd6
Use _CreateShMirrors in ctor
debloip-adsk May 23, 2024
2409262
Individual instance highlighting
debloip-adsk May 23, 2024
0648300
Propagate dirtying from original prims to selection highlight mirrors
debloip-adsk May 23, 2024
cff4d30
Allow multiple selections per prim across multiple conversions
debloip-adsk May 24, 2024
45fa2ea
Base prototype selection highlight support
debloip-adsk May 27, 2024
e2c0cb3
Cleanup
debloip-adsk May 27, 2024
c53dec7
Cleanup of wireframe selection highlight scene index
debloip-adsk May 27, 2024
92d59c9
Use refinedWire vs refinedWireOnSurface in appropriate cases
debloip-adsk May 27, 2024
4253847
Hardcode wireframe color for now
debloip-adsk May 28, 2024
5fab06c
Refactor method to get selection highlight path of a prim
debloip-adsk May 28, 2024
26f9ed6
Rework selection highlight repathing data sources
debloip-adsk May 28, 2024
096307f
Cleanup GetPrim
debloip-adsk May 28, 2024
4e93f73
Rename methods for collecting affected SdfPaths
debloip-adsk May 28, 2024
2e59fa1
Cleanup
debloip-adsk May 28, 2024
bf7be91
Reduce GetPrim calls
debloip-adsk May 28, 2024
e687b19
Move out some utility functions out of class
debloip-adsk May 28, 2024
c6a13df
Cleanup
debloip-adsk May 28, 2024
122067f
Reorder methods
debloip-adsk May 28, 2024
6062073
Minor cleanup
debloip-adsk May 28, 2024
fc0baff
Renaming methods and variables
debloip-adsk May 28, 2024
3d9ed94
Cleanup GetChildPrimPaths, PrimsAdded and PrimsRemoved
debloip-adsk May 28, 2024
bdb3596
Change access of maps
debloip-adsk May 28, 2024
0c07404
Propagate selection data sources to prototypes
debloip-adsk May 28, 2024
96cdaeb
Refactor _PrimsDirtied
debloip-adsk May 29, 2024
aa2cc1b
Handle prototype ancestor selection
debloip-adsk May 29, 2024
09483d3
Highlight instancers if ancestor is highlighted
debloip-adsk May 29, 2024
e98c601
Fix dirtying issue with selection highlight not following prims
debloip-adsk May 29, 2024
791552a
Remove obsolete methods
debloip-adsk May 29, 2024
d8b2aa7
Cleanup
debloip-adsk May 30, 2024
93d176d
Reorder methods to build selection highlight mirror graph
debloip-adsk May 30, 2024
ddae9ab
Cleanup
debloip-adsk May 30, 2024
35b73eb
Fix prim dirtying for masks and selection highlights
debloip-adsk May 30, 2024
94a1b69
Avoid accumulating values in maps indefinitely
debloip-adsk May 30, 2024
c816975
Extract out common code for creating instancer highlight into a method
debloip-adsk May 30, 2024
3303476
Bring back original wireframe highlight color code
debloip-adsk May 30, 2024
d0875fd
Add comments to document certain behaviors
debloip-adsk May 30, 2024
4134e78
Extract out traversal method
debloip-adsk May 30, 2024
33d6d6a
Adjust comment
debloip-adsk May 30, 2024
29550e9
Only highlight instancers through ancestors for non-prototypes
debloip-adsk May 30, 2024
6ea665e
Small check to avoid dirtying needlessly
debloip-adsk May 30, 2024
602f529
Rebuild instancer highlights
debloip-adsk May 31, 2024
fa4cf28
Update existing selection highlighting doc
debloip-adsk May 31, 2024
1fe6d04
Start documenting point instancing selection highlighting
debloip-adsk May 31, 2024
260d658
Add doc paragraph on nested/composed instancers
debloip-adsk May 31, 2024
f70324b
Doc corrections
debloip-adsk May 31, 2024
dde120d
Correct comment
debloip-adsk Jun 3, 2024
683eab4
Add doc to describe current behaviors
debloip-adsk Jun 3, 2024
ffab6ce
Update behavior to be more consistent and update comments
debloip-adsk Jun 3, 2024
17c65ea
Add images to documentation
debloip-adsk Jun 3, 2024
ae3539c
Clarify nesting and composition of instancers
debloip-adsk Jun 3, 2024
19dbb98
Add scene structure examples
debloip-adsk Jun 3, 2024
385baef
Add test for point instancer selection highlight
debloip-adsk Jun 3, 2024
e6c7370
Ensure other instancers are not highlight when selecting top instance…
debloip-adsk Jun 3, 2024
3572020
Add instance highlight test
debloip-adsk Jun 3, 2024
9374da9
Delete USD stage
debloip-adsk Jun 4, 2024
10a4380
Fix USD stage
debloip-adsk Jun 4, 2024
3e1cd52
Fix point instancer and instance tests
debloip-adsk Jun 4, 2024
4843414
Add prototype selection test
debloip-adsk Jun 4, 2024
2715c47
Cleanup test files
debloip-adsk Jun 4, 2024
4664d99
Minor doc correction
debloip-adsk Jun 4, 2024
5017030
Use TfSmallVector for PrimSelectionInfoVector
debloip-adsk Jun 4, 2024
fe8db05
Rename ConvertUfeSelectionToHydra
debloip-adsk Jun 4, 2024
40849dd
Add comment on FindFullySelectedAncestorsInclusive
debloip-adsk Jun 4, 2024
b8f9484
Remove no longer used code
debloip-adsk Jun 4, 2024
59b5949
Accumulate selection dirtied notifs
debloip-adsk Jun 4, 2024
e395606
Allow multiple prim paths for the lead UFE object
debloip-adsk Jun 4, 2024
174c6a9
Revert data producer example
debloip-adsk Jun 4, 2024
fb90a6a
Various cleanups
debloip-adsk Jun 4, 2024
cae452f
Clean wireframe scene index header
debloip-adsk Jun 4, 2024
8b7e9ae
Header cleanups
debloip-adsk Jun 4, 2024
69c850d
Remove SdfPath forward declaration
debloip-adsk Jun 4, 2024
f6e1738
Fix Linux warning
debloip-adsk Jun 4, 2024
359877f
Rename instancerHighlightUsers
debloip-adsk Jun 4, 2024
5e7a22a
Fix disrespected axiom
debloip-adsk Jun 4, 2024
828dfaf
Cleanup test and add some comments
debloip-adsk Jun 4, 2024
b0ac20c
Better document the USD conversion of UFE to Hydra paths
debloip-adsk Jun 4, 2024
d8fe091
Update current limitations
debloip-adsk Jun 4, 2024
5c12b28
Add comments in wireframe scene index
debloip-adsk Jun 4, 2024
0321f2b
Work around non-const schema getters for USD versions before 24.05
debloip-adsk Jun 4, 2024
73c0b29
Update test to compare selected paths from scene index observer and i…
debloip-adsk Jun 4, 2024
cd3cccb
Add images of selection highlight results
debloip-adsk Jun 5, 2024
9af9823
Update implementation doc for point instancer/instance and add sectio…
debloip-adsk Jun 5, 2024
ecc377d
Change an axiom to a verify
debloip-adsk Jun 5, 2024
520a412
Add back reserve call in selectionSceneIndex
debloip-adsk Jun 5, 2024
415c651
Minor doc corrections
debloip-adsk Jun 5, 2024
bff3ddd
Add verify for instance selection numeric path component
debloip-adsk Jun 5, 2024
efb4d76
Fix mask verification
debloip-adsk Jun 5, 2024
f2232c5
Cleanup testMergingSceneIndex edits
debloip-adsk Jun 5, 2024
256e843
Add comment on fully selected when instance selecting
debloip-adsk Jun 5, 2024
efdaafa
Add more comments to test
debloip-adsk Jun 5, 2024
1fcef2e
Minor adjustments to test
debloip-adsk Jun 5, 2024
9561774
Add another comment in test
debloip-adsk Jun 5, 2024
aac8ac3
Rename _IsInstancingRoot
debloip-adsk Jun 5, 2024
3ca1e38
Rework prototype roots vs hierarchies
debloip-adsk Jun 5, 2024
77c3fe5
Whitespace fix
debloip-adsk Jun 5, 2024
2444458
Update comments on PathInterface
debloip-adsk Jun 5, 2024
fc4df13
Refactor pushHydraSelectionsToPathVector
debloip-adsk Jun 10, 2024
1a3abfa
Minor doc clarifications
debloip-adsk Jun 10, 2024
03ec9f4
Rename PrimSelectionInfo to PrimSelection
debloip-adsk Jun 10, 2024
39009f7
Rename isLeadPrim to isLeadObjectPrim
debloip-adsk Jun 11, 2024
e04b7dc
Rename ConvertUfePathToHydraSelections to UfePathToPrimSelections
debloip-adsk Jun 11, 2024
0b8988f
Reformat comment
debloip-adsk Jun 11, 2024
4826d35
Add back SceneIndexPath method
debloip-adsk Jun 11, 2024
c8343d9
Revert unrelated tests changes
debloip-adsk Jun 11, 2024
0cd2a5d
Rename hydra selections to prim selections
debloip-adsk Jun 11, 2024
707744a
Add SceneIndexPaths method for multi prim paths
debloip-adsk Jun 11, 2024
cc8f7fa
Extract out code blocks into anonymous namespace funcs
debloip-adsk Jun 11, 2024
1c4293a
Expose selection highlight mirror tag in wireframe scene index public…
debloip-adsk Jun 11, 2024
9160359
Add mermaid graph to visualize instancer relationships
debloip-adsk Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/images/instanceSelectionHighlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/instanceTranslations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/instancedBy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/instancerTopology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/pointInstancerSelectionHighlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/prototypeSelectionHighlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
212 changes: 197 additions & 15 deletions doc/selectionHighlightingArchitecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ supports Hydra rendering in this repository as the Flow Viewport Toolkit (name
subject to change).

This document will describe the state of Flow Viewport Toolkit selection
highlighting as of 21-Sep-2023.
highlighting as of 31-May-2024.

## Behavior

Expand All @@ -18,16 +18,18 @@ are shown differently in the viewport for ease of understanding.

An application will provide a way to select an object, or to select components
of an object. For example, for a mesh object, these components may be points,
edges, or faces. At time of writing, only object selection highlighting is
supported, and selection highlighting of components is unimplemented.
edges, or faces. Currently, only object selection highlighting and point
instancing highlighting of meshes are supported. Selection highlighting of
components is unimplemented.

## Selection: Application versus Hydra

The application maintains an edit-friendly version of the scene. This scene is
translated into a Hydra scene by scene indices. Correspondingly, there are two
versions of the selection, one in the application, with objects and their paths
described with application-specific classes, and a version of the selection in
the Hydra scene, described as prims and their `SdfPath`s
the Hydra scene, described as prims and their `SdfPath`s, as well as their
associated selection data sources.

## Requirements

Expand All @@ -45,8 +47,8 @@ Requirements for selection highlighting are:
highlight appearance.

- It must be possible to let a data injecting data model provide prims to Hydra
that already contain selection highlighting. At time of writing
(19-Sep-2023), this is true of Maya native Dag data, where selection
that already contain selection highlighting. Currently,
this is true of Maya native Dag data, where selection
highlighting is done by OGS.

## Selection Highlighting Styles
Expand All @@ -59,16 +61,16 @@ special way, e.g. object contour, modified object color, or object overlay.

The former approach is handled by having a plugin provide a selection
highlighting filtering scene index to the Flow Viewport Toolkit, and is the
topic of this document at time of writing (20-Sep-2023). The
latter is handled by having a plugin provide a selection highlighting
task to the Flow Viewport Toolkit, and is currently unimplemented.
topic of this document at time of writing. The latter is handled by having
a plugin provide a selection highlighting task to the Flow Viewport Toolkit,
and is currently unimplemented.

## Added Geometry Plugin Software Architecture Requirements

A selection highlighting plugin that provides added geometry to scene must
provide the following services:

- A way to translate the application's selection path(s) into Hydra paths:
- A way to translate the application's selection path(s) into Hydra paths and data sources:
- So that the appropriate prims in Hydra can be dirtied on selection change.
- So that selected prims in Hydra can have a data source added.
This is embodied in a **Path interface**.
Expand All @@ -83,16 +85,16 @@ provide the following services:
### Selection Change

This
[selection change code](../lib/flowViewport/sceneIndex/fvpSelectionSceneIndex.cpp#L150-L167)
shows the use of the *Path Interface*, through the *SceneIndexPath()* method,
[selection change code](../lib/flowViewport/sceneIndex/fvpSelectionSceneIndex.cpp#L152-L173)
shows the use of the *Path Interface*, through the *ConvertUfePathToHydraSelections()* method,
called on the input scene index. The path interface allows the selection scene
index to translate selected application paths to selected Hydra scene index
paths.

### Wireframe Selection Highlighting

This
[wireframe selection highlighting code](../lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp#L76-L97)
[wireframe selection highlighting code](../lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp#L462-L465)
shows the use of the *Selection*, through the
*HasFullySelectedAncestorInclusive()* method, called on the input selection.
The selection allows a selection highlighting filtering scene index to query
Expand Down Expand Up @@ -178,7 +180,7 @@ index is optional.

The object modeling is the following:
- **Selection**: builtin provided by the Flow Viewport Toolkit.
- Encapsulates the Hydra selection as scene index paths.
- Encapsulates the Hydra selection as scene index paths and selection data sources.
- Is shared by the selection scene index and all selection highlighting
scene indices.
- **Selection scene index**: builtin provided by the Flow Viewport Toolkit.
Expand Down Expand Up @@ -232,7 +234,7 @@ class Selection{
}

class PathInterface{
+SceneIndexPath(Ufe::Path) SdfPath
+ConvertUfePathToHydraSelections(Ufe::Path) SdfPath
}

class SelectionSceneIndex
Expand Down Expand Up @@ -287,3 +289,183 @@ WireframeSelectionHighlightSceneIndex o-- Selection : Read
propagate across scene index inputs, so that if a Maya Dag ancestor is
selected, a USD descendant's appearance can change. This is the same
situation as global transformation and visibility.

## Mesh point instancing wireframe selection highlighting

We currently support wireframe selection highlighting for point instancing of meshes
for the three different point instancing selection modes :

- Point Instancer

![Point instancer selection highlight](images/pointInstancerSelectionHighlight.png)

- Instance

![Instance selection highlight](images/instanceSelectionHighlight.png)

- Prototype

![Prototype selection highlight](images/prototypeSelectionHighlight.png)

Here is an overview of how point instancing works in Hydra, and how we implement
wireframe selection highlighting for it.

### Scene index structure

In Hydra, a point instancer is represented as a prim of type `instancer`,
with an `instancerTopology` data source.

![instancerTopology data source](images/instancerTopology.png)

This data source contains three relevant inner data sources :
- The `prototypes` data source, of type `VtArray<SdfPath>`, lists the paths
to each prototype this point instancer instances.
- The `instanceIndices` data source, a vector data source where each element
data source (`i0, i1, i2, etc.`) is of type `VtArray<int>` and contains
which instances correspond to which prototype. For example, if `i1` contains
`0, 3`, then the first and fourth instances will be using the second prototype.
- The `mask` data source, of type `VtArray<bool>`, which can optionally be used
to show/hide specific instances (e.g. if the 3rd element of the mask is `false`,
then the 3rd instance will be hidden). If this array is empty, all instances will be
shown.

---

Per-instance data is specified using primvar data sources, namely :
- hydra:instanceTranslations
- hydra:instanceRotations
- hydra:instanceScales
- hydra:instanceTransforms

![instanceTranslations primvar data source](images/instanceTranslations.png)

Where the corresponding primvarValue data source lists the instance-specific data.
Note that while the first three are 3-dimensional vectors and `hydra:instanceTransforms`
is a 4x4 matrix, they can all be used simultaneously (internally, they will all be
converted to 4x4 matrices, and then multiplied together).

---

On the other end of instancing, prototype prims have an `instancedBy` data source.

![instancedBy data source](images/instancedBy.png)

This data source contains up to two inner data sources :
- (required) : The `paths` data source, of type `VtArray<SdfPath>`, lists the paths
to each instancer that instances this prototype.
- (optional) : When a sub-hierarchy is prototyped, the `prototypeRoots`, of type
`VtArray<SdfPath>`, lists the paths to the roots of the sub-hierarchies that are being
prototyped. For example, if we are instancing an xform that has a child mesh,
then the prototype xform and mesh prims will each have the same `instancedBy` data source,
where the `paths` data source will point to the instancers that use this prototype, and
where the `prototypeRoots` will point to the xform prim.

---

Some notes about the behavioral impacts of the hierarchical location of prims :
- Prims that are rooted under an instancer will not be drawn unless instanced
- Prototypes that are instanced will still be drawn as if they were not instanced
(i.e. the instances will be drawn in addition to the base prim itself), unless as
mentioned they are rooted under an instancer.

### Nested/Composed instancers

It is possible for an instancer itself to be instanced by another, and thus have both the
`instancerTopology` and the `instancedBy` data sources. Note that this does not preclude
such a prototyped instancer from also drawing geometry itself. If the prototyped instancer
is a child of the instancing instancer, then yes, such a nested instancer will not draw by
itself, and will be instance-drawn through the parent instancer. However, if the prototyped
instancer has no parent instancer, but it is instanced by another instancer somewhere else
in the hierarchy, then both the prototyped instancer will draw as if it were by itself, but
also be instance-drawn by the other instancer.

This nesting and composition of instancers is what leads to most of the complexity of point
instancing selection highlighting. We can view such nesting and composition of instancers as
graphs, with the vertices being the instancer prims, and the edges being the paths contained
in the `instancerTopology/prototypes`, `instancedBy/paths` and `instancedBy/prototypeRoots`
data sources.
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved

### Implementation for point instancer and instance selection

This section will focus on selection highlighting when trying to highlight point instancers
as a whole or specific instances, as these require a more complicated workflow. Unlike standard
selection, we cannot simply override instanced meshes to use the `refinedWireOnSurf`/`wireOnSurf`
HdReprs, as that would lead to highlighting all instances of the prototype all the time. Instead,
we opt for the following approach : when an instancer is selected (entirely or only certain instances),
we will create a mirror of the instancing graph it is a part of, and make the mirror copies of the
instanced meshes draw with a wireframe representation. This mirror graph includes everything from
the most deeply buried prims to the topmost instancers; anything that this instancer affects or is
affected by, including itself. In practice, this means that each prototype and each instancer will
have a corresponding mirror prim for selection highlighting, that will be located alongside it as
a sibling. This way, any parent transforms affecting the original prim will also affect the selection
highlight mirror prim.

For example, given the following scene structure :
```
Root
|__TopInstancer
|__NestedInstancer
|__Prototype
```
the resulting scene structure with selection highlighting would become :
```
Root
|__TopInstancer
| |__NestedInstancer
| | |__Prototype
| | |__Prototype_SelectionHighlight
| |__NestedInstancer_SelectionHighlight
|__TopInstancer_SelectionHighlight
```
where `TopInstancer_SelectionHighlight` would instance `NestedInstancer_SelectionHighlight`, which would in turn instance `Prototype_SelectionHighlight`.

Note that in the case where a prototype is not a single prim but a sub-hierarchy, we only need to
create a single *explicit* selection highlight mirror for the whole prototype sub-hierarchy; the
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
child prims of the selection highlight mirror will simply be pulled from the corresponding original
prim, and thus implicitly be selection highlight mirrors as well.

Another thing to be aware of is that a nested/composed instancer is not necessarily directly selected,
as it is not necessarily a prototype root itself. If an instancer is a child prim of another prim
that is itself selected or instanced by another instancer, these instancers are still composed
together, but will not point to each other directly. Such cases are an example of when we need to
use the `instancedBy/prototypeRoots` data source to properly construct the mirror graph of instancers.

An example of this is the following :
```
Root
|__TopInstancer
|__Prototype
|__ChildInstancer
```
for which we end up with :
```
Root
|__TopInstancer
| |__Prototype
| | |__ChildInstancer
| |__Prototype_SelectionHighlight
| |__ChildInstancer
|__TopInstancer_SelectionHighlight
```
where `TopInstancer_SelectionHighlight` instances `Prototype_SelectionHighlight`, which implicitly draws the selection highlight version of `ChildInstancer`.

Of note are the following selection highlighting scenarios and their corresponding behaviors :
- Selecting a point instancer in its entirety
- If the instancer is a top-level instancer, all instances it draws WILL be highlighted
- If the instancer is a prototype, instances of itself drawn by other instancers will NOT be highlighted
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
- Selecting specific instances of point instancer
- If the instancer is a top-level instancer, the selected instances it draws WILL be highlighted
- If the instancer is a prototype, the instances it would indirectly draw through instances of itself drawn by other instancers will NOT be highlighted
- Selecting a parent prim of a point instancer
- (same as selecting a point instancer in its entirety)

### Implementation for prototype selection

We simply do as for a regular selection, and override the original prim's display style
to draw as a wireframe-on-surface representation.

### Current limitations

- The wireframe colors for point instancer & instance selections might not always be correct (with
respect to the lead/active selection colors). However, prototype selections should be using the
correct colors.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class BlockPrimRemovalPropagationSceneIndex : public PXR_NS::HdSingleInputFilter

//from PathInterface
FVP_API
PXR_NS::SdfPath SceneIndexPath(const Ufe::Path& appPath) const override{
return _pathInterface->SceneIndexPath(appPath);
PrimSelectionInfoVector ConvertUfePathToHydraSelections(const Ufe::Path& appPath) const override{
return _pathInterface->ConvertUfePathToHydraSelections(appPath);
}

protected:
Expand Down
10 changes: 5 additions & 5 deletions lib/flowViewport/sceneIndex/fvpMergingSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MergingSceneIndex::MergingSceneIndex() : HdMergingSceneIndex()
.Msg("MergingSceneIndex::MergingSceneIndex() called.\n");
}

SdfPath MergingSceneIndex::SceneIndexPath(const Ufe::Path& appPath) const
PrimSelectionInfoVector MergingSceneIndex::ConvertUfePathToHydraSelections(const Ufe::Path& appPath) const
{
// FLOW_VIEWPORT_TODO May be able to use a caching scheme for app path to
// scene index path conversion using the run-time ID of the UFE path, as it
Expand All @@ -50,13 +50,13 @@ SdfPath MergingSceneIndex::SceneIndexPath(const Ufe::Path& appPath) const
// scene we know whether it supports the PathInterface or not.
auto pathInterface = dynamic_cast<const PathInterface*>(&*inputScene);
if (pathInterface) {
auto sceneIndexPath = pathInterface->SceneIndexPath(appPath);
if (!sceneIndexPath.IsEmpty()) {
return sceneIndexPath;
auto primSelections = pathInterface->ConvertUfePathToHydraSelections(appPath);
if (!primSelections.empty()) {
return primSelections;
}
}
}
return SdfPath();
return PrimSelectionInfoVector();
}

}
2 changes: 1 addition & 1 deletion lib/flowViewport/sceneIndex/fvpMergingSceneIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MergingSceneIndex
static MergingSceneIndexRefPtr New();

FVP_API
PXR_NS::SdfPath SceneIndexPath(const Ufe::Path& appPath) const override;
PrimSelectionInfoVector ConvertUfePathToHydraSelections(const Ufe::Path& appPath) const override;

private:
MergingSceneIndex();
Expand Down
22 changes: 16 additions & 6 deletions lib/flowViewport/sceneIndex/fvpPathInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,31 @@
#include <ufe/ufe.h>

#include <pxr/pxr.h>
#include <pxr/base/tf/smallVector.h>
#include <pxr/imaging/hd/dataSource.h>
#include <pxr/usd/sdf/path.h>

UFE_NS_DEF {
class Path;
}

PXR_NAMESPACE_OPEN_SCOPE
class SdfPath;
PXR_NAMESPACE_CLOSE_SCOPE

namespace FVP_NS_DEF {

struct PrimSelectionInfo
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
{
PXR_NS::SdfPath primPath;
PXR_NS::HdDataSourceBaseHandle selectionDataSource;
};

// Using TfSmallVector to optimize for selections that map to a few prims,
// which is likely going to be the bulk of use cases.
using PrimSelectionInfoVector = PXR_NS::TfSmallVector<PrimSelectionInfo, 8>;
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved

/// \class PathInterface
///
/// A pure interface class to allow for conversion between an application's
/// path, expressed as a Ufe::Path, into an SdfPath valid for a scene index.
/// path, expressed as a Ufe::Path, into SdfPaths valid for a scene index
/// and selection data sources.
/// To be used as a mix-in class for scene indices.
///
class PathInterface
Expand All @@ -45,7 +55,7 @@ class PathInterface
//! If no such path exists, an empty SdfPath should be returned.
//! \return scene index path.
FVP_API
virtual PXR_NS::SdfPath SceneIndexPath(const Ufe::Path& appPath) const = 0;
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
virtual PrimSelectionInfoVector ConvertUfePathToHydraSelections(const Ufe::Path& appPath) const = 0;
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved

protected:

Expand Down
2 changes: 1 addition & 1 deletion lib/flowViewport/sceneIndex/fvpPathInterfaceSceneIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace FVP_NS_DEF {
///
/// A simple pass-through filtering scene index that adds support for the path
/// interface. Derived classes need only implement the
/// PathInterface::SceneIndexPath() virtual.
/// PathInterface::ConvertUfePathToHydraSelections() virtual.
///
class PathInterfaceSceneIndexBase
: public PXR_NS::HdSingleInputFilteringSceneIndexBase
Expand Down
Loading