pickFromRenderBufferTask.h
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"
32 #include "pxr/imaging/hd/renderBuffer.h"
33 #include "pxr/imaging/hdx/pickTask.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
40 {
42  : primIdBufferPath()
43  , instanceIdBufferPath()
44  , elementIdBufferPath()
45  , normalBufferPath()
46  , depthBufferPath()
47  , cameraId()
48  , overrideWindowPolicy{false, CameraUtilFit}
49  , viewport()
50  {}
51 
52  SdfPath primIdBufferPath;
53  SdfPath instanceIdBufferPath;
54  SdfPath elementIdBufferPath;
55  SdfPath normalBufferPath;
56  SdfPath depthBufferPath;
57 
58  // The id of the camera used to generate the id buffers.
59  SdfPath cameraId;
60 
61  // The framing specifying how the camera frustum in mapped into the
62  // render buffers.
63  CameraUtilFraming framing;
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.
69  GfVec4d viewport;
70 };
71 
80 {
81 public:
82  HDX_API
84 
85  HDX_API
86  ~HdxPickFromRenderBufferTask() override;
87 
89  bool IsConverged() const override;
90 
92  HDX_API
93  void Prepare(HdTaskContext* ctx,
94  HdRenderIndex* renderIndex) override;
95 
97  HDX_API
98  void Execute(HdTaskContext* ctx) override;
99 
100 protected:
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;
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 
141 PXR_NAMESPACE_CLOSE_SCOPE
142 
143 #endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:120
HDX_API void Execute(HdTaskContext *ctx) override
Execute the pick task.
Pick task context params.
Definition: pickTask.h:142
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the pick task.
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:79
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
A task for running picking queries against pre-existing id buffers.
Adapter class providing data exchange with the client scene graph.
bool IsConverged() const override
Hooks for progressive rendering.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality.
Definition: task.h:44
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
A render buffer is a handle to a data resource that can be rendered into, such as a 2d image for a dr...
Definition: renderBuffer.h:49
Framing information.
Definition: framing.h:79