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()
49  , viewport()
50  {}
51 
57 
58  // The id of the camera used to generate the id buffers.
60 
61  // The framing specifying how the camera frustum in mapped into the
62  // render buffers.
64  // Is application overriding the window policy of the camera.
65  std::pair<bool, CameraUtilConformWindowPolicy> overrideWindowPolicy;
66 
67  // The viewport of the camera used to generate the id buffers.
68  // Only used if framing is invalid - for legacy clients.
70 };
71 
72 /// \class HdxPickFromRenderBufferTask
73 ///
74 /// A task for running picking queries against pre-existing id buffers.
75 /// This task remaps the "pick frustum", provided by HdxPickTaskContextParams,
76 /// to the camera frustum used to generate the ID buffers. It then runs the
77 /// pick query against the subset of the ID buffers contained by the pick
78 /// frustum.
80 {
81 public:
82  HDX_API
84 
85  HDX_API
87 
88  /// Hooks for progressive rendering.
89  bool IsConverged() const override;
90 
91  /// Prepare the pick task
92  HDX_API
93  void Prepare(HdTaskContext* ctx,
94  HdRenderIndex* renderIndex) override;
95 
96  /// Execute the pick task
97  HDX_API
98  void Execute(HdTaskContext* ctx) override;
99 
100 protected:
101  /// Sync the render pass resources
102  HDX_API
103  void _Sync(HdSceneDelegate* delegate,
104  HdTaskContext* ctx,
105  HdDirtyBits* dirtyBits) override;
106 
107 private:
108  GfMatrix4d _ComputeProjectionMatrix() const;
109 
111  HdxPickTaskContextParams _contextParams;
112  // We need to cache a pointer to the render index so Execute() can
113  // map prim ID to paths.
114  HdRenderIndex *_index;
115 
116  HdRenderBuffer *_primId;
117  HdRenderBuffer *_instanceId;
118  HdRenderBuffer *_elementId;
119  HdRenderBuffer *_normal;
120  HdRenderBuffer *_depth;
121  const HdCamera *_camera;
122 
123  bool _converged;
124 
125  HdxPickFromRenderBufferTask() = delete;
126  HdxPickFromRenderBufferTask(const HdxPickFromRenderBufferTask &) = delete;
127  HdxPickFromRenderBufferTask &operator =(
128  const HdxPickFromRenderBufferTask &) = delete;
129 };
130 
131 // VtValue requirements
132 HDX_API
133 std::ostream& operator<<(std::ostream& out, const HdxPickFromRenderBufferTaskParams& pv);
134 HDX_API
137 HDX_API
140 
142 
143 #endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
uint32_t HdDirtyBits
Definition: types.h:158
Definition: vec4d.h:62
#define HDX_API
Definition: api.h:40
bool IsConverged() const override
Hooks for progressive rendering.
std::pair< bool, CameraUtilConformWindowPolicy > overrideWindowPolicy
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:291
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:1441
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
Increase width or height.
Definition: conformWindow.h:50