Hi,
I’m implementing my own Hydra render delegate and renderer, and I’m trying to understand the correct way to retrieve the current selection in this context.
Here is how I currently create my Hydra scene:
UsdImagingCreateSceneIndicesInfo info;
info.stage = stage;
UsdImagingSceneIndices si = UsdImagingCreateSceneIndices(info);
SdfPath prefix = SdfPath::AbsoluteRootPath();
_renderIndex->InsertSceneIndex(si.finalSceneIndex, prefix);
_usdStageSI = si.stageSceneIndex;
_selectionSI = si.selectionSceneIndex;
And this is how I set the selection:
void HydraRenderer::setSelection(const std::vector<PXR_NS::SdfPath> &paths)
{
_selectionSI->ClearSelection();
for (const PXR_NS::SdfPath &path : paths)
_selectionSI->AddSelection(path);
}
With this setup, during Sync on selected HdMesh prims, I receive things like DirtyPoints, DirtyTopology, etc.
However, I don’t see a clean way to retrieve only the selection state itself, independently of the usual dirty bits.
One hypothesis I had was to introduce a custom dirty bit for selection, but I don’t see how to integrate that cleanly into the Hydra pipeline.
My question:
What is the correct way, in a custom Hydra render delegate / renderer, to retrieve or track the selection state?
Should I use a custom dirty state, or is there an intended Hydra mechanism for this?
Any guidance or examples would be greatly appreciated.
Thanks!