2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
30 * \brief ID and Library types, which are fundamental for sdna.
36 #include "DNA_listBase.h"
46 typedef struct IDPropertyData {
49 int val, val2; /*note, we actually fit a double into these two ints*/
52 typedef struct IDProperty {
53 struct IDProperty *next, *prev;
56 char name[64]; /* MAX_IDPROP_NAME */
57 int saved; /* saved is used to indicate if this struct has been saved yet.
58 * seemed like a good idea as a pad var was needed anyway :)*/
59 IDPropertyData data; /* note, alignment for 64 bits */
60 int len; /* array length, also (this is important!) string length + 1.
61 * the idea is to be able to reuse array realloc functions on strings.*/
62 /* totallen is total length of allocated array/string, including a buffer.
63 * Note that the buffering is mild; the code comes from python's list implementation.*/
64 int totallen; /*strings and arrays are both buffered, though the buffer isn't saved.*/
67 #define MAX_IDPROP_NAME 64
68 #define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
76 /* the ID link property type hasn't been implemented yet, this will require
77 * some cleanup of blenkernel, most likely.*/
80 #define IDP_IDPARRAY 9
81 #define IDP_NUMTYPES 10
86 #define IDP_STRING_SUB_UTF8 0 /* default */
87 #define IDP_STRING_SUB_BYTE 1 /* arbitrary byte array, _not_ null terminated */
89 #define IDP_FLAG_GHOST (1<<7) /* this means the property is set but RNA will return
90 * false when checking 'RNA_property_is_set',
91 * currently this is a runtime flag */
94 /* add any future new id property types here.*/
96 /* watch it: Sequence has identical beginning. */
98 * ID is the first thing included in all serializable types. It
99 * provides a common handle to place all data in double-linked lists.
102 /* 2 characters for ID code and 64 for actual name */
103 #define MAX_ID_NAME 66
105 /* There's a nasty circular dependency here.... void* to the rescue! I
106 * really wonder why this is needed. */
111 char name[66]; /* MAX_ID_NAME */
114 * LIB_... flags report on status of the datablock this ID belongs
119 IDProperty *properties;
123 * For each library file used, a Library struct is added to Main
124 * WARNING: readfile.c, expand_doit() reads this struct without DNA check!
126 typedef struct Library {
129 struct FileData *filedata;
130 char name[1024]; /* path name used for reading, can be relative and edited in the outliner */
131 char filepath[1024]; /* absolute filepath, this is only for convenience,
132 * 'name' is the real path used on file read but in
133 * some cases its useful to access the absolute one,
134 * This is set on file read.
135 * Use BKE_library_filepath_set() rather than
136 * setting 'name' directly and it will be kept in
138 struct Library *parent; /* set for indirectly linked libs, used in the outliner and while reading */
143 ICON_SIZE_PREVIEW = 1
145 #define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1)
147 typedef struct PreviewImage {
148 /* All values of 2 are really NUM_ICON_SIZES */
152 short changed_timestamp[2];
153 unsigned int *rect[2];
157 * Defines for working with IDs.
159 * The tags represent types! This is a dirty way of enabling RTTI. The
160 * sig_byte end endian defines aren't really used much.
164 #ifdef __BIG_ENDIAN__
166 # define MAKE_ID2(c, d) ( (c)<<8 | (d) )
167 # define MOST_SIG_BYTE 0
171 # define MAKE_ID2(c, d) ( (d)<<8 | (c) )
172 # define MOST_SIG_BYTE 1
173 # define BLITTLE_ENDIAN
176 /* ID from database */
177 #define ID_SCE MAKE_ID2('S', 'C') /* Scene */
178 #define ID_LI MAKE_ID2('L', 'I') /* Library */
179 #define ID_OB MAKE_ID2('O', 'B') /* Object */
180 #define ID_ME MAKE_ID2('M', 'E') /* Mesh */
181 #define ID_CU MAKE_ID2('C', 'U') /* Curve */
182 #define ID_MB MAKE_ID2('M', 'B') /* MetaBall */
183 #define ID_MA MAKE_ID2('M', 'A') /* Material */
184 #define ID_TE MAKE_ID2('T', 'E') /* Texture */
185 #define ID_IM MAKE_ID2('I', 'M') /* Image */
186 #define ID_LT MAKE_ID2('L', 'T') /* Lattice */
187 #define ID_LA MAKE_ID2('L', 'A') /* Lamp */
188 #define ID_CA MAKE_ID2('C', 'A') /* Camera */
189 #define ID_IP MAKE_ID2('I', 'P') /* Ipo (depreciated, replaced by FCurves) */
190 #define ID_KE MAKE_ID2('K', 'E') /* Key (shape key) */
191 #define ID_WO MAKE_ID2('W', 'O') /* World */
192 #define ID_SCR MAKE_ID2('S', 'R') /* Screen */
193 #define ID_SCRN MAKE_ID2('S', 'N') /* (depreciated?) */
194 #define ID_VF MAKE_ID2('V', 'F') /* VectorFont */
195 #define ID_TXT MAKE_ID2('T', 'X') /* Text */
196 #define ID_SPK MAKE_ID2('S', 'K') /* Speaker */
197 #define ID_SO MAKE_ID2('S', 'O') /* Sound */
198 #define ID_GR MAKE_ID2('G', 'R') /* Group */
199 #define ID_ID MAKE_ID2('I', 'D') /* (internal use only) */
200 #define ID_AR MAKE_ID2('A', 'R') /* Armature */
201 #define ID_AC MAKE_ID2('A', 'C') /* Action */
202 #define ID_SCRIPT MAKE_ID2('P', 'Y') /* Script (depreciated) */
203 #define ID_NT MAKE_ID2('N', 'T') /* NodeTree */
204 #define ID_BR MAKE_ID2('B', 'R') /* Brush */
205 #define ID_PA MAKE_ID2('P', 'A') /* ParticleSettings */
206 #define ID_GD MAKE_ID2('G', 'D') /* GreasePencil */
207 #define ID_WM MAKE_ID2('W', 'M') /* WindowManager */
208 #define ID_MC MAKE_ID2('M', 'C') /* MovieClip */
209 #define ID_MSK MAKE_ID2('M', 'S') /* Mask */
211 /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
212 #define ID_SEQ MAKE_ID2('S', 'Q')
214 #define ID_CO MAKE_ID2('C', 'O')
215 /* pose (action channel, used to be ID_AC in code, so we keep code for backwards compat) */
216 #define ID_PO MAKE_ID2('A', 'C')
217 /* used in outliner... */
218 #define ID_NLA MAKE_ID2('N', 'L')
220 #define ID_FLUIDSIM MAKE_ID2('F', 'S')
222 #define ID_REAL_USERS(id) (((ID *)id)->us - ((((ID *)id)->flag & LIB_FAKEUSER) ? 1:0))
224 #define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM))
226 #define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : (_bmain)->name)
231 #define GS(a) (*((short *)(a)))
233 #define ID_NEW(a) if ( (a) && (a)->id.newid ) (a) = (void *)(a)->id.newid
234 #define ID_NEW_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; }
235 #define ID_NEW_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; }
237 /* id->flag: set frist 8 bits always at zero while reading */
240 #define LIB_INDIRECT 2
242 #define LIB_TESTEXT (LIB_TEST | LIB_EXTERN)
243 #define LIB_TESTIND (LIB_TEST | LIB_INDIRECT)
245 #define LIB_NEEDLINK 32
248 #define LIB_FAKEUSER 512
250 #define LIB_DOIT 1024
251 /* tag existing data before linking so we know what is new */
252 #define LIB_PRE_EXISTING 2048
254 #define LIB_ID_RECALC 4096
255 #define LIB_ID_RECALC_DATA 8192