2011-02-17 20:48:12 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-17 20:48:12 +00:00
|
|
|
/** \file DNA_ID.h
|
|
|
|
* \ingroup DNA
|
|
|
|
* \brief ID and Library types, which are fundamental for sdna.
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __DNA_ID_H__
|
|
|
|
#define __DNA_ID_H__
|
2011-12-30 07:25:49 +00:00
|
|
|
|
2006-11-17 04:46:48 +00:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Library;
|
|
|
|
struct FileData;
|
2006-11-17 04:46:48 +00:00
|
|
|
struct ID;
|
2012-12-27 15:07:19 +00:00
|
|
|
struct PackedFile;
|
2006-11-17 04:46:48 +00:00
|
|
|
|
|
|
|
typedef struct IDPropertyData {
|
|
|
|
void *pointer;
|
|
|
|
ListBase group;
|
2008-07-24 19:22:17 +00:00
|
|
|
int val, val2; /*note, we actually fit a double into these two ints*/
|
2006-11-17 04:46:48 +00:00
|
|
|
} IDPropertyData;
|
|
|
|
|
|
|
|
typedef struct IDProperty {
|
|
|
|
struct IDProperty *next, *prev;
|
|
|
|
char type, subtype;
|
|
|
|
short flag;
|
2012-01-11 08:51:06 +00:00
|
|
|
char name[64]; /* MAX_IDPROP_NAME */
|
2012-03-09 18:28:30 +00:00
|
|
|
int saved; /* saved is used to indicate if this struct has been saved yet.
|
|
|
|
* seemed like a good idea as a pad var was needed anyway :)*/
|
2007-04-24 14:52:35 +00:00
|
|
|
IDPropertyData data; /* note, alignment for 64 bits */
|
2006-11-17 04:46:48 +00:00
|
|
|
int len; /* array length, also (this is important!) string length + 1.
|
2011-12-28 11:08:38 +00:00
|
|
|
* the idea is to be able to reuse array realloc functions on strings.*/
|
2011-11-11 13:09:14 +00:00
|
|
|
/* totallen is total length of allocated array/string, including a buffer.
|
|
|
|
* Note that the buffering is mild; the code comes from python's list implementation.*/
|
2012-03-09 18:28:30 +00:00
|
|
|
int totallen; /*strings and arrays are both buffered, though the buffer isn't saved.*/
|
2006-11-17 04:46:48 +00:00
|
|
|
} IDProperty;
|
|
|
|
|
2012-01-11 08:51:06 +00:00
|
|
|
#define MAX_IDPROP_NAME 64
|
2006-11-17 04:46:48 +00:00
|
|
|
#define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
|
|
|
|
|
|
|
|
/*->type*/
|
2008-11-17 18:44:06 +00:00
|
|
|
#define IDP_STRING 0
|
|
|
|
#define IDP_INT 1
|
|
|
|
#define IDP_FLOAT 2
|
|
|
|
#define IDP_ARRAY 5
|
|
|
|
#define IDP_GROUP 6
|
2007-12-24 18:53:37 +00:00
|
|
|
/* the ID link property type hasn't been implemented yet, this will require
|
2011-12-28 11:08:38 +00:00
|
|
|
* some cleanup of blenkernel, most likely.*/
|
2008-11-17 18:44:06 +00:00
|
|
|
#define IDP_ID 7
|
|
|
|
#define IDP_DOUBLE 8
|
2008-12-31 13:16:37 +00:00
|
|
|
#define IDP_IDPARRAY 9
|
|
|
|
#define IDP_NUMTYPES 10
|
2006-11-17 04:46:48 +00:00
|
|
|
|
2011-11-15 09:12:10 +00:00
|
|
|
/*->subtype */
|
|
|
|
|
|
|
|
/* IDP_STRING */
|
|
|
|
#define IDP_STRING_SUB_UTF8 0 /* default */
|
|
|
|
#define IDP_STRING_SUB_BYTE 1 /* arbitrary byte array, _not_ null terminated */
|
2012-01-11 19:33:14 +00:00
|
|
|
/*->flag*/
|
2012-07-26 17:41:09 +00:00
|
|
|
#define IDP_FLAG_GHOST (1<<7) /* this means the property is set but RNA will return
|
2012-01-11 19:33:14 +00:00
|
|
|
* false when checking 'RNA_property_is_set',
|
|
|
|
* currently this is a runtime flag */
|
2011-11-15 09:12:10 +00:00
|
|
|
|
|
|
|
|
2007-12-24 18:53:37 +00:00
|
|
|
/* add any future new id property types here.*/
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-27 11:55:33 +00:00
|
|
|
/* watch it: Sequence has identical beginning. */
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* ID is the first thing included in all serializable types. It
|
|
|
|
* provides a common handle to place all data in double-linked lists.
|
|
|
|
* */
|
2006-11-17 04:46:48 +00:00
|
|
|
|
2012-01-11 08:51:06 +00:00
|
|
|
/* 2 characters for ID code and 64 for actual name */
|
|
|
|
#define MAX_ID_NAME 66
|
2007-12-24 18:53:37 +00:00
|
|
|
|
2006-11-17 04:46:48 +00:00
|
|
|
/* There's a nasty circular dependency here.... void* to the rescue! I
|
|
|
|
* really wonder why this is needed. */
|
2002-10-12 11:37:38 +00:00
|
|
|
typedef struct ID {
|
|
|
|
void *next, *prev;
|
|
|
|
struct ID *newid;
|
|
|
|
struct Library *lib;
|
2012-07-08 00:04:41 +00:00
|
|
|
char name[66]; /* MAX_ID_NAME */
|
2012-01-11 08:51:06 +00:00
|
|
|
short pad, us;
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* LIB_... flags report on status of the datablock this ID belongs
|
|
|
|
* to.
|
|
|
|
*/
|
|
|
|
short flag;
|
2012-01-11 08:51:06 +00:00
|
|
|
int icon_id, pad2;
|
2006-11-17 04:46:48 +00:00
|
|
|
IDProperty *properties;
|
2002-10-12 11:37:38 +00:00
|
|
|
} ID;
|
|
|
|
|
|
|
|
/**
|
2003-04-27 11:55:33 +00:00
|
|
|
* For each library file used, a Library struct is added to Main
|
2006-12-01 10:12:41 +00:00
|
|
|
* WARNING: readfile.c, expand_doit() reads this struct without DNA check!
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
typedef struct Library {
|
|
|
|
ID id;
|
|
|
|
ID *idblock;
|
|
|
|
struct FileData *filedata;
|
2012-01-21 14:54:53 +00:00
|
|
|
char name[1024]; /* path name used for reading, can be relative and edited in the outliner */
|
|
|
|
char filepath[1024]; /* absolute filepath, this is only for convenience,
|
2011-10-23 17:52:20 +00:00
|
|
|
* 'name' is the real path used on file read but in
|
|
|
|
* some cases its useful to access the absolute one,
|
|
|
|
* This is set on file read.
|
|
|
|
* Use BKE_library_filepath_set() rather than
|
2012-05-03 21:35:04 +00:00
|
|
|
* setting 'name' directly and it will be kept in
|
2011-10-23 17:52:20 +00:00
|
|
|
* sync - campbell */
|
2010-04-22 08:25:05 +00:00
|
|
|
struct Library *parent; /* set for indirectly linked libs, used in the outliner and while reading */
|
2012-12-27 15:07:19 +00:00
|
|
|
|
|
|
|
struct PackedFile *packedfile;
|
2002-10-12 11:37:38 +00:00
|
|
|
} Library;
|
|
|
|
|
2011-05-16 18:37:54 +00:00
|
|
|
enum eIconSizes {
|
2012-06-15 14:11:05 +00:00
|
|
|
ICON_SIZE_ICON = 0,
|
|
|
|
ICON_SIZE_PREVIEW = 1
|
2011-05-16 18:37:54 +00:00
|
|
|
};
|
2011-05-17 06:51:31 +00:00
|
|
|
#define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1)
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
typedef struct PreviewImage {
|
2011-05-16 18:37:54 +00:00
|
|
|
/* All values of 2 are really NUM_ICON_SIZES */
|
2011-01-22 04:40:15 +00:00
|
|
|
unsigned int w[2];
|
|
|
|
unsigned int h[2];
|
|
|
|
short changed[2];
|
|
|
|
short changed_timestamp[2];
|
2012-05-03 21:35:04 +00:00
|
|
|
unsigned int *rect[2];
|
2007-09-02 17:25:03 +00:00
|
|
|
} PreviewImage;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Defines for working with IDs.
|
|
|
|
*
|
|
|
|
* The tags represent types! This is a dirty way of enabling RTTI. The
|
|
|
|
* sig_byte end endian defines aren't really used much.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2011-09-19 08:02:17 +00:00
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
/* big endian */
|
|
|
|
# define MAKE_ID2(c, d) ( (c)<<8 | (d) )
|
|
|
|
# define MOST_SIG_BYTE 0
|
|
|
|
# define BBIG_ENDIAN
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
2011-09-19 08:02:17 +00:00
|
|
|
/* little endian */
|
|
|
|
# define MAKE_ID2(c, d) ( (d)<<8 | (c) )
|
|
|
|
# define MOST_SIG_BYTE 1
|
|
|
|
# define BLITTLE_ENDIAN
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
2006-11-25 13:07:28 +00:00
|
|
|
/* ID from database */
|
2009-09-16 01:15:30 +00:00
|
|
|
#define ID_SCE MAKE_ID2('S', 'C') /* Scene */
|
|
|
|
#define ID_LI MAKE_ID2('L', 'I') /* Library */
|
|
|
|
#define ID_OB MAKE_ID2('O', 'B') /* Object */
|
|
|
|
#define ID_ME MAKE_ID2('M', 'E') /* Mesh */
|
|
|
|
#define ID_CU MAKE_ID2('C', 'U') /* Curve */
|
|
|
|
#define ID_MB MAKE_ID2('M', 'B') /* MetaBall */
|
|
|
|
#define ID_MA MAKE_ID2('M', 'A') /* Material */
|
|
|
|
#define ID_TE MAKE_ID2('T', 'E') /* Texture */
|
|
|
|
#define ID_IM MAKE_ID2('I', 'M') /* Image */
|
|
|
|
#define ID_LT MAKE_ID2('L', 'T') /* Lattice */
|
|
|
|
#define ID_LA MAKE_ID2('L', 'A') /* Lamp */
|
|
|
|
#define ID_CA MAKE_ID2('C', 'A') /* Camera */
|
|
|
|
#define ID_IP MAKE_ID2('I', 'P') /* Ipo (depreciated, replaced by FCurves) */
|
|
|
|
#define ID_KE MAKE_ID2('K', 'E') /* Key (shape key) */
|
|
|
|
#define ID_WO MAKE_ID2('W', 'O') /* World */
|
|
|
|
#define ID_SCR MAKE_ID2('S', 'R') /* Screen */
|
|
|
|
#define ID_SCRN MAKE_ID2('S', 'N') /* (depreciated?) */
|
|
|
|
#define ID_VF MAKE_ID2('V', 'F') /* VectorFont */
|
|
|
|
#define ID_TXT MAKE_ID2('T', 'X') /* Text */
|
2011-08-01 11:44:20 +00:00
|
|
|
#define ID_SPK MAKE_ID2('S', 'K') /* Speaker */
|
2009-09-16 01:15:30 +00:00
|
|
|
#define ID_SO MAKE_ID2('S', 'O') /* Sound */
|
|
|
|
#define ID_GR MAKE_ID2('G', 'R') /* Group */
|
|
|
|
#define ID_ID MAKE_ID2('I', 'D') /* (internal use only) */
|
|
|
|
#define ID_AR MAKE_ID2('A', 'R') /* Armature */
|
|
|
|
#define ID_AC MAKE_ID2('A', 'C') /* Action */
|
|
|
|
#define ID_SCRIPT MAKE_ID2('P', 'Y') /* Script (depreciated) */
|
|
|
|
#define ID_NT MAKE_ID2('N', 'T') /* NodeTree */
|
|
|
|
#define ID_BR MAKE_ID2('B', 'R') /* Brush */
|
|
|
|
#define ID_PA MAKE_ID2('P', 'A') /* ParticleSettings */
|
|
|
|
#define ID_GD MAKE_ID2('G', 'D') /* GreasePencil */
|
|
|
|
#define ID_WM MAKE_ID2('W', 'M') /* WindowManager */
|
2011-11-07 12:55:18 +00:00
|
|
|
#define ID_MC MAKE_ID2('M', 'C') /* MovieClip */
|
2012-06-04 16:42:58 +00:00
|
|
|
#define ID_MSK MAKE_ID2('M', 'S') /* Mask */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-10-10 18:05:30 +00:00
|
|
|
/* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
|
|
|
|
#define ID_SEQ MAKE_ID2('S', 'Q')
|
|
|
|
/* constraint */
|
|
|
|
#define ID_CO MAKE_ID2('C', 'O')
|
|
|
|
/* pose (action channel, used to be ID_AC in code, so we keep code for backwards compat) */
|
|
|
|
#define ID_PO MAKE_ID2('A', 'C')
|
|
|
|
/* used in outliner... */
|
|
|
|
#define ID_NLA MAKE_ID2('N', 'L')
|
2006-11-25 13:07:28 +00:00
|
|
|
/* fluidsim Ipo */
|
|
|
|
#define ID_FLUIDSIM MAKE_ID2('F', 'S')
|
|
|
|
|
2010-01-17 20:06:34 +00:00
|
|
|
#define ID_REAL_USERS(id) (((ID *)id)->us - ((((ID *)id)->flag & LIB_FAKEUSER) ? 1:0))
|
|
|
|
|
2011-09-28 18:45:17 +00:00
|
|
|
#define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM))
|
|
|
|
|
2011-10-08 11:02:58 +00:00
|
|
|
#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : (_bmain)->name)
|
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
#ifdef GS
|
2012-05-12 20:39:39 +00:00
|
|
|
# undef GS
|
2011-01-07 19:18:31 +00:00
|
|
|
#endif
|
2013-01-22 04:24:01 +00:00
|
|
|
// #define GS(a) (*((short *)(a)))
|
|
|
|
#define GS(a) (CHECK_TYPE_INLINE(a, const char), (*((short *)(a))))
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
#define ID_NEW(a) if ( (a) && (a)->id.newid ) (a) = (void *)(a)->id.newid
|
|
|
|
#define ID_NEW_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; }
|
|
|
|
#define ID_NEW_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; }
|
|
|
|
|
2003-04-27 11:55:33 +00:00
|
|
|
/* id->flag: set frist 8 bits always at zero while reading */
|
2002-10-12 11:37:38 +00:00
|
|
|
#define LIB_LOCAL 0
|
|
|
|
#define LIB_EXTERN 1
|
|
|
|
#define LIB_INDIRECT 2
|
2012-08-01 15:32:27 +00:00
|
|
|
#define LIB_NEED_EXPAND 8
|
|
|
|
#define LIB_TESTEXT (LIB_NEED_EXPAND | LIB_EXTERN)
|
|
|
|
#define LIB_TESTIND (LIB_NEED_EXPAND | LIB_INDIRECT)
|
2002-10-12 11:37:38 +00:00
|
|
|
#define LIB_READ 16
|
2012-08-01 15:32:27 +00:00
|
|
|
#define LIB_NEED_LINK 32
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#define LIB_NEW 256
|
|
|
|
#define LIB_FAKEUSER 512
|
2003-04-27 11:55:33 +00:00
|
|
|
/* free test flag */
|
2002-10-12 11:37:38 +00:00
|
|
|
#define LIB_DOIT 1024
|
2010-01-07 16:19:38 +00:00
|
|
|
/* tag existing data before linking so we know what is new */
|
|
|
|
#define LIB_PRE_EXISTING 2048
|
2010-12-05 18:59:23 +00:00
|
|
|
/* runtime */
|
|
|
|
#define LIB_ID_RECALC 4096
|
2011-11-02 20:56:52 +00:00
|
|
|
#define LIB_ID_RECALC_DATA 8192
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|