HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pickFromRenderBufferTask.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_PICK_FROM_RENDER_BUFFER_TASK_H
25 #define PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/task.h"
30 
31 #include "pxr/imaging/hd/camera.h"
34 
36 
37 /// Pick task params. This is augmented by HdxPickTaskContextParams, which is
38 /// passed in on the task context.
40 {
46  , depthBufferPath()
47  , cameraId()
48  , viewport()
49  {}
50 
56 
57  // The id of the camera used to generate the id buffers.
59 
60  // The framing specifying how the camera frustum in mapped into the
61  // render buffers.
63  // Is application overriding the window policy of the camera.
64  std::optional<CameraUtilConformWindowPolicy> overrideWindowPolicy;
65 
66  // The viewport of the camera used to generate the id buffers.
67  // Only used if framing is invalid - for legacy clients.
69 };
70 
71 /// \class HdxPickFromRenderBufferTask
72 ///
73 /// A task for running picking queries against pre-existing id buffers.
74 /// This task remaps the "pick frustum", provided by HdxPickTaskContextParams,
75 /// to the camera frustum used to generate the ID buffers. It then runs the
76 /// pick query against the subset of the ID buffers contained by the pick
77 /// frustum.
79 {
80 public:
81  HDX_API
83 
84  HDX_API
86 
87  /// Hooks for progressive rendering.
88  bool IsConverged() const override;
89 
90  /// Prepare the pick task
91  HDX_API
92  void Prepare(HdTaskContext* ctx,
93  HdRenderIndex* renderIndex) override;
94 
95  /// Execute the pick task
96  HDX_API
97  void Execute(HdTaskContext* ctx) override;
98 
99 protected:
100  /// Sync the render pass resources
101  HDX_API
102  void _Sync(HdSceneDelegate* delegate,
103  HdTaskContext* ctx,
104  HdDirtyBits* dirtyBits) override;
105 
106 private:
107  GfMatrix4d _ComputeProjectionMatrix() const;
108 
110  HdxPickTaskContextParams _contextParams;
111  // We need to cache a pointer to the render index so Execute() can
112  // map prim ID to paths.
113  HdRenderIndex *_index;
114 
115  HdRenderBuffer *_primId;
116  HdRenderBuffer *_instanceId;
117  HdRenderBuffer *_elementId;
118  HdRenderBuffer *_normal;
119  HdRenderBuffer *_depth;
120  const HdCamera *_camera;
121 
122  bool _converged;
123 
124  HdxPickFromRenderBufferTask() = delete;
125  HdxPickFromRenderBufferTask(const HdxPickFromRenderBufferTask &) = delete;
126  HdxPickFromRenderBufferTask &operator =(
127  const HdxPickFromRenderBufferTask &) = delete;
128 };
129 
130 // VtValue requirements
131 HDX_API
132 std::ostream& operator<<(std::ostream& out, const HdxPickFromRenderBufferTaskParams& pv);
133 HDX_API
136 HDX_API
139 
141 
142 #endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
uint32_t HdDirtyBits
Definition: types.h:158
std::optional< CameraUtilConformWindowPolicy > overrideWindowPolicy
Definition: vec4d.h:62
#define HDX_API
Definition: api.h:40
bool IsConverged() const override
Hooks for progressive rendering.
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
Definition: path.h:290
HDX_API void Execute(HdTaskContext *ctx) override
Execute the pick task.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
Definition: task.h:44
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the pick task.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDX_API ~HdxPickFromRenderBufferTask() override
HDX_API std::ostream & operator<<(std::ostream &out, const HdxPickFromRenderBufferTaskParams &pv)
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542