HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawItem.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_DRAW_ITEM_H
8 #define PXR_IMAGING_HD_DRAW_ITEM_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
13 #include "pxr/imaging/hd/perfLog.h"
16 
17 #include "pxr/imaging/hf/perfLog.h"
18 
19 #include "pxr/base/gf/matrix4d.h"
20 #include "pxr/base/gf/bbox3d.h"
21 #include "pxr/base/gf/vec2i.h"
22 
24 
25 
26 /// \class HdDrawItem
27 ///
28 /// A draw item is a light-weight representation of an HdRprim's resources and
29 /// material to be used for rendering. The visual representation (HdRepr) of an
30 /// HdRprim might require multiple draw items.
31 ///
32 /// HdDrawItem(s) are created by the HdRprim (HdMesh, HdBasisCurve, ..) for each
33 /// HdRepr. The relevant compositional hierarchy is:
34 ///
35 /// HdRprim
36 /// |
37 /// +--HdRepr(s)
38 /// |
39 /// +--HdDrawItem(s)
40 ///
41 /// HdDrawItem(s) are consumed by HdRenderPass for its HdRprimCollection via
42 /// HdRenderIndex::GetDrawItems.
43 ///
44 /// \note
45 /// Rendering backends may choose to specialize this class.
46 ///
48 {
49 public:
50  HF_MALLOC_TAG_NEW("new HdDrawItem");
51 
52  HD_API
53  HdDrawItem(HdRprimSharedData const *sharedData);
54 
55  HD_API
56  virtual ~HdDrawItem();
57 
58  SdfPath const &GetRprimID() const { return _sharedData->rprimID; }
59 
60  GfBBox3d const & GetBounds() const { return _sharedData->bounds; }
61 
62  GfRange3d const& GetExtent() const {
63  return _sharedData->bounds.GetRange();
64  }
65 
66  GfMatrix4d const& GetMatrix() const {
67  return _sharedData->bounds.GetMatrix();
68  }
69 
71  return &_drawingCoord;
72  }
73 
74  /// Returns the authored visibility, expressed by the delegate.
75  bool GetVisible() const { return _sharedData->visible; }
76 
77  TfToken const& GetMaterialTag() const {
78  return _materialTag;
79  }
80 
81  void SetMaterialTag(TfToken const &materialTag) {
82  _materialTag = materialTag;
83  }
84 
85 protected:
86  /// Returns the drawingCoord
88  return _drawingCoord;
89  }
90 
91  /// Returns the shared data
93  return _sharedData;
94  }
95 
96 private:
97  // configuration of how to bundle the drawing coordinate for this draw item
98  // out of BARs in sharedData
99  HdDrawingCoord _drawingCoord;
100 
101  // pointer to shared data across reprs, owned by rprim:
102  // bufferArrayRanges, bounds, visibility
103  HdRprimSharedData const *_sharedData;
104 
105  /// The materialTag allows the draw items of rprims to be organized into
106  /// different collections based on properties of the prim's material.
107  /// E.g. A renderer may wish to organize opaque and translucent prims
108  /// into different collections so they can be rendered seperately.
109  TfToken _materialTag;
110 };
111 
112 
114 
115 #endif //PXR_IMAGING_HD_DRAW_ITEM_H
GfRange3d const & GetExtent() const
Definition: drawItem.h:62
GfBBox3d const & GetBounds() const
Definition: drawItem.h:60
#define HD_API
Definition: api.h:23
HdDrawingCoord const & _GetDrawingCoord() const
Returns the drawingCoord.
Definition: drawItem.h:87
bool GetVisible() const
Returns the authored visibility, expressed by the delegate.
Definition: drawItem.h:75
HdRprimSharedData const * _GetSharedData() const
Returns the shared data.
Definition: drawItem.h:92
TfToken const & GetMaterialTag() const
Definition: drawItem.h:77
virtual HD_API ~HdDrawItem()
Definition: token.h:70
HF_MALLOC_TAG_NEW("new HdDrawItem")
SdfPath const & GetRprimID() const
Definition: drawItem.h:58
const GfRange3d & GetRange() const
Returns the range of the axis-aligned untransformed box.
Definition: bbox3d.h:115
HdDrawingCoord * GetDrawingCoord()
Definition: drawItem.h:70
HD_API HdDrawItem(HdRprimSharedData const *sharedData)
Definition: path.h:273
void SetMaterialTag(TfToken const &materialTag)
Definition: drawItem.h:81
GfMatrix4d const & GetMatrix() const
Definition: drawItem.h:66
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
const GfMatrix4d & GetMatrix() const
Returns the transformation matrix.
Definition: bbox3d.h:126