24 #ifndef PXR_IMAGING_HDX_PICK_TASK_H 25 #define PXR_IMAGING_HDX_PICK_TASK_H 28 #include "pxr/imaging/hdx/api.h" 30 #include "pxr/imaging/hdSt/textureUtils.h" 31 #include "pxr/imaging/hd/enums.h" 32 #include "pxr/imaging/hd/renderPass.h" 33 #include "pxr/imaging/hd/renderPassState.h" 34 #include "pxr/imaging/hd/rprimCollection.h" 35 #include "pxr/imaging/hd/task.h" 44 #include "pxr/usd/sdf/path.h" 49 PXR_NAMESPACE_OPEN_SCOPE
51 #define HDX_PICK_TOKENS \ 56 (pickPrimsAndInstances) \ 62 (resolveNearestToCamera) \ 63 (resolveNearestToCenter) \ 69 class HdStRenderBuffer;
71 using HdStShaderCodeSharedPtr = std::shared_ptr<class HdStShaderCode>;
81 : cullStyle(HdCullStyleNothing)
82 , enableSceneMaterials(
true)
85 HdCullStyle cullStyle;
86 bool enableSceneMaterials;
103 float normalizedDepth;
105 inline bool IsValid()
const {
110 size_t GetHash()
const;
113 using HdxPickHitVector = std::vector<HdxPickHit>;
144 using DepthMaskCallback = std::function<void(
void)>;
147 : resolution(128, 128)
148 , pickTarget(HdxPickTokens->pickPrimsAndInstances)
149 , resolveMode(HdxPickTokens->resolveNearestToCamera)
150 , doUnpickablesOcclude(
false)
152 , projectionMatrix(1)
154 , depthMaskCallback(
nullptr)
162 bool doUnpickablesOcclude;
165 std::vector<GfVec4d> clipPlanes;
166 DepthMaskCallback depthMaskCallback;
168 HdxPickHitVector *outHits;
196 HdDirtyBits* dirtyBits)
override;
200 void Prepare(HdTaskContext* ctx,
205 void Execute(HdTaskContext* ctx)
override;
212 return (int32_t(idColor[0] & 0xff) << 0) |
213 (int32_t(idColor[1] & 0xff) << 8) |
214 (int32_t(idColor[2] & 0xff) << 16) |
215 (int32_t(idColor[3] & 0xff) << 24);
228 void _InitIfNeeded();
229 void _CreateAovBindings();
230 void _CleanupAovBindings();
231 void _ResizeOrCreateBufferForAOV(
234 void _ConditionStencilWithGLCallback(
235 HdxPickTaskContextParams::DepthMaskCallback maskCallback,
238 bool _UseOcclusionPass()
const;
239 bool _UseWidgetPass()
const;
242 HdStTextureUtils::AlignedBuffer<T>
243 _ReadAovBuffer(
TfToken const & aovName)
const;
249 HdRenderPassSharedPtr _pickableRenderPass;
250 HdRenderPassSharedPtr _occluderRenderPass;
251 HdRenderPassSharedPtr _widgetRenderPass;
255 HdRenderPassStateSharedPtr _pickableRenderPassState;
256 HdRenderPassStateSharedPtr _occluderRenderPassState;
257 HdRenderPassStateSharedPtr _widgetRenderPassState;
261 std::vector<std::unique_ptr<HdStRenderBuffer>> _pickableAovBuffers;
262 HdRenderPassAovBindingVector _pickableAovBindings;
264 size_t _pickableDepthIndex;
266 std::unique_ptr<HdStRenderBuffer> _widgetDepthStencilBuffer;
267 HdRenderPassAovBindingVector _widgetAovBindings;
297 int const* instanceIds,
298 int const* elementIds,
338 void ResolveAll(HdxPickHitVector* allHits)
const;
346 bool _ResolveHit(
int index,
int x,
int y,
float z,
HdxPickHit* hit)
const;
347 size_t _GetHash(
int index)
const;
348 bool _IsValidHit(
int index)
const;
352 int _GetPrimId(
int index)
const {
353 return _primIds ? _primIds[index] : -1;
355 int _GetInstanceId(
int index)
const {
356 return _instanceIds ? _instanceIds[index] : -1;
358 int _GetElementId(
int index)
const {
359 return _elementIds ? _elementIds[index] : -1;
361 int _GetEdgeId(
int index)
const {
362 return _edgeIds ? _edgeIds[index] : -1;
364 int _GetPointId(
int index)
const {
365 return _pointIds ? _pointIds[index] : -1;
371 GfVec3f _GetNormal(
int index)
const;
374 int const* _instanceIds;
375 int const* _elementIds;
377 int const* _pointIds;
379 float const* _depths;
420 PXR_NAMESPACE_CLOSE_SCOPE
422 #endif // PXR_IMAGING_HDX_PICK_TASK_H Basic type for a vector of 4 int components.
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
HDX_API void ResolveUnique(HdxPickHitVector *allHits) const
Return the set of unique hit points, keeping only the nearest depth value.
HDX_API bool IsValid() const
Return whether the result was given well-formed parameters.
Basic type for a vector of 2 int components.
Standard pointer typedefs.
Pick task context params.
Provide architecture-specific memory-alignment information.
Basic type for a vector of 3 float components.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
A set of rendering parameters used among render passes.
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Token for efficient comparison, assignment, and hashing of known strings.
HDX_API void ResolveNearestToCenter(HdxPickHitVector *allHits) const
Return the nearest single hit point from the center of the viewport.
Stores a 4x4 matrix of double elements.
Adapter class providing data exchange with the client scene graph.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
std::vector< TfToken > TfTokenVector
Convenience types.
A named, semantic collection of objects.
A utility class for resolving ID buffers into hits.
A path value used to locate objects in layers or scenegraphs.
static int DecodeIDRenderColor(unsigned char const idColor[4])
Utility: Given a UNorm8Vec4 pixel, unpack it into an int32 ID.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Hydra Graphics Interface.
A renderpass AOV represents a binding of some output of the rendering process to an output buffer.
Basic type for a vector of 2 float components.
A task for running picking queries against the current scene.
A render buffer is a handle to a data resource that can be rendered into, such as a 2d image for a dr...
HDX_API void Execute(HdTaskContext *ctx) override
Execute the pick task.
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HDX_API void ResolveAll(HdxPickHitVector *allHits) const
Return all hit points.
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
HDX_API void ResolveNearestToCamera(HdxPickHitVector *allHits) const
Return the nearest single hit point.
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the pick task.