All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instancer.h
1 //
2 // Copyright 2016 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_HD_ST_INSTANCER_H
25 #define PXR_IMAGING_HD_ST_INSTANCER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/changeTracker.h"
30 #include "pxr/imaging/hd/instancer.h"
31 #include "pxr/usd/sdf/path.h"
32 #include "pxr/base/vt/array.h"
33 #include "pxr/base/tf/hashmap.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 class HdRprim;
38 class HdStDrawItem;
39 struct HdRprimSharedData;
40 
41 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
42 
67 
68 class HdStInstancer : public HdInstancer {
69 public:
71  HDST_API
72  HdStInstancer(HdSceneDelegate* delegate, SdfPath const &id);
73 
74  // Updates the instance primvar buffers.
75  // XXX: Note, this is currently called from rprimUtils instead of the
76  // render index sync phase, so it needs to take a mutex.
77  HDST_API
78  void Sync(HdSceneDelegate *sceneDelegate,
79  HdRenderParam *renderParam,
80  HdDirtyBits *dirtyBits) override;
81 
82  HdBufferArrayRangeSharedPtr GetInstancePrimvarRange() const {
83  return _instancePrimvarRange;
84  }
85 
88  HDST_API
89  VtIntArray GetInstanceIndices(SdfPath const &prototypeId);
90 
91 protected:
92  HDST_API
93  void _GetInstanceIndices(SdfPath const &prototypeId,
94  std::vector<VtIntArray> *instanceIndicesArray);
95 
96  HDST_API
97  void _SyncPrimvars(HdSceneDelegate *sceneDelegate,
98  HdDirtyBits *dirtyBits);
99 
100 private:
101  // # of entries in an instance primvar. This should be consistent between
102  // all primvars, and also consistent with the instance indices (meaning
103  // no instance index is out-of-range).
104  size_t _instancePrimvarNumElements;
105 
106  // The BAR of the instance primvars for this instancer.
107  // (Note: instance indices are computed per prototype and the rprim owns
108  // the bar).
109  HdBufferArrayRangeSharedPtr _instancePrimvarRange;
110 };
111 
112 
113 PXR_NAMESPACE_CLOSE_SCOPE
114 
115 #endif // PXR_IMAGING_HD_ST_INSTANCER_H
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:124
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
HDST_API VtIntArray GetInstanceIndices(SdfPath const &prototypeId)
Populates the instance index indirection buffer for prototypeId and returns a flat array of instance ...
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:68
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
HdSt implements instancing by drawing each proto multiple times with a single draw call...
Definition: instancer.h:68
HDST_API HdStInstancer(HdSceneDelegate *delegate, SdfPath const &id)
Constructor.