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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
8 #define PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
12 #include "pxr/imaging/hdx/task.h"
13 
14 #include "pxr/imaging/hd/camera.h"
17 
19 
20 /// Pick task params. This is augmented by HdxPickTaskContextParams, which is
21 /// passed in on the task context.
23 {
29  , depthBufferPath()
30  , cameraId()
31  , viewport()
32  {}
33 
39 
40  // The id of the camera used to generate the id buffers.
42 
43  // The framing specifying how the camera frustum in mapped into the
44  // render buffers.
46  // Is application overriding the window policy of the camera.
47  std::optional<CameraUtilConformWindowPolicy> overrideWindowPolicy;
48 
49  // The viewport of the camera used to generate the id buffers.
50  // Only used if framing is invalid - for legacy clients.
52 };
53 
54 /// \class HdxPickFromRenderBufferTask
55 ///
56 /// A task for running picking queries against pre-existing id buffers.
57 /// This task remaps the "pick frustum", provided by HdxPickTaskContextParams,
58 /// to the camera frustum used to generate the ID buffers. It then runs the
59 /// pick query against the subset of the ID buffers contained by the pick
60 /// frustum.
62 {
63 public:
65 
66  HDX_API
68 
69  HDX_API
71 
72  /// Hooks for progressive rendering.
73  bool IsConverged() const override;
74 
75  /// Prepare the pick task
76  HDX_API
77  void Prepare(HdTaskContext* ctx,
78  HdRenderIndex* renderIndex) override;
79 
80  /// Execute the pick task
81  HDX_API
82  void Execute(HdTaskContext* ctx) override;
83 
84 protected:
85  /// Sync the render pass resources
86  HDX_API
87  void _Sync(HdSceneDelegate* delegate,
88  HdTaskContext* ctx,
89  HdDirtyBits* dirtyBits) override;
90 
91 private:
92  GfMatrix4d _ComputeProjectionMatrix() const;
93 
95  HdxPickTaskContextParams _contextParams;
96  // We need to cache a pointer to the render index so Execute() can
97  // map prim ID to paths.
98  HdRenderIndex *_index;
99 
100  HdRenderBuffer *_primId;
101  HdRenderBuffer *_instanceId;
102  HdRenderBuffer *_elementId;
103  HdRenderBuffer *_normal;
104  HdRenderBuffer *_depth;
105  const HdCamera *_camera;
106 
107  bool _converged;
108 
109  HdxPickFromRenderBufferTask() = delete;
111  HdxPickFromRenderBufferTask &operator =(
112  const HdxPickFromRenderBufferTask &) = delete;
113 };
114 
115 // VtValue requirements
116 HDX_API
117 std::ostream& operator<<(std::ostream& out, const HdxPickFromRenderBufferTaskParams& pv);
118 HDX_API
121 HDX_API
124 
126 
127 #endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
uint32_t HdDirtyBits
Definition: types.h:143
std::optional< CameraUtilConformWindowPolicy > overrideWindowPolicy
Definition: vec4d.h:45
#define HDX_API
Definition: api.h:23
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:273
HDX_API void Execute(HdTaskContext *ctx) override
Execute the pick task.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: task.h:27
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the pick task.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
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