All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PackedUSD.h
1 //
2 // Copyright 2017 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 __GUSD_GT_PACKEDUSD_H__
25 #define __GUSD_GT_PACKEDUSD_H__
26 
27 #include "gusd/api.h"
28 #include "gusd/purpose.h"
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/sdf/path.h"
32 #include "pxr/usd/usd/timeCode.h"
33 
34 #include <GT/GT_GEOPrimCollect.h>
35 #include <GT/GT_Primitive.h>
36 
37 class GU_PrimPacked;
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
57 
58 class GusdGT_PackedUSD : public GT_Primitive
59 {
60 public:
62  const UT_StringHolder& fileName,
63  const UT_StringHolder& auxFileName,
64  const SdfPath& primPath,
65  const SdfPath& srcPrimPath,
66  exint index,
67  UsdTimeCode frame,
68  GusdPurposeSet purpose, // Unused
69  GT_AttributeListHandle pointAttributes,
70  GT_AttributeListHandle vertexAttributes,
71  GT_AttributeListHandle uniformAttributes,
72  GT_AttributeListHandle detailAttributes,
73  const GU_PrimPacked* prim );
74 
75  GusdGT_PackedUSD(const GusdGT_PackedUSD& other);
76 
77  virtual ~GusdGT_PackedUSD();
78 
79  // GT_Primitive interface --------------------------------------------------
80 public:
81  virtual const char* className() const override;
82 
83  virtual GT_PrimitiveHandle doSoftCopy() const override;
84 
85  GUSD_API
86  static int getStaticPrimitiveType();
87 
88  virtual int getPrimitiveType() const override;
89 
90  virtual void enlargeBounds(UT_BoundingBox boxes[],
91  int nsegments) const override;
92 
93  virtual int getMotionSegments() const override;
94 
95  virtual int64 getMemoryUsage() const override;
96 
97  virtual const GT_AttributeListHandle& getPointAttributes() const override;
98  virtual const GT_AttributeListHandle& getVertexAttributes() const override;
99  virtual const GT_AttributeListHandle& getUniformAttributes() const override;
100  virtual const GT_AttributeListHandle& getDetailAttributes() const override;
101 
102  // -------------------------------------------------------------------------
103 
104  // Get the name of the referenced USD file
105  const UT_StringHolder& getFileName() const { return m_fileName; }
106 
107  // Get the name of the referenced USD file
108  const UT_StringHolder& getAuxFileName() const { return m_auxFileName; }
109 
110  // Get the node path in the referenced USD file
111  const SdfPath& getPrimPath() const { return m_primPath; }
112 
113  const SdfPath& getSrcPrimPath() const { return m_srcPrimPath; }
114 
115  const exint& getInstanceIndex() const { return m_instanceIndex; }
116 
117 private:
118  UT_StringHolder m_fileName;
119  UT_StringHolder m_auxFileName;
120  SdfPath m_primPath;
121  SdfPath m_srcPrimPath;
122  exint m_instanceIndex;
123  UsdTimeCode m_frame;
124  UT_BoundingBox m_box;
125 
126  GT_AttributeListHandle m_pointAttributes;
127  GT_AttributeListHandle m_vertexAttributes;
128  GT_AttributeListHandle m_uniformAttributes;
129  GT_AttributeListHandle m_detailAttributes;
130 };
131 
132 
133 //------------------------------------------------------------------------------
134 // class GusdGT_PackedUSDMesh
135 //------------------------------------------------------------------------------
136 
137 /*
138  * A utility class which supports meshes which have been coalesced together
139  * for viewport efficiency. Based on GT_PackedAlembicMesh in the HDK.
140  */
141 
142 class GusdGT_PackedUSDMesh : public GT_Primitive
143 {
144 public:
145  GusdGT_PackedUSDMesh(
146  const GT_PrimitiveHandle& mesh,
147  int64 id,
148  UT_Array<GT_PrimitiveHandle>& sourceMeshes);
149 
150  virtual ~GusdGT_PackedUSDMesh();
151 
152  virtual const char* className() const override;
153 
154  static int getStaticPrimitiveType();
155 
156  virtual int getPrimitiveType() const override;
157 
158  virtual GT_PrimitiveHandle doSoftCopy() const override;
159 
160  virtual bool refine(
161  GT_Refine& refiner,
162  const GT_RefineParms* parms=nullptr) const override;
163 
164  virtual void enlargeBounds(
165  UT_BoundingBox boxes[],
166  int nsegments) const override;
167 
168  virtual int getMotionSegments() const override;
169 
170  virtual int64 getMemoryUsage() const override;
171 
172  virtual bool getUniqueID(int64& id) const override;
173 
174 private:
175  GT_PrimitiveHandle m_mesh;
176  int64 m_id;
177  // Handles to uncoalesced meshes must be kept alive for viewport picking
178  // to work correctly.
179  UT_Array<GT_PrimitiveHandle> m_sourceMeshes;
180 };
181 
182 
183 //------------------------------------------------------------------------------
184 // class GusdGT_PrimCollect
185 //------------------------------------------------------------------------------
186 
187 /*
188  * A collector for Packed USD primitives which creates corresponding
189  * GusdGT_PackedUSD prims
190  */
191 
192 // XXX This could be named something more explicit like GusdGT_PackedUSDCollect
193 
194 class GusdGT_PrimCollect : public GT_GEOPrimCollect
195 {
196 public:
197  GusdGT_PrimCollect() {}
198  virtual ~GusdGT_PrimCollect();
199 
200  virtual GT_GEOPrimCollectData *
201  beginCollecting(
202  const GT_GEODetailListHandle &geometry,
203  const GT_RefineParms *parms) const;
204 
205  virtual GT_PrimitiveHandle
206  collect(
207  const GT_GEODetailListHandle &geo,
208  const GEO_Primitive *const* prim_list,
209  int nsegments,
210  GT_GEOPrimCollectData *data) const;
211 
212  virtual GT_PrimitiveHandle
213  endCollecting(
214  const GT_GEODetailListHandle &geometry,
215  GT_GEOPrimCollectData *data) const;
216 };
217 
218 PXR_NAMESPACE_CLOSE_SCOPE
219 
220 
221 #endif // __GUSD_GU_PRIMCOLLECT_H__
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
A GT implementation of a packed USD prim.
Definition: GT_PackedUSD.h:58