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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HDX_SELECTION_TASK_H
25 #define PXR_IMAGING_HDX_SELECTION_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hd/task.h"
31 
32 #include "pxr/base/gf/vec4f.h"
33 
34 #include <memory>
35 
37 
38 
39 class HdRenderIndex;
40 class HdSceneDelegate;
41 
43 {
45  float occludedSelectionOpacity; // lerp factor when blending
46  // occluded selection
47  GfVec4f selectionColor; // "active" selection color
48  GfVec4f locateColor; // "rollover" selection color
49 };
50 
51 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
52 
53 /// \class HdxSelectionTask
54 ///
55 /// The SelectionTask is responsible for setting up render pass global buffers
56 /// for selection and depositing those buffers into the task context for down
57 /// stream consumption. Any render pass which wants to display selection may
58 /// extract those buffers and bind them into the current render pass shader to
59 /// enable selection highlighting.
60 ///
61 class HdxSelectionTask : public HdTask
62 {
63 public:
64  HDX_API
65  HdxSelectionTask(HdSceneDelegate* delegate, SdfPath const& id);
66 
67  HDX_API
68  ~HdxSelectionTask() override;
69 
70  /// Sync the render pass resources
71  HDX_API
72  void Sync(HdSceneDelegate* delegate,
73  HdTaskContext* ctx,
74  HdDirtyBits* dirtyBits) override;
75 
76 
77  /// Prepare the tasks resources
78  HDX_API
79  void Prepare(HdTaskContext* ctx,
80  HdRenderIndex* renderIndex) override;
81 
82  /// Execute render pass task
83  HDX_API
84  void Execute(HdTaskContext* ctx) override;
85 
86 
87 private:
88  int _lastVersion;
89  bool _hasSelection;
90  HdxSelectionTaskParams _params;
91  HdBufferArrayRangeSharedPtr _selOffsetBar;
92  HdBufferArrayRangeSharedPtr _selUniformBar;
93  HdBufferArrayRangeSharedPtr _selPointColorsBar;
94 
95  HdxSelectionTask() = delete;
96  HdxSelectionTask(const HdxSelectionTask &) = delete;
97  HdxSelectionTask &operator =(const HdxSelectionTask &) = delete;
98 };
99 
100 // VtValue requirements
101 HDX_API
102 std::ostream& operator<<(std::ostream& out,
103  const HdxSelectionTaskParams& pv);
104 HDX_API
105 bool operator==(const HdxSelectionTaskParams& lhs,
106  const HdxSelectionTaskParams& rhs);
107 HDX_API
108 bool operator!=(const HdxSelectionTaskParams& lhs,
109  const HdxSelectionTaskParams& rhs);
110 
111 
113 
114 #endif //PXR_IMAGING_HDX_SELECTION_TASK_H
115 
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
uint32_t HdDirtyBits
Definition: types.h:158
#define HDX_API
Definition: api.h:40
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:570
Definition: task.h:54
Definition: path.h:290
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
Definition: vec4f.h:63
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:45
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:556
HDX_API std::ostream & operator<<(std::ostream &out, const HdxSelectionTaskParams &pv)