- kinda crazy, but replaced old ME_SIMPLE_SUBDIV method with just
[blender.git] / source / blender / blenkernel / intern / CCGSubSurf.h
1 /* $Id$ */
2
3 typedef void* CCGMeshHDL;
4 typedef void* CCGVertHDL;
5 typedef void* CCGEdgeHDL;
6 typedef void* CCGFaceHDL;
7
8 typedef struct _CCGMeshIFC CCGMeshIFC;
9 struct _CCGMeshIFC {
10         int                     vertUserSize, edgeUserSize, faceUserSize;
11
12         int                     vertDataSize;
13         void            (*vertDataZero)         (CCGMeshHDL m, void *t);
14         int                     (*vertDataEqual)        (CCGMeshHDL m, void *a, void *b);
15         void            (*vertDataCopy)         (CCGMeshHDL m, void *t, void *a);
16         void            (*vertDataAdd)          (CCGMeshHDL m, void *ta, void *b);
17         void            (*vertDataSub)          (CCGMeshHDL m, void *ta, void *b);
18         void            (*vertDataMulN)         (CCGMeshHDL m, void *ta, double n);
19         void            (*vertDataAvg4)         (CCGMeshHDL m, void *t, void *a, void *b, void *c, void *d);
20 };
21
22 /***/
23
24 typedef void* CCGAllocatorHDL;
25
26 typedef struct _CCGAllocatorIFC CCGAllocatorIFC;
27 struct _CCGAllocatorIFC {
28         void*           (*alloc)                        (CCGAllocatorHDL a, int numBytes);
29         void*           (*realloc)                      (CCGAllocatorHDL a, void *ptr, int newSize, int oldSize);
30         void            (*free)                         (CCGAllocatorHDL a, void *ptr);
31         void            (*release)                      (CCGAllocatorHDL a);
32 };
33
34 /***/
35
36 typedef enum {
37         eCCGError_None = 0,
38
39         eCCGError_InvalidSyncState,
40         eCCGError_InvalidValue,
41 } CCGError;
42
43 /***/
44
45 typedef struct _CCGSubSurf CCGSubSurf;
46
47 CCGSubSurf*     ccgSubSurf_new  (CCGMeshIFC *ifc, CCGMeshHDL meshData, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator);
48 void            ccgSubSurf_free (CCGSubSurf *ss);
49
50 CCGError        ccgSubSurf_sync (CCGSubSurf *ss);
51
52 CCGError        ccgSubSurf_initFullSync         (CCGSubSurf *ss);
53 CCGError        ccgSubSurf_initPartialSync      (CCGSubSurf *ss);
54
55 CCGError        ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData);
56 CCGError        ccgSubSurf_syncEdge             (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease);
57 CCGError        ccgSubSurf_syncFace             (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs);
58
59 CCGError        ccgSubSurf_syncVertDel  (CCGSubSurf *ss, CCGVertHDL vHDL);
60 CCGError        ccgSubSurf_syncEdgeDel  (CCGSubSurf *ss, CCGEdgeHDL eHDL);
61 CCGError        ccgSubSurf_syncFaceDel  (CCGSubSurf *ss, CCGFaceHDL fHDL);
62
63 CCGError        ccgSubSurf_processSync  (CCGSubSurf *ss);
64
65 CCGError        ccgSubSurf_setSubdivisionLevels         (CCGSubSurf *ss, int subdivisionLevels);
66 CCGError        ccgSubSurf_setAllowEdgeCreation         (CCGSubSurf *ss, int allowEdgeCreation, float defaultCreaseValue);
67 CCGError        ccgSubSurf_setUseAgeCounts                      (CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset);
68 CCGError        ccgSubSurf_setCalcVertexNormals         (CCGSubSurf *ss, int useVertNormals, int normalDataOffset);
69
70 /***/
71
72 typedef struct _CCGVert CCGVert;
73 typedef struct _CCGEdge CCGEdge;
74 typedef struct _CCGFace CCGFace;
75
76 int                     ccgSubSurf_getNumVerts                          (CCGSubSurf *ss);
77 int                     ccgSubSurf_getNumEdges                          (CCGSubSurf *ss);
78 int                     ccgSubSurf_getNumFaces                          (CCGSubSurf *ss);
79
80 int                     ccgSubSurf_getSubdivisionLevels         (CCGSubSurf *ss);
81 int                     ccgSubSurf_getEdgeSize                          (CCGSubSurf *ss);
82 int                     ccgSubSurf_getEdgeLevelSize                     (CCGSubSurf *ss, int level);
83 int                     ccgSubSurf_getGridSize                          (CCGSubSurf *ss);
84 int                     ccgSubSurf_getGridLevelSize                     (CCGSubSurf *ss, int level);
85
86 CCGVert*        ccgSubSurf_getVert                                      (CCGSubSurf *ss, CCGVertHDL v);
87 CCGVertHDL      ccgSubSurf_getVertVertHandle            (CCGSubSurf *ss, CCGVert *v);
88 int                     ccgSubSurf_getVertNumFaces                      (CCGSubSurf *ss, CCGVert *v);
89 CCGFace*        ccgSubSurf_getVertFace                          (CCGSubSurf *ss, CCGVert *v, int index);
90 int                     ccgSubSurf_getVertNumEdges                      (CCGSubSurf *ss, CCGVert *v);
91 CCGEdge*        ccgSubSurf_getVertEdge                          (CCGSubSurf *ss, CCGVert *v, int index);
92
93 int                     ccgSubSurf_getVertAge                           (CCGSubSurf *ss, CCGVert *v);
94 void*           ccgSubSurf_getVertUserData                      (CCGSubSurf *ss, CCGVert *v);
95 void*           ccgSubSurf_getVertData                          (CCGSubSurf *ss, CCGVert *v);
96 void*           ccgSubSurf_getVertLevelData                     (CCGSubSurf *ss, CCGVert *v, int level);
97
98 CCGEdge*        ccgSubSurf_getEdge                                      (CCGSubSurf *ss, CCGEdgeHDL e);
99 CCGEdgeHDL      ccgSubSurf_getEdgeEdgeHandle            (CCGSubSurf *ss, CCGEdge *e);
100 int                     ccgSubSurf_getEdgeNumFaces                      (CCGSubSurf *ss, CCGEdge *e);
101 CCGFace*        ccgSubSurf_getEdgeFace                          (CCGSubSurf *ss, CCGEdge *e, int index);
102 CCGVert*        ccgSubSurf_getEdgeVert0                         (CCGSubSurf *ss, CCGEdge *e);
103 CCGVert*        ccgSubSurf_getEdgeVert1                         (CCGSubSurf *ss, CCGEdge *e);
104
105 int                     ccgSubSurf_getEdgeAge                           (CCGSubSurf *ss, CCGEdge *e);
106 void*           ccgSubSurf_getEdgeUserData                      (CCGSubSurf *ss, CCGEdge *e);
107 void*           ccgSubSurf_getEdgeDataArray                     (CCGSubSurf *ss, CCGEdge *e);
108 void*           ccgSubSurf_getEdgeData                          (CCGSubSurf *ss, CCGEdge *e, int x);
109 void*           ccgSubSurf_getEdgeLevelData                     (CCGSubSurf *ss, CCGEdge *e, int x, int level);
110
111 CCGFace*        ccgSubSurf_getFace                                      (CCGSubSurf *ss, CCGFaceHDL f);
112 CCGFaceHDL      ccgSubSurf_getFaceFaceHandle            (CCGSubSurf *ss, CCGFace *f);
113 int                     ccgSubSurf_getFaceNumVerts                      (CCGSubSurf *ss, CCGFace *f);
114 CCGVert*        ccgSubSurf_getFaceVert                          (CCGSubSurf *ss, CCGFace *f, int index);
115 CCGEdge*        ccgSubSurf_getFaceEdge                          (CCGSubSurf *ss, CCGFace *f, int index);
116
117 int                     ccgSubSurf_getFaceAge                           (CCGSubSurf *ss, CCGFace *f);
118 void*           ccgSubSurf_getFaceUserData                      (CCGSubSurf *ss, CCGFace *f);
119 void*           ccgSubSurf_getFaceCenterData            (CCGSubSurf *ss, CCGFace *f);
120 void*           ccgSubSurf_getFaceGridEdgeDataArray     (CCGSubSurf *ss, CCGFace *f, int gridIndex);
121 void*           ccgSubSurf_getFaceGridEdgeData          (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x);
122 void*           ccgSubSurf_getFaceGridDataArray         (CCGSubSurf *ss, CCGFace *f, int gridIndex);
123 void*           ccgSubSurf_getFaceGridData                      (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
124
125 int                     ccgSubSurf_getNumFinalVerts             (CCGSubSurf *ss);
126 int                     ccgSubSurf_getNumFinalEdges             (CCGSubSurf *ss);
127 int                     ccgSubSurf_getNumFinalFaces             (CCGSubSurf *ss);
128
129 /***/
130
131 typedef struct _CCGVertIterator CCGVertIterator;
132 typedef struct _CCGEdgeIterator CCGEdgeIterator;
133 typedef struct _CCGFaceIterator CCGFaceIterator;
134
135 CCGVertIterator*        ccgSubSurf_getVertIterator      (CCGSubSurf *ss);
136 CCGEdgeIterator*        ccgSubSurf_getEdgeIterator      (CCGSubSurf *ss);
137 CCGFaceIterator*        ccgSubSurf_getFaceIterator      (CCGSubSurf *ss);
138
139 CCGVert*                        ccgVertIterator_getCurrent      (CCGVertIterator *vi);
140 int                                     ccgVertIterator_isStopped       (CCGVertIterator *vi);
141 void                            ccgVertIterator_next            (CCGVertIterator *vi);
142 void                            ccgVertIterator_free            (CCGVertIterator *vi);
143
144 CCGEdge*                        ccgEdgeIterator_getCurrent      (CCGEdgeIterator *ei);
145 int                                     ccgEdgeIterator_isStopped       (CCGEdgeIterator *ei);
146 void                            ccgEdgeIterator_next            (CCGEdgeIterator *ei);
147 void                            ccgEdgeIterator_free            (CCGEdgeIterator *ei);
148
149 CCGFace*                        ccgFaceIterator_getCurrent      (CCGFaceIterator *fi);
150 int                                     ccgFaceIterator_isStopped       (CCGFaceIterator *fi);
151 void                            ccgFaceIterator_next            (CCGFaceIterator *fi);
152 void                            ccgFaceIterator_free            (CCGFaceIterator *fi);