HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GDT_VertexList.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: GDT Library. (Geo Delta)
7  *
8  * COMMENTS: GDT_VertexList contains tokens for vertex attributes.
9  * All these tokens are not sparse.
10  *
11  */
12 #ifndef __GDT_VertexList_h__
13 #define __GDT_VertexList_h__
14 
15 #include "GDT_API.h"
16 #include "GDT_TokenList.h"
17 
18 #include <UT/UT_IntArray.h>
19 #include <UT/UT_ValArray.h>
20 #include <UT/UT_ValArray.h>
21 #include <GEO/GEO_Detail.h>
22 
24 {
25 public:
27  virtual ~GDT_VertexList() {}
28 
29  // Implement the pure virtual applyDeltas() from GDT_TokenList.
30  virtual void applyDeltas(GEO_Detail &gdp, bool inverse=false) const;
31 
32  // Merge vertex deltas from another GDT_VertexList
33  void mergeVertexDeltas(const GDT_VertexList &other,
34  bool inverse = false);
35 
36  // Apply a scaled delta...
37  void applyScaledDelta(GEO_Detail &gdp, GA_Offset vtxoff,
38  float scale) const;
39 
40  // Overload hiding base class method which requires a GA_AIFEditDeltaMap.
41  void endAttributeChange(const GEO_Detail &gdp);
42 
43  // Compute the vertex offsets array.
44  // This array must always be in sync with the gdp,
45  // otherwise endVertexAttributeChange calls will fail.
46  void updateVertexOffsets(const GEO_Detail &gdp);
47 
49  const GEO_Detail &gdp) const
50  { return gdp.vertexAttribs(); }
51 
52  bool saveOffsets(UT_JSONWriter &w) const;
53  bool loadOffsets(UT_JSONParser &p);
54 
55  virtual bool legacyLoadAttribs(UT_IStream &is, uint size);
56 
57  // Destroy the vertex deltas
58  virtual void destroy();
59 
60 private:
61  // myOffsets is used as a way to flatten the vertex indices. A cell at
62  // index i of myOffsets contains the total number of vertices up to,
63  // but not including the primitive i. For example, myOffsets[0] is always
64  // 0. If primitive 0 had 4 vertices and primitive 1 had 2 then myOffsets[1]
65  // would be 4 and myOffsets[2] would be 6, and so on. That way it is
66  // very efficient to index a vertex based on a vertex number and primitive
67  // number, it's index would be myOffsets[primnum] + vertexnum.
68  // By its nature the offsets array is sorted, so to compute the inverse,
69  // that is to find the primitive and vertex index given and index into
70  // the vertex array, you just have to do a binary search. The last
71  // entry in the array contains the total number of vertices in the gdp.
72  //
73  // Note that this array should be treated as though it were part of the
74  // delta. Since we don't keep around a gdp, this array might not coincide
75  // with the gdp that we have to apply the delta to. This should be treated
76  // the same way we treat topology changes in the other lists.
77  UT_ValArray<GA_Index> myOffsets;
78 };
79 #endif
virtual const GA_AttributeDict & getAttributeDict(const GEO_Detail &gdp) const
#define GDT_API
Definition: GDT_API.h:10
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
GLsizeiptr size
Definition: glcorearb.h:663
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
GA_Size GA_Offset
Definition: GA_Types.h:617
GA_API const UT_StringHolder scale
virtual bool legacyLoadAttribs(UT_IStream &is, uint size)
unsigned int uint
Definition: SYS_Types.h:33
virtual void applyDeltas(GEO_Detail &gdp, bool inverse=0) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual ~GDT_VertexList()
void endAttributeChange(const GA_AIFEditDeltaMap &map)
virtual void destroy()
SYS_FORCE_INLINE const GA_AttributeDict & vertexAttribs() const
Definition: GEO_Detail.h:1829