Blender  V2.59
DNA_ID.h
Go to the documentation of this file.
00001 /*
00002  * $Id: DNA_ID.h 36725 2011-05-17 06:56:10Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 #ifndef DNA_ID_H
00030 #define DNA_ID_H
00031 
00037 #include "DNA_listBase.h"
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 struct Library;
00044 struct FileData;
00045 struct ID;
00046 
00047 typedef struct IDPropertyData {
00048         void *pointer;
00049         ListBase group;
00050         int val, val2; /*note, we actually fit a double into these two ints*/
00051 } IDPropertyData;
00052 
00053 typedef struct IDProperty {
00054         struct IDProperty *next, *prev;
00055         char type, subtype;
00056         short flag;
00057         char name[32];
00058         int saved; /*saved is used to indicate if this struct has been saved yet.
00059                                 seemed like a good idea as a pad var was needed anyway :)*/
00060         IDPropertyData data;    /* note, alignment for 64 bits */
00061         int len; /* array length, also (this is important!) string length + 1.
00062                                 the idea is to be able to reuse array realloc functions on strings.*/
00063         /*totallen is total length of allocated array/string, including a buffer.
00064           Note that the buffering is mild; the code comes from python's list implementation.*/
00065         int totallen; /*strings and arrays are both buffered, though the buffer isn't
00066                                         saved.*/
00067 } IDProperty;
00068 
00069 #define MAX_IDPROP_NAME 32
00070 #define DEFAULT_ALLOC_FOR_NULL_STRINGS  64
00071 
00072 /*->type*/
00073 #define IDP_STRING              0
00074 #define IDP_INT                 1
00075 #define IDP_FLOAT               2
00076 #define IDP_ARRAY               5
00077 #define IDP_GROUP               6
00078 /* the ID link property type hasn't been implemented yet, this will require
00079    some cleanup of blenkernel, most likely.*/
00080 #define IDP_ID                  7
00081 #define IDP_DOUBLE              8
00082 #define IDP_IDPARRAY    9
00083 #define IDP_NUMTYPES    10
00084 
00085 /* add any future new id property types here.*/
00086 
00087 /* watch it: Sequence has identical beginning. */
00093 #define MAX_ID_NAME     24
00094 
00095 /* There's a nasty circular dependency here.... void* to the rescue! I
00096  * really wonder why this is needed. */
00097 typedef struct ID {
00098         void *next, *prev;
00099         struct ID *newid;
00100         struct Library *lib;
00101         char name[24];
00102         short us;
00107         short flag;
00108         int icon_id;
00109         IDProperty *properties;
00110 } ID;
00111 
00116 typedef struct Library {
00117         ID id;
00118         ID *idblock;
00119         struct FileData *filedata;
00120         char name[240];                 /* path name used for reading, can be relative and edited in the outliner */
00121         char filepath[240];             /* temp. absolute filepath, only used while reading */
00122         int tot, pad;                   /* tot, idblock and filedata are only fo read and write */
00123         struct Library *parent; /* set for indirectly linked libs, used in the outliner and while reading */
00124 } Library;
00125 
00126 enum eIconSizes {
00127         ICON_SIZE_ICON,
00128         ICON_SIZE_PREVIEW,
00129 };
00130 #define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1)
00131 
00132 typedef struct PreviewImage {
00133         /* All values of 2 are really NUM_ICON_SIZES */
00134         unsigned int w[2];
00135         unsigned int h[2];
00136         short changed[2];
00137         short changed_timestamp[2];
00138         unsigned int * rect[2];
00139 } PreviewImage;
00140 
00149 #if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__)  || defined (__hppa__) || defined (__BIG_ENDIAN__)
00150 /* big endian */
00151 #define MAKE_ID2(c, d)          ( (c)<<8 | (d) )
00152 #define MOST_SIG_BYTE                           0
00153 #define BBIG_ENDIAN
00154 #else
00155 /* little endian  */
00156 #define MAKE_ID2(c, d)          ( (d)<<8 | (c) )
00157 #define MOST_SIG_BYTE                           1
00158 #define BLITTLE_ENDIAN
00159 #endif
00160 
00161 /* ID from database */
00162 #define ID_SCE          MAKE_ID2('S', 'C') /* Scene */
00163 #define ID_LI           MAKE_ID2('L', 'I') /* Library */
00164 #define ID_OB           MAKE_ID2('O', 'B') /* Object */
00165 #define ID_ME           MAKE_ID2('M', 'E') /* Mesh */
00166 #define ID_CU           MAKE_ID2('C', 'U') /* Curve */
00167 #define ID_MB           MAKE_ID2('M', 'B') /* MetaBall */
00168 #define ID_MA           MAKE_ID2('M', 'A') /* Material */
00169 #define ID_TE           MAKE_ID2('T', 'E') /* Texture */
00170 #define ID_IM           MAKE_ID2('I', 'M') /* Image */
00171 #define ID_LT           MAKE_ID2('L', 'T') /* Lattice */
00172 #define ID_LA           MAKE_ID2('L', 'A') /* Lamp */
00173 #define ID_CA           MAKE_ID2('C', 'A') /* Camera */
00174 #define ID_IP           MAKE_ID2('I', 'P') /* Ipo (depreciated, replaced by FCurves) */
00175 #define ID_KE           MAKE_ID2('K', 'E') /* Key (shape key) */
00176 #define ID_WO           MAKE_ID2('W', 'O') /* World */
00177 #define ID_SCR          MAKE_ID2('S', 'R') /* Screen */
00178 #define ID_SCRN         MAKE_ID2('S', 'N') /* (depreciated?) */
00179 #define ID_VF           MAKE_ID2('V', 'F') /* VectorFont */
00180 #define ID_TXT          MAKE_ID2('T', 'X') /* Text */
00181 #define ID_SO           MAKE_ID2('S', 'O') /* Sound */
00182 #define ID_GR           MAKE_ID2('G', 'R') /* Group */
00183 #define ID_ID           MAKE_ID2('I', 'D') /* (internal use only) */
00184 #define ID_AR           MAKE_ID2('A', 'R') /* Armature */
00185 #define ID_AC           MAKE_ID2('A', 'C') /* Action */
00186 #define ID_SCRIPT       MAKE_ID2('P', 'Y') /* Script (depreciated) */
00187 #define ID_NT           MAKE_ID2('N', 'T') /* NodeTree */
00188 #define ID_BR           MAKE_ID2('B', 'R') /* Brush */
00189 #define ID_PA           MAKE_ID2('P', 'A') /* ParticleSettings */
00190 #define ID_GD           MAKE_ID2('G', 'D') /* GreasePencil */
00191 #define ID_WM           MAKE_ID2('W', 'M') /* WindowManager */
00192 
00193         /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
00194 #define ID_SEQ          MAKE_ID2('S', 'Q')
00195                         /* constraint */
00196 #define ID_CO           MAKE_ID2('C', 'O')
00197                         /* pose (action channel, used to be ID_AC in code, so we keep code for backwards compat) */
00198 #define ID_PO           MAKE_ID2('A', 'C')
00199                         /* used in outliner... */
00200 #define ID_NLA          MAKE_ID2('N', 'L')
00201                         /* fluidsim Ipo */
00202 #define ID_FLUIDSIM     MAKE_ID2('F', 'S')
00203 
00204 #define ID_REAL_USERS(id) (((ID *)id)->us - ((((ID *)id)->flag & LIB_FAKEUSER) ? 1:0))
00205 
00206 #ifdef GS
00207 #undef GS
00208 #endif
00209 #define GS(a)   (*((short *)(a)))
00210 
00211 /* id->flag: set frist 8 bits always at zero while reading */
00212 #define LIB_LOCAL               0
00213 #define LIB_EXTERN              1
00214 #define LIB_INDIRECT    2
00215 #define LIB_TEST                8
00216 #define LIB_TESTEXT             (LIB_TEST | LIB_EXTERN)
00217 #define LIB_TESTIND             (LIB_TEST | LIB_INDIRECT)
00218 #define LIB_READ                16
00219 #define LIB_NEEDLINK    32
00220 
00221 #define LIB_NEW                 256
00222 #define LIB_FAKEUSER    512
00223 /* free test flag */
00224 #define LIB_DOIT                1024
00225 /* tag existing data before linking so we know what is new */
00226 #define LIB_PRE_EXISTING        2048
00227 /* runtime */
00228 #define LIB_ID_RECALC           4096
00229 
00230 #ifdef __cplusplus
00231 }
00232 #endif
00233 
00234 #endif
00235