1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup DNA 22 * \brief ID and Library types, which are fundamental for sdna. 23 */ 24 25 #pragma once 26 27 #include "DNA_defs.h" 28 #include "DNA_listBase.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 struct FileData; 35 struct GHash; 36 struct GPUTexture; 37 struct ID; 38 struct Library; 39 struct PackedFile; 40 41 /* Runtime display data */ 42 struct DrawData; 43 typedef void (*DrawDataInitCb)(struct DrawData *engine_data); 44 typedef void (*DrawDataFreeCb)(struct DrawData *engine_data); 45 46 # 47 # 48 typedef struct DrawData { 49 struct DrawData *next, *prev; 50 struct DrawEngineType *engine_type; 51 /* Only nested data, NOT the engine data itself. */ 52 DrawDataFreeCb free; 53 /* Accumulated recalc flags, which corresponds to ID->recalc flags. */ 54 int recalc; 55 } DrawData; 56 57 typedef struct DrawDataList { 58 struct DrawData *first, *last; 59 } DrawDataList; 60 61 typedef struct IDPropertyData { 62 void *pointer; 63 ListBase group; 64 /** Note, we actually fit a double into these two ints. */ 65 int val, val2; 66 } IDPropertyData; 67 68 typedef struct IDProperty { 69 struct IDProperty *next, *prev; 70 char type, subtype; 71 short flag; 72 /** MAX_IDPROP_NAME. */ 73 char name[64]; 74 75 /* saved is used to indicate if this struct has been saved yet. 76 * seemed like a good idea as a '_pad' var was needed anyway :) */ 77 int saved; 78 /** Note, alignment for 64 bits. */ 79 IDPropertyData data; 80 81 /* array length, also (this is important!) string length + 1. 82 * the idea is to be able to reuse array realloc functions on strings.*/ 83 int len; 84 85 /* Strings and arrays are both buffered, though the buffer isn't saved. */ 86 /* totallen is total length of allocated array/string, including a buffer. 87 * Note that the buffering is mild; the code comes from python's list implementation. */ 88 int totallen; 89 } IDProperty; 90 91 #define MAX_IDPROP_NAME 64 92 #define DEFAULT_ALLOC_FOR_NULL_STRINGS 64 93 94 /*->type*/ 95 enum { 96 IDP_STRING = 0, 97 IDP_INT = 1, 98 IDP_FLOAT = 2, 99 IDP_ARRAY = 5, 100 IDP_GROUP = 6, 101 IDP_ID = 7, 102 IDP_DOUBLE = 8, 103 IDP_IDPARRAY = 9, 104 IDP_NUMTYPES = 10, 105 }; 106 107 /** Used by some IDP utils, keep values in sync with type enum above. */ 108 enum { 109 IDP_TYPE_FILTER_STRING = 1 << 0, 110 IDP_TYPE_FILTER_INT = 1 << 1, 111 IDP_TYPE_FILTER_FLOAT = 1 << 2, 112 IDP_TYPE_FILTER_ARRAY = 1 << 5, 113 IDP_TYPE_FILTER_GROUP = 1 << 6, 114 IDP_TYPE_FILTER_ID = 1 << 7, 115 IDP_TYPE_FILTER_DOUBLE = 1 << 8, 116 IDP_TYPE_FILTER_IDPARRAY = 1 << 9, 117 }; 118 119 /*->subtype */ 120 121 /* IDP_STRING */ 122 enum { 123 IDP_STRING_SUB_UTF8 = 0, /* default */ 124 IDP_STRING_SUB_BYTE = 1, /* arbitrary byte array, _not_ null terminated */ 125 }; 126 127 /*->flag*/ 128 enum { 129 /** This IDProp may be statically overridden. 130 * Should only be used/be relevant for custom properties. */ 131 IDP_FLAG_OVERRIDABLE_LIBRARY = 1 << 0, 132 133 /** This collection item IDProp has been inserted in a local override. 134 * This is used by internal code to distinguish between library-originated items and 135 * local-inserted ones, as many operations are not allowed on the former. */ 136 IDP_FLAG_OVERRIDELIBRARY_LOCAL = 1 << 1, 137 138 /** This means the property is set but RNA will return false when checking 139 * 'RNA_property_is_set', currently this is a runtime flag */ 140 IDP_FLAG_GHOST = 1 << 7, 141 }; 142 143 /* add any future new id property types here.*/ 144 145 /* Static ID override structs. */ 146 147 typedef struct IDOverrideLibraryPropertyOperation { 148 struct IDOverrideLibraryPropertyOperation *next, *prev; 149 150 /* Type of override. */ 151 short operation; 152 short flag; 153 154 /** Runtime, tags are common to both IDOverrideProperty and IDOverridePropertyOperation. */ 155 short tag; 156 char _pad0[2]; 157 158 /* Sub-item references, if needed (for arrays or collections only). 159 * We need both reference and local values to allow e.g. insertion into collections 160 * (constraints, modifiers...). 161 * In collection case, if names are defined, they are used in priority. 162 * Names are pointers (instead of char[64]) to save some space, NULL when unset. 163 * Indices are -1 when unset. */ 164 char *subitem_reference_name; 165 char *subitem_local_name; 166 int subitem_reference_index; 167 int subitem_local_index; 168 } IDOverrideLibraryPropertyOperation; 169 170 /* IDOverridePropertyOperation->operation. */ 171 enum { 172 /* Basic operations. */ 173 IDOVERRIDE_LIBRARY_OP_NOOP = 0, /* Special value, forbids any overriding. */ 174 175 IDOVERRIDE_LIBRARY_OP_REPLACE = 1, /* Fully replace local value by reference one. */ 176 177 /* Numeric-only operations. */ 178 IDOVERRIDE_LIBRARY_OP_ADD = 101, /* Add local value to reference one. */ 179 /* Subtract local value from reference one (needed due to unsigned values etc.). */ 180 IDOVERRIDE_LIBRARY_OP_SUBTRACT = 102, 181 /* Multiply reference value by local one (more useful than diff for scales and the like). */ 182 IDOVERRIDE_LIBRARY_OP_MULTIPLY = 103, 183 184 /* Collection-only operations. */ 185 IDOVERRIDE_LIBRARY_OP_INSERT_AFTER = 201, /* Insert after given reference's subitem. */ 186 IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE = 202, /* Insert before given reference's subitem. */ 187 /* We can add more if needed (move, delete, ...). */ 188 }; 189 190 /* IDOverridePropertyOperation->flag. */ 191 enum { 192 /** User cannot remove that override operation. */ 193 IDOVERRIDE_LIBRARY_FLAG_MANDATORY = 1 << 0, 194 /** User cannot change that override operation. */ 195 IDOVERRIDE_LIBRARY_FLAG_LOCKED = 1 << 1, 196 }; 197 198 /** A single overridden property, contain all operations on this one. */ 199 typedef struct IDOverrideLibraryProperty { 200 struct IDOverrideLibraryProperty *next, *prev; 201 202 /** 203 * Path from ID to overridden property. 204 * *Does not* include indices/names for final arrays/collections items. 205 */ 206 char *rna_path; 207 208 /** List of overriding operations (IDOverridePropertyOperation) applied to this property. */ 209 ListBase operations; 210 211 /** Runtime, tags are common to both IDOverrideProperty and IDOverridePropertyOperation. */ 212 short tag; 213 char _pad[2]; 214 215 /** The property type matching the rna_path. */ 216 unsigned int rna_prop_type; 217 } IDOverrideLibraryProperty; 218 219 /* IDOverrideProperty->tag and IDOverridePropertyOperation->tag. */ 220 enum { 221 /** This override property (operation) is unused and should be removed by cleanup process. */ 222 IDOVERRIDE_LIBRARY_TAG_UNUSED = 1 << 0, 223 }; 224 225 # 226 # 227 typedef struct IDOverrideLibraryRuntime { 228 struct GHash *rna_path_to_override_properties; 229 uint tag; 230 } IDOverrideLibraryRuntime; 231 232 /* IDOverrideLibraryRuntime->tag. */ 233 enum { 234 /** This override needs to be reloaded. */ 235 IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD = 1 << 0, 236 }; 237 238 /* Main container for all overriding data info of a data-block. */ 239 typedef struct IDOverrideLibrary { 240 /** Reference linked ID which this one overrides. */ 241 struct ID *reference; 242 /** List of IDOverrideProperty structs. */ 243 ListBase properties; 244 245 /* Read/write data. */ 246 /* Temp ID storing extra override data (used for differential operations only currently). 247 * Always NULL outside of read/write context. */ 248 struct ID *storage; 249 250 IDOverrideLibraryRuntime *runtime; 251 } IDOverrideLibrary; 252 253 /* watch it: Sequence has identical beginning. */ 254 /** 255 * ID is the first thing included in all serializable types. It 256 * provides a common handle to place all data in double-linked lists. 257 * */ 258 259 /* 2 characters for ID code and 64 for actual name */ 260 #define MAX_ID_NAME 66 261 262 /* There's a nasty circular dependency here.... 'void *' to the rescue! I 263 * really wonder why this is needed. */ 264 typedef struct ID { 265 void *next, *prev; 266 struct ID *newid; 267 struct Library *lib; 268 /** MAX_ID_NAME. */ 269 char name[66]; 270 /** 271 * LIB_... flags report on status of the data-block this ID belongs to 272 * (persistent, saved to and read from .blend). 273 */ 274 short flag; 275 /** 276 * LIB_TAG_... tags (runtime only, cleared at read time). 277 */ 278 int tag; 279 int us; 280 int icon_id; 281 int recalc; 282 /** 283 * Used by undo code. recalc_after_undo_push contains the changes between the 284 * last undo push and the current state. This is accumulated as IDs are tagged 285 * for update in the depsgraph, and only cleared on undo push. 286 * 287 * recalc_up_to_undo_push is saved to undo memory, and is the value of 288 * recalc_after_undo_push at the time of the undo push. This means it can be 289 * used to find the changes between undo states. 290 */ 291 int recalc_up_to_undo_push; 292 int recalc_after_undo_push; 293 294 /** 295 * A session-wide unique identifier for a given ID, that remain the same across potential 296 * re-allocations (e.g. due to undo/redo steps). 297 */ 298 unsigned int session_uuid; 299 300 IDProperty *properties; 301 302 /** Reference linked ID which this one overrides. */ 303 IDOverrideLibrary *override_library; 304 305 /** 306 * Only set for data-blocks which are coming from copy-on-write, points to 307 * the original version of it. 308 */ 309 struct ID *orig_id; 310 311 void *py_instance; 312 } ID; 313 314 /** 315 * For each library file used, a Library struct is added to Main 316 * WARNING: readfile.c, expand_doit() reads this struct without DNA check! 317 */ 318 typedef struct Library { 319 ID id; 320 struct FileData *filedata; 321 /** Path name used for reading, can be relative and edited in the outliner. */ 322 char filepath[1024]; 323 324 /** 325 * Run-time only, absolute file-path (set on read). 326 * This is only for convenience, `filepath` is the real path 327 * used on file read but in some cases its useful to access the absolute one. 328 * 329 * Use #BKE_library_filepath_set() rather than setting `filepath` 330 * directly and it will be kept in sync - campbell 331 */ 332 char filepath_abs[1024]; 333 334 /** Set for indirectly linked libs, used in the outliner and while reading. */ 335 struct Library *parent; 336 337 struct PackedFile *packedfile; 338 339 /* Temp data needed by read/write code. */ 340 int temp_index; 341 /** See BLENDER_FILE_VERSION, BLENDER_FILE_SUBVERSION, needed for do_versions. */ 342 short versionfile, subversionfile; 343 } Library; 344 345 enum eIconSizes { 346 ICON_SIZE_ICON = 0, 347 ICON_SIZE_PREVIEW = 1, 348 349 NUM_ICON_SIZES, 350 }; 351 352 /* for PreviewImage->flag */ 353 enum ePreviewImage_Flag { 354 PRV_CHANGED = (1 << 0), 355 PRV_USER_EDITED = (1 << 1), /* if user-edited, do not auto-update this anymore! */ 356 }; 357 358 /* for PreviewImage->tag */ 359 enum { 360 PRV_TAG_DEFFERED = (1 << 0), /* Actual loading of preview is deferred. */ 361 PRV_TAG_DEFFERED_RENDERING = (1 << 1), /* Deferred preview is being loaded. */ 362 PRV_TAG_DEFFERED_DELETE = (1 << 2), /* Deferred preview should be deleted asap. */ 363 }; 364 365 typedef struct PreviewImage { 366 /* All values of 2 are really NUM_ICON_SIZES */ 367 unsigned int w[2]; 368 unsigned int h[2]; 369 short flag[2]; 370 short changed_timestamp[2]; 371 unsigned int *rect[2]; 372 373 /* Runtime-only data. */ 374 struct GPUTexture *gputexture[2]; 375 /** Used by previews outside of ID context. */ 376 int icon_id; 377 378 /** Runtime data. */ 379 short tag; 380 char _pad[2]; 381 } PreviewImage; 382 383 #define PRV_DEFERRED_DATA(prv) \ 384 (CHECK_TYPE_INLINE(prv, PreviewImage *), \ 385 BLI_assert((prv)->tag & PRV_TAG_DEFFERED), \ 386 (void *)((prv) + 1)) 387 388 /** 389 * Defines for working with IDs. 390 * 391 * The tags represent types! This is a dirty way of enabling RTTI. The 392 * sig_byte end endian defines aren't really used much. 393 */ 394 395 #ifdef __BIG_ENDIAN__ 396 /* big endian */ 397 # define MAKE_ID2(c, d) ((c) << 8 | (d)) 398 #else 399 /* little endian */ 400 # define MAKE_ID2(c, d) ((d) << 8 | (c)) 401 #endif 402 403 /** 404 * ID from database. 405 * 406 * Written to #BHead.code (for file IO) 407 * and the first 2 bytes of #ID.name (for runtime checks, see #GS macro). 408 */ 409 typedef enum ID_Type { 410 ID_SCE = MAKE_ID2('S', 'C'), /* Scene */ 411 ID_LI = MAKE_ID2('L', 'I'), /* Library */ 412 ID_OB = MAKE_ID2('O', 'B'), /* Object */ 413 ID_ME = MAKE_ID2('M', 'E'), /* Mesh */ 414 ID_CU = MAKE_ID2('C', 'U'), /* Curve */ 415 ID_MB = MAKE_ID2('M', 'B'), /* MetaBall */ 416 ID_MA = MAKE_ID2('M', 'A'), /* Material */ 417 ID_TE = MAKE_ID2('T', 'E'), /* Tex (Texture) */ 418 ID_IM = MAKE_ID2('I', 'M'), /* Image */ 419 ID_LT = MAKE_ID2('L', 'T'), /* Lattice */ 420 ID_LA = MAKE_ID2('L', 'A'), /* Light */ 421 ID_CA = MAKE_ID2('C', 'A'), /* Camera */ 422 ID_IP = MAKE_ID2('I', 'P'), /* Ipo (depreciated, replaced by FCurves) */ 423 ID_KE = MAKE_ID2('K', 'E'), /* Key (shape key) */ 424 ID_WO = MAKE_ID2('W', 'O'), /* World */ 425 ID_SCR = MAKE_ID2('S', 'R'), /* Screen */ 426 ID_VF = MAKE_ID2('V', 'F'), /* VFont (Vector Font) */ 427 ID_TXT = MAKE_ID2('T', 'X'), /* Text */ 428 ID_SPK = MAKE_ID2('S', 'K'), /* Speaker */ 429 ID_SO = MAKE_ID2('S', 'O'), /* Sound */ 430 ID_GR = MAKE_ID2('G', 'R'), /* Group */ 431 ID_AR = MAKE_ID2('A', 'R'), /* bArmature */ 432 ID_AC = MAKE_ID2('A', 'C'), /* bAction */ 433 ID_NT = MAKE_ID2('N', 'T'), /* bNodeTree */ 434 ID_BR = MAKE_ID2('B', 'R'), /* Brush */ 435 ID_PA = MAKE_ID2('P', 'A'), /* ParticleSettings */ 436 ID_GD = MAKE_ID2('G', 'D'), /* bGPdata, (Grease Pencil) */ 437 ID_WM = MAKE_ID2('W', 'M'), /* WindowManager */ 438 ID_MC = MAKE_ID2('M', 'C'), /* MovieClip */ 439 ID_MSK = MAKE_ID2('M', 'S'), /* Mask */ 440 ID_LS = MAKE_ID2('L', 'S'), /* FreestyleLineStyle */ 441 ID_PAL = MAKE_ID2('P', 'L'), /* Palette */ 442 ID_PC = MAKE_ID2('P', 'C'), /* PaintCurve */ 443 ID_CF = MAKE_ID2('C', 'F'), /* CacheFile */ 444 ID_WS = MAKE_ID2('W', 'S'), /* WorkSpace */ 445 ID_LP = MAKE_ID2('L', 'P'), /* LightProbe */ 446 ID_HA = MAKE_ID2('H', 'A'), /* Hair */ 447 ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */ 448 ID_VO = MAKE_ID2('V', 'O'), /* Volume */ 449 ID_SIM = MAKE_ID2('S', 'I'), /* Simulation (currently unused) */ 450 } ID_Type; 451 452 /* Only used as 'placeholder' in .blend files for directly linked data-blocks. */ 453 #define ID_LINK_PLACEHOLDER MAKE_ID2('I', 'D') /* (internal use only) */ 454 455 /* Deprecated. */ 456 #define ID_SCRN MAKE_ID2('S', 'N') 457 458 /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */ 459 #define ID_SEQ MAKE_ID2('S', 'Q') 460 /* constraint */ 461 #define ID_CO MAKE_ID2('C', 'O') 462 /* pose (action channel, used to be ID_AC in code, so we keep code for backwards compat) */ 463 #define ID_PO MAKE_ID2('A', 'C') 464 /* used in outliner... */ 465 #define ID_NLA MAKE_ID2('N', 'L') 466 /* fluidsim Ipo */ 467 #define ID_FLUIDSIM MAKE_ID2('F', 'S') 468 469 #define ID_FAKE_USERS(id) ((((const ID *)id)->flag & LIB_FAKEUSER) ? 1 : 0) 470 #define ID_REAL_USERS(id) (((const ID *)id)->us - ID_FAKE_USERS(id)) 471 #define ID_EXTRA_USERS(id) (((const ID *)id)->tag & LIB_TAG_EXTRAUSER ? 1 : 0) 472 473 #define ID_CHECK_UNDO(id) \ 474 ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM) && (GS((id)->name) != ID_WS)) 475 476 #define ID_BLEND_PATH(_bmain, _id) \ 477 ((_id)->lib ? (_id)->lib->filepath_abs : BKE_main_blendfile_path((_bmain))) 478 #define ID_BLEND_PATH_FROM_GLOBAL(_id) \ 479 ((_id)->lib ? (_id)->lib->filepath_abs : BKE_main_blendfile_path_from_global()) 480 481 #define ID_MISSING(_id) ((((const ID *)(_id))->tag & LIB_TAG_MISSING) != 0) 482 483 #define ID_IS_LINKED(_id) (((const ID *)(_id))->lib != NULL) 484 485 /* Note that this is a fairly high-level check, should be used at user interaction level, not in 486 * BKE_library_override typically (especially due to the check on LIB_TAG_EXTERN). */ 487 #define ID_IS_OVERRIDABLE_LIBRARY(_id) \ 488 (ID_IS_LINKED(_id) && !ID_MISSING(_id) && (((const ID *)(_id))->tag & LIB_TAG_EXTERN) != 0 && \ 489 (BKE_idtype_get_info_from_id((const ID *)(_id))->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0) 490 491 #define ID_IS_OVERRIDE_LIBRARY_REAL(_id) \ 492 (((const ID *)(_id))->override_library != NULL && \ 493 ((const ID *)(_id))->override_library->reference != NULL) 494 495 #define ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id) \ 496 ((((const ID *)(_id))->flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE) != 0) 497 498 #define ID_IS_OVERRIDE_LIBRARY(_id) \ 499 (ID_IS_OVERRIDE_LIBRARY_REAL(_id) || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id)) 500 501 #define ID_IS_OVERRIDE_LIBRARY_TEMPLATE(_id) \ 502 (((ID *)(_id))->override_library != NULL && ((ID *)(_id))->override_library->reference == NULL) 503 504 /* Check whether datablock type is covered by copy-on-write. */ 505 #define ID_TYPE_IS_COW(_id_type) (!ELEM(_id_type, ID_BR, ID_PAL, ID_IM)) 506 507 #ifdef GS 508 # undef GS 509 #endif 510 #define GS(a) \ 511 (CHECK_TYPE_ANY(a, char *, const char *, char[66], const char[66]), \ 512 (ID_Type)(*((const short *)(a)))) 513 514 #define ID_NEW_SET(_id, _idn) \ 515 (((ID *)(_id))->newid = (ID *)(_idn), \ 516 ((ID *)(_id))->newid->tag |= LIB_TAG_NEW, \ 517 (void *)((ID *)(_id))->newid) 518 #define ID_NEW_REMAP(a) \ 519 if ((a) && (a)->id.newid) { \ 520 (a) = (void *)(a)->id.newid; \ 521 } \ 522 ((void)0) 523 524 /** id->flag (persitent). */ 525 enum { 526 /** Don't delete the datablock even if unused. */ 527 LIB_FAKEUSER = 1 << 9, 528 /** 529 * The data-block is a sub-data of another one. 530 * Direct persistent references are not allowed. 531 */ 532 LIB_EMBEDDED_DATA = 1 << 10, 533 /** 534 * Datablock is from a library and linked indirectly, with LIB_TAG_INDIRECT 535 * tag set. But the current .blend file also has a weak pointer to it that 536 * we want to restore if possible, and silently drop if it's missing. 537 */ 538 LIB_INDIRECT_WEAK_LINK = 1 << 11, 539 /** 540 * The data-block is a sub-data of another one, which is an override. 541 * Note that this also applies to shapekeys, even though they are not 100% embedded data... 542 */ 543 LIB_EMBEDDED_DATA_LIB_OVERRIDE = 1 << 12, 544 }; 545 546 /** 547 * id->tag (runtime-only). 548 * 549 * Those flags belong to three different categories, 550 * which have different expected handling in code: 551 * 552 * - RESET_BEFORE_USE: piece of code that wants to use such flag 553 * has to ensure they are properly 'reset' first. 554 * - RESET_AFTER_USE: piece of code that wants to use such flag has to ensure they are properly 555 * 'reset' after usage 556 * (though 'lifetime' of those flags is a bit fuzzy, e.g. _RECALC ones are reset on depsgraph 557 * evaluation...). 558 * - RESET_NEVER: those flags are 'status' one, and never actually need any reset 559 * (except on initialization during .blend file reading). 560 */ 561 enum { 562 /* RESET_NEVER Datablock is from current .blend file. */ 563 LIB_TAG_LOCAL = 0, 564 /* RESET_NEVER Datablock is from a library, 565 * but is used (linked) directly by current .blend file. */ 566 LIB_TAG_EXTERN = 1 << 0, 567 /* RESET_NEVER Datablock is from a library, 568 * and is only used (linked) indirectly through other libraries. */ 569 LIB_TAG_INDIRECT = 1 << 1, 570 571 /* RESET_AFTER_USE Flag used internally in readfile.c, 572 * to mark IDs needing to be expanded (only done once). */ 573 LIB_TAG_NEED_EXPAND = 1 << 3, 574 /* RESET_AFTER_USE Flag used internally in readfile.c to mark ID 575 * placeholders for linked data-blocks needing to be read. */ 576 LIB_TAG_ID_LINK_PLACEHOLDER = 1 << 4, 577 /* RESET_AFTER_USE */ 578 LIB_TAG_NEED_LINK = 1 << 5, 579 580 /* RESET_NEVER tag data-block as a place-holder 581 * (because the real one could not be linked from its library e.g.). */ 582 LIB_TAG_MISSING = 1 << 6, 583 584 /* RESET_NEVER tag data-block as being up-to-date regarding its reference. */ 585 LIB_TAG_OVERRIDE_LIBRARY_REFOK = 1 << 9, 586 /* RESET_NEVER tag data-block as needing an auto-override execution, if enabled. */ 587 LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH = 1 << 17, 588 589 /* tag data-block as having an extra user. */ 590 LIB_TAG_EXTRAUSER = 1 << 2, 591 /* tag data-block as having actually increased usercount for the extra virtual user. */ 592 LIB_TAG_EXTRAUSER_SET = 1 << 7, 593 594 /* RESET_AFTER_USE tag newly duplicated/copied IDs. 595 * Also used internally in readfile.c to mark data-blocks needing do_versions. */ 596 LIB_TAG_NEW = 1 << 8, 597 /* RESET_BEFORE_USE free test flag. 598 * TODO make it a RESET_AFTER_USE too. */ 599 LIB_TAG_DOIT = 1 << 10, 600 /* RESET_AFTER_USE tag existing data before linking so we know what is new. */ 601 LIB_TAG_PRE_EXISTING = 1 << 11, 602 603 /* The data-block is a copy-on-write/localized version. */ 604 LIB_TAG_COPIED_ON_WRITE = 1 << 12, 605 LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT = 1 << 13, 606 LIB_TAG_LOCALIZED = 1 << 14, 607 608 /* RESET_NEVER tag data-block for freeing etc. behavior 609 * (usually set when copying real one into temp/runtime one). */ 610 LIB_TAG_NO_MAIN = 1 << 15, /* Datablock is not listed in Main database. */ 611 LIB_TAG_NO_USER_REFCOUNT = 1 << 16, /* Datablock does not refcount usages of other IDs. */ 612 /* Datablock was not allocated by standard system (BKE_libblock_alloc), do not free its memory 613 * (usual type-specific freeing is called though). */ 614 LIB_TAG_NOT_ALLOCATED = 1 << 18, 615 616 /* RESET_AFTER_USE Used by undo system to tag unchanged IDs re-used from old Main (instead of 617 * read from memfile). */ 618 LIB_TAG_UNDO_OLD_ID_REUSED = 1 << 19, 619 }; 620 621 /* Tag given ID for an update in all the dependency graphs. */ 622 typedef enum IDRecalcFlag { 623 /*************************************************************************** 624 * Individual update tags, this is what ID gets tagged for update with. */ 625 626 /* ** Object transformation changed. ** */ 627 ID_RECALC_TRANSFORM = (1 << 0), 628 629 /* ** Object geometry changed. ** 630 * 631 * When object of armature type gets tagged with this flag, its pose is 632 * re-evaluated. 633 * When object of other type is tagged with this flag it makes the modifier 634 * stack to be re-evaluated. 635 * When object data type (mesh, curve, ...) gets tagged with this flag it 636 * makes all objects which shares this data-block to be updated. */ 637 ID_RECALC_GEOMETRY = (1 << 1), 638 639 /* ** Animation or time changed and animation is to be re-evaluated. ** */ 640 ID_RECALC_ANIMATION = (1 << 2), 641 642 /* ** Particle system changed. ** */ 643 /* Only do pathcache etc. */ 644 ID_RECALC_PSYS_REDO = (1 << 3), 645 /* Reset everything including pointcache. */ 646 ID_RECALC_PSYS_RESET = (1 << 4), 647 /* Only child settings changed. */ 648 ID_RECALC_PSYS_CHILD = (1 << 5), 649 /* Physics type changed. */ 650 ID_RECALC_PSYS_PHYS = (1 << 6), 651 652 /* ** Material and shading ** */ 653 654 /* For materials and node trees this means that topology of the shader tree 655 * changed, and the shader is to be recompiled. 656 * For objects it means that the draw batch cache is to be redone. */ 657 ID_RECALC_SHADING = (1 << 7), 658 /* TODO(sergey): Consider adding an explicit ID_RECALC_SHADING_PARAMATERS 659 * which can be used for cases when only socket value changed, to speed up 660 * redraw update in that case. */ 661 662 /* Selection of the ID itself or its components (for example, vertices) did 663 * change, and all the drawing data is to eb updated. */ 664 ID_RECALC_SELECT = (1 << 9), 665 /* Flags on the base did change, and is to be copied onto all the copies of 666 * corresponding objects. */ 667 ID_RECALC_BASE_FLAGS = (1 << 10), 668 ID_RECALC_POINT_CACHE = (1 << 11), 669 /* Only inform editors about the change. Is used to force update of editors 670 * when data-block which is not a part of dependency graph did change. 671 * 672 * For example, brush texture did change and the preview is to be 673 * re-rendered. */ 674 ID_RECALC_EDITORS = (1 << 12), 675 676 /* ** Update copy on write component. ** 677 * This is most generic tag which should only be used when nothing else 678 * matches. 679 */ 680 ID_RECALC_COPY_ON_WRITE = (1 << 13), 681 682 /* Sequences in the sequencer did change. 683 * Use this tag with a scene ID which owns the sequences. */ 684 ID_RECALC_SEQUENCER_STRIPS = (1 << 14), 685 686 ID_RECALC_AUDIO_SEEK = (1 << 15), 687 ID_RECALC_AUDIO_FPS = (1 << 16), 688 ID_RECALC_AUDIO_VOLUME = (1 << 17), 689 ID_RECALC_AUDIO_MUTE = (1 << 18), 690 ID_RECALC_AUDIO_LISTENER = (1 << 19), 691 692 ID_RECALC_AUDIO = (1 << 20), 693 694 ID_RECALC_PARAMETERS = (1 << 21), 695 696 /* Input has changed and datablock is to be reload from disk. 697 * Applies to movie clips to inform that copy-on-written version is to be refreshed for the new 698 * input file or for color space changes. */ 699 ID_RECALC_SOURCE = (1 << 23), 700 701 /* Virtual recalc tag/marker required for undo in some cases, where actual data does not change 702 * and hence do not require an update, but conceptually we are dealing with something new. 703 * 704 * Current known case: linked IDs made local without requiring any copy. While their users do not 705 * require any update, they have actually been 'virtually' remapped from the linked ID to the 706 * local one. 707 */ 708 ID_RECALC_TAG_FOR_UNDO = (1 << 24), 709 710 /*************************************************************************** 711 * Pseudonyms, to have more semantic meaning in the actual code without 712 * using too much low-level and implementation specific tags. */ 713 714 /* Update animation data-block itself, without doing full re-evaluation of 715 * all dependent objects. */ 716 ID_RECALC_ANIMATION_NO_FLUSH = ID_RECALC_COPY_ON_WRITE, 717 718 /*************************************************************************** 719 * Aggregate flags, use only for checks on runtime. 720 * Do NOT use those for tagging. */ 721 722 /* Identifies that SOMETHING has been changed in this ID. */ 723 ID_RECALC_ALL = ~(0), 724 /* Identifies that something in particle system did change. */ 725 ID_RECALC_PSYS_ALL = (ID_RECALC_PSYS_REDO | ID_RECALC_PSYS_RESET | ID_RECALC_PSYS_CHILD | 726 ID_RECALC_PSYS_PHYS), 727 728 } IDRecalcFlag; 729 730 /* To filter ID types (filter_id). 64 bit to fit all types. */ 731 #define FILTER_ID_AC (1ULL << 0) 732 #define FILTER_ID_AR (1ULL << 1) 733 #define FILTER_ID_BR (1ULL << 2) 734 #define FILTER_ID_CA (1ULL << 3) 735 #define FILTER_ID_CU (1ULL << 4) 736 #define FILTER_ID_GD (1ULL << 5) 737 #define FILTER_ID_GR (1ULL << 6) 738 #define FILTER_ID_IM (1ULL << 7) 739 #define FILTER_ID_LA (1ULL << 8) 740 #define FILTER_ID_LS (1ULL << 9) 741 #define FILTER_ID_LT (1ULL << 10) 742 #define FILTER_ID_MA (1ULL << 11) 743 #define FILTER_ID_MB (1ULL << 12) 744 #define FILTER_ID_MC (1ULL << 13) 745 #define FILTER_ID_ME (1ULL << 14) 746 #define FILTER_ID_MSK (1ULL << 15) 747 #define FILTER_ID_NT (1ULL << 16) 748 #define FILTER_ID_OB (1ULL << 17) 749 #define FILTER_ID_PAL (1ULL << 18) 750 #define FILTER_ID_PC (1ULL << 19) 751 #define FILTER_ID_SCE (1ULL << 20) 752 #define FILTER_ID_SPK (1ULL << 21) 753 #define FILTER_ID_SO (1ULL << 22) 754 #define FILTER_ID_TE (1ULL << 23) 755 #define FILTER_ID_TXT (1ULL << 24) 756 #define FILTER_ID_VF (1ULL << 25) 757 #define FILTER_ID_WO (1ULL << 26) 758 #define FILTER_ID_PA (1ULL << 27) 759 #define FILTER_ID_CF (1ULL << 28) 760 #define FILTER_ID_WS (1ULL << 29) 761 #define FILTER_ID_LP (1ULL << 31) 762 #define FILTER_ID_HA (1ULL << 32) 763 #define FILTER_ID_PT (1ULL << 33) 764 #define FILTER_ID_VO (1ULL << 34) 765 #define FILTER_ID_SIM (1ULL << 35) 766 767 #define FILTER_ID_ALL \ 768 (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU | FILTER_ID_GD | \ 769 FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | FILTER_ID_LT | FILTER_ID_MA | \ 770 FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \ 771 FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \ 772 FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \ 773 FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM) 774 775 /* IMPORTANT: this enum matches the order currently use in set_listbasepointers, 776 * keep them in sync! */ 777 enum { 778 INDEX_ID_LI = 0, 779 INDEX_ID_IP, 780 INDEX_ID_AC, 781 INDEX_ID_KE, 782 INDEX_ID_PAL, 783 INDEX_ID_GD, 784 INDEX_ID_NT, 785 INDEX_ID_IM, 786 INDEX_ID_TE, 787 INDEX_ID_MA, 788 INDEX_ID_VF, 789 INDEX_ID_AR, 790 INDEX_ID_CF, 791 INDEX_ID_ME, 792 INDEX_ID_CU, 793 INDEX_ID_MB, 794 INDEX_ID_HA, 795 INDEX_ID_PT, 796 INDEX_ID_VO, 797 INDEX_ID_LT, 798 INDEX_ID_LA, 799 INDEX_ID_CA, 800 INDEX_ID_TXT, 801 INDEX_ID_SO, 802 INDEX_ID_GR, 803 INDEX_ID_PC, 804 INDEX_ID_BR, 805 INDEX_ID_PA, 806 INDEX_ID_SPK, 807 INDEX_ID_LP, 808 INDEX_ID_WO, 809 INDEX_ID_MC, 810 INDEX_ID_SCR, 811 INDEX_ID_OB, 812 INDEX_ID_LS, 813 INDEX_ID_SCE, 814 INDEX_ID_WS, 815 INDEX_ID_WM, 816 INDEX_ID_MSK, 817 INDEX_ID_SIM, 818 INDEX_ID_NULL, 819 INDEX_ID_MAX, 820 }; 821 822 #ifdef __cplusplus 823 } 824 #endif 825