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
74protected:
75 HDST_API
76 void _GetInstanceIndices(SdfPath const &prototypeId,
77 std::vector<VtIntArray> *instanceIndicesArray);
78
79 HDST_API
80 void _SyncPrimvars(HdSceneDelegate *sceneDelegate,
81 HdDirtyBits *dirtyBits);
82
83private:
84 // # of entries in an instance primvar. This should be consistent between
85 // all primvars, and also consistent with the instance indices (meaning
86 // no instance index is out-of-range).
87 size_t _instancePrimvarNumElements;
88
89 // The BAR of the instance primvars for this instancer.
90 // (Note: instance indices are computed per prototype and the rprim owns
91 // the bar).
92 HdBufferArrayRangeSharedPtr _instancePrimvarRange;
93
94 // Visibility
95 bool _visible;
96};
97
98
99PXR_NAMESPACE_CLOSE_SCOPE
100
101#endif // PXR_IMAGING_HD_ST_INSTANCER_H
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 HdStInstancer(HdSceneDelegate *delegate, SdfPath const &id)
Constructor.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274