HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawItemInstance.h
Go to the documentation of this file.
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_DRAW_ITEM_INSTANCE_H
8 #define PXR_IMAGING_HD_ST_DRAW_ITEM_INSTANCE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
13 
15 
16 using HdSt_DrawBatchSharedPtr = std::shared_ptr<class HdSt_DrawBatch>;
17 
18 /// \class HdStDrawItemInstance
19 ///
20 /// A container to store instance state for a drawitem.
21 ///
22 /// During culling, the visibility state will be set. If the instance
23 /// has a batch, the batch will get a DrawItemInstanceChanged
24 /// callback.
25 ///
26 /// The Batch is responsible for calling SetBatch and SetBatchIndex
27 /// when adding / appending the instance. If the batch does not require
28 /// the DrawItemInstanceChanged callback, then this step can be skipped
29 ///
31 {
32 public:
33  HDST_API
34  HdStDrawItemInstance(HdStDrawItem const *drawItem);
35  HDST_API
37 
38  /// Set visibility state
39  HDST_API
40  void SetVisible(bool visible);
41 
42  /// Query visibility state
43  bool IsVisible() const { return _visible; }
44 
45  /// Set index into batch list. Can be used by
46  /// batch during DrawItemInstanceChanged callback
47  HDST_API
48  void SetBatchIndex(size_t batchIndex);
49 
50  /// Query batch index
51  size_t GetBatchIndex() const { return _batchIndex; }
52 
53  /// Set the batch that will receive the DrawItemInstanceChanged
54  /// callback when visibility is updated. Setting batch to NULL
55  /// will disable this callback.
56  // HDST_API
57  void SetBatch(HdSt_DrawBatch *batch);
58 
59  /// Return a const pointer to draw item
60  HdStDrawItem const *GetDrawItem() const { return _drawItem; }
61 
62 private:
63  HdStDrawItemInstance();
64 
65  HdSt_DrawBatch * _batch;
66  HdStDrawItem const * _drawItem;
67  size_t _batchIndex;
68  bool _visible;
69 };
70 
71 
73 
74 #endif // PXR_IMAGING_HD_ST_DRAW_ITEM_INSTANCE_H
75 
HDST_API void SetVisible(bool visible)
Set visibility state.
void SetBatch(HdSt_DrawBatch *batch)
bool IsVisible() const
Query visibility state.
HDST_API ~HdStDrawItemInstance()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
size_t GetBatchIndex() const
Query batch index.
HDST_API void SetBatchIndex(size_t batchIndex)
HdStDrawItem const * GetDrawItem() const
Return a const pointer to draw item.
std::shared_ptr< class HdSt_DrawBatch > HdSt_DrawBatchSharedPtr
Definition: commandBuffer.h:36