Loading...
Searching...
No Matches
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
35PXR_NAMESPACE_OPEN_SCOPE
36
40{
42 : primIdBufferPath()
43 , instanceIdBufferPath()
44 , elementIdBufferPath()
45 , normalBufferPath()
46 , depthBufferPath()
47 , cameraId()
48 , viewport()
49 {}
50
51 SdfPath primIdBufferPath;
52 SdfPath instanceIdBufferPath;
53 SdfPath elementIdBufferPath;
54 SdfPath normalBufferPath;
55 SdfPath depthBufferPath;
56
57 // The id of the camera used to generate the id buffers.
58 SdfPath cameraId;
59
60 // The framing specifying how the camera frustum in mapped into the
61 // render buffers.
62 CameraUtilFraming framing;
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.
68 GfVec4d viewport;
69};
70
79{
80public:
81 HDX_API
83
84 HDX_API
86
88 bool IsConverged() const override;
89
91 HDX_API
92 void Prepare(HdTaskContext* ctx,
93 HdRenderIndex* renderIndex) override;
94
96 HDX_API
97 void Execute(HdTaskContext* ctx) override;
98
99protected:
101 HDX_API
102 void _Sync(HdSceneDelegate* delegate,
103 HdTaskContext* ctx,
104 HdDirtyBits* dirtyBits) override;
105
106private:
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
126 HdxPickFromRenderBufferTask &operator =(
127 const HdxPickFromRenderBufferTask &) = delete;
128};
129
130// VtValue requirements
131HDX_API
132std::ostream& operator<<(std::ostream& out, const HdxPickFromRenderBufferTaskParams& pv);
133HDX_API
134bool operator==(const HdxPickFromRenderBufferTaskParams& lhs,
136HDX_API
137bool operator!=(const HdxPickFromRenderBufferTaskParams& lhs,
139
140PXR_NAMESPACE_CLOSE_SCOPE
141
142#endif //PXR_IMAGING_HDX_PICK_FROM_RENDER_BUFFER_TASK_H
Framing information.
Definition: framing.h:80
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:104
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:50
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
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:45
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
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:235