HDK
 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 ()
 
virtual HDX_API void UpdateSelection (HdRenderIndex *index)
 
virtual HDX_API bool GetSelectionOffsetBuffer (const HdRenderIndex *index, bool enableSelectionHighlight, bool enableLocateHighlight, VtIntArray *offsets) const
 
virtual HDX_API VtVec4fArray GetSelectedPointColors (const HdRenderIndex *index)
 
HDX_API int GetVersion () const
 
HDX_API void SetSelection (HdSelectionSharedPtr const &selection)
 
HDX_API HdSelectionSharedPtr
const & 
GetSelectionMap () const
 

Protected Member Functions

HDX_API void _IncrementVersion ()
 

Detailed Description


Selection highlighting in Hydra:

Hydra Storm (*) 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 Storm 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.

For scene indices, the HdxSelectionTracker uses the HdSelectionsSchema (instaniated with GetFromParent of a prim data source) for a prim to determine the prim's selection status. However, to support scene delegates, we do support settings the selection directly with SetSelection. If both are used, the union of the selections is taken.

Conceptually, the implementation is split into: (a) HdSelection (for clients using scene delegates) : Client facing API that builds a collection of selected items. This is agnostic of the rendering backend. HdSelectionsSchema (for clients using scene indices) : Scene indices can populate this schema for each selected prim. (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 Storm. (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 Storm.


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 109 of file selectionTracker.h.

Constructor & Destructor Documentation

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

Member Function Documentation

HDX_API void HdxSelectionTracker::_IncrementVersion ( )
protected

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

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

Returns selection set with SetSelection.

XXX: Rename to GetSelection

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

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. enableSelectionHighlight will populate selection buffer for any active selection highlighting if true. enableLocateHighlight will populate selection buffer for any active locate (rollover) highlighting if true.

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)

Set the collection of selected objects. The ultimate selection (used for selection highlighting) will be the union of the collection set here and the one computed by querying the scene indices (using the HdxSelectionSceneIndexObserver).

virtual HDX_API void HdxSelectionTracker::UpdateSelection ( HdRenderIndex index)
virtual

Optional override to update the selection (either compute HdSelection and call SetSelection or update a scene index with selection information using the HdSelectionsSchema) during HdxSelectionTask::Prepare.


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