Loading...
Searching...
No Matches
instancer.h
1//
2// Copyright 2016 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_HD_ST_INSTANCER_H
8#define PXR_IMAGING_HD_ST_INSTANCER_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hd/changeTracker.h"
13#include "pxr/imaging/hd/instancer.h"
14#include "pxr/usd/sdf/path.h"
15#include "pxr/base/vt/array.h"
16#include "pxr/base/tf/hashmap.h"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20class HdRprim;
21class HdStDrawItem;
22struct HdRprimSharedData;
23
24using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
25
50
51class HdStInstancer : public HdInstancer {
52public:
54 HDST_API
55 HdStInstancer(HdSceneDelegate* delegate, SdfPath const &id);
56
57 // Updates the instance primvar buffers.
58 // XXX: Note, this is currently called from rprimUtils instead of the
59 // render index sync phase, so it needs to take a mutex.
60 HDST_API
61 void Sync(HdSceneDelegate *sceneDelegate,
62 HdRenderParam *renderParam,
63 HdDirtyBits *dirtyBits) override;
64
65 HdBufferArrayRangeSharedPtr GetInstancePrimvarRange() const {
66 return _instancePrimvarRange;
67 }
68
71 HDST_API
72 VtIntArray GetInstanceIndices(SdfPath const &prototypeId);
73
75 HDST_API
76 bool HasDisplayOpacity() const;
77
79 HDST_API
80 bool HasNormals() const;
81
83 HDST_API
84 const GfMatrix4d& GetTransform() const;
85
87 HDST_API
89
90protected:
91 HDST_API
92 void _GetInstanceIndices(SdfPath const &prototypeId,
93 std::vector<VtIntArray> *instanceIndicesArray);
94
95 HDST_API
96 void _SyncPrimvars(HdSceneDelegate *sceneDelegate,
97 HdDirtyBits *dirtyBits);
98
99private:
100 // # of entries in an instance primvar. This should be consistent between
101 // all primvars, and also consistent with the instance indices (meaning
102 // no instance index is out-of-range).
103 size_t _instancePrimvarNumElements;
104
105 // The BAR of the instance primvars for this instancer.
106 // (Note: instance indices are computed per prototype and the rprim owns
107 // the bar).
108 HdBufferArrayRangeSharedPtr _instancePrimvarRange;
109
110 GfMatrix4d _transform;
111 GfMatrix4d _transformInverse;
112
113 // Visibility
114 bool _visible : 1;
115 bool _hasDisplayOpacity : 1;
116 bool _hasNormals : 1;
117};
118
119
120PXR_NAMESPACE_CLOSE_SCOPE
121
122#endif // PXR_IMAGING_HD_ST_INSTANCER_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:108
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:38
Adapter class providing data exchange with the client scene graph.
HdSt implements instancing by drawing each proto multiple times with a single draw call.
Definition: instancer.h:51
HDST_API VtIntArray GetInstanceIndices(SdfPath const &prototypeId)
Populates the instance index indirection buffer for prototypeId and returns a flat array of instance ...
HDST_API bool HasDisplayOpacity() const
Returns whether "displayOpacity" is defined as an instance primvar.
HDST_API bool HasNormals() const
Returns whether "normals" is defined as an instance primvar.
HDST_API const GfMatrix4d & GetTransform() const
Returns the instancer (prim) transform.
HDST_API const GfMatrix4d & GetTransformInverse() const
Returns the instancer (prim) transform inverse.
HDST_API HdStInstancer(HdSceneDelegate *delegate, SdfPath const &id)
Constructor.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274