=== Custom Transform Orientation ===
[blender.git] / source / blender / src / parametrizer_intern.h
1
2 #ifndef __PARAMETRIZER_INTERN_H__
3 #define __PARAMETRIZER_INTERN_H__
4
5 /* Utils */
6
7 #if 0
8         #define param_assert(condition);
9         #define param_warning(message);
10         #define param_test_equals_ptr(condition);
11         #define param_test_equals_int(condition);
12 #else
13         #define param_assert(condition) \
14                 if (!(condition)) \
15                         { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ }
16         #define param_warning(message) \
17                 { /*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/ }
18         #define param_test_equals_ptr(str, a, b) \
19                 if (a != b) \
20                         { /*printf("Equals %s => %p != %p\n", str, a, b);*/ };
21         #define param_test_equals_int(str, a, b) \
22                 if (a != b) \
23                         { /*printf("Equals %s => %d != %d\n", str, a, b);*/ };
24 #endif
25
26 typedef enum PBool {
27         P_TRUE = 1,
28         P_FALSE = 0
29 } PBool;
30
31 /* Special Purpose Hash */
32
33 typedef long PHashKey;
34
35 typedef struct PHashLink {
36         struct PHashLink *next;
37         PHashKey key;
38 } PHashLink;
39
40 typedef struct PHash {
41         PHashLink **list;
42         PHashLink **buckets;
43         int size, cursize, cursize_id;
44 } PHash;
45
46
47
48 struct PVert;
49 struct PEdge;
50 struct PFace;
51 struct PChart;
52 struct PHandle;
53
54 /* Simplices */
55
56 typedef struct PVert {
57         struct PVert *nextlink;
58
59         union PVertUnion {
60                 PHashKey key;                   /* construct */
61                 int id;                                 /* abf/lscm matrix index */
62                 float distortion;               /* area smoothing */
63                 HeapNode *heaplink;             /* edge collapsing */
64         } u;
65
66         struct PEdge *edge;
67         float *co;
68         float uv[2];
69         unsigned char flag;
70
71 } PVert; 
72
73 typedef struct PEdge {
74         struct PEdge *nextlink;
75
76         union PEdgeUnion {
77                 PHashKey key;                                   /* construct */
78                 int id;                                                 /* abf matrix index */
79                 HeapNode *heaplink;                             /* fill holes */
80                 struct PEdge *nextcollapse;             /* simplification */
81         } u;
82
83         struct PVert *vert;
84         struct PEdge *pair;
85         struct PEdge *next;
86         struct PFace *face;
87         float *orig_uv, old_uv[2];
88         unsigned short flag;
89
90 } PEdge;
91
92 typedef struct PFace {
93         struct PFace *nextlink;
94
95         union PFaceUnion {
96                 PHashKey key;                   /* construct */
97                 int chart;                              /* construct splitting*/
98                 float area3d;                   /* stretch */
99                 int id;                                 /* abf matrix index */
100         } u;
101
102         struct PEdge *edge;
103         unsigned char flag;
104
105 } PFace;
106
107 enum PVertFlag {
108         PVERT_PIN = 1,
109         PVERT_SELECT = 2,
110         PVERT_INTERIOR = 4,
111         PVERT_COLLAPSE = 8,
112         PVERT_SPLIT = 16
113 };
114
115 enum PEdgeFlag {
116         PEDGE_SEAM = 1,
117         PEDGE_VERTEX_SPLIT = 2,
118         PEDGE_PIN = 4,
119         PEDGE_SELECT = 8,
120         PEDGE_DONE = 16,
121         PEDGE_FILLED = 32,
122         PEDGE_COLLAPSE = 64,
123         PEDGE_COLLAPSE_EDGE = 128,
124         PEDGE_COLLAPSE_PAIR = 256
125 };
126
127 /* for flipping faces */
128 #define PEDGE_VERTEX_FLAGS (PEDGE_PIN)
129
130 enum PFaceFlag {
131         PFACE_CONNECTED = 1,
132         PFACE_FILLED = 2,
133         PFACE_COLLAPSE = 4
134 };
135
136 /* Chart */
137
138 typedef struct PChart {
139         PVert *verts;
140         PEdge *edges;
141         PFace *faces;
142         int nverts, nedges, nfaces;
143
144         PVert *collapsed_verts;
145         PEdge *collapsed_edges;
146         PFace *collapsed_faces;
147
148         union PChartUnion {
149                 struct PChartLscm {
150                         NLContext context;
151                         float *abf_alpha;
152                         PVert *pin1, *pin2;
153                 } lscm;
154                 struct PChartPack {
155                         float rescale, area;
156                         float size[2], trans[2];
157                 } pack;
158         } u;
159
160         unsigned char flag;
161         struct PHandle *handle;
162 } PChart;
163
164 enum PChartFlag {
165         PCHART_NOPACK = 1
166 };
167
168 enum PHandleState {
169         PHANDLE_STATE_ALLOCATED,
170         PHANDLE_STATE_CONSTRUCTED,
171         PHANDLE_STATE_LSCM,
172         PHANDLE_STATE_STRETCH
173 };
174
175 typedef struct PHandle {
176         enum PHandleState state;
177         MemArena *arena;
178
179         PChart *construction_chart;
180         PHash *hash_verts;
181         PHash *hash_edges;
182         PHash *hash_faces;
183
184         PChart **charts;
185         int ncharts;
186
187         RNG *rng;
188         float blend;
189 } PHandle;
190
191 #endif /*__PARAMETRIZER_INTERN_H__*/
192