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 #include <mutex>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 class HdRprim;
40 class HdStDrawItem;
41 struct HdRprimSharedData;
42 
43 typedef boost::shared_ptr<class HdBufferArrayRange> HdBufferArrayRangeSharedPtr;
44 
69 
70 class HdStInstancer : public HdInstancer {
71 public:
73  HDST_API
74  HdStInstancer(HdSceneDelegate* delegate, SdfPath const &id,
75  SdfPath const &parentInstancerId);
76 
78  HDST_API
79  HdBufferArrayRangeSharedPtr GetInstancePrimvars(HdRprim *prim,
80  HdStDrawItem *drawItem);
81 
84  HDST_API
85  HdBufferArrayRangeSharedPtr GetInstanceIndices(SdfPath const &prototypeId);
86 
89  HDST_API
90  void PopulateDrawItem(HdRprim *prim,
91  HdStDrawItem *drawItem,
92  HdRprimSharedData *sharedData,
93  HdDirtyBits dirtyBits);
94 
95 protected:
96  HDST_API
97  void _GetInstanceIndices(SdfPath const &prototypeId,
98  std::vector<VtIntArray> *instanceIndicesArray);
99 
100 private:
101  std::mutex _instanceLock;
102  size_t _numInstancePrimvars;
103 
104  HdBufferArrayRangeSharedPtr _instancePrimvarRange;
105  TfHashMap<SdfPath,
106  HdBufferArrayRangeSharedPtr,
107  SdfPath::Hash> _instanceIndexRangeMap;
108 };
109 
110 
111 PXR_NAMESPACE_CLOSE_SCOPE
112 
113 #endif // PXR_IMAGING_HD_ST_INSTANCER_H
HDST_API HdBufferArrayRangeSharedPtr GetInstanceIndices(SdfPath const &prototypeId)
Populates the instance index indirection buffer for prototypeId and returns the buffer range...
HDST_API HdStInstancer(HdSceneDelegate *delegate, SdfPath const &id, SdfPath const &parentInstancerId)
Constructor.
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:119
HDST_API void PopulateDrawItem(HdRprim *prim, HdStDrawItem *drawItem, HdRprimSharedData *sharedData, HdDirtyBits dirtyBits)
Populates the rprim&#39;s draw item with the appropriate instancer buffer range data. ...
HDST_API HdBufferArrayRangeSharedPtr GetInstancePrimvars(HdRprim *prim, HdStDrawItem *drawItem)
Populates instance primvars and returns the buffer range.
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:67
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
HdSt implements instancing by drawing each proto multiple times with a single draw call...
Definition: instancer.h:70