HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PackedAlembic.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_PackedAlembic.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PackedAlembic__
12 #define __GT_PackedAlembic__
13 
14 #include "GT_API.h"
15 #include "GT_GEODetailList.h"
16 #include "GT_GEOPrimPacked.h"
17 #include "GT_PrimInstance.h"
18 
19 class GU_PrimPacked;
20 
21 /// Collection class for a single archive's worth of Alembic primitives.
22 /// This is generally only useful for the viewport.
24 {
25 public:
26  GT_PackedAlembicArchive(const UT_StringHolder &archive_name,
27  const GT_GEODetailListHandle &source_list);
28 
29  const UT_StringHolder &archiveName() const { return myName; }
30 
31  const UT_StringArray &getAlembicObjects() const { return myAlembicObjects; }
32  const GA_OffsetArray &getAlembicOffsets() const { return myAlembicOffsets; }
33 
34  int getPrimitiveType() const override
35  { return GT_PRIM_ALEMBIC_ARCHIVE; }
36 
37  void appendAlembic(GA_Offset alembic_prim_offset)
38  { myAlembicOffsets.append(alembic_prim_offset); }
39 
40  virtual bool bucketPrims(const GT_PackedAlembicArchive *prev_archive,
41  const GT_RefineParms *ref_parms,
42  bool force_update) = 0;
43 
44  int getNumChildPrims() const
45  { return (myConstShapes.entries() +
46  myTransformShapes.entries() +
47  myDeformShapes.entries() +
48  myCombinedShapes.entries()); }
49 
51  { return myConstShapes; }
53  { return myTransformShapes; }
55  { return myDeformShapes; }
57  { return myCombinedShapes; }
58 
59  void enlargeBounds(UT_BoundingBox boxes[],
60  int nsegments) const override;
61  int getMotionSegments() const override { return 1; }
62  int64 getMemoryUsage() const override;
63 
64  void setRefinedSubset(bool reduced_consts,
65  UT_IntArray &const_prims,
66  bool reduced_transforms,
67  UT_IntArray &trans_prims);
68  bool hasConstantSubset() const { return myHasConstSubset; }
69  const UT_IntArray &getConstantSubset() const { return myConstSubset; }
70  bool hasTransformSubset() const { return myHasTransSubset; }
71  const UT_IntArray &getTransformSubset() const { return myTransSubset; }
72 
73  int64 getAlembicVersion() const { return myAlembicVersion; }
74 
76  { return myDetailList->getGeometry(0); }
77  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
78  const GT_RefineParms &refine) override;
79 
80  void setPrimIndex(int idx) { myPrimIndex = idx; }
81  int primIndex() const { return myPrimIndex; }
82 
83 protected:
84  virtual bool archiveMatch(const GT_PackedAlembicArchive *archive) const = 0;
85 
90 
97  unsigned myHasConstSubset : 1,
98  myHasTransSubset : 1;
101 };
102 
103 
104 /// Single Alembic shape (non-instanced)
106 {
107 public:
108  GT_PackedAlembic(const GU_ConstDetailHandle &prim_gdh,
109  const GU_PrimPacked *prim,
110  const GT_DataArrayHandle &vp_mat,
111  const GT_DataArrayHandle &vp_remap,
112  bool build_packed_attribs);
113 
115  ~GT_PackedAlembic() override;
116 
117  virtual void initVisAnim() = 0;
118 
119  int getPrimitiveType() const override
120  { return GT_PRIM_ALEMBIC_SHAPE; }
121 
122  bool hasChanged() const { return myHasChanged; }
123  void changeProcessed() { myHasChanged = false; }
124  bool needsInit() const { return myNeedsInit; }
125  void initProcessed() { myNeedsInit = false; }
126 
127 
128  GT_TransformHandle fullCachedTransform();
129  virtual bool isVisible() = 0;
130 
131  bool getUniqueID(int64 &id) const override
132  { id = myID; return true; }
133 
135  { myAnimType = t; }
136  GEO_AnimationType animationType() const { return myAnimType; }
137 
138  void setVisibilityAnimated(bool anim)
139  { myAnimVis = anim; }
140  bool visibilityAnimated() const { return myAnimVis; }
141 
142  virtual bool getCachedGeometry(GT_PrimitiveHandle &ph) const = 0;
143 
144  virtual void getCachedTransform(GT_TransformHandle &ph) const = 0;
145  virtual void getCachedVisibility(bool &visible) const = 0;
146 
147  GT_TransformHandle applyPrimTransform(const GT_TransformHandle &th)
148  const;
149 
150  int64 alembicVersion() const { return myAlembicVersion; }
151  void setAlembicVersion(int64 v) { myAlembicVersion = v; }
152 
154  { return myDetailAttribs; }
155 protected:
162  float myFrame;
163  unsigned myHasChanged : 1,
164  myAnimVis : 1,
165  myVisibleConst : 1, // only valid when myAnimVis is false.
166  myNeedsInit : 1;
167 };
168 
169 /// Alembic mesh which contains multiple alembic primitives merged together.
171 {
172 public:
173  GT_PackedAlembicMesh(const GT_PrimitiveHandle &packed_geo, int64 id);
174  GT_PackedAlembicMesh(const GT_PrimitiveHandle &packed_geo, int64 id,
175  UT_Array<GT_PrimitiveHandle> &individual_meshes);
177 
178  int getPrimitiveType() const override
179  { return GT_PRIM_ALEMBIC_SHAPE_MESH; }
180  const char *className() const override
181  { return "GT_PackedAlembicMesh"; }
183  { return new GT_PackedAlembicMesh(*this); }
184  bool refine(GT_Refine &refiner,
185  const GT_RefineParms *parms=NULL) const override;
186  void enlargeBounds(UT_BoundingBox boxes[],
187  int nsegments) const override;
188  int getMotionSegments() const override { return 1; }
189  int64 getMemoryUsage() const override;
190  bool getUniqueID(int64 &id) const override
191  { id = myID; return true; }
192 
193  void update(bool initial_update);
195  { return myTransformArray.get() != NULL; }
197  { return myTransformArray.get() != NULL; }
198 
199  int64 alembicVersion() const { return myAlembicVersion; }
200  void setAlembicVersion(int64 v) { myAlembicVersion = v; }
201 
202 private:
203  GT_PrimitiveHandle myMeshGeo;
204  GT_DataArrayHandle myTransformArray;
205  GT_DataArrayHandle myVisibilityArray;
207  int64 myID;
208  int64 myTransID;
209  int64 myVisID;
210  int64 myAlembicVersion;
211 };
212 
213 /// Instanced alembic primitive
215 {
216 public:
220  const GT_PrimitiveHandle &geometry,
221  const GT_TransformArrayHandle &transforms,
222  GEO_AnimationType animation,
223  const GT_GEOOffsetList &packed_prim_offsets=GT_GEOOffsetList(),
227  ~GT_AlembicInstance() override;
228 
229  int getPrimitiveType() const override
230  { return GT_PRIM_ALEMBIC_INSTANCE; }
231 
232  const char *className() const override
233  { return "GT_AlembicInstance"; }
234 
235  GEO_AnimationType animationType() const { return myAnimType; }
236 
237  int64 alembicVersion() const { return myAlembicVersion; }
238  void setAlembicVersion(int64 v) { myAlembicVersion = v; }
239 
240  bool hasChanged() const { return myHasChanged; }
241  void changeProcessed() { myHasChanged = false; }
242 
243  bool needsInit() const { return myNeedsInit; }
244  void initProcessed() { myNeedsInit = false; }
245 
246 protected:
249  unsigned myHasChanged : 1,
250  myNeedsInit : 1;
251 };
252 
253 #endif
GEO_ViewportLOD myLOD
UT_Array< GT_PrimitiveHandle > myCombinedShapes
UT_Array< GT_PrimitiveHandle > myDeformShapes
const UT_Array< GT_PrimitiveHandle > & transformShapes() const
virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
update any cached data for geometry and its attributes
const char * className() const override
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
Single Alembic shape (non-instanced)
const char * className() const override
GEO_AnimationType myAnimType
UT_IntrusivePtr< GT_AttributeList > GT_AttributeListHandle
Definition: GT_Handles.h:24
UT_Array< GT_PrimitiveHandle > myConstShapes
GEO_AnimationType animationType() const
bool hasAnimatedVisibility() const
#define GT_API
Definition: GT_API.h:11
bool needsInit() const
int getMotionSegments() const override
int getMotionSegments() const override
GLenum src
Definition: glcorearb.h:1793
GLdouble GLdouble t
Definition: glew.h:1403
Instanced alembic primitive.
const UT_IntArray & getConstantSubset() const
GA_Size GA_Offset
Definition: GA_Types.h:640
int getPrimitiveType() const override
bool getUniqueID(int64 &id) const override
GEO_AnimationType animationType() const
int64 alembicVersion() const
const UT_StringHolder & archiveName() const
bool hasConstantSubset() const
bool visibilityAnimated() const
GT_AttributeListHandle myDetailAttribs
GT_PrimitiveHandle doSoftCopy() const override
const GT_AttributeListHandle & getDetailAttributes() const override
GEO_AnimationType myAnimType
const GLdouble * v
Definition: glcorearb.h:837
int64 alembicVersion() const
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
const UT_Array< GT_PrimitiveHandle > & combinedShapes() const
int64 getAlembicVersion() const
GEO_AnimationType
bool needsInit() const
long long int64
Definition: SYS_Types.h:116
bool hasChanged() const
const GU_ConstDetailHandle & parentDetail() const
GA_OffsetArray myAlembicOffsets
const UT_Array< GT_PrimitiveHandle > & constantShapes() const
int getPrimitiveType() const override
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
const GA_OffsetArray & getAlembicOffsets() const
GT_GEODetailListHandle myDetailList
virtual int64 getMemoryUsage() const =0
bool hasAnimatedTransforms() const
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
const UT_StringArray & getAlembicObjects() const
int64 alembicVersion() const
Container for a GU packed primitive.
void setAlembicVersion(int64 v)
int getPrimitiveType() const override
GEO_ViewportLOD
void setAnimationType(GEO_AnimationType t)
Alembic mesh which contains multiple alembic primitives merged together.
void appendAlembic(GA_Offset alembic_prim_offset)
int getPrimitiveType() const override
bool hasChanged() const
void setVisibilityAnimated(bool anim)
void setAlembicVersion(int64 v)
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
const UT_Array< GT_PrimitiveHandle > & deformShapes() const
UT_StringArray myAlembicObjects
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
UT_Array< GT_PrimitiveHandle > myTransformShapes
const UT_IntArray & getTransformSubset() const
bool hasTransformSubset() const
void setAlembicVersion(int64 v)
bool getUniqueID(int64 &id) const override