Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DNA_meshdata_types.h « makesdna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3304980f9649daa72111bb8cfcf53fe0d224de79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): none yet.
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file DNA_meshdata_types.h
 *  \ingroup DNA
 */

#ifndef __DNA_MESHDATA_TYPES_H__
#define __DNA_MESHDATA_TYPES_H__

#include "DNA_customdata_types.h"
#include "DNA_listBase.h"

struct Bone;
struct Image;

/*tessellation face, see MLoop/MPoly for the real face data*/
typedef struct MFace {
	unsigned int v1, v2, v3, v4;
	short mat_nr;
	char edcode, flag;  /* we keep edcode, for conversion to edges draw flags in old files */
} MFace;

typedef struct MEdge {
	unsigned int v1, v2;
	char crease, bweight;
	short flag;
} MEdge;

typedef struct MDeformWeight {
	int def_nr;
	float weight;
} MDeformWeight;

typedef struct MDeformVert {
	struct MDeformWeight *dw;
	int totweight;
	int flag;  /* flag only in use for weightpaint now */
} MDeformVert;

typedef struct MVert {
	float co[3];
	short no[3];
	char flag, bweight;
} MVert;

/* tessellation vertex color data.
 * at the moment alpha is abused for vertex painting and not used for transparency, note that red and blue are swapped
 */
typedef struct MCol {
	char a, r, g, b;
} MCol;

/* new face structure, replaces MFace, which is now only used for storing tessellations.*/
typedef struct MPoly {
	/* offset into loop array and number of loops in the face */
	int loopstart;
	int totloop;  /* keep signed since we need to subtract when getting the previous loop */
	short mat_nr;
	char flag, pad;
} MPoly;

/* the e here is because we want to move away from relying on edge hashes.*/
typedef struct MLoop {
	unsigned int v;  /* vertex index */
	unsigned int e;  /* edge index */
} MLoop;

typedef struct MTexPoly {
	struct Image *tpage;
	char flag, transp;
	short mode, tile, pad;
} MTexPoly;

/* can copy from/to MTexPoly/MTFace */
#define ME_MTEXFACE_CPY(dst, src)   \
{                                   \
	(dst)->tpage  = (src)->tpage;   \
	(dst)->flag   = (src)->flag;    \
	(dst)->transp = (src)->transp;  \
	(dst)->mode   = (src)->mode;    \
	(dst)->tile   = (src)->tile;    \
} (void)0

typedef struct MLoopUV {
	float uv[2];
	int flag;
} MLoopUV;

/*mloopuv->flag*/
enum {
	MLOOPUV_EDGESEL = (1 << 0),
	MLOOPUV_VERTSEL = (1 << 1),
	MLOOPUV_PINNED  = (1 << 2),
};

/**
 * at the moment alpha is abused for vertex painting,
 * otherwise it should _always_ be initialized to 255
 * Mostly its not used for transparency...
 * (except for blender-internal rendering, see [#34096]).
 *
 * \note red and blue are _not_ swapped, as they are with #MCol
 */
typedef struct MLoopCol {
	char r, g, b, a;
} MLoopCol;

#define MESH_MLOOPCOL_FROM_MCOL(_mloopcol, _mcol) \
{                                                 \
	MLoopCol   *mloopcol__tmp = _mloopcol;        \
	const MCol *mcol__tmp     = _mcol;            \
	mloopcol__tmp->r = mcol__tmp->b;              \
	mloopcol__tmp->g = mcol__tmp->g;              \
	mloopcol__tmp->b = mcol__tmp->r;              \
	mloopcol__tmp->a = mcol__tmp->a;              \
} (void)0


#define MESH_MLOOPCOL_TO_MCOL(_mloopcol, _mcol) \
{                                               \
	const MLoopCol *mloopcol__tmp = _mloopcol;  \
	MCol           *mcol__tmp     = _mcol;      \
	mcol__tmp->b = mloopcol__tmp->r;            \
	mcol__tmp->g = mloopcol__tmp->g;            \
	mcol__tmp->r = mloopcol__tmp->b;            \
	mcol__tmp->a = mloopcol__tmp->a;            \
} (void)0

typedef struct MSelect {
	int index;
	int type;  /* ME_VSEL/ME_ESEL/ME_FSEL */
} MSelect;

/*tessellation uv face data*/
typedef struct MTFace {
	float uv[4][2];
	struct Image *tpage;
	char flag, transp;
	short mode, tile, unwrap;
} MTFace;

/*Custom Data Properties*/
typedef struct MFloatProperty {
	float f;
} MFloatProperty;
typedef struct MIntProperty {
	int i;
} MIntProperty;
typedef struct MStringProperty {
	char s[255], s_len;
} MStringProperty;

typedef struct OrigSpaceFace {
	float uv[4][2];
} OrigSpaceFace;

typedef struct OrigSpaceLoop {
	float uv[2];
} OrigSpaceLoop;

typedef struct MDisps {
	/* Strange bug in SDNA: if disps pointer comes first, it fails to see totdisp */
	int totdisp;
	int level;
	float (*disps)[3];

	/* Used for hiding parts of a multires mesh. Essentially the multires equivalent of MVert.flag's ME_HIDE bit.
	 * NOTE: This is a bitmap, keep in sync with type used in BLI_bitmap.h
	 */
	unsigned int *hidden;
} MDisps;

/** Multires structs kept for compatibility with old files **/
typedef struct MultiresCol {
	float a, r, g, b;
} MultiresCol;

typedef struct MultiresColFace {
	/* vertex colors */
	MultiresCol col[4];
} MultiresColFace;

typedef struct MultiresFace {
	unsigned int v[4];
	unsigned int mid;
	char flag, mat_nr, pad[2];
} MultiresFace;

typedef struct MultiresEdge {
	unsigned int v[2];
	unsigned int mid;
} MultiresEdge;

struct MultiresMapNode;
typedef struct MultiresLevel {
	struct MultiresLevel *next, *prev;

	MultiresFace *faces;
	MultiresColFace *colfaces;
	MultiresEdge *edges;

	unsigned int totvert, totface, totedge, pad;

	/* Kept for compatibility with even older files */
	MVert *verts;
} MultiresLevel;

typedef struct Multires {
	ListBase levels;
	MVert *verts;

	unsigned char level_count, current, newlvl, edgelvl, pinlvl, renderlvl;
	unsigned char use_col, flag;

	/* Special level 1 data that cannot be modified from other levels */
	CustomData vdata;
	CustomData fdata;
	short *edge_flags;
	char *edge_creases;
} Multires;

/** End Multires **/

typedef struct MRecast {
	int i;
} MRecast;

typedef struct GridPaintMask {
	/* The data array contains gridsize*gridsize elements */
	float *data;

	/* The maximum multires level associated with this grid */
	unsigned int level;

	int pad;
} GridPaintMask;

typedef enum MVertSkinFlag {
	/* Marks a vertex as the edge-graph root, used for calculating rotations for all connected edges (recursively).
	 * Also used to choose a root when generating an armature.
	 */
	MVERT_SKIN_ROOT = 1,

	/* Marks a branch vertex (vertex with more than two connected edges), so that it's neighbors are
	 * directly hulled together, rather than the default of generating intermediate frames.
	 */
	MVERT_SKIN_LOOSE = 2,
} MVertSkinFlag;

typedef struct MVertSkin {
	/* Radii of the skin, define how big the generated frames are. Currently only the first two elements are used. */
	float radius[3];

	/* MVertSkinFlag */
	int flag;
} MVertSkin;

typedef struct FreestyleEdge {
	char flag;
	char pad[3];
} FreestyleEdge;

/* FreestyleEdge->flag */
enum {
	FREESTYLE_EDGE_MARK = 1,
};

typedef struct FreestyleFace {
	char flag;
	char pad[3];
} FreestyleFace;

/* FreestyleFace->flag */
enum {
	FREESTYLE_FACE_MARK = 1,
};

/* mvert->flag */
enum {
/*	SELECT              = (1 << 0), */
	ME_VERT_TMP_TAG     = (1 << 2),
	ME_HIDE             = (1 << 4),
	ME_VERT_MERGED      = (1 << 6),
	ME_VERT_PBVH_UPDATE = (1 << 7),
};

/* medge->flag */
enum {
/*	SELECT              = (1 << 0), */
	ME_EDGEDRAW         = (1 << 1),
	ME_SEAM             = (1 << 2),
/*	ME_HIDE             = (1 << 4), */
	ME_EDGERENDER       = (1 << 5),
	ME_LOOSEEDGE        = (1 << 7),
	ME_EDGE_TMP_TAG     = (1 << 8),
	ME_SHARP            = (1 << 9),  /* only reason this flag remains a 'short' */
};

/* puno = vertexnormal (mface) */
enum {
	ME_PROJXY = (1 << 4),
	ME_PROJXZ = (1 << 5),
	ME_PROJYZ = (1 << 6),
};

/* edcode (mface) */
enum {
	ME_V1V2 = (1 << 0),
	ME_V2V3 = (1 << 1),
	ME_V3V1 = (1 << 2),
	ME_V3V4 = ME_V3V1,
	ME_V4V1 = (1 << 3),
};

/* flag (mface) */
enum {
	ME_SMOOTH   = (1 << 0),
	ME_FACE_SEL = (1 << 1),
/*	ME_HIDE     = (1 << 4), */ 
};

#define ME_POLY_LOOP_PREV(mloop, mp, i)  (&(mloop)[(mp)->loopstart + (((i) + (mp)->totloop - 1) % (mp)->totloop)])
#define ME_POLY_LOOP_NEXT(mloop, mp, i)  (&(mloop)[(mp)->loopstart + (((i) + 1) % (mp)->totloop)])

/* mselect->type */
enum {
	ME_VSEL = 0,
	ME_ESEL = 1,
	ME_FSEL = 2,
};

/* mtface->flag */
enum {
	// TF_SELECT = (1 << 0),  /* use MFace hide flag (after 2.43), should be able to reuse after 2.44 */
	// TF_ACTIVE = (1 << 1),  /* deprecated! */
	TF_SEL1   = (1 << 2),
	TF_SEL2   = (1 << 3),
	TF_SEL3   = (1 << 4),
	TF_SEL4   = (1 << 5),
};

/* mtface->mode */
enum {
	TF_DYNAMIC    = (1 << 0),
	TF_ALPHASORT  = (1 << 1),
	TF_TEX        = (1 << 2),
	TF_SHAREDVERT = (1 << 3),
	TF_LIGHT      = (1 << 4),

	TF_CONVERTED  = (1 << 5),  /* tface converted to material */

	TF_SHAREDCOL  = (1 << 6),
	// TF_TILES      = (1 << 7),  /* deprecated */
	TF_BILLBOARD  = (1 << 8),
	TF_TWOSIDE    = (1 << 9),
	TF_INVISIBLE  = (1 << 10),

	TF_OBCOL      = (1 << 11),
	TF_BILLBOARD2 = (1 << 12),  /* with Z axis constraint */
	TF_SHADOW     = (1 << 13),
	TF_BMFONT     = (1 << 14),
};

/* mtface->transp, values 1-4 are used as flags in the GL, WARNING, TF_SUB cant work with this */
enum {
	TF_SOLID = 0,
	TF_ADD   = (1 << 0),
	TF_ALPHA = (1 << 1),
	TF_CLIP  = (1 << 2),  /* clipmap alpha/binary alpha all or nothing! */

	TF_SUB   = 3,  /* sub is not available in the user interface anymore */
};

/* mtface->unwrap */
enum {
	TF_DEPRECATED1 = (1 << 0),
	TF_DEPRECATED2 = (1 << 1),
	TF_DEPRECATED3 = (1 << 2),
	TF_DEPRECATED4 = (1 << 3),
	TF_PIN1        = (1 << 4),
	TF_PIN2        = (1 << 5),
	TF_PIN3        = (1 << 6),
	TF_PIN4        = (1 << 7),
};

#endif  /* __DNA_MESHDATA_TYPES_H__ */