HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
selectionTask.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HDX_SELECTION_TASK_H
8 #define PXR_IMAGING_HDX_SELECTION_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
13 #include "pxr/imaging/hd/task.h"
14 
15 #include "pxr/base/gf/vec4f.h"
16 
17 #include <memory>
18 
20 
21 
22 class HdRenderIndex;
23 class HdSceneDelegate;
24 
26 {
29  float occludedSelectionOpacity; // lerp factor when blending
30  // occluded selection
31  GfVec4f selectionColor; // "active" selection color
32  GfVec4f locateColor; // "rollover" selection color
33 };
34 
35 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
36 
37 /// \class HdxSelectionTask
38 ///
39 /// The SelectionTask is responsible for setting up render pass global buffers
40 /// for selection and depositing those buffers into the task context for down
41 /// stream consumption. Any render pass which wants to display selection may
42 /// extract those buffers and bind them into the current render pass shader to
43 /// enable selection highlighting.
44 ///
45 class HdxSelectionTask : public HdTask
46 {
47 public:
49 
50  HDX_API
51  HdxSelectionTask(HdSceneDelegate* delegate, SdfPath const& id);
52 
53  HDX_API
54  ~HdxSelectionTask() override;
55 
56  /// Sync the render pass resources
57  HDX_API
58  void Sync(HdSceneDelegate* delegate,
59  HdTaskContext* ctx,
60  HdDirtyBits* dirtyBits) override;
61 
62 
63  /// Prepare the tasks resources
64  HDX_API
65  void Prepare(HdTaskContext* ctx,
66  HdRenderIndex* renderIndex) override;
67 
68  /// Execute render pass task
69  HDX_API
70  void Execute(HdTaskContext* ctx) override;
71 
72 
73 private:
74  int _lastVersion;
75  bool _hasSelection;
76  HdxSelectionTaskParams _params;
77  HdBufferArrayRangeSharedPtr _selOffsetBar;
78  HdBufferArrayRangeSharedPtr _selUniformBar;
79  size_t _pointColorsBufferSize;
80 
81  HdxSelectionTask() = delete;
82  HdxSelectionTask(const HdxSelectionTask &) = delete;
83  HdxSelectionTask &operator =(const HdxSelectionTask &) = delete;
84 };
85 
86 // VtValue requirements
87 HDX_API
88 std::ostream& operator<<(std::ostream& out,
89  const HdxSelectionTaskParams& pv);
90 HDX_API
91 bool operator==(const HdxSelectionTaskParams& lhs,
92  const HdxSelectionTaskParams& rhs);
93 HDX_API
94 bool operator!=(const HdxSelectionTaskParams& lhs,
95  const HdxSelectionTaskParams& rhs);
96 
97 
99 
100 #endif //PXR_IMAGING_HDX_SELECTION_TASK_H
101 
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
uint32_t HdDirtyBits
Definition: types.h:143
#define HDX_API
Definition: api.h:23
HDX_API ~HdxSelectionTask() override
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Definition: task.h:43
Definition: path.h:273
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: vec4f.h:45
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:27
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HDX_API std::ostream & operator<<(std::ostream &out, const HdxSelectionTaskParams &pv)