Skip to content

EMSUSD-3791 - Hydra 2.0 scene index migration (6/7) - #4779

Open
danqua wants to merge 1 commit into
quastd/scene-index-migration-6from
quastd/scene-index-migration-7
Open

danqua wants to merge 1 commit into
quastd/scene-index-migration-6from
quastd/scene-index-migration-7

Conversation

@danqua

@danqua danqua commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Highlight single point instances with the VP2 scene index.

With the scene index flag on, picking one point instance highlighted the whole point instancer. Selection goes through UsdImagingSelectionSceneIndex, and its AddSelection takes only a path, so the picked instance index was lost. This PR fills that in inside the producer, so only the picked instance is highlighted, as on the legacy path.

Highlights

  • For a point instancer that the chain draws as an instancer, PopulateSelection now:
    • Collects the rprims it draws. That includes rprims drawn again by native instances or nested point instancers inside its prototypes.
    • Maps the picked instance index to Hydra instance ids with HdInstancerTopologySchema::ComputeInstanceIndicesForProto.
  • These results are cached for each selection pass, so picking many instances doesn't redo the work.
  • New HdVP2UsdProducer::ClearSelection, which ProxyRenderDelegate calls before it rebuilds the selection. It does nothing for the Hydra 1.0 producer.

Tests

Three new cases in testVP2RenderDelegatePointInstanceSelection. Each picks instance 1 and compares the viewport snapshot against a simpler scene that draws the same thing. The cases cover:

  • prototypes that live outside the instancer,
  • native instances inside a prototype,
  • a point instancer nested inside another one.

@danqua
danqua added this pull request to stack #4774 October 8, 2026 14:19
@seando-adsk seando-adsk added the vp2renderdelegate Related to VP2RenderDelegate label Oct 9, 2026
@danqua
danqua force-pushed the quastd/scene-index-migration-7 branch 2 times, most recently from 6ee2611 to 2c91cd7 Compare October 16, 2026 08:26
@danqua
danqua force-pushed the quastd/scene-index-migration-7 branch 2 times, most recently from 7e3b5a9 to ee8fdae Compare October 20, 2026 08:19
return scenePaths;
}

/* Collects the rprims a point instancer draws, so a single point instance can

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this strictly for point instancers or also scene graph instancing? I thought through hydra it was one and the same


// A top-level UsdGeomPointInstancer keeps its scene path through the
// propagating scene indices, so the USD path doubles as its chain path and
// the chain draws it as an instancer. One the chain does not draw as an

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

YOu use ""chain path" in many comment, to be sure, that's essentially the usd path prefixed with the scene index root thing?

// prototype, or above the proxy's primPath - is left to AddSelection.
const HdSceneIndexPrim prim = _selectionSceneIndex->GetPrim(instancer);
const HdPathArrayDataSourceHandle prototypes
= HdInstancerTopologySchema::GetFromParent(prim.dataSource).GetPrototypes();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if GetPrototype is always fast? Sometimes some hydra getters ar not that fast if they resolve stuff, because you could skip it if rim.primType != HdPrimTypeTokens->instancer


const auto first = [](const HdPathArrayDataSourceHandle& paths) -> SdfPath {
if (paths) {
const VtArray<SdfPath> values = paths->GetTypedValue(0.0f);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the 0.0?

};

_PointInstanceRprims& rprims = cached->second.emplace();
const VtArray<SdfPath> instancerRoots = prototypes->GetTypedValue(0.0f);

@deboisj deboisj Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it a timecode? If so maybe query at the detalut timecode to be explicit

UsdImagingSelectionSceneIndex::AddSelection takes only a path, so
picking one point instance highlighted the whole instancer. For a point
instancer the chain draws as an instancer, PopulateSelection now
collects the rprims it draws, including those instanced again by native
instances or nested point instancers in its prototypes, and maps the
picked instance index to instance ids through
HdInstancerTopologySchema::ComputeInstanceIndicesForProto. The results
are cached per selection pass.

Add HdVP2UsdProducer::ClearSelection, which ProxyRenderDelegate calls
before rebuilding the selection (a no-op for the UsdImagingDelegate
producer).
@antonkhelou
antonkhelou force-pushed the quastd/scene-index-migration-7 branch from ee8fdae to b3c8897 Compare October 20, 2026 14:09
auto [ids, inserted] = _instanceIds.try_emplace(prototypeRoot);
if (inserted) {
// Not const: ComputeInstanceIndicesForProto is non-const before USD
// 26.08. Make this const once the minimum reaches 26.08.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe add a TODO so it can be found easily

= _InstanceIds(usdPath, rprim.prototypeRoot);
const auto id = ids.find(instanceIndex);
if (id == ids.end()) {
// This prototype does not instantiate the picked index.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an error scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vp2renderdelegate Related to VP2RenderDelegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants