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 {
46  float occludedSelectionOpacity; // lerp factor when blending
47  // occluded selection
48  GfVec4f selectionColor; // "active" selection color
49  GfVec4f locateColor; // "rollover" selection color
50 };
51 
52 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
53 
54 /// \class HdxSelectionTask
55 ///
56 /// The SelectionTask is responsible for setting up render pass global buffers
57 /// for selection and depositing those buffers into the task context for down
58 /// stream consumption. Any render pass which wants to display selection may
59 /// extract those buffers and bind them into the current render pass shader to
60 /// enable selection highlighting.
61 ///
62 class HdxSelectionTask : public HdTask
63 {
64 public:
65  HDX_API
66  HdxSelectionTask(HdSceneDelegate* delegate, SdfPath const& id);
67 
68  HDX_API
69  ~HdxSelectionTask() override;
70 
71  /// Sync the render pass resources
72  HDX_API
73  void Sync(HdSceneDelegate* delegate,
74  HdTaskContext* ctx,
75  HdDirtyBits* dirtyBits) override;
76 
77 
78  /// Prepare the tasks resources
79  HDX_API
80  void Prepare(HdTaskContext* ctx,
81  HdRenderIndex* renderIndex) override;
82 
83  /// Execute render pass task
84  HDX_API
85  void Execute(HdTaskContext* ctx) override;
86 
87 
88 private:
89  int _lastVersion;
90  bool _hasSelection;
91  HdxSelectionTaskParams _params;
92  HdBufferArrayRangeSharedPtr _selOffsetBar;
93  HdBufferArrayRangeSharedPtr _selUniformBar;
94  size_t _pointColorsBufferSize;
95 
96  HdxSelectionTask() = delete;
97  HdxSelectionTask(const HdxSelectionTask &) = delete;
98  HdxSelectionTask &operator =(const HdxSelectionTask &) = delete;
99 };
100 
101 // VtValue requirements
102 HDX_API
103 std::ostream& operator<<(std::ostream& out,
104  const HdxSelectionTaskParams& pv);
105 HDX_API
106 bool operator==(const HdxSelectionTaskParams& lhs,
107  const HdxSelectionTaskParams& rhs);
108 HDX_API
109 bool operator!=(const HdxSelectionTaskParams& lhs,
110  const HdxSelectionTaskParams& rhs);
111 
112 
114 
115 #endif //PXR_IMAGING_HDX_SELECTION_TASK_H
116 
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:556
Definition: task.h:54
Definition: path.h:290
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
Definition: vec4f.h:62
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:44
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)