selectionTask.h
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"
29 #include "pxr/imaging/hdx/version.h"
30 #include "pxr/imaging/hd/task.h"
31 
32 #include "pxr/base/gf/vec4f.h"
33 
34 #include <memory>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 class HdRenderIndex;
40 class HdSceneDelegate;
41 
42 struct HdxSelectionTaskParams
43 {
44  bool enableSelection;
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 
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 
71  HDX_API
72  void Sync(HdSceneDelegate* delegate,
73  HdTaskContext* ctx,
74  HdDirtyBits* dirtyBits) override;
75 
76 
78  HDX_API
79  void Prepare(HdTaskContext* ctx,
80  HdRenderIndex* renderIndex) override;
81 
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 
112 PXR_NAMESPACE_CLOSE_SCOPE
113 
114 #endif //PXR_IMAGING_HDX_SELECTION_TASK_H
115 
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:120
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
The SelectionTask is responsible for setting up render pass global buffers for selection and depositi...
Definition: selectionTask.h:61