HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GDT_VertexList() override {}
28 
29  // Implement the pure virtual applyDeltas() from GDT_TokenList.
30  void applyDeltas(GEO_Detail &gdp,
31  bool inverse = false) const override;
32 
33  // Merge vertex deltas from another GDT_VertexList
34  void mergeVertexDeltas(const GDT_VertexList &other,
35  bool inverse = false);
36 
37  // Apply a scaled delta...
38  void applyScaledDelta(GEO_Detail &gdp, GA_Offset vtxoff,
39  float scale) const;
40 
41  // Reset elements with deltas to the values from the source detail.
42  void resetElementsFromSource(GEO_Detail &gdp,
43  const GEO_Detail &src_gdp) const;
44 
45  // Apply stored deltas for elements also recordered in other to the
46  // given gdp.
47  void applyIntersectionDeltas(GEO_Detail &gdp,
48  const GDT_VertexList &other) const;
49 
50  // Overload hiding base class method which requires a GA_AIFEditDeltaMap.
51  void endAttributeChange(const GEO_Detail &gdp);
52 
53  // Compute the vertex offsets array.
54  // This array must always be in sync with the gdp,
55  // otherwise endVertexAttributeChange calls will fail.
56  void updateVertexOffsets(const GEO_Detail &gdp);
57 
59  const GEO_Detail &gdp) const override
60  { return gdp.vertexAttribs(); }
61 
62  bool saveOffsets(UT_JSONWriter &w) const;
63  bool loadOffsets(UT_JSONParser &p);
64 
66  uint size) override;
67 
68  // Destroy the vertex deltas
69  void destroy() override;
70 
71 private:
72  // myOffsets is used as a way to flatten the vertex indices. A cell at
73  // index i of myOffsets contains the total number of vertices up to,
74  // but not including the primitive i. For example, myOffsets[0] is always
75  // 0. If primitive 0 had 4 vertices and primitive 1 had 2 then myOffsets[1]
76  // would be 4 and myOffsets[2] would be 6, and so on. That way it is
77  // very efficient to index a vertex based on a vertex number and primitive
78  // number, it's index would be myOffsets[primnum] + vertexnum.
79  // By its nature the offsets array is sorted, so to compute the inverse,
80  // that is to find the primitive and vertex index given and index into
81  // the vertex array, you just have to do a binary search. The last
82  // entry in the array contains the total number of vertices in the gdp.
83  //
84  // Note that this array should be treated as though it were part of the
85  // delta. Since we don't keep around a gdp, this array might not coincide
86  // with the gdp that we have to apply the delta to. This should be treated
87  // the same way we treat topology changes in the other lists.
88  UT_ValArray<GA_Index> myOffsets;
89 };
90 #endif
#define GDT_API
Definition: GDT_API.h:10
GLsizeiptr size
Definition: glew.h:1681
~GDT_VertexList() override
GLenum GLenum GLenum GLenum GLenum scale
Definition: glew.h:13880
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
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:639
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
virtual bool legacyLoadAttribs(UT_IStream &is, uint size)
virtual void applyDeltas(GEO_Detail &gdp, bool inverse=0) const =0
GLfloat GLfloat p
Definition: glew.h:16321
const GA_AttributeDict & getAttributeDict(const GEO_Detail &gdp) const override
void endAttributeChange(const GA_AIFEditDeltaMap &map)
unsigned int uint
Definition: SYS_Types.h:45
virtual void destroy()
SYS_FORCE_INLINE const GA_AttributeDict & vertexAttribs() const
Definition: GEO_Detail.h:1904