All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdxSelectionTracker Class Reference

#include <selectionTracker.h>

Public Member Functions

HDX_API HdxSelectionTracker ()
virtual ~HdxSelectionTracker ()=default
virtual HDX_API void UpdateSelection (HdRenderIndex *index)
virtual HDX_API bool GetSelectionOffsetBuffer (HdRenderIndex const *index, bool enableSelection, VtIntArray *offsets) const
virtual HDX_API VtVec4fArray GetSelectedPointColors () const
HDX_API int GetVersion () const
HDX_API void SetSelection (HdSelectionSharedPtr const &selection)
HDX_API HdSelectionSharedPtr
GetSelectionMap () const
 XXX: Rename to GetSelection. More...

Protected Member Functions

HDX_API void _IncrementVersion ()
virtual HDX_API bool _GetSelectionOffsets (HdSelection::HighlightMode const &mode, HdRenderIndex const *index, size_t modeOffset, std::vector< int > *offsets) const

Detailed Description

Selection highlighting in Hydra:

Hydra Stream (*) supports selection highlighting of: (a) a set of rprims, wherein each rprim is entirely highlighted (b) a set of instances of an rprim, wherein each instance is highlighted (c) a set of subprimitives of an rprim, wherein each subprim is highlighted. Subprimitives support is limited to elements (faces of meshes, or individual curves of basis curves), edges of meshes/curves, and points of meshes.

  • While the goal is have an architecture that is extensible by rendering backends, the current implementation is heavily influenced by the Stream(GL) backend.

Background: The current selection implementation is, in a sense, global in nature. If there are no selected objects, we do not bind any selection-related resources, nor does the shader execute any selection-related operations.

If there are one or more selected objects, we don't choose to have them in a separate 'selection' collection. Instead, we stick by AZDO principles and avoid command buffer changes as a result of selection updates (which would involve removal of draw items corresponding to the selected objects from each render pass' command buffer and building the selection pass' command buffer). We build an integer buffer encoding of the selected items, for use in the fragment shader, that allows us to perform a small number of lookups to quickly tell us if a fragment needs to be highlighted.

Conceptually, the implementation is split into: (a) HdSelection : Client facing API that builds a collection of selected items. This is agnostic of the rendering backend. (b) HdxSelectionTracker: Base class that observes (a) and encodes it as needed by (c). This may be specialized to be backend specific. (c) HdxSelectionTask : A scene task that, currently, only syncs resources related to selection highlighting. Currently, this is tied to Stream. (d) HdxRenderSetupTask : A scene task that sets up the render pass shader to use the selection highlighting mixin in the render pass(es) of HdxRenderTask. This is relevant only to Stream.

HdxSelectionTracker takes HdSelection and generates a GPU buffer to be used

HdxSelectionTracker is a base class for observing selection state and providing selection highlighting details to interested clients.

Applications may use HdxSelectionTracker as-is, or extend it as needed.

HdxSelectionTask takes HdxSelectionTracker as a task parameter, and uploads the selection buffer encoding to the GPU.

Definition at line 101 of file selectionTracker.h.

Constructor & Destructor Documentation

HDX_API HdxSelectionTracker::HdxSelectionTracker ( )
virtual HdxSelectionTracker::~HdxSelectionTracker ( )

Member Function Documentation

virtual HDX_API bool HdxSelectionTracker::_GetSelectionOffsets ( HdSelection::HighlightMode const mode,
HdRenderIndex const index,
size_t  modeOffset,
std::vector< int > *  offsets 
) const
HDX_API void HdxSelectionTracker::_IncrementVersion ( )

Increments the internal selection state version, used for invalidation via GetVersion().

virtual HDX_API VtVec4fArray HdxSelectionTracker::GetSelectedPointColors ( ) const
HDX_API HdSelectionSharedPtr const& HdxSelectionTracker::GetSelectionMap ( ) const

XXX: Rename to GetSelection.

Definition at line 143 of file selectionTracker.h.

virtual HDX_API bool HdxSelectionTracker::GetSelectionOffsetBuffer ( HdRenderIndex const index,
bool  enableSelection,
VtIntArray *  offsets 
) const

Encodes the selection state (HdxSelection) as an integer array. This is uploaded to the GPU and decoded in the fragment shader to provide selection highlighting behavior. See HdxSelectionTask. Returns true if offsets has anything selected. enableSelection is a global on/off switch for selection; if it's false, nothing will be encoded.

HDX_API int HdxSelectionTracker::GetVersion ( ) const

Returns a monotonically increasing version number, which increments whenever the result of GetBuffers has changed. Note that this number may overflow and become negative, thus clients should use a not-equal comparison.

HDX_API void HdxSelectionTracker::SetSelection ( HdSelectionSharedPtr const selection)

The collection of selected objects is expected to be created externally and set via SetSelection.

Definition at line 136 of file selectionTracker.h.

virtual HDX_API void HdxSelectionTracker::UpdateSelection ( HdRenderIndex index)

Optional override to update the HdSelection during HdxSelectionTask::Sync.

The documentation for this class was generated from the following file: