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 HDST_INSTANCER_H
25 #define HDST_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 HdDrawItem;
40 struct HdRprimSharedData;
41 
42 typedef boost::shared_ptr<class HdBufferArrayRange> HdBufferArrayRangeSharedPtr;
43 
68 
69 class HdStInstancer : public HdInstancer {
70 public:
72  HDST_API
73  HdStInstancer(HdSceneDelegate* delegate, SdfPath const &id,
74  SdfPath const &parentInstancerId);
75 
77  HDST_API
78  HdBufferArrayRangeSharedPtr GetInstancePrimvars();
79 
82  HDST_API
83  HdBufferArrayRangeSharedPtr GetInstanceIndices(SdfPath const &prototypeId);
84 
87  HDST_API
88  void PopulateDrawItem(HdDrawItem *drawItem, HdRprimSharedData *sharedData,
89  HdDirtyBits dirtyBits);
90 
91 protected:
92  HDST_API
93  void _GetInstanceIndices(SdfPath const &prototypeId,
94  std::vector<VtIntArray> *instanceIndicesArray);
95 
96 private:
97  std::mutex _instanceLock;
98  size_t _numInstancePrimvars;
99 
100  HdBufferArrayRangeSharedPtr _instancePrimvarRange;
101  TfHashMap<SdfPath,
102  HdBufferArrayRangeSharedPtr,
103  SdfPath::Hash> _instanceIndexRangeMap;
104 };
105 
106 
107 PXR_NAMESPACE_CLOSE_SCOPE
108 
109 #endif // HDST_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(HdDrawItem *drawItem, HdRprimSharedData *sharedData, HdDirtyBits dirtyBits)
Populates the rprim&#39;s draw item with the appropriate instancer buffer range data. ...
HDST_API HdBufferArrayRangeSharedPtr GetInstancePrimvars()
Populates instance primvars and returns the buffer range.
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:69
A draw item is a light-weight representation of an HdRprim&#39;s resources and material to be used for re...
Definition: drawItem.h:66