Loading...
Searching...
No Matches
pickFromRenderBufferTask.h
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"
15#include "pxr/imaging/hd/renderBuffer.h"
16#include "pxr/imaging/hdx/pickTask.h"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
23{
25 : primIdBufferPath()
26 , instanceIdBufferPath()
27 , elementIdBufferPath()
28 , normalBufferPath()
29 , depthBufferPath()
30 , cameraId()
31 , viewport()
32 {}
33
34 SdfPath primIdBufferPath;
35 SdfPath instanceIdBufferPath;
36 SdfPath elementIdBufferPath;
37 SdfPath normalBufferPath;
38 SdfPath depthBufferPath;
39
40 // The id of the camera used to generate the id buffers.
41 SdfPath cameraId;
42
43 // The framing specifying how the camera frustum in mapped into the
44 // render buffers.
45 CameraUtilFraming framing;
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.
51 GfVec4d viewport;
52};
53
62{
63public:
65
66 HDX_API
68
69 HDX_API
71
73 bool IsConverged() const override;
74
76 HDX_API
77 void Prepare(HdTaskContext* ctx,
78 HdRenderIndex* renderIndex) override;
79
81 HDX_API
82 void Execute(HdTaskContext* ctx) override;
83
84protected:
86 HDX_API
87 void _Sync(HdSceneDelegate* delegate,
88 HdTaskContext* ctx,
89 HdDirtyBits* dirtyBits) override;
90
91private:
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
111 HdxPickFromRenderBufferTask &operator =(
112 const HdxPickFromRenderBufferTask &) = delete;
113};
114
115// VtValue requirements
116HDX_API
117std::ostream& operator<<(std::ostream& out, const HdxPickFromRenderBufferTaskParams& pv);
118HDX_API
119bool operator==(const HdxPickFromRenderBufferTaskParams& lhs,
121HDX_API
122bool operator!=(const HdxPickFromRenderBufferTaskParams& lhs,
124
125PXR_NAMESPACE_CLOSE_SCOPE
126
127#endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
Framing information.
Definition: framing.h:63
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type for a vector of 4 double components.
Definition: vec4d.h:46
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:92
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:33
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
Adapter class providing data exchange with the client scene graph.
A task for running picking queries against pre-existing id buffers.
bool IsConverged() const override
Hooks for progressive rendering.
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the pick task.
HDX_API void Execute(HdTaskContext *ctx) override
Execute the pick task.
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality.
Definition: task.h:28
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Pick task context params.
Definition: pickTask.h:259