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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenloader
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_blend_defs.h72
-rw-r--r--source/blender/blenloader/BLO_readfile.h115
-rw-r--r--source/blender/blenloader/BLO_undofile.h35
-rw-r--r--source/blender/blenloader/BLO_writefile.h14
-rw-r--r--source/blender/blenloader/CMakeLists.txt98
-rw-r--r--source/blender/blenloader/intern/blend_validate.c274
-rw-r--r--source/blender/blenloader/intern/readblenentry.c532
-rw-r--r--source/blender/blenloader/intern/readfile.c17162
-rw-r--r--source/blender/blenloader/intern/readfile.h151
-rw-r--r--source/blender/blenloader/intern/undofile.c198
-rw-r--r--source/blender/blenloader/intern/versioning_250.c4044
-rw-r--r--source/blender/blenloader/intern/versioning_260.c4637
-rw-r--r--source/blender/blenloader/intern/versioning_270.c3240
-rw-r--r--source/blender/blenloader/intern/versioning_280.c5773
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c544
-rw-r--r--source/blender/blenloader/intern/versioning_dna.c28
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c4735
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c881
-rw-r--r--source/blender/blenloader/intern/writefile.c6603
19 files changed, 24668 insertions, 24468 deletions
diff --git a/source/blender/blenloader/BLO_blend_defs.h b/source/blender/blenloader/BLO_blend_defs.h
index aefe3a7de08..0787d054141 100644
--- a/source/blender/blenloader/BLO_blend_defs.h
+++ b/source/blender/blenloader/BLO_blend_defs.h
@@ -24,10 +24,10 @@
/* INTEGER CODES */
#ifdef __BIG_ENDIAN__
/* Big Endian */
-# define BLEND_MAKE_ID(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) )
+# define BLEND_MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d))
#else
/* Little Endian */
-# define BLEND_MAKE_ID(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) )
+# define BLEND_MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
#endif
/**
@@ -36,41 +36,41 @@
* These coexist with ID codes such as #ID_OB, #ID_SCE ... etc.
*/
enum {
- /**
- * Arbitrary allocated memory
- * (typically owned by #ID's, will be freed when there are no users).
- */
- DATA = BLEND_MAKE_ID('D', 'A', 'T', 'A'),
- /**
- * Used for #Global struct.
- */
- GLOB = BLEND_MAKE_ID('G', 'L', 'O', 'B'),
- /**
- * Used for storing the encoded SDNA string
- * (decoded into an #SDNA on load).
- */
- DNA1 = BLEND_MAKE_ID('D', 'N', 'A', '1'),
- /**
- * Used to store thumbnail previews, written between #REND and #GLOB blocks,
- * (ignored for regular file reading).
- */
- TEST = BLEND_MAKE_ID('T', 'E', 'S', 'T'),
- /**
- * Used for #RenderInfo, basic Scene and frame range info,
- * can be easily read by other applications without writing a full blend file parser.
- */
- REND = BLEND_MAKE_ID('R', 'E', 'N', 'D'),
- /**
- * Used for #UserDef, (user-preferences data).
- * (written to #BLENDER_STARTUP_FILE & #BLENDER_USERPREF_FILE).
- */
- USER = BLEND_MAKE_ID('U', 'S', 'E', 'R'),
- /**
- * Terminate reading (no data).
- */
- ENDB = BLEND_MAKE_ID('E', 'N', 'D', 'B'),
+ /**
+ * Arbitrary allocated memory
+ * (typically owned by #ID's, will be freed when there are no users).
+ */
+ DATA = BLEND_MAKE_ID('D', 'A', 'T', 'A'),
+ /**
+ * Used for #Global struct.
+ */
+ GLOB = BLEND_MAKE_ID('G', 'L', 'O', 'B'),
+ /**
+ * Used for storing the encoded SDNA string
+ * (decoded into an #SDNA on load).
+ */
+ DNA1 = BLEND_MAKE_ID('D', 'N', 'A', '1'),
+ /**
+ * Used to store thumbnail previews, written between #REND and #GLOB blocks,
+ * (ignored for regular file reading).
+ */
+ TEST = BLEND_MAKE_ID('T', 'E', 'S', 'T'),
+ /**
+ * Used for #RenderInfo, basic Scene and frame range info,
+ * can be easily read by other applications without writing a full blend file parser.
+ */
+ REND = BLEND_MAKE_ID('R', 'E', 'N', 'D'),
+ /**
+ * Used for #UserDef, (user-preferences data).
+ * (written to #BLENDER_STARTUP_FILE & #BLENDER_USERPREF_FILE).
+ */
+ USER = BLEND_MAKE_ID('U', 'S', 'E', 'R'),
+ /**
+ * Terminate reading (no data).
+ */
+ ENDB = BLEND_MAKE_ID('E', 'N', 'D', 'B'),
};
#define BLEN_THUMB_MEMSIZE_FILE(_x, _y) (sizeof(int) * (2 + (size_t)(_x) * (size_t)(_y)))
-#endif /* __BLO_BLEND_DEFS_H__ */
+#endif /* __BLO_BLEND_DEFS_H__ */
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index bff35167792..cf00e4d5f84 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -47,65 +47,66 @@ struct wmWindowManager;
typedef struct BlendHandle BlendHandle;
typedef enum eBlenFileType {
- BLENFILETYPE_BLEND = 1,
- BLENFILETYPE_PUB = 2,
- BLENFILETYPE_RUNTIME = 3,
+ BLENFILETYPE_BLEND = 1,
+ BLENFILETYPE_PUB = 2,
+ BLENFILETYPE_RUNTIME = 3,
} eBlenFileType;
typedef struct BlendFileData {
- struct Main *main;
- struct UserDef *user;
+ struct Main *main;
+ struct UserDef *user;
- int fileflags;
- int globalf;
- char filename[1024]; /* 1024 = FILE_MAX */
+ int fileflags;
+ int globalf;
+ char filename[1024]; /* 1024 = FILE_MAX */
- struct bScreen *curscreen; /* TODO think this isn't needed anymore? */
- struct Scene *curscene;
- struct ViewLayer *cur_view_layer; /* layer to activate in workspaces when reading without UI */
+ struct bScreen *curscreen; /* TODO think this isn't needed anymore? */
+ struct Scene *curscene;
+ struct ViewLayer *cur_view_layer; /* layer to activate in workspaces when reading without UI */
- eBlenFileType type;
+ eBlenFileType type;
} BlendFileData;
typedef struct WorkspaceConfigFileData {
- struct Main *main; /* has to be freed when done reading file data */
+ struct Main *main; /* has to be freed when done reading file data */
- struct ListBase workspaces;
+ struct ListBase workspaces;
} WorkspaceConfigFileData;
struct BlendFileReadParams {
- uint skip_flags : 2; /* eBLOReadSkip */
- uint is_startup : 1;
+ uint skip_flags : 2; /* eBLOReadSkip */
+ uint is_startup : 1;
};
/* skip reading some data-block types (may want to skip screen data too). */
typedef enum eBLOReadSkip {
- BLO_READ_SKIP_NONE = 0,
- BLO_READ_SKIP_USERDEF = (1 << 0),
- BLO_READ_SKIP_DATA = (1 << 1),
+ BLO_READ_SKIP_NONE = 0,
+ BLO_READ_SKIP_USERDEF = (1 << 0),
+ BLO_READ_SKIP_DATA = (1 << 1),
} eBLOReadSkip;
-#define BLO_READ_SKIP_ALL \
- (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
-
-BlendFileData *BLO_read_from_file(
- const char *filepath,
- eBLOReadSkip skip_flags,
- struct ReportList *reports);
-BlendFileData *BLO_read_from_memory(
- const void *mem, int memsize,
- eBLOReadSkip skip_flags,
- struct ReportList *reports);
-BlendFileData *BLO_read_from_memfile(
- struct Main *oldmain, const char *filename, struct MemFile *memfile,
- eBLOReadSkip skip_flags,
- struct ReportList *reports);
+#define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
+
+BlendFileData *BLO_read_from_file(const char *filepath,
+ eBLOReadSkip skip_flags,
+ struct ReportList *reports);
+BlendFileData *BLO_read_from_memory(const void *mem,
+ int memsize,
+ eBLOReadSkip skip_flags,
+ struct ReportList *reports);
+BlendFileData *BLO_read_from_memfile(struct Main *oldmain,
+ const char *filename,
+ struct MemFile *memfile,
+ eBLOReadSkip skip_flags,
+ struct ReportList *reports);
void BLO_blendfiledata_free(BlendFileData *bfd);
BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports);
BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize);
-struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names);
+struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
+ int ofblocktype,
+ int *tot_names);
struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev);
struct LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh);
@@ -123,31 +124,41 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
* Note: merged with 'user-level' options from operators etc. in 16 lower bits
* (see eFileSel_Params_Flag in DNA_space_types.h). */
typedef enum BLO_LibLinkFlags {
- /* Generate a placeholder (empty ID) if not found in current lib file. */
- BLO_LIBLINK_USE_PLACEHOLDERS = 1 << 16,
- /* Force loaded ID to be tagged as LIB_TAG_INDIRECT (used in reload context only). */
- BLO_LIBLINK_FORCE_INDIRECT = 1 << 17,
+ /* Generate a placeholder (empty ID) if not found in current lib file. */
+ BLO_LIBLINK_USE_PLACEHOLDERS = 1 << 16,
+ /* Force loaded ID to be tagged as LIB_TAG_INDIRECT (used in reload context only). */
+ BLO_LIBLINK_FORCE_INDIRECT = 1 << 17,
} BLO_LinkFlags;
struct Main *BLO_library_link_begin(struct Main *mainvar, BlendHandle **bh, const char *filepath);
-struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name);
+struct ID *BLO_library_link_named_part(struct Main *mainl,
+ BlendHandle **bh,
+ const short idcode,
+ const char *name);
struct ID *BLO_library_link_named_part_ex(
- struct Main *mainl, BlendHandle **bh,
- const short idcode, const char *name, const int flag);
-void BLO_library_link_end(
- struct Main *mainl, BlendHandle **bh, int flag,
- struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d);
-
-int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const unsigned int id_types_mask);
+ struct Main *mainl, BlendHandle **bh, const short idcode, const char *name, const int flag);
+void BLO_library_link_end(struct Main *mainl,
+ BlendHandle **bh,
+ int flag,
+ struct Main *bmain,
+ struct Scene *scene,
+ struct ViewLayer *view_layer,
+ const struct View3D *v3d);
+
+int BLO_library_link_copypaste(struct Main *mainl,
+ BlendHandle *bh,
+ const unsigned int id_types_mask);
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
/* internal function but we need to expose it */
-void blo_lib_link_restore(
- struct Main *oldmain, struct Main *newmain, struct wmWindowManager *curwm,
- struct Scene *curscene, struct ViewLayer *cur_render_layer);
+void blo_lib_link_restore(struct Main *oldmain,
+ struct Main *newmain,
+ struct wmWindowManager *curwm,
+ struct Scene *curscene,
+ struct ViewLayer *cur_render_layer);
-typedef void (*BLOExpandDoitCallback) (void *fdhandle, struct Main *mainvar, void *idv);
+typedef void (*BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv);
void BLO_main_expander(BLOExpandDoitCallback expand_doit_func);
void BLO_expand_main(void *fdhandle, struct Main *mainvar);
@@ -168,4 +179,4 @@ extern const struct bTheme U_theme_default;
}
#endif
-#endif /* __BLO_READFILE_H__ */
+#endif /* __BLO_READFILE_H__ */
diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h
index 1b71081547a..0388b3f3520 100644
--- a/source/blender/blenloader/BLO_undofile.h
+++ b/source/blender/blenloader/BLO_undofile.h
@@ -28,36 +28,39 @@
struct Scene;
typedef struct {
- void *next, *prev;
- const char *buf;
- /** Size in bytes. */
- unsigned int size;
- /** When true, this chunk doesn't own the memory, it's shared with a previous #MemFileChunk */
- bool is_identical;
+ void *next, *prev;
+ const char *buf;
+ /** Size in bytes. */
+ unsigned int size;
+ /** When true, this chunk doesn't own the memory, it's shared with a previous #MemFileChunk */
+ bool is_identical;
} MemFileChunk;
typedef struct MemFile {
- ListBase chunks;
- size_t size;
+ ListBase chunks;
+ size_t size;
} MemFile;
typedef struct MemFileUndoData {
- char filename[1024]; /* FILE_MAX */
- MemFile memfile;
- size_t undo_size;
+ char filename[1024]; /* FILE_MAX */
+ MemFile memfile;
+ size_t undo_size;
} MemFileUndoData;
/* actually only used writefile.c */
-extern void memfile_chunk_add(
- MemFile *memfile, const char *buf, unsigned int size,
- MemFileChunk **compchunk_step);
+extern void memfile_chunk_add(MemFile *memfile,
+ const char *buf,
+ unsigned int size,
+ MemFileChunk **compchunk_step);
/* exports */
extern void BLO_memfile_free(MemFile *memfile);
extern void BLO_memfile_merge(MemFile *first, MemFile *second);
/* utilities */
-extern struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *bmain, struct Scene **r_scene);
+extern struct Main *BLO_memfile_main_get(struct MemFile *memfile,
+ struct Main *bmain,
+ struct Scene **r_scene);
extern bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename);
-#endif /* __BLO_UNDOFILE_H__ */
+#endif /* __BLO_UNDOFILE_H__ */
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index db9899ea95b..d83abf7f9ed 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -30,10 +30,14 @@ struct Main;
struct MemFile;
struct ReportList;
-extern bool BLO_write_file(
- struct Main *mainvar, const char *filepath, int write_flags,
- struct ReportList *reports, const struct BlendThumbnail *thumb);
-extern bool BLO_write_file_mem(
- struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags);
+extern bool BLO_write_file(struct Main *mainvar,
+ const char *filepath,
+ int write_flags,
+ struct ReportList *reports,
+ const struct BlendThumbnail *thumb);
+extern bool BLO_write_file_mem(struct Main *mainvar,
+ struct MemFile *compare,
+ struct MemFile *current,
+ int write_flags);
#endif
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index ffb77a02aa1..5b6c91ee1fe 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -19,82 +19,82 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
- .
- ../blenfont
- ../blenkernel
- ../blenlib
- ../blentranslation
- ../depsgraph
- ../draw
- ../imbuf
- ../makesdna
- ../makesrna
- ../nodes
- ../render/extern/include
- ../windowmanager
- ../../../intern/guardedalloc
+ .
+ ../blenfont
+ ../blenkernel
+ ../blenlib
+ ../blentranslation
+ ../depsgraph
+ ../draw
+ ../imbuf
+ ../makesdna
+ ../makesrna
+ ../nodes
+ ../render/extern/include
+ ../windowmanager
+ ../../../intern/guardedalloc
- # for writefile.c: dna_type_offsets.h
- ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
+ # for writefile.c: dna_type_offsets.h
+ ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
)
set(INC_SYS
- ${ZLIB_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIRS}
)
set(SRC
- ${CMAKE_SOURCE_DIR}/release/datafiles/userdef/userdef_default_theme.c
- intern/blend_validate.c
- intern/readblenentry.c
- intern/readfile.c
- intern/undofile.c
- intern/versioning_250.c
- intern/versioning_260.c
- intern/versioning_270.c
- intern/versioning_280.c
- intern/versioning_defaults.c
- intern/versioning_dna.c
- intern/versioning_legacy.c
- intern/versioning_userdef.c
- intern/writefile.c
+ ${CMAKE_SOURCE_DIR}/release/datafiles/userdef/userdef_default_theme.c
+ intern/blend_validate.c
+ intern/readblenentry.c
+ intern/readfile.c
+ intern/undofile.c
+ intern/versioning_250.c
+ intern/versioning_260.c
+ intern/versioning_270.c
+ intern/versioning_280.c
+ intern/versioning_defaults.c
+ intern/versioning_dna.c
+ intern/versioning_legacy.c
+ intern/versioning_userdef.c
+ intern/writefile.c
- BLO_blend_defs.h
- BLO_blend_validate.h
- BLO_readfile.h
- BLO_undofile.h
- BLO_writefile.h
- intern/readfile.h
+ BLO_blend_defs.h
+ BLO_blend_validate.h
+ BLO_readfile.h
+ BLO_undofile.h
+ BLO_writefile.h
+ intern/readfile.h
)
set(LIB
- bf_blenkernel
- bf_blenlib
+ bf_blenkernel
+ bf_blenlib
)
if(WITH_BUILDINFO)
- add_definitions(-DWITH_BUILDINFO)
+ add_definitions(-DWITH_BUILDINFO)
endif()
if(WITH_PYTHON)
- if(WITH_PYTHON_SECURITY)
- add_definitions(-DWITH_PYTHON_SECURITY)
- endif()
+ if(WITH_PYTHON_SECURITY)
+ add_definitions(-DWITH_PYTHON_SECURITY)
+ endif()
endif()
if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
endif()
if(WITH_CODEC_FFMPEG)
- add_definitions(-DWITH_FFMPEG)
+ add_definitions(-DWITH_FFMPEG)
endif()
if(WITH_ALEMBIC)
- list(APPEND INC
- ../alembic
- )
- add_definitions(-DWITH_ALEMBIC)
+ list(APPEND INC
+ ../alembic
+ )
+ add_definitions(-DWITH_ALEMBIC)
endif()
blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 4d4a20adbdf..1ca274dd68a 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -22,7 +22,7 @@
* \note Does not *fix* anything, only reports found errors.
*/
-#include <string.h> // for strrchr strncmp strstr
+#include <string.h> // for strrchr strncmp strstr
#include "BLI_utildefines.h"
@@ -48,137 +48,153 @@
/** Check (but do *not* fix) that all linked data-blocks are still valid (i.e. pointing to the right library). */
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
{
- ListBase mainlist;
- bool is_valid = true;
-
- BKE_main_lock(bmain);
-
- blo_split_main(&mainlist, bmain);
-
- ListBase *lbarray[MAX_LIBARRAY];
- int i = set_listbasepointers(bmain, lbarray);
- while (i--) {
- for (ID *id = lbarray[i]->first; id != NULL; id = id->next) {
- if (id->lib != NULL) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s is in local database while being linked from library %s!", id->name, id->lib->name);
- }
- }
- }
-
- for (Main *curmain = bmain->next; curmain != NULL; curmain = curmain->next) {
- Library *curlib = curmain->curlib;
- if (curlib == NULL) {
- BKE_report(reports, RPT_ERROR,
- "Library database with NULL library datablock!");
- continue;
- }
-
- BKE_library_filepath_set(bmain, curlib, curlib->name);
- BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
-
- if (bh == NULL) {
- BKE_reportf(reports, RPT_ERROR,
- "Library ID %s not found at expected path %s!", curlib->id.name, curlib->filepath);
- continue;
- }
-
- i = set_listbasepointers(curmain, lbarray);
- while (i--) {
- ID *id = lbarray[i]->first;
- if (id == NULL) {
- continue;
- }
-
- if (GS(id->name) == ID_LI) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "Library ID %s in library %s, this should not happen!", id->name, curlib->name);
- continue;
- }
-
- int totnames = 0;
- LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), &totnames);
- for (; id != NULL; id = id->next) {
- if (id->lib == NULL) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s has NULL lib pointer while being in library %s!", id->name, curlib->name);
- continue;
- }
- if (id->lib != curlib) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s has mismatched lib pointer!", id->name);
- continue;
- }
-
- LinkNode *name = names;
- for (; name; name = name->next) {
- char *str_name = (char *)name->link;
- if (id->name[2] == str_name[0] && STREQ(str_name, id->name + 2)) {
- break;
- }
- }
-
- if (name == NULL) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s not found in library %s anymore!", id->name, id->lib->name);
- continue;
- }
- }
-
- BLI_linklist_free(names, free);
- }
-
- BLO_blendhandle_close(bh);
- }
-
- blo_join_main(&mainlist);
-
- BLI_assert(BLI_listbase_is_single(&mainlist));
- BLI_assert(mainlist.first == (void *)bmain);
-
- BKE_main_unlock(bmain);
-
- return is_valid;
+ ListBase mainlist;
+ bool is_valid = true;
+
+ BKE_main_lock(bmain);
+
+ blo_split_main(&mainlist, bmain);
+
+ ListBase *lbarray[MAX_LIBARRAY];
+ int i = set_listbasepointers(bmain, lbarray);
+ while (i--) {
+ for (ID *id = lbarray[i]->first; id != NULL; id = id->next) {
+ if (id->lib != NULL) {
+ is_valid = false;
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "ID %s is in local database while being linked from library %s!",
+ id->name,
+ id->lib->name);
+ }
+ }
+ }
+
+ for (Main *curmain = bmain->next; curmain != NULL; curmain = curmain->next) {
+ Library *curlib = curmain->curlib;
+ if (curlib == NULL) {
+ BKE_report(reports, RPT_ERROR, "Library database with NULL library datablock!");
+ continue;
+ }
+
+ BKE_library_filepath_set(bmain, curlib, curlib->name);
+ BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
+
+ if (bh == NULL) {
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "Library ID %s not found at expected path %s!",
+ curlib->id.name,
+ curlib->filepath);
+ continue;
+ }
+
+ i = set_listbasepointers(curmain, lbarray);
+ while (i--) {
+ ID *id = lbarray[i]->first;
+ if (id == NULL) {
+ continue;
+ }
+
+ if (GS(id->name) == ID_LI) {
+ is_valid = false;
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "Library ID %s in library %s, this should not happen!",
+ id->name,
+ curlib->name);
+ continue;
+ }
+
+ int totnames = 0;
+ LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), &totnames);
+ for (; id != NULL; id = id->next) {
+ if (id->lib == NULL) {
+ is_valid = false;
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "ID %s has NULL lib pointer while being in library %s!",
+ id->name,
+ curlib->name);
+ continue;
+ }
+ if (id->lib != curlib) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR, "ID %s has mismatched lib pointer!", id->name);
+ continue;
+ }
+
+ LinkNode *name = names;
+ for (; name; name = name->next) {
+ char *str_name = (char *)name->link;
+ if (id->name[2] == str_name[0] && STREQ(str_name, id->name + 2)) {
+ break;
+ }
+ }
+
+ if (name == NULL) {
+ is_valid = false;
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "ID %s not found in library %s anymore!",
+ id->name,
+ id->lib->name);
+ continue;
+ }
+ }
+
+ BLI_linklist_free(names, free);
+ }
+
+ BLO_blendhandle_close(bh);
+ }
+
+ blo_join_main(&mainlist);
+
+ BLI_assert(BLI_listbase_is_single(&mainlist));
+ BLI_assert(mainlist.first == (void *)bmain);
+
+ BKE_main_unlock(bmain);
+
+ return is_valid;
}
/** Check (and fix if needed) that shape key's 'from' pointer is valid. */
bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
{
- ListBase *lb;
- ID *id;
- bool is_valid = true;
-
- BKE_main_lock(bmain);
-
- FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
- {
- FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
- {
- if (!BKE_key_idtype_support(GS(id->name))) {
- break;
- }
- if (id->lib == NULL) {
- /* We assume lib data is valid... */
- Key *shapekey = BKE_key_from_id(id);
- if (shapekey != NULL && shapekey->from != id) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s uses shapekey %s, but its 'from' pointer is invalid (%p), fixing...",
- id->name, shapekey->id.name, shapekey->from);
- shapekey->from = id;
- }
- }
- }
- FOREACH_MAIN_LISTBASE_ID_END;
- }
- FOREACH_MAIN_LISTBASE_END;
-
- BKE_main_unlock(bmain);
-
- return is_valid;
+ ListBase *lb;
+ ID *id;
+ bool is_valid = true;
+
+ BKE_main_lock(bmain);
+
+ FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
+ {
+ FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
+ {
+ if (!BKE_key_idtype_support(GS(id->name))) {
+ break;
+ }
+ if (id->lib == NULL) {
+ /* We assume lib data is valid... */
+ Key *shapekey = BKE_key_from_id(id);
+ if (shapekey != NULL && shapekey->from != id) {
+ is_valid = false;
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "ID %s uses shapekey %s, but its 'from' pointer is invalid (%p), fixing...",
+ id->name,
+ shapekey->id.name,
+ shapekey->from);
+ shapekey->from = id;
+ }
+ }
+ }
+ FOREACH_MAIN_LISTBASE_ID_END;
+ }
+ FOREACH_MAIN_LISTBASE_END;
+
+ BKE_main_unlock(bmain);
+
+ return is_valid;
}
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 1cd63c4bdfe..6441c6d7a39 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -22,7 +22,6 @@
* \ingroup blenloader
*/
-
#include <stddef.h>
#include <stdlib.h>
@@ -41,7 +40,6 @@
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"
-
#include "BKE_main.h"
#include "BKE_idcode.h"
@@ -51,7 +49,7 @@
#include "readfile.h"
-#include "BLI_sys_types.h" // needed for intptr_t
+#include "BLI_sys_types.h" // needed for intptr_t
#ifdef WIN32
# include "BLI_winstuff.h"
@@ -71,11 +69,11 @@ void BLO_blendhandle_print_sizes(BlendHandle *, void *);
*/
BlendHandle *BLO_blendhandle_from_file(const char *filepath, ReportList *reports)
{
- BlendHandle *bh;
+ BlendHandle *bh;
- bh = (BlendHandle *)blo_filedata_from_file(filepath, reports);
+ bh = (BlendHandle *)blo_filedata_from_file(filepath, reports);
- return bh;
+ return bh;
}
/**
@@ -87,41 +85,46 @@ BlendHandle *BLO_blendhandle_from_file(const char *filepath, ReportList *reports
*/
BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize)
{
- BlendHandle *bh;
+ BlendHandle *bh;
- bh = (BlendHandle *)blo_filedata_from_memory(mem, memsize, NULL);
+ bh = (BlendHandle *)blo_filedata_from_memory(mem, memsize, NULL);
- return bh;
+ return bh;
}
void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
{
- FileData *fd = (FileData *)bh;
- BHead *bhead;
-
- fprintf(fp, "[\n");
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ENDB)
- break;
- else {
- const short *sp = fd->filesdna->structs[bhead->SDNAnr];
- const char *name = fd->filesdna->types[sp[0]];
- char buf[4];
-
- buf[0] = (bhead->code >> 24) & 0xFF;
- buf[1] = (bhead->code >> 16) & 0xFF;
- buf[2] = (bhead->code >> 8) & 0xFF;
- buf[3] = (bhead->code >> 0) & 0xFF;
-
- buf[0] = buf[0] ? buf[0] : ' ';
- buf[1] = buf[1] ? buf[1] : ' ';
- buf[2] = buf[2] ? buf[2] : ' ';
- buf[3] = buf[3] ? buf[3] : ' ';
-
- fprintf(fp, "['%.4s', '%s', %d, %ld ],\n", buf, name, bhead->nr, (long int)(bhead->len + sizeof(BHead)));
- }
- }
- fprintf(fp, "]\n");
+ FileData *fd = (FileData *)bh;
+ BHead *bhead;
+
+ fprintf(fp, "[\n");
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == ENDB)
+ break;
+ else {
+ const short *sp = fd->filesdna->structs[bhead->SDNAnr];
+ const char *name = fd->filesdna->types[sp[0]];
+ char buf[4];
+
+ buf[0] = (bhead->code >> 24) & 0xFF;
+ buf[1] = (bhead->code >> 16) & 0xFF;
+ buf[2] = (bhead->code >> 8) & 0xFF;
+ buf[3] = (bhead->code >> 0) & 0xFF;
+
+ buf[0] = buf[0] ? buf[0] : ' ';
+ buf[1] = buf[1] ? buf[1] : ' ';
+ buf[2] = buf[2] ? buf[2] : ' ';
+ buf[3] = buf[3] ? buf[3] : ' ';
+
+ fprintf(fp,
+ "['%.4s', '%s', %d, %ld ],\n",
+ buf,
+ name,
+ bhead->nr,
+ (long int)(bhead->len + sizeof(BHead)));
+ }
+ }
+ fprintf(fp, "]\n");
}
/**
@@ -134,24 +137,24 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
*/
LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names)
{
- FileData *fd = (FileData *)bh;
- LinkNode *names = NULL;
- BHead *bhead;
- int tot = 0;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ofblocktype) {
- const char *idname = blo_bhead_id_name(fd, bhead);
-
- BLI_linklist_prepend(&names, strdup(idname + 2));
- tot++;
- }
- else if (bhead->code == ENDB)
- break;
- }
-
- *tot_names = tot;
- return names;
+ FileData *fd = (FileData *)bh;
+ LinkNode *names = NULL;
+ BHead *bhead;
+ int tot = 0;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == ofblocktype) {
+ const char *idname = blo_bhead_id_name(fd, bhead);
+
+ BLI_linklist_prepend(&names, strdup(idname + 2));
+ tot++;
+ }
+ else if (bhead->code == ENDB)
+ break;
+ }
+
+ *tot_names = tot;
+ return names;
}
/**
@@ -164,84 +167,83 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
*/
LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev)
{
- FileData *fd = (FileData *)bh;
- LinkNode *previews = NULL;
- BHead *bhead;
- int looking = 0;
- PreviewImage *prv = NULL;
- PreviewImage *new_prv = NULL;
- int tot = 0;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ofblocktype) {
- const char *idname = blo_bhead_id_name(fd, bhead);
- switch (GS(idname)) {
- case ID_MA: /* fall through */
- case ID_TE: /* fall through */
- case ID_IM: /* fall through */
- case ID_WO: /* fall through */
- case ID_LA: /* fall through */
- case ID_OB: /* fall through */
- case ID_GR: /* fall through */
- case ID_SCE: /* fall through */
- new_prv = MEM_callocN(sizeof(PreviewImage), "newpreview");
- BLI_linklist_prepend(&previews, new_prv);
- tot++;
- looking = 1;
- break;
- default:
- break;
- }
- }
- else if (bhead->code == DATA) {
- if (looking) {
- if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage") ) {
- prv = BLO_library_read_struct(fd, bhead, "PreviewImage");
- if (prv) {
- memcpy(new_prv, prv, sizeof(PreviewImage));
- if (prv->rect[0] && prv->w[0] && prv->h[0]) {
- bhead = blo_bhead_next(fd, bhead);
- BLI_assert((new_prv->w[0] * new_prv->h[0] * sizeof(uint)) == bhead->len);
- new_prv->rect[0] = BLO_library_read_struct(fd, bhead, "PreviewImage Icon Rect");
- }
- else {
- /* This should not be needed, but can happen in 'broken' .blend files,
- * better handle this gracefully than crashing. */
- BLI_assert(prv->rect[0] == NULL && prv->w[0] == 0 && prv->h[0] == 0);
- new_prv->rect[0] = NULL;
- new_prv->w[0] = new_prv->h[0] = 0;
- }
-
- if (prv->rect[1] && prv->w[1] && prv->h[1]) {
- bhead = blo_bhead_next(fd, bhead);
- BLI_assert((new_prv->w[1] * new_prv->h[1] * sizeof(uint)) == bhead->len);
- new_prv->rect[1] = BLO_library_read_struct(fd, bhead, "PreviewImage Image Rect");
- }
- else {
- /* This should not be needed, but can happen in 'broken' .blend files,
- * better handle this gracefully than crashing. */
- BLI_assert(prv->rect[1] == NULL && prv->w[1] == 0 && prv->h[1] == 0);
- new_prv->rect[1] = NULL;
- new_prv->w[1] = new_prv->h[1] = 0;
- }
- MEM_freeN(prv);
- }
- }
- }
- }
- else if (bhead->code == ENDB) {
- break;
- }
- else {
- looking = 0;
- new_prv = NULL;
- prv = NULL;
- }
-
- }
-
- *tot_prev = tot;
- return previews;
+ FileData *fd = (FileData *)bh;
+ LinkNode *previews = NULL;
+ BHead *bhead;
+ int looking = 0;
+ PreviewImage *prv = NULL;
+ PreviewImage *new_prv = NULL;
+ int tot = 0;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == ofblocktype) {
+ const char *idname = blo_bhead_id_name(fd, bhead);
+ switch (GS(idname)) {
+ case ID_MA: /* fall through */
+ case ID_TE: /* fall through */
+ case ID_IM: /* fall through */
+ case ID_WO: /* fall through */
+ case ID_LA: /* fall through */
+ case ID_OB: /* fall through */
+ case ID_GR: /* fall through */
+ case ID_SCE: /* fall through */
+ new_prv = MEM_callocN(sizeof(PreviewImage), "newpreview");
+ BLI_linklist_prepend(&previews, new_prv);
+ tot++;
+ looking = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ else if (bhead->code == DATA) {
+ if (looking) {
+ if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage")) {
+ prv = BLO_library_read_struct(fd, bhead, "PreviewImage");
+ if (prv) {
+ memcpy(new_prv, prv, sizeof(PreviewImage));
+ if (prv->rect[0] && prv->w[0] && prv->h[0]) {
+ bhead = blo_bhead_next(fd, bhead);
+ BLI_assert((new_prv->w[0] * new_prv->h[0] * sizeof(uint)) == bhead->len);
+ new_prv->rect[0] = BLO_library_read_struct(fd, bhead, "PreviewImage Icon Rect");
+ }
+ else {
+ /* This should not be needed, but can happen in 'broken' .blend files,
+ * better handle this gracefully than crashing. */
+ BLI_assert(prv->rect[0] == NULL && prv->w[0] == 0 && prv->h[0] == 0);
+ new_prv->rect[0] = NULL;
+ new_prv->w[0] = new_prv->h[0] = 0;
+ }
+
+ if (prv->rect[1] && prv->w[1] && prv->h[1]) {
+ bhead = blo_bhead_next(fd, bhead);
+ BLI_assert((new_prv->w[1] * new_prv->h[1] * sizeof(uint)) == bhead->len);
+ new_prv->rect[1] = BLO_library_read_struct(fd, bhead, "PreviewImage Image Rect");
+ }
+ else {
+ /* This should not be needed, but can happen in 'broken' .blend files,
+ * better handle this gracefully than crashing. */
+ BLI_assert(prv->rect[1] == NULL && prv->w[1] == 0 && prv->h[1] == 0);
+ new_prv->rect[1] = NULL;
+ new_prv->w[1] = new_prv->h[1] = 0;
+ }
+ MEM_freeN(prv);
+ }
+ }
+ }
+ }
+ else if (bhead->code == ENDB) {
+ break;
+ }
+ else {
+ looking = 0;
+ new_prv = NULL;
+ prv = NULL;
+ }
+ }
+
+ *tot_prev = tot;
+ return previews;
}
/**
@@ -252,29 +254,29 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
*/
LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
{
- FileData *fd = (FileData *)bh;
- GSet *gathered = BLI_gset_ptr_new("linkable_groups gh");
- LinkNode *names = NULL;
- BHead *bhead;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ENDB) {
- break;
- }
- else if (BKE_idcode_is_valid(bhead->code)) {
- if (BKE_idcode_is_linkable(bhead->code)) {
- const char *str = BKE_idcode_to_name(bhead->code);
-
- if (BLI_gset_add(gathered, (void *)str)) {
- BLI_linklist_prepend(&names, strdup(str));
- }
- }
- }
- }
-
- BLI_gset_free(gathered, NULL);
-
- return names;
+ FileData *fd = (FileData *)bh;
+ GSet *gathered = BLI_gset_ptr_new("linkable_groups gh");
+ LinkNode *names = NULL;
+ BHead *bhead;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == ENDB) {
+ break;
+ }
+ else if (BKE_idcode_is_valid(bhead->code)) {
+ if (BKE_idcode_is_linkable(bhead->code)) {
+ const char *str = BKE_idcode_to_name(bhead->code);
+
+ if (BLI_gset_add(gathered, (void *)str)) {
+ BLI_linklist_prepend(&names, strdup(str));
+ }
+ }
+ }
+ }
+
+ BLI_gset_free(gathered, NULL);
+
+ return names;
}
/**
@@ -284,9 +286,9 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
*/
void BLO_blendhandle_close(BlendHandle *bh)
{
- FileData *fd = (FileData *)bh;
+ FileData *fd = (FileData *)bh;
- blo_filedata_free(fd);
+ blo_filedata_free(fd);
}
/**********/
@@ -299,23 +301,22 @@ void BLO_blendhandle_close(BlendHandle *bh)
* \param reports: If the return value is NULL, errors indicating the cause of the failure.
* \return The data of the file.
*/
-BlendFileData *BLO_read_from_file(
- const char *filepath,
- eBLOReadSkip skip_flags,
- ReportList *reports)
+BlendFileData *BLO_read_from_file(const char *filepath,
+ eBLOReadSkip skip_flags,
+ ReportList *reports)
{
- BlendFileData *bfd = NULL;
- FileData *fd;
-
- fd = blo_filedata_from_file(filepath, reports);
- if (fd) {
- fd->reports = reports;
- fd->skip_flags = skip_flags;
- bfd = blo_read_file_internal(fd, filepath);
- blo_filedata_free(fd);
- }
-
- return bfd;
+ BlendFileData *bfd = NULL;
+ FileData *fd;
+
+ fd = blo_filedata_from_file(filepath, reports);
+ if (fd) {
+ fd->reports = reports;
+ fd->skip_flags = skip_flags;
+ bfd = blo_read_file_internal(fd, filepath);
+ blo_filedata_free(fd);
+ }
+
+ return bfd;
}
/**
@@ -327,23 +328,23 @@ BlendFileData *BLO_read_from_file(
* \param reports: If the return value is NULL, errors indicating the cause of the failure.
* \return The data of the file.
*/
-BlendFileData *BLO_read_from_memory(
- const void *mem, int memsize,
- eBLOReadSkip skip_flags,
- ReportList *reports)
+BlendFileData *BLO_read_from_memory(const void *mem,
+ int memsize,
+ eBLOReadSkip skip_flags,
+ ReportList *reports)
{
- BlendFileData *bfd = NULL;
- FileData *fd;
-
- fd = blo_filedata_from_memory(mem, memsize, reports);
- if (fd) {
- fd->reports = reports;
- fd->skip_flags = skip_flags;
- bfd = blo_read_file_internal(fd, "");
- blo_filedata_free(fd);
- }
-
- return bfd;
+ BlendFileData *bfd = NULL;
+ FileData *fd;
+
+ fd = blo_filedata_from_memory(mem, memsize, reports);
+ if (fd) {
+ fd->reports = reports;
+ fd->skip_flags = skip_flags;
+ bfd = blo_read_file_internal(fd, "");
+ blo_filedata_free(fd);
+ }
+
+ return bfd;
}
/**
@@ -352,100 +353,101 @@ BlendFileData *BLO_read_from_memory(
* \param oldmain: old main, from which we will keep libraries and other datablocks that should not have changed.
* \param filename: current file, only for retrieving library data.
*/
-BlendFileData *BLO_read_from_memfile(
- Main *oldmain, const char *filename, MemFile *memfile,
- eBLOReadSkip skip_flags,
- ReportList *reports)
+BlendFileData *BLO_read_from_memfile(Main *oldmain,
+ const char *filename,
+ MemFile *memfile,
+ eBLOReadSkip skip_flags,
+ ReportList *reports)
{
- BlendFileData *bfd = NULL;
- FileData *fd;
- ListBase old_mainlist;
+ BlendFileData *bfd = NULL;
+ FileData *fd;
+ ListBase old_mainlist;
- fd = blo_filedata_from_memfile(memfile, reports);
- if (fd) {
- fd->reports = reports;
- fd->skip_flags = skip_flags;
- BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase));
+ fd = blo_filedata_from_memfile(memfile, reports);
+ if (fd) {
+ fd->reports = reports;
+ fd->skip_flags = skip_flags;
+ BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase));
- /* clear ob->proxy_from pointers in old main */
- blo_clear_proxy_pointers_from_lib(oldmain);
+ /* clear ob->proxy_from pointers in old main */
+ blo_clear_proxy_pointers_from_lib(oldmain);
- /* separate libraries from old main */
- blo_split_main(&old_mainlist, oldmain);
- /* add the library pointers in oldmap lookup */
- blo_add_library_pointer_map(&old_mainlist, fd);
+ /* separate libraries from old main */
+ blo_split_main(&old_mainlist, oldmain);
+ /* add the library pointers in oldmap lookup */
+ blo_add_library_pointer_map(&old_mainlist, fd);
- /* makes lookup of existing images in old main */
- blo_make_image_pointer_map(fd, oldmain);
+ /* makes lookup of existing images in old main */
+ blo_make_image_pointer_map(fd, oldmain);
- /* makes lookup of existing light caches in old main */
- blo_make_scene_pointer_map(fd, oldmain);
+ /* makes lookup of existing light caches in old main */
+ blo_make_scene_pointer_map(fd, oldmain);
- /* makes lookup of existing video clips in old main */
- blo_make_movieclip_pointer_map(fd, oldmain);
+ /* makes lookup of existing video clips in old main */
+ blo_make_movieclip_pointer_map(fd, oldmain);
- /* make lookups of existing sound data in old main */
- blo_make_sound_pointer_map(fd, oldmain);
+ /* make lookups of existing sound data in old main */
+ blo_make_sound_pointer_map(fd, oldmain);
- /* removed packed data from this trick - it's internal data that needs saves */
+ /* removed packed data from this trick - it's internal data that needs saves */
- bfd = blo_read_file_internal(fd, filename);
+ bfd = blo_read_file_internal(fd, filename);
- /* ensures relinked light caches are not freed */
- blo_end_scene_pointer_map(fd, oldmain);
+ /* ensures relinked light caches are not freed */
+ blo_end_scene_pointer_map(fd, oldmain);
- /* ensures relinked images are not freed */
- blo_end_image_pointer_map(fd, oldmain);
+ /* ensures relinked images are not freed */
+ blo_end_image_pointer_map(fd, oldmain);
- /* ensures relinked movie clips are not freed */
- blo_end_movieclip_pointer_map(fd, oldmain);
+ /* ensures relinked movie clips are not freed */
+ blo_end_movieclip_pointer_map(fd, oldmain);
- /* ensures relinked sounds are not freed */
- blo_end_sound_pointer_map(fd, oldmain);
+ /* ensures relinked sounds are not freed */
+ blo_end_sound_pointer_map(fd, oldmain);
- /* Still in-use libraries have already been moved from oldmain to new mainlist,
- * but oldmain itself shall *never* be 'transferred' to new mainlist! */
- BLI_assert(old_mainlist.first == oldmain);
+ /* Still in-use libraries have already been moved from oldmain to new mainlist,
+ * but oldmain itself shall *never* be 'transferred' to new mainlist! */
+ BLI_assert(old_mainlist.first == oldmain);
- if (bfd && old_mainlist.first != old_mainlist.last) {
- /* Even though directly used libs have been already moved to new main, indirect ones have not.
- * This is a bit annoying, but we have no choice but to keep them all for now - means some now unused
- * data may remain in memory, but think we'll have to live with it. */
- Main *libmain, *libmain_next;
- Main *newmain = bfd->main;
- ListBase new_mainlist = {newmain, newmain};
+ if (bfd && old_mainlist.first != old_mainlist.last) {
+ /* Even though directly used libs have been already moved to new main, indirect ones have not.
+ * This is a bit annoying, but we have no choice but to keep them all for now - means some now unused
+ * data may remain in memory, but think we'll have to live with it. */
+ Main *libmain, *libmain_next;
+ Main *newmain = bfd->main;
+ ListBase new_mainlist = {newmain, newmain};
- for (libmain = oldmain->next; libmain; libmain = libmain_next) {
- libmain_next = libmain->next;
- /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent
- * to detect indirect-linked ones... */
- if (libmain->curlib && (libmain->curlib->parent != NULL)) {
- BLI_remlink(&old_mainlist, libmain);
- BLI_addtail(&new_mainlist, libmain);
- }
- else {
+ for (libmain = oldmain->next; libmain; libmain = libmain_next) {
+ libmain_next = libmain->next;
+ /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent
+ * to detect indirect-linked ones... */
+ if (libmain->curlib && (libmain->curlib->parent != NULL)) {
+ BLI_remlink(&old_mainlist, libmain);
+ BLI_addtail(&new_mainlist, libmain);
+ }
+ else {
#ifdef PRINT_DEBUG
- printf("Dropped Main for lib: %s\n", libmain->curlib->id.name);
+ printf("Dropped Main for lib: %s\n", libmain->curlib->id.name);
#endif
- }
- }
- /* In any case, we need to move all lib datablocks themselves - those are 'first level data',
- * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */
- BLI_movelisttolist(&newmain->libraries, &oldmain->libraries);
+ }
+ }
+ /* In any case, we need to move all lib datablocks themselves - those are 'first level data',
+ * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */
+ BLI_movelisttolist(&newmain->libraries, &oldmain->libraries);
- blo_join_main(&new_mainlist);
- }
+ blo_join_main(&new_mainlist);
+ }
- /* printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1); */
+ /* printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1); */
- /* That way, libs (aka mains) we did not reuse in new undone/redone state
- * will be cleared together with oldmain... */
- blo_join_main(&old_mainlist);
+ /* That way, libs (aka mains) we did not reuse in new undone/redone state
+ * will be cleared together with oldmain... */
+ blo_join_main(&old_mainlist);
- blo_filedata_free(fd);
- }
+ blo_filedata_free(fd);
+ }
- return bfd;
+ return bfd;
}
/**
@@ -455,13 +457,13 @@ BlendFileData *BLO_read_from_memfile(
*/
void BLO_blendfiledata_free(BlendFileData *bfd)
{
- if (bfd->main) {
- BKE_main_free(bfd->main);
- }
+ if (bfd->main) {
+ BKE_main_free(bfd->main);
+ }
- if (bfd->user) {
- MEM_freeN(bfd->user);
- }
+ if (bfd->user) {
+ MEM_freeN(bfd->user);
+ }
- MEM_freeN(bfd);
+ MEM_freeN(bfd);
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2543271e691..e05edfdd44e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -24,21 +24,21 @@
#include "zlib.h"
#include <limits.h>
-#include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
-#include <stdlib.h> // for getenv atoi
-#include <stddef.h> // for offsetof
-#include <fcntl.h> // for open
-#include <string.h> // for strrchr strncmp strstr
-#include <math.h> // for fabs
-#include <stdarg.h> /* for va_start/end */
-#include <time.h> /* for gmtime */
-#include <ctype.h> /* for isdigit */
+#include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
+#include <stdlib.h> // for getenv atoi
+#include <stddef.h> // for offsetof
+#include <fcntl.h> // for open
+#include <string.h> // for strrchr strncmp strstr
+#include <math.h> // for fabs
+#include <stdarg.h> /* for va_start/end */
+#include <time.h> /* for gmtime */
+#include <ctype.h> /* for isdigit */
#include "BLI_utildefines.h"
#ifndef WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> // for read close
#else
-# include <io.h> // for open close read
+# include <io.h> // for open close read
# include "winsock2.h"
# include "BLI_winstuff.h"
#endif
@@ -119,7 +119,7 @@
#include "BKE_curve.h"
#include "BKE_effect.h"
#include "BKE_fcurve.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" // for G
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_idcode.h"
@@ -129,13 +129,13 @@
#include "BKE_library_idmap.h"
#include "BKE_library_override.h"
#include "BKE_library_query.h"
-#include "BKE_main.h" // for Main
+#include "BKE_main.h" // for Main
#include "BKE_material.h"
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
-#include "BKE_node.h" // for tree type defines
+#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
#include "BKE_ocean.h"
#include "BKE_outliner_treehash.h"
@@ -242,7 +242,6 @@
# define DEBUG_PRINTF(...)
#endif
-
/* local prototypes */
static void read_libraries(FileData *basefd, ListBase *mainlist);
static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
@@ -257,22 +256,21 @@ static void direct_link_animdata(FileData *fd, AnimData *adt);
static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt);
typedef struct BHeadN {
- struct BHeadN *next, *prev;
+ struct BHeadN *next, *prev;
#ifdef USE_BHEAD_READ_ON_DEMAND
- /** Use to read the data from the file directly into memory as needed. */
- off64_t file_offset;
- /** When set, the remainder of this allocation is the data, otherwise it needs to be read. */
- bool has_data;
+ /** Use to read the data from the file directly into memory as needed. */
+ off64_t file_offset;
+ /** When set, the remainder of this allocation is the data, otherwise it needs to be read. */
+ bool has_data;
#endif
- struct BHead bhead;
+ struct BHead bhead;
} BHeadN;
#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -offsetof(BHeadN, bhead)))
/* We could change this in the future, for now it's simplest if only data is delayed
* because ID names are used in lookup tables. */
-#define BHEAD_USE_READ_ON_DEMAND(bhead) \
- ((bhead)->code == DATA)
+#define BHEAD_USE_READ_ON_DEMAND(bhead) ((bhead)->code == DATA)
/* this function ensures that reports are printed,
* in the case of libraray linking errors this is important!
@@ -283,27 +281,27 @@ typedef struct BHeadN {
void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
{
- char fixed_buf[1024]; /* should be long enough */
+ char fixed_buf[1024]; /* should be long enough */
- va_list args;
+ va_list args;
- va_start(args, format);
- vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
- va_end(args);
+ va_start(args, format);
+ vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
+ va_end(args);
- fixed_buf[sizeof(fixed_buf) - 1] = '\0';
+ fixed_buf[sizeof(fixed_buf) - 1] = '\0';
- BKE_report(reports, type, fixed_buf);
+ BKE_report(reports, type, fixed_buf);
- if (G.background == 0) {
- printf("%s: %s\n", BKE_report_type_str(type), fixed_buf);
- }
+ if (G.background == 0) {
+ printf("%s: %s\n", BKE_report_type_str(type), fixed_buf);
+ }
}
/* for reporting linking messages */
static const char *library_parent_filepath(Library *lib)
{
- return lib->parent ? lib->parent->filepath : "<direct>";
+ return lib->parent ? lib->parent->filepath : "<direct>";
}
/* -------------------------------------------------------------------- */
@@ -311,20 +309,20 @@ static const char *library_parent_filepath(Library *lib)
* \{ */
typedef struct OldNew {
- const void *oldp;
- void *newp;
- /* `nr` is "user count" for data, and ID code for libdata. */
- int nr;
+ const void *oldp;
+ void *newp;
+ /* `nr` is "user count" for data, and ID code for libdata. */
+ int nr;
} OldNew;
typedef struct OldNewMap {
- /* Array that stores the actual entries. */
- OldNew *entries;
- int nentries;
- /* Hashmap that stores indices into the `entries` array. */
- int32_t *map;
+ /* Array that stores the actual entries. */
+ OldNew *entries;
+ int nentries;
+ /* Hashmap that stores indices into the `entries` array. */
+ int32_t *map;
- int capacity_exp;
+ int capacity_exp;
} OldNewMap;
#define ENTRIES_CAPACITY(onm) (1 << (onm)->capacity_exp)
@@ -335,147 +333,158 @@ typedef struct OldNewMap {
/* based on the probing algorithm used in Python dicts. */
#define ITER_SLOTS(onm, KEY, SLOT_NAME, INDEX_NAME) \
- uint32_t hash = BLI_ghashutil_ptrhash(KEY); \
- uint32_t mask = SLOT_MASK(onm); \
- uint perturb = hash; \
- int SLOT_NAME = mask & hash; \
- int INDEX_NAME = onm->map[SLOT_NAME]; \
- for (;;SLOT_NAME = mask & ((5 * SLOT_NAME) + 1 + perturb), perturb >>= PERTURB_SHIFT, INDEX_NAME = onm->map[SLOT_NAME])
+ uint32_t hash = BLI_ghashutil_ptrhash(KEY); \
+ uint32_t mask = SLOT_MASK(onm); \
+ uint perturb = hash; \
+ int SLOT_NAME = mask & hash; \
+ int INDEX_NAME = onm->map[SLOT_NAME]; \
+ for (;; SLOT_NAME = mask & ((5 * SLOT_NAME) + 1 + perturb), \
+ perturb >>= PERTURB_SHIFT, \
+ INDEX_NAME = onm->map[SLOT_NAME])
static void oldnewmap_insert_index_in_map(OldNewMap *onm, const void *ptr, int index)
{
- ITER_SLOTS(onm, ptr, slot, stored_index) {
- if (stored_index == -1) {
- onm->map[slot] = index;
- break;
- }
- }
+ ITER_SLOTS(onm, ptr, slot, stored_index)
+ {
+ if (stored_index == -1) {
+ onm->map[slot] = index;
+ break;
+ }
+ }
}
static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
{
- ITER_SLOTS(onm, entry.oldp, slot, index) {
- if (index == -1) {
- onm->entries[onm->nentries] = entry;
- onm->map[slot] = onm->nentries;
- onm->nentries++;
- break;
- }
- else if (onm->entries[index].oldp == entry.oldp) {
- onm->entries[index] = entry;
- break;
- }
- }
+ ITER_SLOTS(onm, entry.oldp, slot, index)
+ {
+ if (index == -1) {
+ onm->entries[onm->nentries] = entry;
+ onm->map[slot] = onm->nentries;
+ onm->nentries++;
+ break;
+ }
+ else if (onm->entries[index].oldp == entry.oldp) {
+ onm->entries[index] = entry;
+ break;
+ }
+ }
}
static OldNew *oldnewmap_lookup_entry(const OldNewMap *onm, const void *addr)
{
- ITER_SLOTS(onm, addr, slot, index) {
- if (index >= 0) {
- OldNew *entry = &onm->entries[index];
- if (entry->oldp == addr) {
- return entry;
- }
- }
- else {
- return NULL;
- }
- }
+ ITER_SLOTS(onm, addr, slot, index)
+ {
+ if (index >= 0) {
+ OldNew *entry = &onm->entries[index];
+ if (entry->oldp == addr) {
+ return entry;
+ }
+ }
+ else {
+ return NULL;
+ }
+ }
}
static void oldnewmap_clear_map(OldNewMap *onm)
{
- memset(onm->map, 0xFF, MAP_CAPACITY(onm) * sizeof(*onm->map));
+ memset(onm->map, 0xFF, MAP_CAPACITY(onm) * sizeof(*onm->map));
}
static void oldnewmap_increase_size(OldNewMap *onm)
{
- onm->capacity_exp++;
- onm->entries = MEM_reallocN(onm->entries, sizeof(*onm->entries) * ENTRIES_CAPACITY(onm));
- onm->map = MEM_reallocN(onm->map, sizeof(*onm->map) * MAP_CAPACITY(onm));
- oldnewmap_clear_map(onm);
- for (int i = 0; i < onm->nentries; i++) {
- oldnewmap_insert_index_in_map(onm, onm->entries[i].oldp, i);
- }
+ onm->capacity_exp++;
+ onm->entries = MEM_reallocN(onm->entries, sizeof(*onm->entries) * ENTRIES_CAPACITY(onm));
+ onm->map = MEM_reallocN(onm->map, sizeof(*onm->map) * MAP_CAPACITY(onm));
+ oldnewmap_clear_map(onm);
+ for (int i = 0; i < onm->nentries; i++) {
+ oldnewmap_insert_index_in_map(onm, onm->entries[i].oldp, i);
+ }
}
-
/* Public OldNewMap API */
static OldNewMap *oldnewmap_new(void)
{
- OldNewMap *onm = MEM_callocN(sizeof(*onm), "OldNewMap");
+ OldNewMap *onm = MEM_callocN(sizeof(*onm), "OldNewMap");
- onm->capacity_exp = DEFAULT_SIZE_EXP;
- onm->entries = MEM_malloc_arrayN(ENTRIES_CAPACITY(onm), sizeof(*onm->entries), "OldNewMap.entries");
- onm->map = MEM_malloc_arrayN(MAP_CAPACITY(onm), sizeof(*onm->map), "OldNewMap.map");
- oldnewmap_clear_map(onm);
+ onm->capacity_exp = DEFAULT_SIZE_EXP;
+ onm->entries = MEM_malloc_arrayN(
+ ENTRIES_CAPACITY(onm), sizeof(*onm->entries), "OldNewMap.entries");
+ onm->map = MEM_malloc_arrayN(MAP_CAPACITY(onm), sizeof(*onm->map), "OldNewMap.map");
+ oldnewmap_clear_map(onm);
- return onm;
+ return onm;
}
static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
{
- if (oldaddr == NULL || newaddr == NULL) return;
+ if (oldaddr == NULL || newaddr == NULL)
+ return;
- if (UNLIKELY(onm->nentries == ENTRIES_CAPACITY(onm))) {
- oldnewmap_increase_size(onm);
- }
+ if (UNLIKELY(onm->nentries == ENTRIES_CAPACITY(onm))) {
+ oldnewmap_increase_size(onm);
+ }
- OldNew entry;
- entry.oldp = oldaddr;
- entry.newp = newaddr;
- entry.nr = nr;
- oldnewmap_insert_or_replace(onm, entry);
+ OldNew entry;
+ entry.oldp = oldaddr;
+ entry.newp = newaddr;
+ entry.nr = nr;
+ oldnewmap_insert_or_replace(onm, entry);
}
void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
{
- oldnewmap_insert(onm, oldaddr, newaddr, nr);
+ oldnewmap_insert(onm, oldaddr, newaddr, nr);
}
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool increase_users)
{
- OldNew *entry = oldnewmap_lookup_entry(onm, addr);
- if (entry == NULL) return NULL;
- if (increase_users) entry->nr++;
- return entry->newp;
+ OldNew *entry = oldnewmap_lookup_entry(onm, addr);
+ if (entry == NULL)
+ return NULL;
+ if (increase_users)
+ entry->nr++;
+ return entry->newp;
}
/* for libdata, OldNew.nr has ID code, no increment */
static void *oldnewmap_liblookup(OldNewMap *onm, const void *addr, const void *lib)
{
- if (addr == NULL) return NULL;
+ if (addr == NULL)
+ return NULL;
- ID *id = oldnewmap_lookup_and_inc(onm, addr, false);
- if (id == NULL) return NULL;
- if (!lib || id->lib) return id;
- return NULL;
+ ID *id = oldnewmap_lookup_and_inc(onm, addr, false);
+ if (id == NULL)
+ return NULL;
+ if (!lib || id->lib)
+ return id;
+ return NULL;
}
static void oldnewmap_free_unused(OldNewMap *onm)
{
- for (int i = 0; i < onm->nentries; i++) {
- OldNew *entry = &onm->entries[i];
- if (entry->nr == 0) {
- MEM_freeN(entry->newp);
- entry->newp = NULL;
- }
- }
+ for (int i = 0; i < onm->nentries; i++) {
+ OldNew *entry = &onm->entries[i];
+ if (entry->nr == 0) {
+ MEM_freeN(entry->newp);
+ entry->newp = NULL;
+ }
+ }
}
static void oldnewmap_clear(OldNewMap *onm)
{
- onm->capacity_exp = DEFAULT_SIZE_EXP;
- oldnewmap_clear_map(onm);
- onm->nentries = 0;
+ onm->capacity_exp = DEFAULT_SIZE_EXP;
+ oldnewmap_clear_map(onm);
+ onm->nentries = 0;
}
static void oldnewmap_free(OldNewMap *onm)
{
- MEM_freeN(onm->entries);
- MEM_freeN(onm->map);
- MEM_freeN(onm);
+ MEM_freeN(onm->entries);
+ MEM_freeN(onm->map);
+ MEM_freeN(onm);
}
#undef ENTRIES_CAPACITY
@@ -493,188 +502,189 @@ static void oldnewmap_free(OldNewMap *onm)
static void add_main_to_main(Main *mainvar, Main *from)
{
- ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
- int a;
+ ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
+ int a;
- set_listbasepointers(mainvar, lbarray);
- a = set_listbasepointers(from, fromarray);
- while (a--) {
- BLI_movelisttolist(lbarray[a], fromarray[a]);
- }
+ set_listbasepointers(mainvar, lbarray);
+ a = set_listbasepointers(from, fromarray);
+ while (a--) {
+ BLI_movelisttolist(lbarray[a], fromarray[a]);
+ }
}
void blo_join_main(ListBase *mainlist)
{
- Main *tojoin, *mainl;
+ Main *tojoin, *mainl;
- mainl = mainlist->first;
- while ((tojoin = mainl->next)) {
- add_main_to_main(mainl, tojoin);
- BLI_remlink(mainlist, tojoin);
- BKE_main_free(tojoin);
- }
+ mainl = mainlist->first;
+ while ((tojoin = mainl->next)) {
+ add_main_to_main(mainl, tojoin);
+ BLI_remlink(mainlist, tojoin);
+ BKE_main_free(tojoin);
+ }
}
static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint lib_main_array_len)
{
- for (ID *id = lb_src->first, *idnext; id; id = idnext) {
- idnext = id->next;
-
- if (id->lib) {
- if (((uint)id->lib->temp_index < lib_main_array_len) &&
- /* this check should never fail, just incase 'id->lib' is a dangling pointer. */
- (lib_main_array[id->lib->temp_index]->curlib == id->lib))
- {
- Main *mainvar = lib_main_array[id->lib->temp_index];
- ListBase *lb_dst = which_libbase(mainvar, GS(id->name));
- BLI_remlink(lb_src, id);
- BLI_addtail(lb_dst, id);
- }
- else {
- printf("%s: invalid library for '%s'\n", __func__, id->name);
- BLI_assert(0);
- }
- }
- }
+ for (ID *id = lb_src->first, *idnext; id; id = idnext) {
+ idnext = id->next;
+
+ if (id->lib) {
+ if (((uint)id->lib->temp_index < lib_main_array_len) &&
+ /* this check should never fail, just incase 'id->lib' is a dangling pointer. */
+ (lib_main_array[id->lib->temp_index]->curlib == id->lib)) {
+ Main *mainvar = lib_main_array[id->lib->temp_index];
+ ListBase *lb_dst = which_libbase(mainvar, GS(id->name));
+ BLI_remlink(lb_src, id);
+ BLI_addtail(lb_dst, id);
+ }
+ else {
+ printf("%s: invalid library for '%s'\n", __func__, id->name);
+ BLI_assert(0);
+ }
+ }
+ }
}
void blo_split_main(ListBase *mainlist, Main *main)
{
- mainlist->first = mainlist->last = main;
- main->next = NULL;
+ mainlist->first = mainlist->last = main;
+ main->next = NULL;
- if (BLI_listbase_is_empty(&main->libraries))
- return;
+ if (BLI_listbase_is_empty(&main->libraries))
+ return;
- /* (Library.temp_index -> Main), lookup table */
- const uint lib_main_array_len = BLI_listbase_count(&main->libraries);
- Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__);
+ /* (Library.temp_index -> Main), lookup table */
+ const uint lib_main_array_len = BLI_listbase_count(&main->libraries);
+ Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__);
- int i = 0;
- for (Library *lib = main->libraries.first; lib; lib = lib->id.next, i++) {
- Main *libmain = BKE_main_new();
- libmain->curlib = lib;
- libmain->versionfile = lib->versionfile;
- libmain->subversionfile = lib->subversionfile;
- BLI_addtail(mainlist, libmain);
- lib->temp_index = i;
- lib_main_array[i] = libmain;
- }
+ int i = 0;
+ for (Library *lib = main->libraries.first; lib; lib = lib->id.next, i++) {
+ Main *libmain = BKE_main_new();
+ libmain->curlib = lib;
+ libmain->versionfile = lib->versionfile;
+ libmain->subversionfile = lib->subversionfile;
+ BLI_addtail(mainlist, libmain);
+ lib->temp_index = i;
+ lib_main_array[i] = libmain;
+ }
- ListBase *lbarray[MAX_LIBARRAY];
- i = set_listbasepointers(main, lbarray);
- while (i--) {
- ID *id = lbarray[i]->first;
- if (id == NULL || GS(id->name) == ID_LI) {
- continue; /* no ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */
- }
- split_libdata(lbarray[i], lib_main_array, lib_main_array_len);
- }
+ ListBase *lbarray[MAX_LIBARRAY];
+ i = set_listbasepointers(main, lbarray);
+ while (i--) {
+ ID *id = lbarray[i]->first;
+ if (id == NULL || GS(id->name) == ID_LI) {
+ continue; /* no ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */
+ }
+ split_libdata(lbarray[i], lib_main_array, lib_main_array_len);
+ }
- MEM_freeN(lib_main_array);
+ MEM_freeN(lib_main_array);
}
static void read_file_version(FileData *fd, Main *main)
{
- BHead *bhead;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == GLOB) {
- FileGlobal *fg = read_struct(fd, bhead, "Global");
- if (fg) {
- main->subversionfile = fg->subversion;
- main->minversionfile = fg->minversion;
- main->minsubversionfile = fg->minsubversion;
- MEM_freeN(fg);
- }
- else if (bhead->code == ENDB)
- break;
- }
- }
- if (main->curlib) {
- main->curlib->versionfile = main->versionfile;
- main->curlib->subversionfile = main->subversionfile;
- }
+ BHead *bhead;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == GLOB) {
+ FileGlobal *fg = read_struct(fd, bhead, "Global");
+ if (fg) {
+ main->subversionfile = fg->subversion;
+ main->minversionfile = fg->minversion;
+ main->minsubversionfile = fg->minsubversion;
+ MEM_freeN(fg);
+ }
+ else if (bhead->code == ENDB)
+ break;
+ }
+ }
+ if (main->curlib) {
+ main->curlib->versionfile = main->versionfile;
+ main->curlib->subversionfile = main->subversionfile;
+ }
}
#ifdef USE_GHASH_BHEAD
static void read_file_bhead_idname_map_create(FileData *fd)
{
- BHead *bhead;
+ BHead *bhead;
- /* dummy values */
- bool is_link = false;
- int code_prev = ENDB;
- uint reserve = 0;
+ /* dummy values */
+ bool is_link = false;
+ int code_prev = ENDB;
+ uint reserve = 0;
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (code_prev != bhead->code) {
- code_prev = bhead->code;
- is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
- }
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (code_prev != bhead->code) {
+ code_prev = bhead->code;
+ is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
+ }
- if (is_link) {
- reserve += 1;
- }
- }
+ if (is_link) {
+ reserve += 1;
+ }
+ }
- BLI_assert(fd->bhead_idname_hash == NULL);
+ BLI_assert(fd->bhead_idname_hash == NULL);
- fd->bhead_idname_hash = BLI_ghash_str_new_ex(__func__, reserve);
+ fd->bhead_idname_hash = BLI_ghash_str_new_ex(__func__, reserve);
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (code_prev != bhead->code) {
- code_prev = bhead->code;
- is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
- }
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (code_prev != bhead->code) {
+ code_prev = bhead->code;
+ is_link = BKE_idcode_is_valid(code_prev) ? BKE_idcode_is_linkable(code_prev) : false;
+ }
- if (is_link) {
- BLI_ghash_insert(fd->bhead_idname_hash, (void *)blo_bhead_id_name(fd, bhead), bhead);
- }
- }
+ if (is_link) {
+ BLI_ghash_insert(fd->bhead_idname_hash, (void *)blo_bhead_id_name(fd, bhead), bhead);
+ }
+ }
}
#endif
-
static Main *blo_find_main(FileData *fd, const char *filepath, const char *relabase)
{
- ListBase *mainlist = fd->mainlist;
- Main *m;
- Library *lib;
- char name1[FILE_MAX];
+ ListBase *mainlist = fd->mainlist;
+ Main *m;
+ Library *lib;
+ char name1[FILE_MAX];
- BLI_strncpy(name1, filepath, sizeof(name1));
- BLI_cleanup_path(relabase, name1);
+ BLI_strncpy(name1, filepath, sizeof(name1));
+ BLI_cleanup_path(relabase, name1);
-// printf("blo_find_main: relabase %s\n", relabase);
-// printf("blo_find_main: original in %s\n", filepath);
-// printf("blo_find_main: converted to %s\n", name1);
+ // printf("blo_find_main: relabase %s\n", relabase);
+ // printf("blo_find_main: original in %s\n", filepath);
+ // printf("blo_find_main: converted to %s\n", name1);
- for (m = mainlist->first; m; m = m->next) {
- const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
+ for (m = mainlist->first; m; m = m->next) {
+ const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
- if (BLI_path_cmp(name1, libname) == 0) {
- if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
- return m;
- }
- }
+ if (BLI_path_cmp(name1, libname) == 0) {
+ if (G.debug & G_DEBUG)
+ printf("blo_find_main: found library %s\n", libname);
+ return m;
+ }
+ }
- m = BKE_main_new();
- BLI_addtail(mainlist, m);
+ m = BKE_main_new();
+ BLI_addtail(mainlist, m);
- /* Add library datablock itself to 'main' Main, since libraries are **never** linked data.
- * Fixes bug where you could end with all ID_LI datablocks having the same name... */
- lib = BKE_libblock_alloc(mainlist->first, ID_LI, BLI_path_basename(filepath), 0);
- lib->id.us = ID_FAKE_USERS(lib); /* Important, consistency with main ID reading code from read_libblock(). */
- BLI_strncpy(lib->name, filepath, sizeof(lib->name));
- BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
+ /* Add library datablock itself to 'main' Main, since libraries are **never** linked data.
+ * Fixes bug where you could end with all ID_LI datablocks having the same name... */
+ lib = BKE_libblock_alloc(mainlist->first, ID_LI, BLI_path_basename(filepath), 0);
+ lib->id.us = ID_FAKE_USERS(
+ lib); /* Important, consistency with main ID reading code from read_libblock(). */
+ BLI_strncpy(lib->name, filepath, sizeof(lib->name));
+ BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
- m->curlib = lib;
+ m->curlib = lib;
- read_file_version(fd, m);
+ read_file_version(fd, m);
- if (G.debug & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath);
- return m;
+ if (G.debug & G_DEBUG)
+ printf("blo_find_main: added new lib %s\n", filepath);
+ return m;
}
/** \} */
@@ -685,340 +695,339 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
static void switch_endian_bh4(BHead4 *bhead)
{
- /* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0) bhead->code >>= 16;
+ /* the ID_.. codes */
+ if ((bhead->code & 0xFFFF) == 0)
+ bhead->code >>= 16;
- if (bhead->code != ENDB) {
- BLI_endian_switch_int32(&bhead->len);
- BLI_endian_switch_int32(&bhead->SDNAnr);
- BLI_endian_switch_int32(&bhead->nr);
- }
+ if (bhead->code != ENDB) {
+ BLI_endian_switch_int32(&bhead->len);
+ BLI_endian_switch_int32(&bhead->SDNAnr);
+ BLI_endian_switch_int32(&bhead->nr);
+ }
}
static void switch_endian_bh8(BHead8 *bhead)
{
- /* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0) bhead->code >>= 16;
+ /* the ID_.. codes */
+ if ((bhead->code & 0xFFFF) == 0)
+ bhead->code >>= 16;
- if (bhead->code != ENDB) {
- BLI_endian_switch_int32(&bhead->len);
- BLI_endian_switch_int32(&bhead->SDNAnr);
- BLI_endian_switch_int32(&bhead->nr);
- }
+ if (bhead->code != ENDB) {
+ BLI_endian_switch_int32(&bhead->len);
+ BLI_endian_switch_int32(&bhead->SDNAnr);
+ BLI_endian_switch_int32(&bhead->nr);
+ }
}
static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
{
- BHead4 *bhead4 = (BHead4 *)bhead;
- int64_t old;
+ BHead4 *bhead4 = (BHead4 *)bhead;
+ int64_t old;
- bhead4->code = bhead8->code;
- bhead4->len = bhead8->len;
+ bhead4->code = bhead8->code;
+ bhead4->len = bhead8->len;
- if (bhead4->code != ENDB) {
- /* perform a endian swap on 64bit pointers, otherwise the pointer might map to zero
- * 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000
- */
- if (do_endian_swap) {
- BLI_endian_switch_int64(&bhead8->old);
- }
+ if (bhead4->code != ENDB) {
+ /* perform a endian swap on 64bit pointers, otherwise the pointer might map to zero
+ * 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000
+ */
+ if (do_endian_swap) {
+ BLI_endian_switch_int64(&bhead8->old);
+ }
- /* this patch is to avoid a long long being read from not-eight aligned positions
- * is necessary on any modern 64bit architecture) */
- memcpy(&old, &bhead8->old, 8);
- bhead4->old = (int)(old >> 3);
+ /* this patch is to avoid a long long being read from not-eight aligned positions
+ * is necessary on any modern 64bit architecture) */
+ memcpy(&old, &bhead8->old, 8);
+ bhead4->old = (int)(old >> 3);
- bhead4->SDNAnr = bhead8->SDNAnr;
- bhead4->nr = bhead8->nr;
- }
+ bhead4->SDNAnr = bhead8->SDNAnr;
+ bhead4->nr = bhead8->nr;
+ }
}
static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
{
- BHead8 *bhead8 = (BHead8 *)bhead;
+ BHead8 *bhead8 = (BHead8 *)bhead;
- bhead8->code = bhead4->code;
- bhead8->len = bhead4->len;
+ bhead8->code = bhead4->code;
+ bhead8->len = bhead4->len;
- if (bhead8->code != ENDB) {
- bhead8->old = bhead4->old;
- bhead8->SDNAnr = bhead4->SDNAnr;
- bhead8->nr = bhead4->nr;
- }
+ if (bhead8->code != ENDB) {
+ bhead8->old = bhead4->old;
+ bhead8->SDNAnr = bhead4->SDNAnr;
+ bhead8->nr = bhead4->nr;
+ }
}
static BHeadN *get_bhead(FileData *fd)
{
- BHeadN *new_bhead = NULL;
- int readsize;
-
- if (fd) {
- if (!fd->is_eof) {
- /* initializing to zero isn't strictly needed but shuts valgrind up
- * since uninitialized memory gets compared */
- BHead8 bhead8 = {0};
- BHead4 bhead4 = {0};
- BHead bhead = {0};
-
- /* First read the bhead structure.
- * Depending on the platform the file was written on this can
- * be a big or little endian BHead4 or BHead8 structure.
- *
- * As usual 'ENDB' (the last *partial* bhead of the file)
- * needs some special handling. We don't want to EOF just yet.
- */
- if (fd->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) {
- bhead4.code = DATA;
- readsize = fd->read(fd, &bhead4, sizeof(bhead4));
-
- if (readsize == sizeof(bhead4) || bhead4.code == ENDB) {
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- switch_endian_bh4(&bhead4);
- }
-
- if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
- bh8_from_bh4(&bhead, &bhead4);
- }
- else {
- /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
- BLI_assert(sizeof(bhead) == sizeof(bhead4));
- memcpy(&bhead, &bhead4, MIN2(sizeof(bhead), sizeof(bhead4)));
- }
- }
- else {
- fd->is_eof = true;
- bhead.len = 0;
- }
- }
- else {
- bhead8.code = DATA;
- readsize = fd->read(fd, &bhead8, sizeof(bhead8));
-
- if (readsize == sizeof(bhead8) || bhead8.code == ENDB) {
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- switch_endian_bh8(&bhead8);
- }
-
- if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
- bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
- }
- else {
- /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
- BLI_assert(sizeof(bhead) == sizeof(bhead8));
- memcpy(&bhead, &bhead8, MIN2(sizeof(bhead), sizeof(bhead8)));
- }
- }
- else {
- fd->is_eof = true;
- bhead.len = 0;
- }
- }
-
- /* make sure people are not trying to pass bad blend files */
- if (bhead.len < 0) {
- fd->is_eof = true;
- }
-
- /* bhead now contains the (converted) bhead structure. Now read
- * the associated data and put everything in a BHeadN (creative naming !)
- */
- if (fd->is_eof) {
- /* pass */
- }
+ BHeadN *new_bhead = NULL;
+ int readsize;
+
+ if (fd) {
+ if (!fd->is_eof) {
+ /* initializing to zero isn't strictly needed but shuts valgrind up
+ * since uninitialized memory gets compared */
+ BHead8 bhead8 = {0};
+ BHead4 bhead4 = {0};
+ BHead bhead = {0};
+
+ /* First read the bhead structure.
+ * Depending on the platform the file was written on this can
+ * be a big or little endian BHead4 or BHead8 structure.
+ *
+ * As usual 'ENDB' (the last *partial* bhead of the file)
+ * needs some special handling. We don't want to EOF just yet.
+ */
+ if (fd->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) {
+ bhead4.code = DATA;
+ readsize = fd->read(fd, &bhead4, sizeof(bhead4));
+
+ if (readsize == sizeof(bhead4) || bhead4.code == ENDB) {
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ switch_endian_bh4(&bhead4);
+ }
+
+ if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
+ bh8_from_bh4(&bhead, &bhead4);
+ }
+ else {
+ /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
+ BLI_assert(sizeof(bhead) == sizeof(bhead4));
+ memcpy(&bhead, &bhead4, MIN2(sizeof(bhead), sizeof(bhead4)));
+ }
+ }
+ else {
+ fd->is_eof = true;
+ bhead.len = 0;
+ }
+ }
+ else {
+ bhead8.code = DATA;
+ readsize = fd->read(fd, &bhead8, sizeof(bhead8));
+
+ if (readsize == sizeof(bhead8) || bhead8.code == ENDB) {
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ switch_endian_bh8(&bhead8);
+ }
+
+ if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
+ bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
+ }
+ else {
+ /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
+ BLI_assert(sizeof(bhead) == sizeof(bhead8));
+ memcpy(&bhead, &bhead8, MIN2(sizeof(bhead), sizeof(bhead8)));
+ }
+ }
+ else {
+ fd->is_eof = true;
+ bhead.len = 0;
+ }
+ }
+
+ /* make sure people are not trying to pass bad blend files */
+ if (bhead.len < 0) {
+ fd->is_eof = true;
+ }
+
+ /* bhead now contains the (converted) bhead structure. Now read
+ * the associated data and put everything in a BHeadN (creative naming !)
+ */
+ if (fd->is_eof) {
+ /* pass */
+ }
#ifdef USE_BHEAD_READ_ON_DEMAND
- else if (fd->seek != NULL && BHEAD_USE_READ_ON_DEMAND(&bhead)) {
- /* Delay reading bhead content. */
- new_bhead = MEM_mallocN(sizeof(BHeadN), "new_bhead");
- if (new_bhead) {
- new_bhead->next = new_bhead->prev = NULL;
- new_bhead->file_offset = fd->file_offset;
- new_bhead->has_data = false;
- new_bhead->bhead = bhead;
- off64_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
- if (seek_new == -1) {
- fd->is_eof = true;
- MEM_freeN(new_bhead);
- new_bhead = NULL;
- }
- BLI_assert(fd->file_offset == seek_new);
- }
- else {
- fd->is_eof = true;
- }
- }
+ else if (fd->seek != NULL && BHEAD_USE_READ_ON_DEMAND(&bhead)) {
+ /* Delay reading bhead content. */
+ new_bhead = MEM_mallocN(sizeof(BHeadN), "new_bhead");
+ if (new_bhead) {
+ new_bhead->next = new_bhead->prev = NULL;
+ new_bhead->file_offset = fd->file_offset;
+ new_bhead->has_data = false;
+ new_bhead->bhead = bhead;
+ off64_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
+ if (seek_new == -1) {
+ fd->is_eof = true;
+ MEM_freeN(new_bhead);
+ new_bhead = NULL;
+ }
+ BLI_assert(fd->file_offset == seek_new);
+ }
+ else {
+ fd->is_eof = true;
+ }
+ }
#endif
- else {
- new_bhead = MEM_mallocN(sizeof(BHeadN) + bhead.len, "new_bhead");
- if (new_bhead) {
- new_bhead->next = new_bhead->prev = NULL;
+ else {
+ new_bhead = MEM_mallocN(sizeof(BHeadN) + bhead.len, "new_bhead");
+ if (new_bhead) {
+ new_bhead->next = new_bhead->prev = NULL;
#ifdef USE_BHEAD_READ_ON_DEMAND
- new_bhead->file_offset = 0; /* don't seek. */
- new_bhead->has_data = true;
+ new_bhead->file_offset = 0; /* don't seek. */
+ new_bhead->has_data = true;
#endif
- new_bhead->bhead = bhead;
+ new_bhead->bhead = bhead;
- readsize = fd->read(fd, new_bhead + 1, bhead.len);
+ readsize = fd->read(fd, new_bhead + 1, bhead.len);
- if (readsize != bhead.len) {
- fd->is_eof = true;
- MEM_freeN(new_bhead);
- new_bhead = NULL;
- }
- }
- else {
- fd->is_eof = true;
- }
- }
- }
- }
+ if (readsize != bhead.len) {
+ fd->is_eof = true;
+ MEM_freeN(new_bhead);
+ new_bhead = NULL;
+ }
+ }
+ else {
+ fd->is_eof = true;
+ }
+ }
+ }
+ }
- /* We've read a new block. Now add it to the list
- * of blocks.
- */
- if (new_bhead) {
- BLI_addtail(&fd->bhead_list, new_bhead);
- }
+ /* We've read a new block. Now add it to the list
+ * of blocks.
+ */
+ if (new_bhead) {
+ BLI_addtail(&fd->bhead_list, new_bhead);
+ }
- return new_bhead;
+ return new_bhead;
}
BHead *blo_bhead_first(FileData *fd)
{
- BHeadN *new_bhead;
- BHead *bhead = NULL;
+ BHeadN *new_bhead;
+ BHead *bhead = NULL;
- /* Rewind the file
- * Read in a new block if necessary
- */
- new_bhead = fd->bhead_list.first;
- if (new_bhead == NULL) {
- new_bhead = get_bhead(fd);
- }
+ /* Rewind the file
+ * Read in a new block if necessary
+ */
+ new_bhead = fd->bhead_list.first;
+ if (new_bhead == NULL) {
+ new_bhead = get_bhead(fd);
+ }
- if (new_bhead) {
- bhead = &new_bhead->bhead;
- }
+ if (new_bhead) {
+ bhead = &new_bhead->bhead;
+ }
- return bhead;
+ return bhead;
}
BHead *blo_bhead_prev(FileData *UNUSED(fd), BHead *thisblock)
{
- BHeadN *bheadn = BHEADN_FROM_BHEAD(thisblock);
- BHeadN *prev = bheadn->prev;
+ BHeadN *bheadn = BHEADN_FROM_BHEAD(thisblock);
+ BHeadN *prev = bheadn->prev;
- return (prev) ? &prev->bhead : NULL;
+ return (prev) ? &prev->bhead : NULL;
}
BHead *blo_bhead_next(FileData *fd, BHead *thisblock)
{
- BHeadN *new_bhead = NULL;
- BHead *bhead = NULL;
+ BHeadN *new_bhead = NULL;
+ BHead *bhead = NULL;
- if (thisblock) {
- /* bhead is actually a sub part of BHeadN
- * We calculate the BHeadN pointer from the BHead pointer below */
- new_bhead = BHEADN_FROM_BHEAD(thisblock);
+ if (thisblock) {
+ /* bhead is actually a sub part of BHeadN
+ * We calculate the BHeadN pointer from the BHead pointer below */
+ new_bhead = BHEADN_FROM_BHEAD(thisblock);
- /* get the next BHeadN. If it doesn't exist we read in the next one */
- new_bhead = new_bhead->next;
- if (new_bhead == NULL) {
- new_bhead = get_bhead(fd);
- }
- }
+ /* get the next BHeadN. If it doesn't exist we read in the next one */
+ new_bhead = new_bhead->next;
+ if (new_bhead == NULL) {
+ new_bhead = get_bhead(fd);
+ }
+ }
- if (new_bhead) {
- /* here we do the reverse:
- * go from the BHeadN pointer to the BHead pointer */
- bhead = &new_bhead->bhead;
- }
+ if (new_bhead) {
+ /* here we do the reverse:
+ * go from the BHeadN pointer to the BHead pointer */
+ bhead = &new_bhead->bhead;
+ }
- return bhead;
+ return bhead;
}
#ifdef USE_BHEAD_READ_ON_DEMAND
static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
{
- bool success = true;
- BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
- BLI_assert(new_bhead->has_data == false && new_bhead->file_offset != 0);
- off64_t offset_backup = fd->file_offset;
- if (UNLIKELY(fd->seek(fd, new_bhead->file_offset, SEEK_SET) == -1)) {
- success = false;
- }
- else {
- if (fd->read(fd, buf, new_bhead->bhead.len) != new_bhead->bhead.len) {
- success = false;
- }
- }
- if (fd->seek(fd, offset_backup, SEEK_SET) == -1) {
- success = false;
- }
- return success;
+ bool success = true;
+ BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
+ BLI_assert(new_bhead->has_data == false && new_bhead->file_offset != 0);
+ off64_t offset_backup = fd->file_offset;
+ if (UNLIKELY(fd->seek(fd, new_bhead->file_offset, SEEK_SET) == -1)) {
+ success = false;
+ }
+ else {
+ if (fd->read(fd, buf, new_bhead->bhead.len) != new_bhead->bhead.len) {
+ success = false;
+ }
+ }
+ if (fd->seek(fd, offset_backup, SEEK_SET) == -1) {
+ success = false;
+ }
+ return success;
}
static BHead *blo_bhead_read_full(FileData *fd, BHead *thisblock)
{
- BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
- BHeadN *new_bhead_data = MEM_mallocN(sizeof(BHeadN) + new_bhead->bhead.len, "new_bhead");
- new_bhead_data->bhead = new_bhead->bhead;
- new_bhead_data->file_offset = new_bhead->file_offset;
- new_bhead_data->has_data = true;
- if (!blo_bhead_read_data(fd, thisblock, new_bhead_data + 1)) {
- MEM_freeN(new_bhead_data);
- return NULL;
- }
- return &new_bhead_data->bhead;
+ BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
+ BHeadN *new_bhead_data = MEM_mallocN(sizeof(BHeadN) + new_bhead->bhead.len, "new_bhead");
+ new_bhead_data->bhead = new_bhead->bhead;
+ new_bhead_data->file_offset = new_bhead->file_offset;
+ new_bhead_data->has_data = true;
+ if (!blo_bhead_read_data(fd, thisblock, new_bhead_data + 1)) {
+ MEM_freeN(new_bhead_data);
+ return NULL;
+ }
+ return &new_bhead_data->bhead;
}
-#endif /* USE_BHEAD_READ_ON_DEMAND */
+#endif /* USE_BHEAD_READ_ON_DEMAND */
/* Warning! Caller's responsibility to ensure given bhead **is** and ID one! */
const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead)
{
- return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_name_offs);
+ return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_name_offs);
}
static void decode_blender_header(FileData *fd)
{
- char header[SIZEOFBLENDERHEADER], num[4];
- int readsize;
-
- /* read in the header data */
- readsize = fd->read(fd, header, sizeof(header));
-
- if (readsize == sizeof(header) &&
- STREQLEN(header, "BLENDER", 7) &&
- ELEM(header[7], '_', '-') &&
- ELEM(header[8], 'v', 'V') &&
- (isdigit(header[9]) && isdigit(header[10]) && isdigit(header[11])))
- {
- fd->flags |= FD_FLAGS_FILE_OK;
-
- /* what size are pointers in the file ? */
- if (header[7] == '_') {
- fd->flags |= FD_FLAGS_FILE_POINTSIZE_IS_4;
- if (sizeof(void *) != 4) {
- fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
- }
- }
- else {
- if (sizeof(void *) != 8) {
- fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
- }
- }
-
- /* is the file saved in a different endian
- * than we need ?
- */
- if (((header[8] == 'v') ? L_ENDIAN : B_ENDIAN) != ENDIAN_ORDER) {
- fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
- }
-
- /* get the version number */
- memcpy(num, header + 9, 3);
- num[3] = 0;
- fd->fileversion = atoi(num);
- }
+ char header[SIZEOFBLENDERHEADER], num[4];
+ int readsize;
+
+ /* read in the header data */
+ readsize = fd->read(fd, header, sizeof(header));
+
+ if (readsize == sizeof(header) && STREQLEN(header, "BLENDER", 7) && ELEM(header[7], '_', '-') &&
+ ELEM(header[8], 'v', 'V') &&
+ (isdigit(header[9]) && isdigit(header[10]) && isdigit(header[11]))) {
+ fd->flags |= FD_FLAGS_FILE_OK;
+
+ /* what size are pointers in the file ? */
+ if (header[7] == '_') {
+ fd->flags |= FD_FLAGS_FILE_POINTSIZE_IS_4;
+ if (sizeof(void *) != 4) {
+ fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
+ }
+ }
+ else {
+ if (sizeof(void *) != 8) {
+ fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
+ }
+ }
+
+ /* is the file saved in a different endian
+ * than we need ?
+ */
+ if (((header[8] == 'v') ? L_ENDIAN : B_ENDIAN) != ENDIAN_ORDER) {
+ fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
+ }
+
+ /* get the version number */
+ memcpy(num, header + 9, 3);
+ num[3] = 0;
+ fd->fileversion = atoi(num);
+ }
}
/**
@@ -1026,88 +1035,88 @@ static void decode_blender_header(FileData *fd)
*/
static bool read_file_dna(FileData *fd, const char **r_error_message)
{
- BHead *bhead;
- int subversion = 0;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == GLOB) {
- /* Before this, the subversion didn't exist in 'FileGlobal' so the subversion
- * value isn't accessible for the purpose of DNA versioning in this case. */
- if (fd->fileversion <= 242) {
- continue;
- }
- /* We can't use read_global because this needs 'DNA1' to be decoded,
- * however the first 4 chars are _always_ the subversion. */
- FileGlobal *fg = (void *)&bhead[1];
- BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr");
- char num[5];
- memcpy(num, fg->subvstr, 4);
- num[4] = 0;
- subversion = atoi(num);
- }
- else if (bhead->code == DNA1) {
- const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
-
- fd->filesdna = DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap, true, r_error_message);
- if (fd->filesdna) {
- blo_do_versions_dna(fd->filesdna, fd->fileversion, subversion);
- fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
- /* used to retrieve ID names from (bhead+1) */
- fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
-
- return true;
- }
- else {
- return false;
- }
-
- }
- else if (bhead->code == ENDB)
- break;
- }
-
- *r_error_message = "Missing DNA block";
- return false;
+ BHead *bhead;
+ int subversion = 0;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == GLOB) {
+ /* Before this, the subversion didn't exist in 'FileGlobal' so the subversion
+ * value isn't accessible for the purpose of DNA versioning in this case. */
+ if (fd->fileversion <= 242) {
+ continue;
+ }
+ /* We can't use read_global because this needs 'DNA1' to be decoded,
+ * however the first 4 chars are _always_ the subversion. */
+ FileGlobal *fg = (void *)&bhead[1];
+ BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr");
+ char num[5];
+ memcpy(num, fg->subvstr, 4);
+ num[4] = 0;
+ subversion = atoi(num);
+ }
+ else if (bhead->code == DNA1) {
+ const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
+
+ fd->filesdna = DNA_sdna_from_data(
+ &bhead[1], bhead->len, do_endian_swap, true, r_error_message);
+ if (fd->filesdna) {
+ blo_do_versions_dna(fd->filesdna, fd->fileversion, subversion);
+ fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
+ /* used to retrieve ID names from (bhead+1) */
+ fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
+
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else if (bhead->code == ENDB)
+ break;
+ }
+
+ *r_error_message = "Missing DNA block";
+ return false;
}
static int *read_file_thumbnail(FileData *fd)
{
- BHead *bhead;
- int *blend_thumb = NULL;
+ BHead *bhead;
+ int *blend_thumb = NULL;
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == TEST) {
- const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
- int *data = (int *)(bhead + 1);
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == TEST) {
+ const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
+ int *data = (int *)(bhead + 1);
- if (bhead->len < (2 * sizeof(int))) {
- break;
- }
+ if (bhead->len < (2 * sizeof(int))) {
+ break;
+ }
- if (do_endian_swap) {
- BLI_endian_switch_int32(&data[0]);
- BLI_endian_switch_int32(&data[1]);
- }
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&data[0]);
+ BLI_endian_switch_int32(&data[1]);
+ }
- const int width = data[0];
- const int height = data[1];
- if (!BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
- break;
- }
- if (bhead->len < BLEN_THUMB_MEMSIZE_FILE(width, height)) {
- break;
- }
+ const int width = data[0];
+ const int height = data[1];
+ if (!BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
+ break;
+ }
+ if (bhead->len < BLEN_THUMB_MEMSIZE_FILE(width, height)) {
+ break;
+ }
- blend_thumb = data;
- break;
- }
- else if (bhead->code != REND) {
- /* Thumbnail is stored in TEST immediately after first REND... */
- break;
- }
- }
+ blend_thumb = data;
+ break;
+ }
+ else if (bhead->code != REND) {
+ /* Thumbnail is stored in TEST immediately after first REND... */
+ break;
+ }
+ }
- return blend_thumb;
+ return blend_thumb;
}
/** \} */
@@ -1120,245 +1129,256 @@ static int *read_file_thumbnail(FileData *fd)
static int fd_read_data_from_file(FileData *filedata, void *buffer, uint size)
{
- int readsize = read(filedata->filedes, buffer, size);
+ int readsize = read(filedata->filedes, buffer, size);
- if (readsize < 0) {
- readsize = EOF;
- }
- else {
- filedata->file_offset += readsize;
- }
+ if (readsize < 0) {
+ readsize = EOF;
+ }
+ else {
+ filedata->file_offset += readsize;
+ }
- return (readsize);
+ return (readsize);
}
static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence)
{
- filedata->file_offset = lseek(filedata->filedes, offset, whence);
- return filedata->file_offset;
+ filedata->file_offset = lseek(filedata->filedes, offset, whence);
+ return filedata->file_offset;
}
/* GZip file reading. */
static int fd_read_gzip_from_file(FileData *filedata, void *buffer, uint size)
{
- int readsize = gzread(filedata->gzfiledes, buffer, size);
+ int readsize = gzread(filedata->gzfiledes, buffer, size);
- if (readsize < 0) {
- readsize = EOF;
- }
- else {
- filedata->file_offset += readsize;
- }
+ if (readsize < 0) {
+ readsize = EOF;
+ }
+ else {
+ filedata->file_offset += readsize;
+ }
- return (readsize);
+ return (readsize);
}
/* Memory reading. */
static int fd_read_from_memory(FileData *filedata, void *buffer, uint size)
{
- /* don't read more bytes then there are available in the buffer */
- int readsize = (int)MIN2(size, (uint)(filedata->buffersize - filedata->file_offset));
+ /* don't read more bytes then there are available in the buffer */
+ int readsize = (int)MIN2(size, (uint)(filedata->buffersize - filedata->file_offset));
- memcpy(buffer, filedata->buffer + filedata->file_offset, readsize);
- filedata->file_offset += readsize;
+ memcpy(buffer, filedata->buffer + filedata->file_offset, readsize);
+ filedata->file_offset += readsize;
- return (readsize);
+ return (readsize);
}
/* MemFile reading. */
static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
{
- static size_t seek = SIZE_MAX; /* the current position */
- static size_t offset = 0; /* size of previous chunks */
- static MemFileChunk *chunk = NULL;
- size_t chunkoffset, readsize, totread;
-
- if (size == 0) return 0;
-
- if (seek != (size_t)filedata->file_offset) {
- chunk = filedata->memfile->chunks.first;
- seek = 0;
-
- while (chunk) {
- if (seek + chunk->size > (size_t)filedata->file_offset) {
- break;
- }
- seek += chunk->size;
- chunk = chunk->next;
- }
- offset = seek;
- seek = filedata->file_offset;
- }
-
- if (chunk) {
- totread = 0;
-
- do {
- /* first check if it's on the end if current chunk */
- if (seek - offset == chunk->size) {
- offset += chunk->size;
- chunk = chunk->next;
- }
-
- /* debug, should never happen */
- if (chunk == NULL) {
- printf("illegal read, chunk zero\n");
- return 0;
- }
-
- chunkoffset = seek - offset;
- readsize = size - totread;
-
- /* data can be spread over multiple chunks, so clamp size
- * to within this chunk, and then it will read further in
- * the next chunk */
- if (chunkoffset + readsize > chunk->size)
- readsize = chunk->size - chunkoffset;
-
- memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
- totread += readsize;
- filedata->file_offset += readsize;
- seek += readsize;
- } while (totread < size);
-
- return totread;
- }
-
- return 0;
+ static size_t seek = SIZE_MAX; /* the current position */
+ static size_t offset = 0; /* size of previous chunks */
+ static MemFileChunk *chunk = NULL;
+ size_t chunkoffset, readsize, totread;
+
+ if (size == 0)
+ return 0;
+
+ if (seek != (size_t)filedata->file_offset) {
+ chunk = filedata->memfile->chunks.first;
+ seek = 0;
+
+ while (chunk) {
+ if (seek + chunk->size > (size_t)filedata->file_offset) {
+ break;
+ }
+ seek += chunk->size;
+ chunk = chunk->next;
+ }
+ offset = seek;
+ seek = filedata->file_offset;
+ }
+
+ if (chunk) {
+ totread = 0;
+
+ do {
+ /* first check if it's on the end if current chunk */
+ if (seek - offset == chunk->size) {
+ offset += chunk->size;
+ chunk = chunk->next;
+ }
+
+ /* debug, should never happen */
+ if (chunk == NULL) {
+ printf("illegal read, chunk zero\n");
+ return 0;
+ }
+
+ chunkoffset = seek - offset;
+ readsize = size - totread;
+
+ /* data can be spread over multiple chunks, so clamp size
+ * to within this chunk, and then it will read further in
+ * the next chunk */
+ if (chunkoffset + readsize > chunk->size)
+ readsize = chunk->size - chunkoffset;
+
+ memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
+ totread += readsize;
+ filedata->file_offset += readsize;
+ seek += readsize;
+ } while (totread < size);
+
+ return totread;
+ }
+
+ return 0;
}
static FileData *filedata_new(void)
{
- FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
+ FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
- fd->filedes = -1;
- fd->gzfiledes = NULL;
+ fd->filedes = -1;
+ fd->gzfiledes = NULL;
- fd->memsdna = DNA_sdna_current_get();
+ fd->memsdna = DNA_sdna_current_get();
- fd->datamap = oldnewmap_new();
- fd->globmap = oldnewmap_new();
- fd->libmap = oldnewmap_new();
+ fd->datamap = oldnewmap_new();
+ fd->globmap = oldnewmap_new();
+ fd->libmap = oldnewmap_new();
- return fd;
+ return fd;
}
static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
{
- decode_blender_header(fd);
-
- if (fd->flags & FD_FLAGS_FILE_OK) {
- const char *error_message = NULL;
- if (read_file_dna(fd, &error_message) == false) {
- BKE_reportf(reports, RPT_ERROR,
- "Failed to read blend file '%s': %s",
- fd->relabase, error_message);
- blo_filedata_free(fd);
- fd = NULL;
- }
- }
- else {
- BKE_reportf(reports, RPT_ERROR, "Failed to read blend file '%s', not a blend file", fd->relabase);
- blo_filedata_free(fd);
- fd = NULL;
- }
-
- return fd;
-}
-
-static FileData *blo_filedata_from_file_descriptor(const char *filepath, ReportList *reports, int file)
-{
- FileDataReadFn *read_fn = NULL;
- FileDataSeekFn *seek_fn = NULL; /* Optional. */
-
- gzFile gzfile = (gzFile)Z_NULL;
-
- char header[7];
-
- /* Regular file. */
- errno = 0;
- if (read(file, header, sizeof(header)) != sizeof(header)) {
- BKE_reportf(reports, RPT_WARNING, "Unable to read '%s': %s",
- filepath, errno ? strerror(errno) : TIP_("insufficient content"));
- return NULL;
- }
- else {
- lseek(file, 0, SEEK_SET);
- }
-
- /* Regular file. */
- if (memcmp(header, "BLENDER", sizeof(header)) == 0) {
- read_fn = fd_read_data_from_file;
- seek_fn = fd_seek_data_from_file;
- }
-
- /* Gzip file. */
- errno = 0;
- if ((read_fn == NULL) &&
- /* Check header magic. */
- (header[0] == 0x1f && header[1] == 0x8b))
- {
- gzfile = BLI_gzopen(filepath, "rb");
- if (gzfile == (gzFile)Z_NULL) {
- BKE_reportf(reports, RPT_WARNING, "Unable to open '%s': %s",
- filepath, errno ? strerror(errno) : TIP_("unknown error reading file"));
- return NULL;
- }
- else {
- /* 'seek_fn' is too slow for gzip, don't set it. */
- read_fn = fd_read_gzip_from_file;
- /* Caller must close. */
- file = -1;
- }
- }
-
- if (read_fn == NULL) {
- BKE_reportf(reports, RPT_WARNING, "Unrecognized file format '%s'", filepath);
- return NULL;
- }
-
- FileData *fd = filedata_new();
-
- fd->filedes = file;
- fd->gzfiledes = gzfile;
-
- fd->read = read_fn;
- fd->seek = seek_fn;
-
- return fd;
+ decode_blender_header(fd);
+
+ if (fd->flags & FD_FLAGS_FILE_OK) {
+ const char *error_message = NULL;
+ if (read_file_dna(fd, &error_message) == false) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Failed to read blend file '%s': %s", fd->relabase, error_message);
+ blo_filedata_free(fd);
+ fd = NULL;
+ }
+ }
+ else {
+ BKE_reportf(
+ reports, RPT_ERROR, "Failed to read blend file '%s', not a blend file", fd->relabase);
+ blo_filedata_free(fd);
+ fd = NULL;
+ }
+
+ return fd;
+}
+
+static FileData *blo_filedata_from_file_descriptor(const char *filepath,
+ ReportList *reports,
+ int file)
+{
+ FileDataReadFn *read_fn = NULL;
+ FileDataSeekFn *seek_fn = NULL; /* Optional. */
+
+ gzFile gzfile = (gzFile)Z_NULL;
+
+ char header[7];
+
+ /* Regular file. */
+ errno = 0;
+ if (read(file, header, sizeof(header)) != sizeof(header)) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Unable to read '%s': %s",
+ filepath,
+ errno ? strerror(errno) : TIP_("insufficient content"));
+ return NULL;
+ }
+ else {
+ lseek(file, 0, SEEK_SET);
+ }
+
+ /* Regular file. */
+ if (memcmp(header, "BLENDER", sizeof(header)) == 0) {
+ read_fn = fd_read_data_from_file;
+ seek_fn = fd_seek_data_from_file;
+ }
+
+ /* Gzip file. */
+ errno = 0;
+ if ((read_fn == NULL) &&
+ /* Check header magic. */
+ (header[0] == 0x1f && header[1] == 0x8b)) {
+ gzfile = BLI_gzopen(filepath, "rb");
+ if (gzfile == (gzFile)Z_NULL) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Unable to open '%s': %s",
+ filepath,
+ errno ? strerror(errno) : TIP_("unknown error reading file"));
+ return NULL;
+ }
+ else {
+ /* 'seek_fn' is too slow for gzip, don't set it. */
+ read_fn = fd_read_gzip_from_file;
+ /* Caller must close. */
+ file = -1;
+ }
+ }
+
+ if (read_fn == NULL) {
+ BKE_reportf(reports, RPT_WARNING, "Unrecognized file format '%s'", filepath);
+ return NULL;
+ }
+
+ FileData *fd = filedata_new();
+
+ fd->filedes = file;
+ fd->gzfiledes = gzfile;
+
+ fd->read = read_fn;
+ fd->seek = seek_fn;
+
+ return fd;
}
static FileData *blo_filedata_from_file_open(const char *filepath, ReportList *reports)
{
- errno = 0;
- const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
- if (file == -1) {
- BKE_reportf(reports, RPT_WARNING, "Unable to open '%s': %s",
- filepath, errno ? strerror(errno) : TIP_("unknown error reading file"));
- return NULL;
- }
- FileData *fd = blo_filedata_from_file_descriptor(filepath, reports, file);
- if ((fd == NULL) || (fd->filedes == -1)) {
- close(file);
- }
- return fd;
+ errno = 0;
+ const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
+ if (file == -1) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Unable to open '%s': %s",
+ filepath,
+ errno ? strerror(errno) : TIP_("unknown error reading file"));
+ return NULL;
+ }
+ FileData *fd = blo_filedata_from_file_descriptor(filepath, reports, file);
+ if ((fd == NULL) || (fd->filedes == -1)) {
+ close(file);
+ }
+ return fd;
}
/* cannot be called with relative paths anymore! */
/* on each new library added, it now checks for the current FileData and expands relativeness */
FileData *blo_filedata_from_file(const char *filepath, ReportList *reports)
{
- FileData *fd = blo_filedata_from_file_open(filepath, reports);
- if (fd != NULL) {
- /* needed for library_append and read_libraries */
- BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
+ FileData *fd = blo_filedata_from_file_open(filepath, reports);
+ if (fd != NULL) {
+ /* needed for library_append and read_libraries */
+ BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
- return blo_decode_and_check(fd, reports);
- }
- return NULL;
+ return blo_decode_and_check(fd, reports);
+ }
+ return NULL;
}
/**
@@ -1367,171 +1387,171 @@ FileData *blo_filedata_from_file(const char *filepath, ReportList *reports)
*/
static FileData *blo_filedata_from_file_minimal(const char *filepath)
{
- FileData *fd = blo_filedata_from_file_open(filepath, NULL);
- if (fd != NULL) {
- decode_blender_header(fd);
- if (fd->flags & FD_FLAGS_FILE_OK) {
- return fd;
- }
- blo_filedata_free(fd);
- }
- return NULL;
+ FileData *fd = blo_filedata_from_file_open(filepath, NULL);
+ if (fd != NULL) {
+ decode_blender_header(fd);
+ if (fd->flags & FD_FLAGS_FILE_OK) {
+ return fd;
+ }
+ blo_filedata_free(fd);
+ }
+ return NULL;
}
static int fd_read_gzip_from_memory(FileData *filedata, void *buffer, uint size)
{
- int err;
+ int err;
- filedata->strm.next_out = (Bytef *)buffer;
- filedata->strm.avail_out = size;
+ filedata->strm.next_out = (Bytef *)buffer;
+ filedata->strm.avail_out = size;
- // Inflate another chunk.
- err = inflate(&filedata->strm, Z_SYNC_FLUSH);
+ // Inflate another chunk.
+ err = inflate(&filedata->strm, Z_SYNC_FLUSH);
- if (err == Z_STREAM_END) {
- return 0;
- }
- else if (err != Z_OK) {
- printf("fd_read_gzip_from_memory: zlib error\n");
- return 0;
- }
+ if (err == Z_STREAM_END) {
+ return 0;
+ }
+ else if (err != Z_OK) {
+ printf("fd_read_gzip_from_memory: zlib error\n");
+ return 0;
+ }
- filedata->file_offset += size;
+ filedata->file_offset += size;
- return (size);
+ return (size);
}
static int fd_read_gzip_from_memory_init(FileData *fd)
{
- fd->strm.next_in = (Bytef *)fd->buffer;
- fd->strm.avail_in = fd->buffersize;
- fd->strm.total_out = 0;
- fd->strm.zalloc = Z_NULL;
- fd->strm.zfree = Z_NULL;
+ fd->strm.next_in = (Bytef *)fd->buffer;
+ fd->strm.avail_in = fd->buffersize;
+ fd->strm.total_out = 0;
+ fd->strm.zalloc = Z_NULL;
+ fd->strm.zfree = Z_NULL;
- if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK)
- return 0;
+ if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK)
+ return 0;
- fd->read = fd_read_gzip_from_memory;
+ fd->read = fd_read_gzip_from_memory;
- return 1;
+ return 1;
}
FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *reports)
{
- if (!mem || memsize < SIZEOFBLENDERHEADER) {
- BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
- return NULL;
- }
- else {
- FileData *fd = filedata_new();
- const char *cp = mem;
+ if (!mem || memsize < SIZEOFBLENDERHEADER) {
+ BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
+ return NULL;
+ }
+ else {
+ FileData *fd = filedata_new();
+ const char *cp = mem;
- fd->buffer = mem;
- fd->buffersize = memsize;
+ fd->buffer = mem;
+ fd->buffersize = memsize;
- /* test if gzip */
- if (cp[0] == 0x1f && cp[1] == 0x8b) {
- if (0 == fd_read_gzip_from_memory_init(fd)) {
- blo_filedata_free(fd);
- return NULL;
- }
- }
- else
- fd->read = fd_read_from_memory;
+ /* test if gzip */
+ if (cp[0] == 0x1f && cp[1] == 0x8b) {
+ if (0 == fd_read_gzip_from_memory_init(fd)) {
+ blo_filedata_free(fd);
+ return NULL;
+ }
+ }
+ else
+ fd->read = fd_read_from_memory;
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
- }
+ return blo_decode_and_check(fd, reports);
+ }
}
FileData *blo_filedata_from_memfile(MemFile *memfile, ReportList *reports)
{
- if (!memfile) {
- BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
- return NULL;
- }
- else {
- FileData *fd = filedata_new();
- fd->memfile = memfile;
+ if (!memfile) {
+ BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
+ return NULL;
+ }
+ else {
+ FileData *fd = filedata_new();
+ fd->memfile = memfile;
- fd->read = fd_read_from_memfile;
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ fd->read = fd_read_from_memfile;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
- }
+ return blo_decode_and_check(fd, reports);
+ }
}
-
void blo_filedata_free(FileData *fd)
{
- if (fd) {
- if (fd->filedes != -1) {
- close(fd->filedes);
- }
+ if (fd) {
+ if (fd->filedes != -1) {
+ close(fd->filedes);
+ }
- if (fd->gzfiledes != NULL) {
- gzclose(fd->gzfiledes);
- }
+ if (fd->gzfiledes != NULL) {
+ gzclose(fd->gzfiledes);
+ }
- if (fd->strm.next_in) {
- if (inflateEnd(&fd->strm) != Z_OK) {
- printf("close gzip stream error\n");
- }
- }
+ if (fd->strm.next_in) {
+ if (inflateEnd(&fd->strm) != Z_OK) {
+ printf("close gzip stream error\n");
+ }
+ }
- if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) {
- MEM_freeN((void *)fd->buffer);
- fd->buffer = NULL;
- }
+ if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) {
+ MEM_freeN((void *)fd->buffer);
+ fd->buffer = NULL;
+ }
- /* Free all BHeadN data blocks */
+ /* Free all BHeadN data blocks */
#ifndef NDEBUG
- BLI_freelistN(&fd->bhead_list);
+ BLI_freelistN(&fd->bhead_list);
#else
- /* Sanity check we're not keeping memory we don't need. */
- LISTBASE_FOREACH_MUTABLE (BHeadN *, new_bhead, &fd->bhead_list) {
- if (fd->seek != NULL && BHEAD_USE_READ_ON_DEMAND(&new_bhead->bhead)) {
- BLI_assert(new_bhead->has_data == 0);
- }
- MEM_freeN(new_bhead);
- }
+ /* Sanity check we're not keeping memory we don't need. */
+ LISTBASE_FOREACH_MUTABLE(BHeadN *, new_bhead, &fd->bhead_list)
+ {
+ if (fd->seek != NULL && BHEAD_USE_READ_ON_DEMAND(&new_bhead->bhead)) {
+ BLI_assert(new_bhead->has_data == 0);
+ }
+ MEM_freeN(new_bhead);
+ }
#endif
- if (fd->filesdna)
- DNA_sdna_free(fd->filesdna);
- if (fd->compflags)
- MEM_freeN((void *)fd->compflags);
-
- if (fd->datamap)
- oldnewmap_free(fd->datamap);
- if (fd->globmap)
- oldnewmap_free(fd->globmap);
- if (fd->imamap)
- oldnewmap_free(fd->imamap);
- if (fd->movieclipmap)
- oldnewmap_free(fd->movieclipmap);
- if (fd->scenemap)
- oldnewmap_free(fd->scenemap);
- if (fd->soundmap)
- oldnewmap_free(fd->soundmap);
- if (fd->packedmap)
- oldnewmap_free(fd->packedmap);
- if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
- oldnewmap_free(fd->libmap);
- if (fd->bheadmap)
- MEM_freeN(fd->bheadmap);
+ if (fd->filesdna)
+ DNA_sdna_free(fd->filesdna);
+ if (fd->compflags)
+ MEM_freeN((void *)fd->compflags);
+
+ if (fd->datamap)
+ oldnewmap_free(fd->datamap);
+ if (fd->globmap)
+ oldnewmap_free(fd->globmap);
+ if (fd->imamap)
+ oldnewmap_free(fd->imamap);
+ if (fd->movieclipmap)
+ oldnewmap_free(fd->movieclipmap);
+ if (fd->scenemap)
+ oldnewmap_free(fd->scenemap);
+ if (fd->soundmap)
+ oldnewmap_free(fd->soundmap);
+ if (fd->packedmap)
+ oldnewmap_free(fd->packedmap);
+ if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
+ oldnewmap_free(fd->libmap);
+ if (fd->bheadmap)
+ MEM_freeN(fd->bheadmap);
#ifdef USE_GHASH_BHEAD
- if (fd->bhead_idname_hash) {
- BLI_ghash_free(fd->bhead_idname_hash, NULL, NULL);
- }
+ if (fd->bhead_idname_hash) {
+ BLI_ghash_free(fd->bhead_idname_hash, NULL, NULL);
+ }
#endif
- MEM_freeN(fd);
- }
+ MEM_freeN(fd);
+ }
}
/** \} */
@@ -1549,8 +1569,8 @@ void blo_filedata_free(FileData *fd)
*/
bool BLO_has_bfile_extension(const char *str)
{
- const char *ext_test[4] = {".blend", ".ble", ".blend.gz", NULL};
- return BLI_path_extension_check_array(str, ext_test);
+ const char *ext_test[4] = {".blend", ".ble", ".blend.gz", NULL};
+ return BLI_path_extension_check_array(str, ext_test);
}
/**
@@ -1566,61 +1586,61 @@ bool BLO_has_bfile_extension(const char *str)
*/
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
{
- /* We might get some data names with slashes, so we have to go up in path until we find blend file itself,
- * then we now next path item is group, and everything else is data name. */
- char *slash = NULL, *prev_slash = NULL, c = '\0';
-
- r_dir[0] = '\0';
- if (r_group) {
- *r_group = NULL;
- }
- if (r_name) {
- *r_name = NULL;
- }
-
- /* if path leads to an existing directory, we can be sure we're not (in) a library */
- if (BLI_is_dir(path)) {
- return false;
- }
-
- strcpy(r_dir, path);
-
- while ((slash = (char *)BLI_last_slash(r_dir))) {
- char tc = *slash;
- *slash = '\0';
- if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
- break;
- }
- else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
- break;
- }
-
- if (prev_slash) {
- *prev_slash = c;
- }
- prev_slash = slash;
- c = tc;
- }
-
- if (!slash) {
- return false;
- }
-
- if (slash[1] != '\0') {
- BLI_assert(strlen(slash + 1) < BLO_GROUP_MAX);
- if (r_group) {
- *r_group = slash + 1;
- }
- }
-
- if (prev_slash && (prev_slash[1] != '\0')) {
- BLI_assert(strlen(prev_slash + 1) < MAX_ID_NAME - 2);
- if (r_name) {
- *r_name = prev_slash + 1;
- }
- }
-
- return true;
+ /* We might get some data names with slashes, so we have to go up in path until we find blend file itself,
+ * then we now next path item is group, and everything else is data name. */
+ char *slash = NULL, *prev_slash = NULL, c = '\0';
+
+ r_dir[0] = '\0';
+ if (r_group) {
+ *r_group = NULL;
+ }
+ if (r_name) {
+ *r_name = NULL;
+ }
+
+ /* if path leads to an existing directory, we can be sure we're not (in) a library */
+ if (BLI_is_dir(path)) {
+ return false;
+ }
+
+ strcpy(r_dir, path);
+
+ while ((slash = (char *)BLI_last_slash(r_dir))) {
+ char tc = *slash;
+ *slash = '\0';
+ if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
+ break;
+ }
+ else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
+ break;
+ }
+
+ if (prev_slash) {
+ *prev_slash = c;
+ }
+ prev_slash = slash;
+ c = tc;
+ }
+
+ if (!slash) {
+ return false;
+ }
+
+ if (slash[1] != '\0') {
+ BLI_assert(strlen(slash + 1) < BLO_GROUP_MAX);
+ if (r_group) {
+ *r_group = slash + 1;
+ }
+ }
+
+ if (prev_slash && (prev_slash[1] != '\0')) {
+ BLI_assert(strlen(prev_slash + 1) < MAX_ID_NAME - 2);
+ if (r_name) {
+ *r_name = prev_slash + 1;
+ }
+ }
+
+ return true;
}
/**
@@ -1632,31 +1652,32 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
*/
BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
{
- FileData *fd;
- BlendThumbnail *data = NULL;
- int *fd_data;
+ FileData *fd;
+ BlendThumbnail *data = NULL;
+ int *fd_data;
- fd = blo_filedata_from_file_minimal(filepath);
- fd_data = fd ? read_file_thumbnail(fd) : NULL;
+ fd = blo_filedata_from_file_minimal(filepath);
+ fd_data = fd ? read_file_thumbnail(fd) : NULL;
- if (fd_data) {
- const int width = fd_data[0];
- const int height = fd_data[1];
- if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
- const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
- data = MEM_mallocN(sz, __func__);
- if (data) {
- BLI_assert((sz - sizeof(*data)) == (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*fd_data) * 2)));
- data->width = width;
- data->height = height;
- memcpy(data->rect, &fd_data[2], sz - sizeof(*data));
- }
- }
- }
+ if (fd_data) {
+ const int width = fd_data[0];
+ const int height = fd_data[1];
+ if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
+ const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
+ data = MEM_mallocN(sz, __func__);
+ if (data) {
+ BLI_assert((sz - sizeof(*data)) ==
+ (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*fd_data) * 2)));
+ data->width = width;
+ data->height = height;
+ memcpy(data->rect, &fd_data[2], sz - sizeof(*data));
+ }
+ }
+ }
- blo_filedata_free(fd);
+ blo_filedata_free(fd);
- return data;
+ return data;
}
/** \} */
@@ -1665,119 +1686,130 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
/** \name Old/New Pointer Map
* \{ */
-static void *newdataadr(FileData *fd, const void *adr) /* only direct databocks */
+static void *newdataadr(FileData *fd, const void *adr) /* only direct databocks */
{
- return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
+ return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
}
-static void *newdataadr_no_us(FileData *fd, const void *adr) /* only direct databocks */
+static void *newdataadr_no_us(FileData *fd, const void *adr) /* only direct databocks */
{
- return oldnewmap_lookup_and_inc(fd->datamap, adr, false);
+ return oldnewmap_lookup_and_inc(fd->datamap, adr, false);
}
-static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with global linking */
+static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with global linking */
{
- return oldnewmap_lookup_and_inc(fd->globmap, adr, true);
+ return oldnewmap_lookup_and_inc(fd->globmap, adr, true);
}
-static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
+static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
{
- if (fd->imamap && adr)
- return oldnewmap_lookup_and_inc(fd->imamap, adr, true);
- return NULL;
+ if (fd->imamap && adr)
+ return oldnewmap_lookup_and_inc(fd->imamap, adr, true);
+ return NULL;
}
-static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
+static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
{
- if (fd->scenemap && adr)
- return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
- return NULL;
+ if (fd->scenemap && adr)
+ return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
+ return NULL;
}
-static void *newmclipadr(FileData *fd, const void *adr) /* used to restore movie clip data after undo */
+static void *newmclipadr(FileData *fd,
+ const void *adr) /* used to restore movie clip data after undo */
{
- if (fd->movieclipmap && adr)
- return oldnewmap_lookup_and_inc(fd->movieclipmap, adr, true);
- return NULL;
+ if (fd->movieclipmap && adr)
+ return oldnewmap_lookup_and_inc(fd->movieclipmap, adr, true);
+ return NULL;
}
-static void *newsoundadr(FileData *fd, const void *adr) /* used to restore sound data after undo */
+static void *newsoundadr(FileData *fd, const void *adr) /* used to restore sound data after undo */
{
- if (fd->soundmap && adr)
- return oldnewmap_lookup_and_inc(fd->soundmap, adr, true);
- return NULL;
+ if (fd->soundmap && adr)
+ return oldnewmap_lookup_and_inc(fd->soundmap, adr, true);
+ return NULL;
}
-static void *newpackedadr(FileData *fd, const void *adr) /* used to restore packed data after undo */
+static void *newpackedadr(FileData *fd,
+ const void *adr) /* used to restore packed data after undo */
{
- if (fd->packedmap && adr)
- return oldnewmap_lookup_and_inc(fd->packedmap, adr, true);
+ if (fd->packedmap && adr)
+ return oldnewmap_lookup_and_inc(fd->packedmap, adr, true);
- return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
+ return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
}
-
-static void *newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
+static void *newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
{
- return oldnewmap_liblookup(fd->libmap, adr, lib);
+ return oldnewmap_liblookup(fd->libmap, adr, lib);
}
-void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
+void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
{
- return newlibadr(fd, lib, adr);
+ return newlibadr(fd, lib, adr);
}
-static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
+static void *newlibadr_us(FileData *fd,
+ const void *lib,
+ const void *adr) /* increases user number */
{
- ID *id = newlibadr(fd, lib, adr);
+ ID *id = newlibadr(fd, lib, adr);
- id_us_plus_no_lib(id);
+ id_us_plus_no_lib(id);
- return id;
+ return id;
}
-void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
+void *blo_do_versions_newlibadr_us(FileData *fd,
+ const void *lib,
+ const void *adr) /* increases user number */
{
- return newlibadr_us(fd, lib, adr);
+ return newlibadr_us(fd, lib, adr);
}
-static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) /* ensures real user */
+static void *newlibadr_real_us(FileData *fd,
+ const void *lib,
+ const void *adr) /* ensures real user */
{
- ID *id = newlibadr(fd, lib, adr);
+ ID *id = newlibadr(fd, lib, adr);
- id_us_ensure_real(id);
+ id_us_ensure_real(id);
- return id;
+ return id;
}
static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const void *old, void *new)
{
- for (int i = 0; i < fd->libmap->nentries; i++) {
- OldNew *entry = &fd->libmap->entries[i];
+ for (int i = 0; i < fd->libmap->nentries; i++) {
+ OldNew *entry = &fd->libmap->entries[i];
- if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) {
- entry->newp = new;
- if (new) entry->nr = GS( ((ID *)new)->name);
- }
- }
+ if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) {
+ entry->newp = new;
+ if (new)
+ entry->nr = GS(((ID *)new)->name);
+ }
+ }
}
-static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist, FileData *basefd, void *old, void *new)
+static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
+ FileData *basefd,
+ void *old,
+ void *new)
{
- Main *mainptr;
+ Main *mainptr;
- for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
- FileData *fd;
+ for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
+ FileData *fd;
- if (mainptr->curlib)
- fd = mainptr->curlib->filedata;
- else
- fd = basefd;
+ if (mainptr->curlib)
+ fd = mainptr->curlib->filedata;
+ else
+ fd = basefd;
- if (fd) {
- change_link_placeholder_to_real_ID_pointer_fd(fd, old, new);
- }
- }
+ if (fd) {
+ change_link_placeholder_to_real_ID_pointer_fd(fd, old, new);
+ }
+ }
}
/* lib linked proxy objects point to our local data, we need
@@ -1788,318 +1820,319 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist, FileD
*/
void blo_clear_proxy_pointers_from_lib(Main *oldmain)
{
- Object *ob = oldmain->objects.first;
+ Object *ob = oldmain->objects.first;
- for (; ob; ob = ob->id.next) {
- if (ob->id.lib != NULL && ob->proxy_from != NULL && ob->proxy_from->id.lib == NULL) {
- ob->proxy_from = NULL;
- }
- }
+ for (; ob; ob = ob->id.next) {
+ if (ob->id.lib != NULL && ob->proxy_from != NULL && ob->proxy_from->id.lib == NULL) {
+ ob->proxy_from = NULL;
+ }
+ }
}
void blo_make_scene_pointer_map(FileData *fd, Main *oldmain)
{
- Scene *sce = oldmain->scenes.first;
+ Scene *sce = oldmain->scenes.first;
- fd->scenemap = oldnewmap_new();
+ fd->scenemap = oldnewmap_new();
- for (; sce; sce = sce->id.next) {
- if (sce->eevee.light_cache) {
- struct LightCache *light_cache = sce->eevee.light_cache;
- oldnewmap_insert(fd->scenemap, light_cache, light_cache, 0);
- }
- }
+ for (; sce; sce = sce->id.next) {
+ if (sce->eevee.light_cache) {
+ struct LightCache *light_cache = sce->eevee.light_cache;
+ oldnewmap_insert(fd->scenemap, light_cache, light_cache, 0);
+ }
+ }
}
void blo_end_scene_pointer_map(FileData *fd, Main *oldmain)
{
- OldNew *entry = fd->scenemap->entries;
- Scene *sce = oldmain->scenes.first;
- int i;
+ OldNew *entry = fd->scenemap->entries;
+ Scene *sce = oldmain->scenes.first;
+ int i;
- /* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->scenemap->nentries; i++, entry++) {
- if (entry->nr > 0)
- entry->newp = NULL;
- }
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->scenemap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
- for (; sce; sce = sce->id.next) {
- sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
- }
+ for (; sce; sce = sce->id.next) {
+ sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
+ }
}
void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima = oldmain->images.first;
- Scene *sce = oldmain->scenes.first;
- int a;
-
- fd->imamap = oldnewmap_new();
-
- for (; ima; ima = ima->id.next) {
- if (ima->cache) {
- oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0);
- }
- for (a = 0; a < TEXTARGET_COUNT; a++) {
- if (ima->gputexture[a]) {
- oldnewmap_insert(fd->imamap, ima->gputexture[a], ima->gputexture[a], 0);
- }
- }
- if (ima->rr) {
- oldnewmap_insert(fd->imamap, ima->rr, ima->rr, 0);
- }
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
- if (slot->render) {
- oldnewmap_insert(fd->imamap, slot->render, slot->render, 0);
- }
- }
- }
- for (; sce; sce = sce->id.next) {
- if (sce->nodetree && sce->nodetree->previews) {
- bNodeInstanceHashIterator iter;
- NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews) {
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
- oldnewmap_insert(fd->imamap, preview, preview, 0);
- }
- }
- }
+ Image *ima = oldmain->images.first;
+ Scene *sce = oldmain->scenes.first;
+ int a;
+
+ fd->imamap = oldnewmap_new();
+
+ for (; ima; ima = ima->id.next) {
+ if (ima->cache) {
+ oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0);
+ }
+ for (a = 0; a < TEXTARGET_COUNT; a++) {
+ if (ima->gputexture[a]) {
+ oldnewmap_insert(fd->imamap, ima->gputexture[a], ima->gputexture[a], 0);
+ }
+ }
+ if (ima->rr) {
+ oldnewmap_insert(fd->imamap, ima->rr, ima->rr, 0);
+ }
+ LISTBASE_FOREACH (RenderSlot *, slot, &ima->renderslots) {
+ if (slot->render) {
+ oldnewmap_insert(fd->imamap, slot->render, slot->render, 0);
+ }
+ }
+ }
+ for (; sce; sce = sce->id.next) {
+ if (sce->nodetree && sce->nodetree->previews) {
+ bNodeInstanceHashIterator iter;
+ NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews)
+ {
+ bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ oldnewmap_insert(fd->imamap, preview, preview, 0);
+ }
+ }
+ }
}
/* set old main image ibufs to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
{
- OldNew *entry = fd->imamap->entries;
- Image *ima = oldmain->images.first;
- Scene *sce = oldmain->scenes.first;
- int i;
-
- /* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->imamap->nentries; i++, entry++) {
- if (entry->nr > 0)
- entry->newp = NULL;
- }
-
- for (; ima; ima = ima->id.next) {
- ima->cache = newimaadr(fd, ima->cache);
- if (ima->cache == NULL) {
- ima->gpuflag = 0;
- for (i = 0; i < TEXTARGET_COUNT; i++) {
- ima->gputexture[i] = NULL;
- }
- ima->rr = NULL;
- }
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
- slot->render = newimaadr(fd, slot->render);
- }
-
- for (i = 0; i < TEXTARGET_COUNT; i++)
- ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
- ima->rr = newimaadr(fd, ima->rr);
- }
- for (; sce; sce = sce->id.next) {
- if (sce->nodetree && sce->nodetree->previews) {
- bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews");
- bNodeInstanceHashIterator iter;
-
- /* reconstruct the preview hash, only using remaining pointers */
- NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews) {
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
- if (preview) {
- bNodePreview *new_preview = newimaadr(fd, preview);
- if (new_preview) {
- bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- BKE_node_instance_hash_insert(new_previews, key, new_preview);
- }
- }
- }
- BKE_node_instance_hash_free(sce->nodetree->previews, NULL);
- sce->nodetree->previews = new_previews;
- }
- }
+ OldNew *entry = fd->imamap->entries;
+ Image *ima = oldmain->images.first;
+ Scene *sce = oldmain->scenes.first;
+ int i;
+
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->imamap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
+
+ for (; ima; ima = ima->id.next) {
+ ima->cache = newimaadr(fd, ima->cache);
+ if (ima->cache == NULL) {
+ ima->gpuflag = 0;
+ for (i = 0; i < TEXTARGET_COUNT; i++) {
+ ima->gputexture[i] = NULL;
+ }
+ ima->rr = NULL;
+ }
+ LISTBASE_FOREACH (RenderSlot *, slot, &ima->renderslots) {
+ slot->render = newimaadr(fd, slot->render);
+ }
+
+ for (i = 0; i < TEXTARGET_COUNT; i++)
+ ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
+ ima->rr = newimaadr(fd, ima->rr);
+ }
+ for (; sce; sce = sce->id.next) {
+ if (sce->nodetree && sce->nodetree->previews) {
+ bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews");
+ bNodeInstanceHashIterator iter;
+
+ /* reconstruct the preview hash, only using remaining pointers */
+ NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews)
+ {
+ bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ if (preview) {
+ bNodePreview *new_preview = newimaadr(fd, preview);
+ if (new_preview) {
+ bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
+ BKE_node_instance_hash_insert(new_previews, key, new_preview);
+ }
+ }
+ }
+ BKE_node_instance_hash_free(sce->nodetree->previews, NULL);
+ sce->nodetree->previews = new_previews;
+ }
+ }
}
void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain)
{
- MovieClip *clip = oldmain->movieclips.first;
- Scene *sce = oldmain->scenes.first;
+ MovieClip *clip = oldmain->movieclips.first;
+ Scene *sce = oldmain->scenes.first;
- fd->movieclipmap = oldnewmap_new();
+ fd->movieclipmap = oldnewmap_new();
- for (; clip; clip = clip->id.next) {
- if (clip->cache)
- oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0);
+ for (; clip; clip = clip->id.next) {
+ if (clip->cache)
+ oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0);
- if (clip->tracking.camera.intrinsics)
- oldnewmap_insert(fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0);
- }
+ if (clip->tracking.camera.intrinsics)
+ oldnewmap_insert(
+ fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0);
+ }
- for (; sce; sce = sce->id.next) {
- if (sce->nodetree) {
- bNode *node;
- for (node = sce->nodetree->nodes.first; node; node = node->next)
- if (node->type == CMP_NODE_MOVIEDISTORTION)
- oldnewmap_insert(fd->movieclipmap, node->storage, node->storage, 0);
- }
- }
+ for (; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
+ bNode *node;
+ for (node = sce->nodetree->nodes.first; node; node = node->next)
+ if (node->type == CMP_NODE_MOVIEDISTORTION)
+ oldnewmap_insert(fd->movieclipmap, node->storage, node->storage, 0);
+ }
+ }
}
/* set old main movie clips caches to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain)
{
- OldNew *entry = fd->movieclipmap->entries;
- MovieClip *clip = oldmain->movieclips.first;
- Scene *sce = oldmain->scenes.first;
- int i;
+ OldNew *entry = fd->movieclipmap->entries;
+ MovieClip *clip = oldmain->movieclips.first;
+ Scene *sce = oldmain->scenes.first;
+ int i;
- /* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->movieclipmap->nentries; i++, entry++) {
- if (entry->nr > 0)
- entry->newp = NULL;
- }
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->movieclipmap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
- for (; clip; clip = clip->id.next) {
- clip->cache = newmclipadr(fd, clip->cache);
- clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
- }
+ for (; clip; clip = clip->id.next) {
+ clip->cache = newmclipadr(fd, clip->cache);
+ clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
+ }
- for (; sce; sce = sce->id.next) {
- if (sce->nodetree) {
- bNode *node;
- for (node = sce->nodetree->nodes.first; node; node = node->next)
- if (node->type == CMP_NODE_MOVIEDISTORTION)
- node->storage = newmclipadr(fd, node->storage);
- }
- }
+ for (; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
+ bNode *node;
+ for (node = sce->nodetree->nodes.first; node; node = node->next)
+ if (node->type == CMP_NODE_MOVIEDISTORTION)
+ node->storage = newmclipadr(fd, node->storage);
+ }
+ }
}
void blo_make_sound_pointer_map(FileData *fd, Main *oldmain)
{
- bSound *sound = oldmain->sounds.first;
+ bSound *sound = oldmain->sounds.first;
- fd->soundmap = oldnewmap_new();
+ fd->soundmap = oldnewmap_new();
- for (; sound; sound = sound->id.next) {
- if (sound->waveform)
- oldnewmap_insert(fd->soundmap, sound->waveform, sound->waveform, 0);
- }
+ for (; sound; sound = sound->id.next) {
+ if (sound->waveform)
+ oldnewmap_insert(fd->soundmap, sound->waveform, sound->waveform, 0);
+ }
}
/* set old main sound caches to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_sound_pointer_map(FileData *fd, Main *oldmain)
{
- OldNew *entry = fd->soundmap->entries;
- bSound *sound = oldmain->sounds.first;
- int i;
+ OldNew *entry = fd->soundmap->entries;
+ bSound *sound = oldmain->sounds.first;
+ int i;
- /* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->soundmap->nentries; i++, entry++) {
- if (entry->nr > 0)
- entry->newp = NULL;
- }
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->soundmap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
- for (; sound; sound = sound->id.next) {
- sound->waveform = newsoundadr(fd, sound->waveform);
- }
+ for (; sound; sound = sound->id.next) {
+ sound->waveform = newsoundadr(fd, sound->waveform);
+ }
}
/* XXX disabled this feature - packed files also belong in temp saves and quit.blend, to make restore work */
static void insert_packedmap(FileData *fd, PackedFile *pf)
{
- oldnewmap_insert(fd->packedmap, pf, pf, 0);
- oldnewmap_insert(fd->packedmap, pf->data, pf->data, 0);
+ oldnewmap_insert(fd->packedmap, pf, pf, 0);
+ oldnewmap_insert(fd->packedmap, pf->data, pf->data, 0);
}
void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Library *lib;
+ Image *ima;
+ VFont *vfont;
+ bSound *sound;
+ Library *lib;
- fd->packedmap = oldnewmap_new();
+ fd->packedmap = oldnewmap_new();
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
+ for (ima = oldmain->images.first; ima; ima = ima->id.next) {
+ ImagePackedFile *imapf;
- if (ima->packedfile)
- insert_packedmap(fd, ima->packedfile);
+ if (ima->packedfile)
+ insert_packedmap(fd, ima->packedfile);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
- if (imapf->packedfile)
- insert_packedmap(fd, imapf->packedfile);
- }
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
+ if (imapf->packedfile)
+ insert_packedmap(fd, imapf->packedfile);
+ }
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
- if (vfont->packedfile)
- insert_packedmap(fd, vfont->packedfile);
+ for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
+ if (vfont->packedfile)
+ insert_packedmap(fd, vfont->packedfile);
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
- if (sound->packedfile)
- insert_packedmap(fd, sound->packedfile);
-
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
- if (lib->packedfile)
- insert_packedmap(fd, lib->packedfile);
+ for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
+ if (sound->packedfile)
+ insert_packedmap(fd, sound->packedfile);
+ for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
+ if (lib->packedfile)
+ insert_packedmap(fd, lib->packedfile);
}
/* set old main packed data to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Library *lib;
- OldNew *entry = fd->packedmap->entries;
- int i;
+ Image *ima;
+ VFont *vfont;
+ bSound *sound;
+ Library *lib;
+ OldNew *entry = fd->packedmap->entries;
+ int i;
- /* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->packedmap->nentries; i++, entry++) {
- if (entry->nr > 0)
- entry->newp = NULL;
- }
+ /* used entries were restored, so we put them to zero */
+ for (i = 0; i < fd->packedmap->nentries; i++, entry++) {
+ if (entry->nr > 0)
+ entry->newp = NULL;
+ }
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
+ for (ima = oldmain->images.first; ima; ima = ima->id.next) {
+ ImagePackedFile *imapf;
- ima->packedfile = newpackedadr(fd, ima->packedfile);
+ ima->packedfile = newpackedadr(fd, ima->packedfile);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
- imapf->packedfile = newpackedadr(fd, imapf->packedfile);
- }
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
+ imapf->packedfile = newpackedadr(fd, imapf->packedfile);
+ }
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
- vfont->packedfile = newpackedadr(fd, vfont->packedfile);
+ for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
+ vfont->packedfile = newpackedadr(fd, vfont->packedfile);
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
- sound->packedfile = newpackedadr(fd, sound->packedfile);
+ for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
+ sound->packedfile = newpackedadr(fd, sound->packedfile);
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
- lib->packedfile = newpackedadr(fd, lib->packedfile);
+ for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
+ lib->packedfile = newpackedadr(fd, lib->packedfile);
}
-
/* undo file support: add all library pointers in lookup */
void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
{
- Main *ptr = old_mainlist->first;
- ListBase *lbarray[MAX_LIBARRAY];
+ Main *ptr = old_mainlist->first;
+ ListBase *lbarray[MAX_LIBARRAY];
- for (ptr = ptr->next; ptr; ptr = ptr->next) {
- int i = set_listbasepointers(ptr, lbarray);
- while (i--) {
- ID *id;
- for (id = lbarray[i]->first; id; id = id->next)
- oldnewmap_insert(fd->libmap, id, id, GS(id->name));
- }
- }
+ for (ptr = ptr->next; ptr; ptr = ptr->next) {
+ int i = set_listbasepointers(ptr, lbarray);
+ while (i--) {
+ ID *id;
+ for (id = lbarray[i]->first; id; id = id->next)
+ oldnewmap_insert(fd->libmap, id, id, GS(id->name));
+ }
+ }
- fd->old_mainlist = old_mainlist;
+ fd->old_mainlist = old_mainlist;
}
/** \} */
@@ -2110,186 +2143,189 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead)
{
- int blocksize, nblocks;
- char *data;
+ int blocksize, nblocks;
+ char *data;
- data = (char *)(bhead + 1);
- blocksize = filesdna->types_size[filesdna->structs[bhead->SDNAnr][0]];
+ data = (char *)(bhead + 1);
+ blocksize = filesdna->types_size[filesdna->structs[bhead->SDNAnr][0]];
- nblocks = bhead->nr;
- while (nblocks--) {
- DNA_struct_switch_endian(filesdna, bhead->SDNAnr, data);
+ nblocks = bhead->nr;
+ while (nblocks--) {
+ DNA_struct_switch_endian(filesdna, bhead->SDNAnr, data);
- data += blocksize;
- }
+ data += blocksize;
+ }
}
static void *read_struct(FileData *fd, BHead *bh, const char *blockname)
{
- void *temp = NULL;
+ void *temp = NULL;
- if (bh->len) {
+ if (bh->len) {
#ifdef USE_BHEAD_READ_ON_DEMAND
- BHead *bh_orig = bh;
+ BHead *bh_orig = bh;
#endif
- /* switch is based on file dna */
- if (bh->SDNAnr && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
+ /* switch is based on file dna */
+ if (bh->SDNAnr && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
#ifdef USE_BHEAD_READ_ON_DEMAND
- if (BHEADN_FROM_BHEAD(bh)->has_data == false) {
- bh = blo_bhead_read_full(fd, bh);
- if (UNLIKELY(bh == NULL)) {
- fd->flags &= ~FD_FLAGS_FILE_OK;
- return NULL;
- }
- }
+ if (BHEADN_FROM_BHEAD(bh)->has_data == false) {
+ bh = blo_bhead_read_full(fd, bh);
+ if (UNLIKELY(bh == NULL)) {
+ fd->flags &= ~FD_FLAGS_FILE_OK;
+ return NULL;
+ }
+ }
#endif
- switch_endian_structs(fd->filesdna, bh);
- }
+ switch_endian_structs(fd->filesdna, bh);
+ }
- if (fd->compflags[bh->SDNAnr] != SDNA_CMP_REMOVED) {
- if (fd->compflags[bh->SDNAnr] == SDNA_CMP_NOT_EQUAL) {
+ if (fd->compflags[bh->SDNAnr] != SDNA_CMP_REMOVED) {
+ if (fd->compflags[bh->SDNAnr] == SDNA_CMP_NOT_EQUAL) {
#ifdef USE_BHEAD_READ_ON_DEMAND
- if (BHEADN_FROM_BHEAD(bh)->has_data == false) {
- bh = blo_bhead_read_full(fd, bh);
- if (UNLIKELY(bh == NULL)) {
- fd->flags &= ~FD_FLAGS_FILE_OK;
- return NULL;
- }
- }
+ if (BHEADN_FROM_BHEAD(bh)->has_data == false) {
+ bh = blo_bhead_read_full(fd, bh);
+ if (UNLIKELY(bh == NULL)) {
+ fd->flags &= ~FD_FLAGS_FILE_OK;
+ return NULL;
+ }
+ }
#endif
- temp = DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh + 1));
- }
- else {
- /* SDNA_CMP_EQUAL */
- temp = MEM_mallocN(bh->len, blockname);
+ temp = DNA_struct_reconstruct(
+ fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh + 1));
+ }
+ else {
+ /* SDNA_CMP_EQUAL */
+ temp = MEM_mallocN(bh->len, blockname);
#ifdef USE_BHEAD_READ_ON_DEMAND
- if (BHEADN_FROM_BHEAD(bh)->has_data) {
- memcpy(temp, (bh + 1), bh->len);
- }
- else {
- /* Instead of allocating the bhead, then copying it,
- * read the data from the file directly into the memory. */
- if (UNLIKELY(!blo_bhead_read_data(fd, bh, temp))) {
- fd->flags &= ~FD_FLAGS_FILE_OK;
- MEM_freeN(temp);
- temp = NULL;
- }
- }
+ if (BHEADN_FROM_BHEAD(bh)->has_data) {
+ memcpy(temp, (bh + 1), bh->len);
+ }
+ else {
+ /* Instead of allocating the bhead, then copying it,
+ * read the data from the file directly into the memory. */
+ if (UNLIKELY(!blo_bhead_read_data(fd, bh, temp))) {
+ fd->flags &= ~FD_FLAGS_FILE_OK;
+ MEM_freeN(temp);
+ temp = NULL;
+ }
+ }
#else
- memcpy(temp, (bh + 1), bh->len);
+ memcpy(temp, (bh + 1), bh->len);
#endif
- }
- }
+ }
+ }
#ifdef USE_BHEAD_READ_ON_DEMAND
- if (bh_orig != bh) {
- MEM_freeN(BHEADN_FROM_BHEAD(bh));
- }
+ if (bh_orig != bh) {
+ MEM_freeN(BHEADN_FROM_BHEAD(bh));
+ }
#endif
- }
+ }
- return temp;
+ return temp;
}
typedef void (*link_list_cb)(FileData *fd, void *data);
-static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */
+static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */
{
- Link *ln, *prev;
+ Link *ln, *prev;
- if (BLI_listbase_is_empty(lb)) return;
+ if (BLI_listbase_is_empty(lb))
+ return;
- lb->first = newdataadr(fd, lb->first);
- if (callback != NULL) {
- callback(fd, lb->first);
- }
- ln = lb->first;
- prev = NULL;
- while (ln) {
- ln->next = newdataadr(fd, ln->next);
- if (ln->next != NULL && callback != NULL) {
- callback(fd, ln->next);
- }
- ln->prev = prev;
- prev = ln;
- ln = ln->next;
- }
- lb->last = prev;
+ lb->first = newdataadr(fd, lb->first);
+ if (callback != NULL) {
+ callback(fd, lb->first);
+ }
+ ln = lb->first;
+ prev = NULL;
+ while (ln) {
+ ln->next = newdataadr(fd, ln->next);
+ if (ln->next != NULL && callback != NULL) {
+ callback(fd, ln->next);
+ }
+ ln->prev = prev;
+ prev = ln;
+ ln = ln->next;
+ }
+ lb->last = prev;
}
-static void link_list(FileData *fd, ListBase *lb) /* only direct data */
+static void link_list(FileData *fd, ListBase *lb) /* only direct data */
{
- link_list_ex(fd, lb, NULL);
+ link_list_ex(fd, lb, NULL);
}
-static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
+static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
{
- Link *ln, *prev;
- void *poin;
+ Link *ln, *prev;
+ void *poin;
- if (BLI_listbase_is_empty(lb)) return;
- poin = newdataadr(fd, lb->first);
- if (lb->first) {
- oldnewmap_insert(fd->globmap, lb->first, poin, 0);
- }
- lb->first = poin;
+ if (BLI_listbase_is_empty(lb))
+ return;
+ poin = newdataadr(fd, lb->first);
+ if (lb->first) {
+ oldnewmap_insert(fd->globmap, lb->first, poin, 0);
+ }
+ lb->first = poin;
- ln = lb->first;
- prev = NULL;
- while (ln) {
- poin = newdataadr(fd, ln->next);
- if (ln->next) {
- oldnewmap_insert(fd->globmap, ln->next, poin, 0);
- }
- ln->next = poin;
- ln->prev = prev;
- prev = ln;
- ln = ln->next;
- }
- lb->last = prev;
+ ln = lb->first;
+ prev = NULL;
+ while (ln) {
+ poin = newdataadr(fd, ln->next);
+ if (ln->next) {
+ oldnewmap_insert(fd->globmap, ln->next, poin, 0);
+ }
+ ln->next = poin;
+ ln->prev = prev;
+ prev = ln;
+ ln = ln->next;
+ }
+ lb->last = prev;
}
static void test_pointer_array(FileData *fd, void **mat)
{
- int64_t *lpoin, *lmat;
- int *ipoin, *imat;
- size_t len;
-
- /* manually convert the pointer array in
- * the old dna format to a pointer array in
- * the new dna format.
- */
- if (*mat) {
- len = MEM_allocN_len(*mat) / fd->filesdna->pointer_size;
-
- if (fd->filesdna->pointer_size == 8 && fd->memsdna->pointer_size == 4) {
- ipoin = imat = MEM_malloc_arrayN(len, 4, "newmatar");
- lpoin = *mat;
-
- while (len-- > 0) {
- if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
- BLI_endian_switch_int64(lpoin);
- *ipoin = (int)((*lpoin) >> 3);
- ipoin++;
- lpoin++;
- }
- MEM_freeN(*mat);
- *mat = imat;
- }
-
- if (fd->filesdna->pointer_size == 4 && fd->memsdna->pointer_size == 8) {
- lpoin = lmat = MEM_malloc_arrayN(len, 8, "newmatar");
- ipoin = *mat;
-
- while (len-- > 0) {
- *lpoin = *ipoin;
- ipoin++;
- lpoin++;
- }
- MEM_freeN(*mat);
- *mat = lmat;
- }
- }
+ int64_t *lpoin, *lmat;
+ int *ipoin, *imat;
+ size_t len;
+
+ /* manually convert the pointer array in
+ * the old dna format to a pointer array in
+ * the new dna format.
+ */
+ if (*mat) {
+ len = MEM_allocN_len(*mat) / fd->filesdna->pointer_size;
+
+ if (fd->filesdna->pointer_size == 8 && fd->memsdna->pointer_size == 4) {
+ ipoin = imat = MEM_malloc_arrayN(len, 4, "newmatar");
+ lpoin = *mat;
+
+ while (len-- > 0) {
+ if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
+ BLI_endian_switch_int64(lpoin);
+ *ipoin = (int)((*lpoin) >> 3);
+ ipoin++;
+ lpoin++;
+ }
+ MEM_freeN(*mat);
+ *mat = imat;
+ }
+
+ if (fd->filesdna->pointer_size == 4 && fd->memsdna->pointer_size == 8) {
+ lpoin = lmat = MEM_malloc_arrayN(len, 8, "newmatar");
+ ipoin = *mat;
+
+ while (len-- > 0) {
+ *lpoin = *ipoin;
+ ipoin++;
+ lpoin++;
+ }
+ MEM_freeN(*mat);
+ *mat = lmat;
+ }
+ }
}
/** \} */
@@ -2303,178 +2339,178 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd);
static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData *fd)
{
- IDProperty *array;
- int i;
+ IDProperty *array;
+ int i;
- /* since we didn't save the extra buffer, set totallen to len */
- prop->totallen = prop->len;
- prop->data.pointer = newdataadr(fd, prop->data.pointer);
+ /* since we didn't save the extra buffer, set totallen to len */
+ prop->totallen = prop->len;
+ prop->data.pointer = newdataadr(fd, prop->data.pointer);
- array = (IDProperty *)prop->data.pointer;
+ array = (IDProperty *)prop->data.pointer;
- /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared
- * theres not really anything we can do to correct this, at least don't crash */
- if (array == NULL) {
- prop->len = 0;
- prop->totallen = 0;
- }
+ /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared
+ * theres not really anything we can do to correct this, at least don't crash */
+ if (array == NULL) {
+ prop->len = 0;
+ prop->totallen = 0;
+ }
-
- for (i = 0; i < prop->len; i++)
- IDP_DirectLinkProperty(&array[i], switch_endian, fd);
+ for (i = 0; i < prop->len; i++)
+ IDP_DirectLinkProperty(&array[i], switch_endian, fd);
}
static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd)
{
- IDProperty **array;
- int i;
-
- /* since we didn't save the extra buffer, set totallen to len */
- prop->totallen = prop->len;
- prop->data.pointer = newdataadr(fd, prop->data.pointer);
-
- if (prop->subtype == IDP_GROUP) {
- test_pointer_array(fd, prop->data.pointer);
- array = prop->data.pointer;
-
- for (i = 0; i < prop->len; i++)
- IDP_DirectLinkProperty(array[i], switch_endian, fd);
- }
- else if (prop->subtype == IDP_DOUBLE) {
- if (switch_endian) {
- BLI_endian_switch_double_array(prop->data.pointer, prop->len);
- }
- }
- else {
- if (switch_endian) {
- /* also used for floats */
- BLI_endian_switch_int32_array(prop->data.pointer, prop->len);
- }
- }
+ IDProperty **array;
+ int i;
+
+ /* since we didn't save the extra buffer, set totallen to len */
+ prop->totallen = prop->len;
+ prop->data.pointer = newdataadr(fd, prop->data.pointer);
+
+ if (prop->subtype == IDP_GROUP) {
+ test_pointer_array(fd, prop->data.pointer);
+ array = prop->data.pointer;
+
+ for (i = 0; i < prop->len; i++)
+ IDP_DirectLinkProperty(array[i], switch_endian, fd);
+ }
+ else if (prop->subtype == IDP_DOUBLE) {
+ if (switch_endian) {
+ BLI_endian_switch_double_array(prop->data.pointer, prop->len);
+ }
+ }
+ else {
+ if (switch_endian) {
+ /* also used for floats */
+ BLI_endian_switch_int32_array(prop->data.pointer, prop->len);
+ }
+ }
}
static void IDP_DirectLinkString(IDProperty *prop, FileData *fd)
{
- /*since we didn't save the extra string buffer, set totallen to len.*/
- prop->totallen = prop->len;
- prop->data.pointer = newdataadr(fd, prop->data.pointer);
+ /*since we didn't save the extra string buffer, set totallen to len.*/
+ prop->totallen = prop->len;
+ prop->data.pointer = newdataadr(fd, prop->data.pointer);
}
static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *fd)
{
- ListBase *lb = &prop->data.group;
- IDProperty *loop;
+ ListBase *lb = &prop->data.group;
+ IDProperty *loop;
- link_list(fd, lb);
+ link_list(fd, lb);
- /*Link child id properties now*/
- for (loop = prop->data.group.first; loop; loop = loop->next) {
- IDP_DirectLinkProperty(loop, switch_endian, fd);
- }
+ /*Link child id properties now*/
+ for (loop = prop->data.group.first; loop; loop = loop->next) {
+ IDP_DirectLinkProperty(loop, switch_endian, fd);
+ }
}
static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
{
- switch (prop->type) {
- case IDP_GROUP:
- IDP_DirectLinkGroup(prop, switch_endian, fd);
- break;
- case IDP_STRING:
- IDP_DirectLinkString(prop, fd);
- break;
- case IDP_ARRAY:
- IDP_DirectLinkArray(prop, switch_endian, fd);
- break;
- case IDP_IDPARRAY:
- IDP_DirectLinkIDPArray(prop, switch_endian, fd);
- break;
- case IDP_DOUBLE:
- /* erg, stupid doubles. since I'm storing them
- * in the same field as int val; val2 in the
- * IDPropertyData struct, they have to deal with
- * endianness specifically
- *
- * in theory, val and val2 would've already been swapped
- * if switch_endian is true, so we have to first unswap
- * them then reswap them as a single 64-bit entity.
- */
-
- if (switch_endian) {
- BLI_endian_switch_int32(&prop->data.val);
- BLI_endian_switch_int32(&prop->data.val2);
- BLI_endian_switch_int64((int64_t *)&prop->data.val);
- }
- break;
- case IDP_INT:
- case IDP_FLOAT:
- case IDP_ID:
- break; /* Nothing special to do here. */
- default:
- /* Unknown IDP type, nuke it (we cannot handle unknown types everywhere in code,
- * IDP are way too polymorphic to do it safely. */
- printf("%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->type);
- /* Note: we do not attempt to free unknown prop, we have no way to know how to do that! */
- prop->type = IDP_INT;
- prop->subtype = 0;
- IDP_Int(prop) = 0;
- }
+ switch (prop->type) {
+ case IDP_GROUP:
+ IDP_DirectLinkGroup(prop, switch_endian, fd);
+ break;
+ case IDP_STRING:
+ IDP_DirectLinkString(prop, fd);
+ break;
+ case IDP_ARRAY:
+ IDP_DirectLinkArray(prop, switch_endian, fd);
+ break;
+ case IDP_IDPARRAY:
+ IDP_DirectLinkIDPArray(prop, switch_endian, fd);
+ break;
+ case IDP_DOUBLE:
+ /* erg, stupid doubles. since I'm storing them
+ * in the same field as int val; val2 in the
+ * IDPropertyData struct, they have to deal with
+ * endianness specifically
+ *
+ * in theory, val and val2 would've already been swapped
+ * if switch_endian is true, so we have to first unswap
+ * them then reswap them as a single 64-bit entity.
+ */
+
+ if (switch_endian) {
+ BLI_endian_switch_int32(&prop->data.val);
+ BLI_endian_switch_int32(&prop->data.val2);
+ BLI_endian_switch_int64((int64_t *)&prop->data.val);
+ }
+ break;
+ case IDP_INT:
+ case IDP_FLOAT:
+ case IDP_ID:
+ break; /* Nothing special to do here. */
+ default:
+ /* Unknown IDP type, nuke it (we cannot handle unknown types everywhere in code,
+ * IDP are way too polymorphic to do it safely. */
+ printf(
+ "%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->type);
+ /* Note: we do not attempt to free unknown prop, we have no way to know how to do that! */
+ prop->type = IDP_INT;
+ prop->subtype = 0;
+ IDP_Int(prop) = 0;
+ }
}
#define IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd) \
- _IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd, __func__)
-
-static void _IDP_DirectLinkGroup_OrFree(
- IDProperty **prop, int switch_endian, FileData *fd,
- const char *caller_func_id)
-{
- if (*prop) {
- if ((*prop)->type == IDP_GROUP) {
- IDP_DirectLinkGroup(*prop, switch_endian, fd);
- }
- else {
- /* corrupt file! */
- printf("%s: found non group data, freeing type %d!\n",
- caller_func_id, (*prop)->type);
- /* don't risk id, data's likely corrupt. */
- // IDP_FreeProperty(*prop);
- *prop = NULL;
- }
- }
+ _IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd, __func__)
+
+static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop,
+ int switch_endian,
+ FileData *fd,
+ const char *caller_func_id)
+{
+ if (*prop) {
+ if ((*prop)->type == IDP_GROUP) {
+ IDP_DirectLinkGroup(*prop, switch_endian, fd);
+ }
+ else {
+ /* corrupt file! */
+ printf("%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
+ /* don't risk id, data's likely corrupt. */
+ // IDP_FreeProperty(*prop);
+ *prop = NULL;
+ }
+ }
}
static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
{
- if (!prop)
- return;
-
- switch (prop->type) {
- case IDP_ID: /* PointerProperty */
- {
- void *newaddr = newlibadr_us(fd, NULL, IDP_Id(prop));
- if (IDP_Id(prop) && !newaddr && G.debug) {
- printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
- }
- prop->data.pointer = newaddr;
- break;
- }
- case IDP_IDPARRAY: /* CollectionProperty */
- {
- IDProperty *idp_array = IDP_IDPArray(prop);
- for (int i = 0; i < prop->len; i++) {
- IDP_LibLinkProperty(&(idp_array[i]), fd);
- }
- break;
- }
- case IDP_GROUP: /* PointerProperty */
- {
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
- IDP_LibLinkProperty(loop, fd);
- }
- break;
- }
- default:
- break; /* Nothing to do for other IDProps. */
- }
+ if (!prop)
+ return;
+
+ switch (prop->type) {
+ case IDP_ID: /* PointerProperty */
+ {
+ void *newaddr = newlibadr_us(fd, NULL, IDP_Id(prop));
+ if (IDP_Id(prop) && !newaddr && G.debug) {
+ printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
+ }
+ prop->data.pointer = newaddr;
+ break;
+ }
+ case IDP_IDPARRAY: /* CollectionProperty */
+ {
+ IDProperty *idp_array = IDP_IDPArray(prop);
+ for (int i = 0; i < prop->len; i++) {
+ IDP_LibLinkProperty(&(idp_array[i]), fd);
+ }
+ break;
+ }
+ case IDP_GROUP: /* PointerProperty */
+ {
+ for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ IDP_LibLinkProperty(loop, fd);
+ }
+ break;
+ }
+ default:
+ break; /* Nothing to do for other IDProps. */
+ }
}
/** \} */
@@ -2485,21 +2521,21 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_prv)
{
- PreviewImage *prv = newdataadr(fd, old_prv);
+ PreviewImage *prv = newdataadr(fd, old_prv);
- if (prv) {
- int i;
- for (i = 0; i < NUM_ICON_SIZES; ++i) {
- if (prv->rect[i]) {
- prv->rect[i] = newdataadr(fd, prv->rect[i]);
- }
- prv->gputexture[i] = NULL;
- }
- prv->icon_id = 0;
- prv->tag = 0;
- }
+ if (prv) {
+ int i;
+ for (i = 0; i < NUM_ICON_SIZES; ++i) {
+ if (prv->rect[i]) {
+ prv->rect[i] = newdataadr(fd, prv->rect[i]);
+ }
+ prv->gputexture[i] = NULL;
+ }
+ prv->icon_id = 0;
+ prv->tag = 0;
+ }
- return prv;
+ return prv;
}
/** \} */
@@ -2510,64 +2546,64 @@ static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_p
static void lib_link_id(FileData *fd, Main *main)
{
- ListBase *lbarray[MAX_LIBARRAY];
- int base_count, i;
+ ListBase *lbarray[MAX_LIBARRAY];
+ int base_count, i;
- base_count = set_listbasepointers(main, lbarray);
+ base_count = set_listbasepointers(main, lbarray);
- for (i = 0; i < base_count; i++) {
- ListBase *lb = lbarray[i];
- ID *id;
+ for (i = 0; i < base_count; i++) {
+ ListBase *lb = lbarray[i];
+ ID *id;
- for (id = lb->first; id; id = id->next) {
- if (id->override_static) {
- id->override_static->reference = newlibadr_us(fd, id->lib, id->override_static->reference);
- id->override_static->storage = newlibadr_us(fd, id->lib, id->override_static->storage);
- }
- }
- }
+ for (id = lb->first; id; id = id->next) {
+ if (id->override_static) {
+ id->override_static->reference = newlibadr_us(fd, id->lib, id->override_static->reference);
+ id->override_static->storage = newlibadr_us(fd, id->lib, id->override_static->storage);
+ }
+ }
+ }
}
static void direct_link_id_override_property_operation_cb(FileData *fd, void *data)
{
- IDOverrideStaticPropertyOperation *opop = data;
+ IDOverrideStaticPropertyOperation *opop = data;
- opop->subitem_reference_name = newdataadr(fd, opop->subitem_reference_name);
- opop->subitem_local_name = newdataadr(fd, opop->subitem_local_name);
+ opop->subitem_reference_name = newdataadr(fd, opop->subitem_reference_name);
+ opop->subitem_local_name = newdataadr(fd, opop->subitem_local_name);
}
static void direct_link_id_override_property_cb(FileData *fd, void *data)
{
- IDOverrideStaticProperty *op = data;
+ IDOverrideStaticProperty *op = data;
- op->rna_path = newdataadr(fd, op->rna_path);
- link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb);
+ op->rna_path = newdataadr(fd, op->rna_path);
+ link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb);
}
static void direct_link_id(FileData *fd, ID *id)
{
- /*link direct data of ID properties*/
- if (id->properties) {
- id->properties = newdataadr(fd, id->properties);
- /* this case means the data was written incorrectly, it should not happen */
- IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
- id->py_instance = NULL;
+ /*link direct data of ID properties*/
+ if (id->properties) {
+ id->properties = newdataadr(fd, id->properties);
+ /* this case means the data was written incorrectly, it should not happen */
+ IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+ id->py_instance = NULL;
- /* That way datablock reading not going through main read_libblock() function are still in a clear tag state.
- * (glowering at certain nodetree fake datablock here...). */
- id->tag = 0;
+ /* That way datablock reading not going through main read_libblock() function are still in a clear tag state.
+ * (glowering at certain nodetree fake datablock here...). */
+ id->tag = 0;
- /* Link direct data of overrides. */
- if (id->override_static) {
- id->override_static = newdataadr(fd, id->override_static);
- link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb);
- }
+ /* Link direct data of overrides. */
+ if (id->override_static) {
+ id->override_static = newdataadr(fd, id->override_static);
+ link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb);
+ }
- DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
- if (drawdata) {
- BLI_listbase_clear((ListBase *)drawdata);
- }
+ DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
+ if (drawdata) {
+ BLI_listbase_clear((ListBase *)drawdata);
+ }
}
/** \} */
@@ -2579,16 +2615,16 @@ static void direct_link_id(FileData *fd, ID *id)
/* cuma itself has been read! */
static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
{
- int a;
+ int a;
- /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
- cumap->flag &= ~CUMA_PREMULLED;
+ /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
+ cumap->flag &= ~CUMA_PREMULLED;
- for (a = 0; a < CM_TOT; a++) {
- cumap->cm[a].curve = newdataadr(fd, cumap->cm[a].curve);
- cumap->cm[a].table = NULL;
- cumap->cm[a].premultable = NULL;
- }
+ for (a = 0; a < CM_TOT; a++) {
+ cumap->cm[a].curve = newdataadr(fd, cumap->cm[a].curve);
+ cumap->cm[a].table = NULL;
+ cumap->cm[a].premultable = NULL;
+ }
}
/** \} */
@@ -2600,70 +2636,73 @@ static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
/* library brush linking after fileread */
static void lib_link_brush(FileData *fd, Main *main)
{
- /* only link ID pointers */
- for (Brush *brush = main->brushes.first; brush; brush = brush->id.next) {
- if (brush->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(brush->id.properties, fd);
-
- /* brush->(mask_)mtex.obj is ignored on purpose? */
- brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex);
- brush->mask_mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mask_mtex.tex);
- brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image);
- brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
- brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
-
- /* link default grease pencil palette */
- if (brush->gpencil_settings != NULL) {
- if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
- brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
-
- if (!brush->gpencil_settings->material) {
- brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
- }
- }
- else {
- brush->gpencil_settings->material = NULL;
- }
- }
-
- brush->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ /* only link ID pointers */
+ for (Brush *brush = main->brushes.first; brush; brush = brush->id.next) {
+ if (brush->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(brush->id.properties, fd);
+
+ /* brush->(mask_)mtex.obj is ignored on purpose? */
+ brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex);
+ brush->mask_mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mask_mtex.tex);
+ brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image);
+ brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
+ brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
+
+ /* link default grease pencil palette */
+ if (brush->gpencil_settings != NULL) {
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ brush->gpencil_settings->material = newlibadr_us(
+ fd, brush->id.lib, brush->gpencil_settings->material);
+
+ if (!brush->gpencil_settings->material) {
+ brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
+ }
+ }
+ else {
+ brush->gpencil_settings->material = NULL;
+ }
+ }
+
+ brush->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_brush(FileData *fd, Brush *brush)
{
- /* brush itself has been read */
+ /* brush itself has been read */
- /* fallof curve */
- brush->curve = newdataadr(fd, brush->curve);
+ /* fallof curve */
+ brush->curve = newdataadr(fd, brush->curve);
- brush->gradient = newdataadr(fd, brush->gradient);
+ brush->gradient = newdataadr(fd, brush->gradient);
- if (brush->curve)
- direct_link_curvemapping(fd, brush->curve);
- else
- BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
+ if (brush->curve)
+ direct_link_curvemapping(fd, brush->curve);
+ else
+ BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
- /* grease pencil */
- brush->gpencil_settings = newdataadr(fd, brush->gpencil_settings);
- if (brush->gpencil_settings != NULL) {
- brush->gpencil_settings->curve_sensitivity = newdataadr(fd, brush->gpencil_settings->curve_sensitivity);
- brush->gpencil_settings->curve_strength = newdataadr(fd, brush->gpencil_settings->curve_strength);
- brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
+ /* grease pencil */
+ brush->gpencil_settings = newdataadr(fd, brush->gpencil_settings);
+ if (brush->gpencil_settings != NULL) {
+ brush->gpencil_settings->curve_sensitivity = newdataadr(
+ fd, brush->gpencil_settings->curve_sensitivity);
+ brush->gpencil_settings->curve_strength = newdataadr(fd,
+ brush->gpencil_settings->curve_strength);
+ brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
- if (brush->gpencil_settings->curve_sensitivity)
- direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
+ if (brush->gpencil_settings->curve_sensitivity)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
- if (brush->gpencil_settings->curve_strength)
- direct_link_curvemapping(fd, brush->gpencil_settings->curve_strength);
+ if (brush->gpencil_settings->curve_strength)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_strength);
- if (brush->gpencil_settings->curve_jitter)
- direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
- }
+ if (brush->gpencil_settings->curve_jitter)
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
+ }
- brush->preview = NULL;
- brush->icon_imbuf = NULL;
+ brush->preview = NULL;
+ brush->icon_imbuf = NULL;
}
/** \} */
@@ -2674,38 +2713,38 @@ static void direct_link_brush(FileData *fd, Brush *brush)
static void lib_link_palette(FileData *fd, Main *main)
{
- /* only link ID pointers */
- for (Palette *palette = main->palettes.first; palette; palette = palette->id.next) {
- if (palette->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(palette->id.properties, fd);
+ /* only link ID pointers */
+ for (Palette *palette = main->palettes.first; palette; palette = palette->id.next) {
+ if (palette->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(palette->id.properties, fd);
- palette->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ palette->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_palette(FileData *fd, Palette *palette)
{
- /* palette itself has been read */
- link_list(fd, &palette->colors);
+ /* palette itself has been read */
+ link_list(fd, &palette->colors);
}
static void lib_link_paint_curve(FileData *fd, Main *main)
{
- /* only link ID pointers */
- for (PaintCurve *pc = main->paintcurves.first; pc; pc = pc->id.next) {
- if (pc->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(pc->id.properties, fd);
+ /* only link ID pointers */
+ for (PaintCurve *pc = main->paintcurves.first; pc; pc = pc->id.next) {
+ if (pc->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(pc->id.properties, fd);
- pc->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ pc->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_paint_curve(FileData *fd, PaintCurve *pc)
{
- pc->points = newdataadr(fd, pc->points);
+ pc->points = newdataadr(fd, pc->points);
}
/** \} */
@@ -2716,13 +2755,13 @@ static void direct_link_paint_curve(FileData *fd, PaintCurve *pc)
static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
{
- PackedFile *pf = newpackedadr(fd, oldpf);
+ PackedFile *pf = newpackedadr(fd, oldpf);
- if (pf) {
- pf->data = newpackedadr(fd, pf->data);
- }
+ if (pf) {
+ pf->data = newpackedadr(fd, pf->data);
+ }
- return pf;
+ return pf;
}
/** \} */
@@ -2734,68 +2773,68 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
// XXX deprecated - old animation system
static void lib_link_ipo(FileData *fd, Main *main)
{
- Ipo *ipo;
+ Ipo *ipo;
- for (ipo = main->ipo.first; ipo; ipo = ipo->id.next) {
- if (ipo->id.tag & LIB_TAG_NEED_LINK) {
- IpoCurve *icu;
- for (icu = ipo->curve.first; icu; icu = icu->next) {
- if (icu->driver)
- icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
- }
- ipo->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ for (ipo = main->ipo.first; ipo; ipo = ipo->id.next) {
+ if (ipo->id.tag & LIB_TAG_NEED_LINK) {
+ IpoCurve *icu;
+ for (icu = ipo->curve.first; icu; icu = icu->next) {
+ if (icu->driver)
+ icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
+ }
+ ipo->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
// XXX deprecated - old animation system
static void direct_link_ipo(FileData *fd, Ipo *ipo)
{
- IpoCurve *icu;
+ IpoCurve *icu;
- link_list(fd, &(ipo->curve));
+ link_list(fd, &(ipo->curve));
- for (icu = ipo->curve.first; icu; icu = icu->next) {
- icu->bezt = newdataadr(fd, icu->bezt);
- icu->bp = newdataadr(fd, icu->bp);
- icu->driver = newdataadr(fd, icu->driver);
- }
+ for (icu = ipo->curve.first; icu; icu = icu->next) {
+ icu->bezt = newdataadr(fd, icu->bezt);
+ icu->bp = newdataadr(fd, icu->bp);
+ icu->driver = newdataadr(fd, icu->driver);
+ }
}
// XXX deprecated - old animation system
static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
{
- bActionStrip *strip;
- bActionModifier *amod;
+ bActionStrip *strip;
+ bActionModifier *amod;
- for (strip = striplist->first; strip; strip = strip->next) {
- strip->object = newlibadr(fd, id->lib, strip->object);
- strip->act = newlibadr_us(fd, id->lib, strip->act);
- strip->ipo = newlibadr(fd, id->lib, strip->ipo);
- for (amod = strip->modifiers.first; amod; amod = amod->next)
- amod->ob = newlibadr(fd, id->lib, amod->ob);
- }
+ for (strip = striplist->first; strip; strip = strip->next) {
+ strip->object = newlibadr(fd, id->lib, strip->object);
+ strip->act = newlibadr_us(fd, id->lib, strip->act);
+ strip->ipo = newlibadr(fd, id->lib, strip->ipo);
+ for (amod = strip->modifiers.first; amod; amod = amod->next)
+ amod->ob = newlibadr(fd, id->lib, amod->ob);
+ }
}
// XXX deprecated - old animation system
static void direct_link_nlastrips(FileData *fd, ListBase *strips)
{
- bActionStrip *strip;
+ bActionStrip *strip;
- link_list(fd, strips);
+ link_list(fd, strips);
- for (strip = strips->first; strip; strip = strip->next)
- link_list(fd, &strip->modifiers);
+ for (strip = strips->first; strip; strip = strip->next)
+ link_list(fd, &strip->modifiers);
}
// XXX deprecated - old animation system
static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbase)
{
- bConstraintChannel *chan;
+ bConstraintChannel *chan;
- for (chan = chanbase->first; chan; chan = chan->next) {
- chan->ipo = newlibadr_us(fd, id->lib, chan->ipo);
- }
+ for (chan = chanbase->first; chan; chan = chan->next) {
+ chan->ipo = newlibadr_us(fd, id->lib, chan->ipo);
+ }
}
/** \} */
@@ -2806,239 +2845,231 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas
static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
{
- FModifier *fcm;
+ FModifier *fcm;
- for (fcm = list->first; fcm; fcm = fcm->next) {
- /* data for specific modifiers */
- switch (fcm->type) {
- case FMODIFIER_TYPE_PYTHON:
- {
- FMod_Python *data = (FMod_Python *)fcm->data;
- data->script = newlibadr(fd, id->lib, data->script);
+ for (fcm = list->first; fcm; fcm = fcm->next) {
+ /* data for specific modifiers */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_PYTHON: {
+ FMod_Python *data = (FMod_Python *)fcm->data;
+ data->script = newlibadr(fd, id->lib, data->script);
- break;
- }
- }
- }
+ break;
+ }
+ }
+ }
}
static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
{
- FCurve *fcu;
+ FCurve *fcu;
- if (list == NULL)
- return;
+ if (list == NULL)
+ return;
- /* relink ID-block references... */
- for (fcu = list->first; fcu; fcu = fcu->next) {
- /* driver data */
- if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
+ /* relink ID-block references... */
+ for (fcu = list->first; fcu; fcu = fcu->next) {
+ /* driver data */
+ if (fcu->driver) {
+ ChannelDriver *driver = fcu->driver;
+ DriverVar *dvar;
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER_BEGIN(dvar)
- {
- /* only relink if still used */
- if (tarIndex < dvar->num_targets)
- dtar->id = newlibadr(fd, id->lib, dtar->id);
- else
- dtar->id = NULL;
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ /* only relink if still used */
+ if (tarIndex < dvar->num_targets)
+ dtar->id = newlibadr(fd, id->lib, dtar->id);
+ else
+ dtar->id = NULL;
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
- /* modifiers */
- lib_link_fmodifiers(fd, id, &fcu->modifiers);
- }
+ /* modifiers */
+ lib_link_fmodifiers(fd, id, &fcu->modifiers);
+ }
}
-
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve)
{
- FModifier *fcm;
+ FModifier *fcm;
- for (fcm = list->first; fcm; fcm = fcm->next) {
- /* relink general data */
- fcm->data = newdataadr(fd, fcm->data);
- fcm->curve = curve;
+ for (fcm = list->first; fcm; fcm = fcm->next) {
+ /* relink general data */
+ fcm->data = newdataadr(fd, fcm->data);
+ fcm->curve = curve;
- /* do relinking of data for specific types */
- switch (fcm->type) {
- case FMODIFIER_TYPE_GENERATOR:
- {
- FMod_Generator *data = (FMod_Generator *)fcm->data;
+ /* do relinking of data for specific types */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_GENERATOR: {
+ FMod_Generator *data = (FMod_Generator *)fcm->data;
- data->coefficients = newdataadr(fd, data->coefficients);
+ data->coefficients = newdataadr(fd, data->coefficients);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_float_array(data->coefficients, data->arraysize);
- }
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array(data->coefficients, data->arraysize);
+ }
- break;
- }
- case FMODIFIER_TYPE_ENVELOPE:
- {
- FMod_Envelope *data = (FMod_Envelope *)fcm->data;
+ break;
+ }
+ case FMODIFIER_TYPE_ENVELOPE: {
+ FMod_Envelope *data = (FMod_Envelope *)fcm->data;
- data->data = newdataadr(fd, data->data);
+ data->data = newdataadr(fd, data->data);
- break;
- }
- case FMODIFIER_TYPE_PYTHON:
- {
- FMod_Python *data = (FMod_Python *)fcm->data;
+ break;
+ }
+ case FMODIFIER_TYPE_PYTHON: {
+ FMod_Python *data = (FMod_Python *)fcm->data;
- data->prop = newdataadr(fd, data->prop);
- IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ data->prop = newdataadr(fd, data->prop);
+ IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- break;
- }
- }
- }
+ break;
+ }
+ }
+ }
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fcurves(FileData *fd, ListBase *list)
{
- FCurve *fcu;
-
- /* link F-Curve data to F-Curve again (non ID-libs) */
- for (fcu = list->first; fcu; fcu = fcu->next) {
- /* curve data */
- fcu->bezt = newdataadr(fd, fcu->bezt);
- fcu->fpt = newdataadr(fd, fcu->fpt);
-
- /* rna path */
- fcu->rna_path = newdataadr(fd, fcu->rna_path);
-
- /* group */
- fcu->grp = newdataadr(fd, fcu->grp);
-
- /* clear disabled flag - allows disabled drivers to be tried again ([#32155]),
- * but also means that another method for "reviving disabled F-Curves" exists
- */
- fcu->flag &= ~FCURVE_DISABLED;
-
- /* driver */
- fcu->driver = newdataadr(fd, fcu->driver);
- if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
-
- /* compiled expression data will need to be regenerated (old pointer may still be set here) */
- driver->expr_comp = NULL;
- driver->expr_simple = NULL;
-
- /* give the driver a fresh chance - the operating environment may be different now
- * (addons, etc. may be different) so the driver namespace may be sane now [#32155]
- */
- driver->flag &= ~DRIVER_FLAG_INVALID;
-
- /* relink variables, targets and their paths */
- link_list(fd, &driver->variables);
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER_BEGIN(dvar)
- {
- /* only relink the targets being used */
- if (tarIndex < dvar->num_targets)
- dtar->rna_path = newdataadr(fd, dtar->rna_path);
- else
- dtar->rna_path = NULL;
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* modifiers */
- link_list(fd, &fcu->modifiers);
- direct_link_fmodifiers(fd, &fcu->modifiers, fcu);
- }
+ FCurve *fcu;
+
+ /* link F-Curve data to F-Curve again (non ID-libs) */
+ for (fcu = list->first; fcu; fcu = fcu->next) {
+ /* curve data */
+ fcu->bezt = newdataadr(fd, fcu->bezt);
+ fcu->fpt = newdataadr(fd, fcu->fpt);
+
+ /* rna path */
+ fcu->rna_path = newdataadr(fd, fcu->rna_path);
+
+ /* group */
+ fcu->grp = newdataadr(fd, fcu->grp);
+
+ /* clear disabled flag - allows disabled drivers to be tried again ([#32155]),
+ * but also means that another method for "reviving disabled F-Curves" exists
+ */
+ fcu->flag &= ~FCURVE_DISABLED;
+
+ /* driver */
+ fcu->driver = newdataadr(fd, fcu->driver);
+ if (fcu->driver) {
+ ChannelDriver *driver = fcu->driver;
+ DriverVar *dvar;
+
+ /* compiled expression data will need to be regenerated (old pointer may still be set here) */
+ driver->expr_comp = NULL;
+ driver->expr_simple = NULL;
+
+ /* give the driver a fresh chance - the operating environment may be different now
+ * (addons, etc. may be different) so the driver namespace may be sane now [#32155]
+ */
+ driver->flag &= ~DRIVER_FLAG_INVALID;
+
+ /* relink variables, targets and their paths */
+ link_list(fd, &driver->variables);
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ /* only relink the targets being used */
+ if (tarIndex < dvar->num_targets)
+ dtar->rna_path = newdataadr(fd, dtar->rna_path);
+ else
+ dtar->rna_path = NULL;
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* modifiers */
+ link_list(fd, &fcu->modifiers);
+ direct_link_fmodifiers(fd, &fcu->modifiers, fcu);
+ }
}
-
static void lib_link_action(FileData *fd, Main *main)
{
- for (bAction *act = main->actions.first; act; act = act->id.next) {
- if (act->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(act->id.properties, fd);
+ for (bAction *act = main->actions.first; act; act = act->id.next) {
+ if (act->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(act->id.properties, fd);
-// XXX deprecated - old animation system <<<
- for (bActionChannel *chan = act->chanbase.first; chan; chan = chan->next) {
- chan->ipo = newlibadr_us(fd, act->id.lib, chan->ipo);
- lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
- }
-// >>> XXX deprecated - old animation system
+ // XXX deprecated - old animation system <<<
+ for (bActionChannel *chan = act->chanbase.first; chan; chan = chan->next) {
+ chan->ipo = newlibadr_us(fd, act->id.lib, chan->ipo);
+ lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
+ }
+ // >>> XXX deprecated - old animation system
- lib_link_fcurves(fd, &act->id, &act->curves);
+ lib_link_fcurves(fd, &act->id, &act->curves);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
- if (marker->camera) {
- marker->camera = newlibadr(fd, act->id.lib, marker->camera);
- }
- }
+ for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ if (marker->camera) {
+ marker->camera = newlibadr(fd, act->id.lib, marker->camera);
+ }
+ }
- act->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ act->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_action(FileData *fd, bAction *act)
{
- bActionChannel *achan; // XXX deprecated - old animation system
- bActionGroup *agrp;
+ bActionChannel *achan; // XXX deprecated - old animation system
+ bActionGroup *agrp;
- link_list(fd, &act->curves);
- link_list(fd, &act->chanbase); // XXX deprecated - old animation system
- link_list(fd, &act->groups);
- link_list(fd, &act->markers);
+ link_list(fd, &act->curves);
+ link_list(fd, &act->chanbase); // XXX deprecated - old animation system
+ link_list(fd, &act->groups);
+ link_list(fd, &act->markers);
-// XXX deprecated - old animation system <<<
- for (achan = act->chanbase.first; achan; achan = achan->next) {
- achan->grp = newdataadr(fd, achan->grp);
+ // XXX deprecated - old animation system <<<
+ for (achan = act->chanbase.first; achan; achan = achan->next) {
+ achan->grp = newdataadr(fd, achan->grp);
- link_list(fd, &achan->constraintChannels);
- }
-// >>> XXX deprecated - old animation system
+ link_list(fd, &achan->constraintChannels);
+ }
+ // >>> XXX deprecated - old animation system
- direct_link_fcurves(fd, &act->curves);
+ direct_link_fcurves(fd, &act->curves);
- for (agrp = act->groups.first; agrp; agrp = agrp->next) {
- agrp->channels.first = newdataadr(fd, agrp->channels.first);
- agrp->channels.last = newdataadr(fd, agrp->channels.last);
- }
+ for (agrp = act->groups.first; agrp; agrp = agrp->next) {
+ agrp->channels.first = newdataadr(fd, agrp->channels.first);
+ agrp->channels.last = newdataadr(fd, agrp->channels.last);
+ }
}
static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
{
- NlaStrip *strip;
+ NlaStrip *strip;
- for (strip = list->first; strip; strip = strip->next) {
- /* check strip's children */
- lib_link_nladata_strips(fd, id, &strip->strips);
+ for (strip = list->first; strip; strip = strip->next) {
+ /* check strip's children */
+ lib_link_nladata_strips(fd, id, &strip->strips);
- /* check strip's F-Curves */
- lib_link_fcurves(fd, id, &strip->fcurves);
+ /* check strip's F-Curves */
+ lib_link_fcurves(fd, id, &strip->fcurves);
- /* reassign the counted-reference to action */
- strip->act = newlibadr_us(fd, id->lib, strip->act);
+ /* reassign the counted-reference to action */
+ strip->act = newlibadr_us(fd, id->lib, strip->act);
- /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
- if ((strip->act) && (strip->act->idroot == 0))
- strip->act->idroot = GS(id->name);
- }
+ /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
+ if ((strip->act) && (strip->act->idroot == 0))
+ strip->act->idroot = GS(id->name);
+ }
}
static void lib_link_nladata(FileData *fd, ID *id, ListBase *list)
{
- NlaTrack *nlt;
+ NlaTrack *nlt;
- /* we only care about the NLA strips inside the tracks */
- for (nlt = list->first; nlt; nlt = nlt->next) {
- lib_link_nladata_strips(fd, id, &nlt->strips);
- }
+ /* we only care about the NLA strips inside the tracks */
+ for (nlt = list->first; nlt; nlt = nlt->next) {
+ lib_link_nladata_strips(fd, id, &nlt->strips);
+ }
}
/* This handles Animato NLA-Strips linking
@@ -3046,122 +3077,122 @@ static void lib_link_nladata(FileData *fd, ID *id, ListBase *list)
*/
static void direct_link_nladata_strips(FileData *fd, ListBase *list)
{
- NlaStrip *strip;
+ NlaStrip *strip;
- for (strip = list->first; strip; strip = strip->next) {
- /* strip's child strips */
- link_list(fd, &strip->strips);
- direct_link_nladata_strips(fd, &strip->strips);
+ for (strip = list->first; strip; strip = strip->next) {
+ /* strip's child strips */
+ link_list(fd, &strip->strips);
+ direct_link_nladata_strips(fd, &strip->strips);
- /* strip's F-Curves */
- link_list(fd, &strip->fcurves);
- direct_link_fcurves(fd, &strip->fcurves);
+ /* strip's F-Curves */
+ link_list(fd, &strip->fcurves);
+ direct_link_fcurves(fd, &strip->fcurves);
- /* strip's F-Modifiers */
- link_list(fd, &strip->modifiers);
- direct_link_fmodifiers(fd, &strip->modifiers, NULL);
- }
+ /* strip's F-Modifiers */
+ link_list(fd, &strip->modifiers);
+ direct_link_fmodifiers(fd, &strip->modifiers, NULL);
+ }
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_nladata(FileData *fd, ListBase *list)
{
- NlaTrack *nlt;
+ NlaTrack *nlt;
- for (nlt = list->first; nlt; nlt = nlt->next) {
- /* relink list of strips */
- link_list(fd, &nlt->strips);
+ for (nlt = list->first; nlt; nlt = nlt->next) {
+ /* relink list of strips */
+ link_list(fd, &nlt->strips);
- /* relink strip data */
- direct_link_nladata_strips(fd, &nlt->strips);
- }
+ /* relink strip data */
+ direct_link_nladata_strips(fd, &nlt->strips);
+ }
}
/* ------- */
static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
+ KeyingSet *ks;
+ KS_Path *ksp;
- /* here, we're only interested in the ID pointer stored in some of the paths */
- for (ks = list->first; ks; ks = ks->next) {
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- ksp->id = newlibadr(fd, id->lib, ksp->id);
- }
- }
+ /* here, we're only interested in the ID pointer stored in some of the paths */
+ for (ks = list->first; ks; ks = ks->next) {
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ ksp->id = newlibadr(fd, id->lib, ksp->id);
+ }
+ }
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_keyingsets(FileData *fd, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
+ KeyingSet *ks;
+ KS_Path *ksp;
- /* link KeyingSet data to KeyingSet again (non ID-libs) */
- for (ks = list->first; ks; ks = ks->next) {
- /* paths */
- link_list(fd, &ks->paths);
+ /* link KeyingSet data to KeyingSet again (non ID-libs) */
+ for (ks = list->first; ks; ks = ks->next) {
+ /* paths */
+ link_list(fd, &ks->paths);
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- /* rna path */
- ksp->rna_path = newdataadr(fd, ksp->rna_path);
- }
- }
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ /* rna path */
+ ksp->rna_path = newdataadr(fd, ksp->rna_path);
+ }
+ }
}
/* ------- */
static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
{
- if (adt == NULL)
- return;
+ if (adt == NULL)
+ return;
- /* link action data */
- adt->action = newlibadr_us(fd, id->lib, adt->action);
- adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact);
+ /* link action data */
+ adt->action = newlibadr_us(fd, id->lib, adt->action);
+ adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact);
- /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
- if ((adt->action) && (adt->action->idroot == 0))
- adt->action->idroot = GS(id->name);
- if ((adt->tmpact) && (adt->tmpact->idroot == 0))
- adt->tmpact->idroot = GS(id->name);
+ /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
+ if ((adt->action) && (adt->action->idroot == 0))
+ adt->action->idroot = GS(id->name);
+ if ((adt->tmpact) && (adt->tmpact->idroot == 0))
+ adt->tmpact->idroot = GS(id->name);
- /* link drivers */
- lib_link_fcurves(fd, id, &adt->drivers);
+ /* link drivers */
+ lib_link_fcurves(fd, id, &adt->drivers);
- /* overrides don't have lib-link for now, so no need to do anything */
+ /* overrides don't have lib-link for now, so no need to do anything */
- /* link NLA-data */
- lib_link_nladata(fd, id, &adt->nla_tracks);
+ /* link NLA-data */
+ lib_link_nladata(fd, id, &adt->nla_tracks);
}
static void direct_link_animdata(FileData *fd, AnimData *adt)
{
- /* NOTE: must have called newdataadr already before doing this... */
- if (adt == NULL)
- return;
+ /* NOTE: must have called newdataadr already before doing this... */
+ if (adt == NULL)
+ return;
- /* link drivers */
- link_list(fd, &adt->drivers);
- direct_link_fcurves(fd, &adt->drivers);
- adt->driver_array = NULL;
+ /* link drivers */
+ link_list(fd, &adt->drivers);
+ direct_link_fcurves(fd, &adt->drivers);
+ adt->driver_array = NULL;
- /* link overrides */
- // TODO...
+ /* link overrides */
+ // TODO...
- /* link NLA-data */
- link_list(fd, &adt->nla_tracks);
- direct_link_nladata(fd, &adt->nla_tracks);
+ /* link NLA-data */
+ link_list(fd, &adt->nla_tracks);
+ direct_link_nladata(fd, &adt->nla_tracks);
- /* relink active track/strip - even though strictly speaking this should only be used
- * if we're in 'tweaking mode', we need to be able to have this loaded back for
- * undo, but also since users may not exit tweakmode before saving (#24535)
- */
- // TODO: it's not really nice that anyone should be able to save the file in this
- // state, but it's going to be too hard to enforce this single case...
- adt->act_track = newdataadr(fd, adt->act_track);
- adt->actstrip = newdataadr(fd, adt->actstrip);
+ /* relink active track/strip - even though strictly speaking this should only be used
+ * if we're in 'tweaking mode', we need to be able to have this loaded back for
+ * undo, but also since users may not exit tweakmode before saving (#24535)
+ */
+ // TODO: it's not really nice that anyone should be able to save the file in this
+ // state, but it's going to be too hard to enforce this single case...
+ adt->act_track = newdataadr(fd, adt->act_track);
+ adt->actstrip = newdataadr(fd, adt->actstrip);
}
/** \} */
@@ -3172,26 +3203,27 @@ static void direct_link_animdata(FileData *fd, AnimData *adt)
static void lib_link_cachefiles(FileData *fd, Main *bmain)
{
- /* only link ID pointers */
- for (CacheFile *cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
- if (cache_file->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(cache_file->id.properties, fd);
- lib_link_animdata(fd, &cache_file->id, cache_file->adt);
+ /* only link ID pointers */
+ for (CacheFile *cache_file = bmain->cachefiles.first; cache_file;
+ cache_file = cache_file->id.next) {
+ if (cache_file->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(cache_file->id.properties, fd);
+ lib_link_animdata(fd, &cache_file->id, cache_file->adt);
- cache_file->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ cache_file->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
{
- BLI_listbase_clear(&cache_file->object_paths);
- cache_file->handle = NULL;
- cache_file->handle_mutex = NULL;
+ BLI_listbase_clear(&cache_file->object_paths);
+ cache_file->handle = NULL;
+ cache_file->handle_mutex = NULL;
- /* relink animdata */
- cache_file->adt = newdataadr(fd, cache_file->adt);
- direct_link_animdata(fd, cache_file->adt);
+ /* relink animdata */
+ cache_file->adt = newdataadr(fd, cache_file->adt);
+ direct_link_animdata(fd, cache_file->adt);
}
/** \} */
@@ -3202,74 +3234,74 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
static void lib_link_workspaces(FileData *fd, Main *bmain)
{
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
- ID *id = (ID *)workspace;
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
+ ListBase *layouts = BKE_workspace_layouts_get(workspace);
+ ID *id = (ID *)workspace;
- if ((id->tag & LIB_TAG_NEED_LINK) == 0) {
- continue;
- }
- IDP_LibLinkProperty(id->properties, fd);
- id_us_ensure_real(id);
+ if ((id->tag & LIB_TAG_NEED_LINK) == 0) {
+ continue;
+ }
+ IDP_LibLinkProperty(id->properties, fd);
+ id_us_ensure_real(id);
- for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
- layout->screen = newlibadr_us(fd, id->lib, layout->screen);
+ for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
+ layout->screen = newlibadr_us(fd, id->lib, layout->screen);
- layout_next = layout->next;
- if (layout->screen) {
- if (ID_IS_LINKED(id)) {
- layout->screen->winid = 0;
- if (layout->screen->temp) {
- /* delete temp layouts when appending */
- BKE_workspace_layout_remove(bmain, workspace, layout);
- }
- }
- }
- }
+ layout_next = layout->next;
+ if (layout->screen) {
+ if (ID_IS_LINKED(id)) {
+ layout->screen->winid = 0;
+ if (layout->screen->temp) {
+ /* delete temp layouts when appending */
+ BKE_workspace_layout_remove(bmain, workspace, layout);
+ }
+ }
+ }
+ }
- id->tag &= ~LIB_TAG_NEED_LINK;
- }
+ id->tag &= ~LIB_TAG_NEED_LINK;
+ }
}
static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main *main)
{
- link_list(fd, BKE_workspace_layouts_get(workspace));
- link_list(fd, &workspace->hook_layout_relations);
- link_list(fd, &workspace->owner_ids);
- link_list(fd, &workspace->tools);
-
- for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first;
- relation;
- relation = relation->next)
- {
- relation->parent = newglobadr(fd, relation->parent); /* data from window - need to access through global oldnew-map */
- relation->value = newdataadr(fd, relation->value);
- }
-
- /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data
- * when reading windows, so have to update windows after/when reading workspaces. */
- for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpaceLayout *act_layout = newdataadr(fd, BKE_workspace_active_layout_get(win->workspace_hook));
- if (act_layout) {
- BKE_workspace_active_layout_set(win->workspace_hook, act_layout);
- }
- }
- }
-
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
- tref->runtime = NULL;
- tref->properties = newdataadr(fd, tref->properties);
- IDP_DirectLinkGroup_OrFree(&tref->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
-
- workspace->status_text = NULL;
+ link_list(fd, BKE_workspace_layouts_get(workspace));
+ link_list(fd, &workspace->hook_layout_relations);
+ link_list(fd, &workspace->owner_ids);
+ link_list(fd, &workspace->tools);
+
+ for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; relation;
+ relation = relation->next) {
+ relation->parent = newglobadr(
+ fd, relation->parent); /* data from window - need to access through global oldnew-map */
+ relation->value = newdataadr(fd, relation->value);
+ }
+
+ /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data
+ * when reading windows, so have to update windows after/when reading workspaces. */
+ for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ WorkSpaceLayout *act_layout = newdataadr(
+ fd, BKE_workspace_active_layout_get(win->workspace_hook));
+ if (act_layout) {
+ BKE_workspace_active_layout_set(win->workspace_hook, act_layout);
+ }
+ }
+ }
+
+ for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ tref->runtime = NULL;
+ tref->properties = newdataadr(fd, tref->properties);
+ IDP_DirectLinkGroup_OrFree(&tref->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+
+ workspace->status_text = NULL;
}
static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook *hook, ID *id)
{
- WorkSpace *workspace = BKE_workspace_active_get(hook);
- BKE_workspace_active_set(hook, newlibadr(fd, id->lib, workspace));
+ WorkSpace *workspace = BKE_workspace_active_get(hook);
+ BKE_workspace_active_set(hook, newlibadr(fd, id->lib, workspace));
}
/** \} */
@@ -3281,48 +3313,48 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
/* Single node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
+ bNode *node;
+ bNodeSocket *sock;
- IDP_LibLinkProperty(ntree->id.properties, fd);
- lib_link_animdata(fd, &ntree->id, ntree->adt);
+ IDP_LibLinkProperty(ntree->id.properties, fd);
+ lib_link_animdata(fd, &ntree->id, ntree->adt);
- ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd);
+ ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd);
- for (node = ntree->nodes.first; node; node = node->next) {
- /* Link ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_LibLinkProperty(node->prop, fd);
+ for (node = ntree->nodes.first; node; node = node->next) {
+ /* Link ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_LibLinkProperty(node->prop, fd);
- node->id = newlibadr_us(fd, id->lib, node->id);
+ node->id = newlibadr_us(fd, id->lib, node->id);
- for (sock = node->inputs.first; sock; sock = sock->next) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
- for (sock = node->outputs.first; sock; sock = sock->next) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
- }
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ IDP_LibLinkProperty(sock->prop, fd);
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ IDP_LibLinkProperty(sock->prop, fd);
+ }
+ }
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ IDP_LibLinkProperty(sock->prop, fd);
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ IDP_LibLinkProperty(sock->prop, fd);
+ }
}
/* library ntree linking after fileread */
static void lib_link_nodetree(FileData *fd, Main *main)
{
- /* only link ID pointers */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- if (ntree->id.tag & LIB_TAG_NEED_LINK) {
- lib_link_ntree(fd, &ntree->id, ntree);
+ /* only link ID pointers */
+ for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
+ if (ntree->id.tag & LIB_TAG_NEED_LINK) {
+ lib_link_ntree(fd, &ntree->id, ntree);
- ntree->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ ntree->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/* updates group node socket identifier so that
@@ -3330,36 +3362,36 @@ static void lib_link_nodetree(FileData *fd, Main *main)
*/
static void lib_node_do_versions_group_indices(bNode *gnode)
{
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNodeSocket *sock;
- bNodeLink *link;
-
- for (sock = gnode->outputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->tonode == NULL && link->fromsock->own_index == old_index) {
- strcpy(sock->identifier, link->fromsock->identifier);
- /* deprecated */
- sock->own_index = link->fromsock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
- for (sock = gnode->inputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->fromnode == NULL && link->tosock->own_index == old_index) {
- strcpy(sock->identifier, link->tosock->identifier);
- /* deprecated */
- sock->own_index = link->tosock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ for (sock = gnode->outputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->tonode == NULL && link->fromsock->own_index == old_index) {
+ strcpy(sock->identifier, link->fromsock->identifier);
+ /* deprecated */
+ sock->own_index = link->fromsock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
+ for (sock = gnode->inputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->fromnode == NULL && link->tosock->own_index == old_index) {
+ strcpy(sock->identifier, link->tosock->identifier);
+ /* deprecated */
+ sock->own_index = link->tosock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
}
/* verify types for nodes and groups, all data has to be read */
@@ -3367,335 +3399,350 @@ static void lib_node_do_versions_group_indices(bNode *gnode)
* typedefs */
static void lib_verify_nodetree(Main *main, int UNUSED(open))
{
- /* this crashes blender on undo/redo */
+ /* this crashes blender on undo/redo */
#if 0
- if (open == 1) {
- reinit_nodesystem();
- }
+ if (open == 1) {
+ reinit_nodesystem();
+ }
#endif
- /* set node->typeinfo pointers */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- ntreeSetTypes(NULL, ntree);
- } FOREACH_NODETREE_END;
-
- /* verify static socket templates */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- node_verify_socket_templates(ntree, node);
- } FOREACH_NODETREE_END;
-
- {
- bool has_old_groups = false;
- /* XXX this should actually be part of do_versions, but since we need
- * finished library linking, it is not possible there. Instead in do_versions
- * we have set the NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 flag, so at this point we can do the
- * actual group node updates.
- */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2) {
- has_old_groups = 1;
- }
- }
-
- if (has_old_groups) {
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- /* updates external links for all group nodes in a tree */
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2))
- lib_node_do_versions_group_indices(node);
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
- }
- }
-
- {
- /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
- * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already
- * (see NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2).
- *
- * XXX this should actually be part of do_versions,
- * but needs valid typeinfo pointers to create interface nodes.
- *
- * Note: theoretically only needed in node groups (main->nodetree),
- * but due to a temporary bug such links could have been added in all trees,
- * so have to clean up all of them ...
- */
-
- FOREACH_NODETREE_BEGIN(main, ntree, id) {
- if (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP) {
- bNode *input_node = NULL, *output_node = NULL;
- int num_inputs = 0, num_outputs = 0;
- bNodeLink *link, *next_link;
- /* Only create new interface nodes for actual older files.
- * New file versions already have input/output nodes with duplicate links,
- * in that case just remove the invalid links.
- */
- const bool create_io_nodes = (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0;
-
- float input_locx = 1000000.0f, input_locy = 0.0f;
- float output_locx = -1000000.0f, output_locy = 0.0f;
- /* rough guess, not nice but we don't have access to UI constants here ... */
- static const float offsetx = 42 + 3 * 20 + 20;
- /*static const float offsety = 0.0f;*/
-
- if (create_io_nodes) {
- if (ntree->inputs.first)
- input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
-
- if (ntree->outputs.first)
- output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
- }
-
- /* Redirect links from/to the node tree interface to input/output node.
- * If the fromnode/tonode pointers are NULL, this means a link from/to
- * the ntree interface sockets, which need to be redirected to new interface nodes.
- */
- for (link = ntree->links.first; link; link = next_link) {
- bool free_link = false;
- next_link = link->next;
-
- if (link->fromnode == NULL) {
- if (input_node) {
- link->fromnode = input_node;
- link->fromsock = node_group_input_find_socket(input_node, link->fromsock->identifier);
- ++num_inputs;
-
- if (link->tonode) {
- if (input_locx > link->tonode->locx - offsetx)
- input_locx = link->tonode->locx - offsetx;
- input_locy += link->tonode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (link->tonode == NULL) {
- if (output_node) {
- link->tonode = output_node;
- link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
- ++num_outputs;
-
- if (link->fromnode) {
- if (output_locx < link->fromnode->locx + offsetx)
- output_locx = link->fromnode->locx + offsetx;
- output_locy += link->fromnode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (free_link)
- nodeRemLink(ntree, link);
- }
-
- if (num_inputs > 0) {
- input_locy /= num_inputs;
- input_node->locx = input_locx;
- input_node->locy = input_locy;
- }
- if (num_outputs > 0) {
- output_locy /= num_outputs;
- output_node->locx = output_locx;
- output_node->locy = output_locy;
- }
-
- /* clear do_versions flags */
- ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP | NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE);
- }
- }
- FOREACH_NODETREE_END;
- }
-
- /* verify all group user nodes */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntreeVerifyNodes(main, &ntree->id);
- }
-
- /* make update calls where necessary */
- {
- FOREACH_NODETREE_BEGIN(main, ntree, id) {
- /* make an update call for the tree */
- ntreeUpdateTree(main, ntree);
- } FOREACH_NODETREE_END;
- }
+ /* set node->typeinfo pointers */
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
+ ntreeSetTypes(NULL, ntree);
+ }
+ FOREACH_NODETREE_END;
+
+ /* verify static socket templates */
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next)
+ node_verify_socket_templates(ntree, node);
+ }
+ FOREACH_NODETREE_END;
+
+ {
+ bool has_old_groups = false;
+ /* XXX this should actually be part of do_versions, but since we need
+ * finished library linking, it is not possible there. Instead in do_versions
+ * we have set the NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 flag, so at this point we can do the
+ * actual group node updates.
+ */
+ for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
+ if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2) {
+ has_old_groups = 1;
+ }
+ }
+
+ if (has_old_groups) {
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
+ /* updates external links for all group nodes in a tree */
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP) {
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2))
+ lib_node_do_versions_group_indices(node);
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
+ ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
+ }
+ }
+
+ {
+ /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
+ * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already
+ * (see NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2).
+ *
+ * XXX this should actually be part of do_versions,
+ * but needs valid typeinfo pointers to create interface nodes.
+ *
+ * Note: theoretically only needed in node groups (main->nodetree),
+ * but due to a temporary bug such links could have been added in all trees,
+ * so have to clean up all of them ...
+ */
+
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
+ if (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP) {
+ bNode *input_node = NULL, *output_node = NULL;
+ int num_inputs = 0, num_outputs = 0;
+ bNodeLink *link, *next_link;
+ /* Only create new interface nodes for actual older files.
+ * New file versions already have input/output nodes with duplicate links,
+ * in that case just remove the invalid links.
+ */
+ const bool create_io_nodes = (ntree->flag &
+ NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0;
+
+ float input_locx = 1000000.0f, input_locy = 0.0f;
+ float output_locx = -1000000.0f, output_locy = 0.0f;
+ /* rough guess, not nice but we don't have access to UI constants here ... */
+ static const float offsetx = 42 + 3 * 20 + 20;
+ /*static const float offsety = 0.0f;*/
+
+ if (create_io_nodes) {
+ if (ntree->inputs.first)
+ input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
+
+ if (ntree->outputs.first)
+ output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
+ }
+
+ /* Redirect links from/to the node tree interface to input/output node.
+ * If the fromnode/tonode pointers are NULL, this means a link from/to
+ * the ntree interface sockets, which need to be redirected to new interface nodes.
+ */
+ for (link = ntree->links.first; link; link = next_link) {
+ bool free_link = false;
+ next_link = link->next;
+
+ if (link->fromnode == NULL) {
+ if (input_node) {
+ link->fromnode = input_node;
+ link->fromsock = node_group_input_find_socket(input_node,
+ link->fromsock->identifier);
+ ++num_inputs;
+
+ if (link->tonode) {
+ if (input_locx > link->tonode->locx - offsetx)
+ input_locx = link->tonode->locx - offsetx;
+ input_locy += link->tonode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (link->tonode == NULL) {
+ if (output_node) {
+ link->tonode = output_node;
+ link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
+ ++num_outputs;
+
+ if (link->fromnode) {
+ if (output_locx < link->fromnode->locx + offsetx)
+ output_locx = link->fromnode->locx + offsetx;
+ output_locy += link->fromnode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (free_link)
+ nodeRemLink(ntree, link);
+ }
+
+ if (num_inputs > 0) {
+ input_locy /= num_inputs;
+ input_node->locx = input_locx;
+ input_node->locy = input_locy;
+ }
+ if (num_outputs > 0) {
+ output_locy /= num_outputs;
+ output_node->locx = output_locx;
+ output_node->locy = output_locy;
+ }
+
+ /* clear do_versions flags */
+ ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP |
+ NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE);
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ /* verify all group user nodes */
+ for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
+ ntreeVerifyNodes(main, &ntree->id);
+ }
+
+ /* make update calls where necessary */
+ {
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
+ /* make an update call for the tree */
+ ntreeUpdateTree(main, ntree);
+ }
+ FOREACH_NODETREE_END;
+ }
}
static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
{
- sock->prop = newdataadr(fd, sock->prop);
- IDP_DirectLinkGroup_OrFree(&sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ sock->prop = newdataadr(fd, sock->prop);
+ IDP_DirectLinkGroup_OrFree(&sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- sock->link = newdataadr(fd, sock->link);
- sock->typeinfo = NULL;
- sock->storage = newdataadr(fd, sock->storage);
- sock->default_value = newdataadr(fd, sock->default_value);
- sock->cache = NULL;
+ sock->link = newdataadr(fd, sock->link);
+ sock->typeinfo = NULL;
+ sock->storage = newdataadr(fd, sock->storage);
+ sock->default_value = newdataadr(fd, sock->default_value);
+ sock->cache = NULL;
}
/* ntree itself has been read! */
static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
{
- /* note: writing and reading goes in sync, for speed */
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
-
- ntree->init = 0; /* to set callbacks and force setting types */
- ntree->is_updating = false;
- ntree->typeinfo = NULL;
- ntree->interface_type = NULL;
-
- ntree->progress = NULL;
- ntree->execdata = NULL;
- ntree->duplilock = NULL;
-
- ntree->adt = newdataadr(fd, ntree->adt);
- direct_link_animdata(fd, ntree->adt);
-
- ntree->id.recalc &= ~ID_RECALC_ALL;
-
- link_list(fd, &ntree->nodes);
- for (node = ntree->nodes.first; node; node = node->next) {
- node->typeinfo = NULL;
-
- link_list(fd, &node->inputs);
- link_list(fd, &node->outputs);
-
- node->prop = newdataadr(fd, node->prop);
- IDP_DirectLinkGroup_OrFree(&node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-
- link_list(fd, &node->internal_links);
- for (link = node->internal_links.first; link; link = link->next) {
- link->fromnode = newdataadr(fd, link->fromnode);
- link->fromsock = newdataadr(fd, link->fromsock);
- link->tonode = newdataadr(fd, link->tonode);
- link->tosock = newdataadr(fd, link->tosock);
- }
-
- if (node->type == CMP_NODE_MOVIEDISTORTION) {
- node->storage = newmclipadr(fd, node->storage);
- }
- else {
- node->storage = newdataadr(fd, node->storage);
- }
-
- if (node->storage) {
- /* could be handlerized at some point */
- if (ntree->type == NTREE_SHADER) {
- if (node->type == SH_NODE_CURVE_VEC || node->type == SH_NODE_CURVE_RGB) {
- direct_link_curvemapping(fd, node->storage);
- }
- else if (node->type == SH_NODE_SCRIPT) {
- NodeShaderScript *nss = (NodeShaderScript *)node->storage;
- nss->bytecode = newdataadr(fd, nss->bytecode);
- }
- else if (node->type == SH_NODE_TEX_POINTDENSITY) {
- NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage;
- memset(&npd->pd, 0, sizeof(npd->pd));
- }
- else if (node->type == SH_NODE_TEX_IMAGE) {
- NodeTexImage *tex = (NodeTexImage *)node->storage;
- tex->iuser.ok = 1;
- tex->iuser.scene = NULL;
- }
- else if (node->type == SH_NODE_TEX_ENVIRONMENT) {
- NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage;
- tex->iuser.ok = 1;
- tex->iuser.scene = NULL;
- }
- }
- else if (ntree->type == NTREE_COMPOSIT) {
- if (ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) {
- direct_link_curvemapping(fd, node->storage);
- }
- else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
- ImageUser *iuser = node->storage;
- iuser->ok = 1;
- iuser->scene = NULL;
- }
- else if (node->type == CMP_NODE_CRYPTOMATTE) {
- NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
- nc->matte_id = newdataadr(fd, nc->matte_id);
- }
- }
- else if (ntree->type == NTREE_TEXTURE) {
- if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME) {
- direct_link_curvemapping(fd, node->storage);
- }
- else if (node->type == TEX_NODE_IMAGE) {
- ImageUser *iuser = node->storage;
- iuser->ok = 1;
- iuser->scene = NULL;
- }
- }
- }
- }
- link_list(fd, &ntree->links);
-
- /* and we connect the rest */
- for (node = ntree->nodes.first; node; node = node->next) {
- node->parent = newdataadr(fd, node->parent);
- node->lasty = 0;
-
- for (sock = node->inputs.first; sock; sock = sock->next)
- direct_link_node_socket(fd, sock);
- for (sock = node->outputs.first; sock; sock = sock->next)
- direct_link_node_socket(fd, sock);
- }
-
- /* interface socket lists */
- link_list(fd, &ntree->inputs);
- link_list(fd, &ntree->outputs);
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- direct_link_node_socket(fd, sock);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- direct_link_node_socket(fd, sock);
-
- for (link = ntree->links.first; link; link = link->next) {
- link->fromnode = newdataadr(fd, link->fromnode);
- link->tonode = newdataadr(fd, link->tonode);
- link->fromsock = newdataadr(fd, link->fromsock);
- link->tosock = newdataadr(fd, link->tosock);
- }
+ /* note: writing and reading goes in sync, for speed */
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ ntree->init = 0; /* to set callbacks and force setting types */
+ ntree->is_updating = false;
+ ntree->typeinfo = NULL;
+ ntree->interface_type = NULL;
+
+ ntree->progress = NULL;
+ ntree->execdata = NULL;
+ ntree->duplilock = NULL;
+
+ ntree->adt = newdataadr(fd, ntree->adt);
+ direct_link_animdata(fd, ntree->adt);
+
+ ntree->id.recalc &= ~ID_RECALC_ALL;
+
+ link_list(fd, &ntree->nodes);
+ for (node = ntree->nodes.first; node; node = node->next) {
+ node->typeinfo = NULL;
+
+ link_list(fd, &node->inputs);
+ link_list(fd, &node->outputs);
+
+ node->prop = newdataadr(fd, node->prop);
+ IDP_DirectLinkGroup_OrFree(&node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+
+ link_list(fd, &node->internal_links);
+ for (link = node->internal_links.first; link; link = link->next) {
+ link->fromnode = newdataadr(fd, link->fromnode);
+ link->fromsock = newdataadr(fd, link->fromsock);
+ link->tonode = newdataadr(fd, link->tonode);
+ link->tosock = newdataadr(fd, link->tosock);
+ }
+
+ if (node->type == CMP_NODE_MOVIEDISTORTION) {
+ node->storage = newmclipadr(fd, node->storage);
+ }
+ else {
+ node->storage = newdataadr(fd, node->storage);
+ }
+
+ if (node->storage) {
+ /* could be handlerized at some point */
+ if (ntree->type == NTREE_SHADER) {
+ if (node->type == SH_NODE_CURVE_VEC || node->type == SH_NODE_CURVE_RGB) {
+ direct_link_curvemapping(fd, node->storage);
+ }
+ else if (node->type == SH_NODE_SCRIPT) {
+ NodeShaderScript *nss = (NodeShaderScript *)node->storage;
+ nss->bytecode = newdataadr(fd, nss->bytecode);
+ }
+ else if (node->type == SH_NODE_TEX_POINTDENSITY) {
+ NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage;
+ memset(&npd->pd, 0, sizeof(npd->pd));
+ }
+ else if (node->type == SH_NODE_TEX_IMAGE) {
+ NodeTexImage *tex = (NodeTexImage *)node->storage;
+ tex->iuser.ok = 1;
+ tex->iuser.scene = NULL;
+ }
+ else if (node->type == SH_NODE_TEX_ENVIRONMENT) {
+ NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage;
+ tex->iuser.ok = 1;
+ tex->iuser.scene = NULL;
+ }
+ }
+ else if (ntree->type == NTREE_COMPOSIT) {
+ if (ELEM(node->type,
+ CMP_NODE_TIME,
+ CMP_NODE_CURVE_VEC,
+ CMP_NODE_CURVE_RGB,
+ CMP_NODE_HUECORRECT)) {
+ direct_link_curvemapping(fd, node->storage);
+ }
+ else if (ELEM(node->type,
+ CMP_NODE_IMAGE,
+ CMP_NODE_R_LAYERS,
+ CMP_NODE_VIEWER,
+ CMP_NODE_SPLITVIEWER)) {
+ ImageUser *iuser = node->storage;
+ iuser->ok = 1;
+ iuser->scene = NULL;
+ }
+ else if (node->type == CMP_NODE_CRYPTOMATTE) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+ nc->matte_id = newdataadr(fd, nc->matte_id);
+ }
+ }
+ else if (ntree->type == NTREE_TEXTURE) {
+ if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME) {
+ direct_link_curvemapping(fd, node->storage);
+ }
+ else if (node->type == TEX_NODE_IMAGE) {
+ ImageUser *iuser = node->storage;
+ iuser->ok = 1;
+ iuser->scene = NULL;
+ }
+ }
+ }
+ }
+ link_list(fd, &ntree->links);
+
+ /* and we connect the rest */
+ for (node = ntree->nodes.first; node; node = node->next) {
+ node->parent = newdataadr(fd, node->parent);
+ node->lasty = 0;
+
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ direct_link_node_socket(fd, sock);
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ direct_link_node_socket(fd, sock);
+ }
+
+ /* interface socket lists */
+ link_list(fd, &ntree->inputs);
+ link_list(fd, &ntree->outputs);
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ direct_link_node_socket(fd, sock);
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ direct_link_node_socket(fd, sock);
+
+ for (link = ntree->links.first; link; link = link->next) {
+ link->fromnode = newdataadr(fd, link->fromnode);
+ link->tonode = newdataadr(fd, link->tonode);
+ link->fromsock = newdataadr(fd, link->fromsock);
+ link->tosock = newdataadr(fd, link->tosock);
+ }
#if 0
- if (ntree->previews) {
- bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews");
- bNodeInstanceHashIterator iter;
-
- NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
- if (preview) {
- bNodePreview *new_preview = newimaadr(fd, preview);
- if (new_preview) {
- bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- BKE_node_instance_hash_insert(new_previews, key, new_preview);
- }
- }
- }
- BKE_node_instance_hash_free(ntree->previews, NULL);
- ntree->previews = new_previews;
- }
+ if (ntree->previews) {
+ bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews");
+ bNodeInstanceHashIterator iter;
+
+ NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
+ bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ if (preview) {
+ bNodePreview *new_preview = newimaadr(fd, preview);
+ if (new_preview) {
+ bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
+ BKE_node_instance_hash_insert(new_previews, key, new_preview);
+ }
+ }
+ }
+ BKE_node_instance_hash_free(ntree->previews, NULL);
+ ntree->previews = new_previews;
+ }
#else
- /* XXX TODO */
- ntree->previews = NULL;
+ /* XXX TODO */
+ ntree->previews = NULL;
#endif
- /* type verification is in lib-link */
+ /* type verification is in lib-link */
}
/** \} */
@@ -3706,234 +3753,231 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
/* temp struct used to transport needed info to lib_link_constraint_cb() */
typedef struct tConstraintLinkData {
- FileData *fd;
- ID *id;
+ FileData *fd;
+ ID *id;
} tConstraintLinkData;
/* callback function used to relink constraint ID-links */
-static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *userdata)
+static void lib_link_constraint_cb(bConstraint *UNUSED(con),
+ ID **idpoin,
+ bool is_reference,
+ void *userdata)
{
- tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
+ tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
- /* for reference types, we need to increment the usercounts on load... */
- if (is_reference) {
- /* reference type - with usercount */
- *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin);
- }
- else {
- /* target type - no usercount needed */
- *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin);
- }
+ /* for reference types, we need to increment the usercounts on load... */
+ if (is_reference) {
+ /* reference type - with usercount */
+ *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin);
+ }
+ else {
+ /* target type - no usercount needed */
+ *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin);
+ }
}
static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
{
- tConstraintLinkData cld;
- bConstraint *con;
+ tConstraintLinkData cld;
+ bConstraint *con;
- /* legacy fixes */
- for (con = conlist->first; con; con = con->next) {
- /* patch for error introduced by changing constraints (dunno how) */
- /* if con->data type changes, dna cannot resolve the pointer! (ton) */
- if (con->data == NULL) {
- con->type = CONSTRAINT_TYPE_NULL;
- }
- /* own ipo, all constraints have it */
- con->ipo = newlibadr_us(fd, id->lib, con->ipo); // XXX deprecated - old animation system
+ /* legacy fixes */
+ for (con = conlist->first; con; con = con->next) {
+ /* patch for error introduced by changing constraints (dunno how) */
+ /* if con->data type changes, dna cannot resolve the pointer! (ton) */
+ if (con->data == NULL) {
+ con->type = CONSTRAINT_TYPE_NULL;
+ }
+ /* own ipo, all constraints have it */
+ con->ipo = newlibadr_us(fd, id->lib, con->ipo); // XXX deprecated - old animation system
- /* If linking from a library, clear 'local' static override flag. */
- if (id->lib != NULL) {
- con->flag &= ~CONSTRAINT_STATICOVERRIDE_LOCAL;
- }
- }
+ /* If linking from a library, clear 'local' static override flag. */
+ if (id->lib != NULL) {
+ con->flag &= ~CONSTRAINT_STATICOVERRIDE_LOCAL;
+ }
+ }
- /* relink all ID-blocks used by the constraints */
- cld.fd = fd;
- cld.id = id;
+ /* relink all ID-blocks used by the constraints */
+ cld.fd = fd;
+ cld.id = id;
- BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
+ BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
}
static void direct_link_constraints(FileData *fd, ListBase *lb)
{
- bConstraint *con;
-
- link_list(fd, lb);
- for (con = lb->first; con; con = con->next) {
- con->data = newdataadr(fd, con->data);
-
- switch (con->type) {
- case CONSTRAINT_TYPE_PYTHON:
- {
- bPythonConstraint *data = con->data;
-
- link_list(fd, &data->targets);
-
- data->prop = newdataadr(fd, data->prop);
- IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- break;
- }
- case CONSTRAINT_TYPE_ARMATURE:
- {
- bArmatureConstraint *data = con->data;
-
- link_list(fd, &data->targets);
-
- break;
- }
- case CONSTRAINT_TYPE_SPLINEIK:
- {
- bSplineIKConstraint *data = con->data;
-
- data->points = newdataadr(fd, data->points);
- break;
- }
- case CONSTRAINT_TYPE_KINEMATIC:
- {
- bKinematicConstraint *data = con->data;
-
- con->lin_error = 0.f;
- con->rot_error = 0.f;
-
- /* version patch for runtime flag, was not cleared in some case */
- data->flag &= ~CONSTRAINT_IK_AUTO;
- break;
- }
- case CONSTRAINT_TYPE_CHILDOF:
- {
- /* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
- if (con->ownspace == CONSTRAINT_SPACE_POSE)
- con->flag |= CONSTRAINT_SPACEONCE;
- break;
- }
- case CONSTRAINT_TYPE_TRANSFORM_CACHE:
- {
- bTransformCacheConstraint *data = con->data;
- data->reader = NULL;
- }
- }
- }
+ bConstraint *con;
+
+ link_list(fd, lb);
+ for (con = lb->first; con; con = con->next) {
+ con->data = newdataadr(fd, con->data);
+
+ switch (con->type) {
+ case CONSTRAINT_TYPE_PYTHON: {
+ bPythonConstraint *data = con->data;
+
+ link_list(fd, &data->targets);
+
+ data->prop = newdataadr(fd, data->prop);
+ IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ break;
+ }
+ case CONSTRAINT_TYPE_ARMATURE: {
+ bArmatureConstraint *data = con->data;
+
+ link_list(fd, &data->targets);
+
+ break;
+ }
+ case CONSTRAINT_TYPE_SPLINEIK: {
+ bSplineIKConstraint *data = con->data;
+
+ data->points = newdataadr(fd, data->points);
+ break;
+ }
+ case CONSTRAINT_TYPE_KINEMATIC: {
+ bKinematicConstraint *data = con->data;
+
+ con->lin_error = 0.f;
+ con->rot_error = 0.f;
+
+ /* version patch for runtime flag, was not cleared in some case */
+ data->flag &= ~CONSTRAINT_IK_AUTO;
+ break;
+ }
+ case CONSTRAINT_TYPE_CHILDOF: {
+ /* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
+ if (con->ownspace == CONSTRAINT_SPACE_POSE)
+ con->flag |= CONSTRAINT_SPACEONCE;
+ break;
+ }
+ case CONSTRAINT_TYPE_TRANSFORM_CACHE: {
+ bTransformCacheConstraint *data = con->data;
+ data->reader = NULL;
+ }
+ }
+ }
}
static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
{
- bArmature *arm = ob->data;
-
- if (!pose || !arm)
- return;
+ bArmature *arm = ob->data;
- /* always rebuild to match proxy or lib changes, but on Undo */
- bool rebuild = false;
+ if (!pose || !arm)
+ return;
- if (fd->memfile == NULL) {
- if (ob->proxy || ob->id.lib != arm->id.lib) {
- rebuild = true;
- }
- }
+ /* always rebuild to match proxy or lib changes, but on Undo */
+ bool rebuild = false;
- /* avoid string */
- GHash *bone_hash = BKE_armature_bone_from_name_map(arm);
+ if (fd->memfile == NULL) {
+ if (ob->proxy || ob->id.lib != arm->id.lib) {
+ rebuild = true;
+ }
+ }
- if (ob->proxy) {
- /* sync proxy layer */
- if (pose->proxy_layer)
- arm->layer = pose->proxy_layer;
+ /* avoid string */
+ GHash *bone_hash = BKE_armature_bone_from_name_map(arm);
- /* sync proxy active bone */
- if (pose->proxy_act_bone[0]) {
- Bone *bone = BLI_ghash_lookup(bone_hash, pose->proxy_act_bone);
- if (bone) {
- arm->act_bone = bone;
- }
- }
- }
+ if (ob->proxy) {
+ /* sync proxy layer */
+ if (pose->proxy_layer)
+ arm->layer = pose->proxy_layer;
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- lib_link_constraints(fd, (ID *)ob, &pchan->constraints);
+ /* sync proxy active bone */
+ if (pose->proxy_act_bone[0]) {
+ Bone *bone = BLI_ghash_lookup(bone_hash, pose->proxy_act_bone);
+ if (bone) {
+ arm->act_bone = bone;
+ }
+ }
+ }
- pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name);
+ for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ lib_link_constraints(fd, (ID *)ob, &pchan->constraints);
- IDP_LibLinkProperty(pchan->prop, fd);
+ pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name);
- pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
- if (UNLIKELY(pchan->bone == NULL)) {
- rebuild = true;
- }
- else if ((ob->id.lib == NULL) && arm->id.lib) {
- /* local pose selection copied to armature, bit hackish */
- pchan->bone->flag &= ~BONE_SELECTED;
- pchan->bone->flag |= pchan->selectflag;
- }
- }
+ IDP_LibLinkProperty(pchan->prop, fd);
- BLI_ghash_free(bone_hash, NULL, NULL);
+ pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
+ if (UNLIKELY(pchan->bone == NULL)) {
+ rebuild = true;
+ }
+ else if ((ob->id.lib == NULL) && arm->id.lib) {
+ /* local pose selection copied to armature, bit hackish */
+ pchan->bone->flag &= ~BONE_SELECTED;
+ pchan->bone->flag |= pchan->selectflag;
+ }
+ }
+ BLI_ghash_free(bone_hash, NULL, NULL);
- if (rebuild) {
- DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- BKE_pose_tag_recalc(bmain, pose);
- }
+ if (rebuild) {
+ DEG_id_tag_update_ex(
+ bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
+ BKE_pose_tag_recalc(bmain, pose);
+ }
}
static void lib_link_bones(FileData *fd, Bone *bone)
{
- IDP_LibLinkProperty(bone->prop, fd);
+ IDP_LibLinkProperty(bone->prop, fd);
- for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) {
- lib_link_bones(fd, curbone);
- }
+ for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) {
+ lib_link_bones(fd, curbone);
+ }
}
static void lib_link_armature(FileData *fd, Main *main)
{
- for (bArmature *arm = main->armatures.first; arm; arm = arm->id.next) {
- if (arm->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(arm->id.properties, fd);
- lib_link_animdata(fd, &arm->id, arm->adt);
+ for (bArmature *arm = main->armatures.first; arm; arm = arm->id.next) {
+ if (arm->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(arm->id.properties, fd);
+ lib_link_animdata(fd, &arm->id, arm->adt);
- for (Bone *curbone = arm->bonebase.first; curbone; curbone = curbone->next) {
- lib_link_bones(fd, curbone);
- }
+ for (Bone *curbone = arm->bonebase.first; curbone; curbone = curbone->next) {
+ lib_link_bones(fd, curbone);
+ }
- arm->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ arm->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_bones(FileData *fd, Bone *bone)
{
- Bone *child;
+ Bone *child;
- bone->parent = newdataadr(fd, bone->parent);
- bone->prop = newdataadr(fd, bone->prop);
- IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ bone->parent = newdataadr(fd, bone->parent);
+ bone->prop = newdataadr(fd, bone->prop);
+ IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- bone->bbone_next = newdataadr(fd, bone->bbone_next);
- bone->bbone_prev = newdataadr(fd, bone->bbone_prev);
+ bone->bbone_next = newdataadr(fd, bone->bbone_next);
+ bone->bbone_prev = newdataadr(fd, bone->bbone_prev);
- bone->flag &= ~BONE_DRAW_ACTIVE;
+ bone->flag &= ~BONE_DRAW_ACTIVE;
- link_list(fd, &bone->childbase);
+ link_list(fd, &bone->childbase);
- for (child = bone->childbase.first; child; child = child->next)
- direct_link_bones(fd, child);
+ for (child = bone->childbase.first; child; child = child->next)
+ direct_link_bones(fd, child);
}
static void direct_link_armature(FileData *fd, bArmature *arm)
{
- Bone *bone;
+ Bone *bone;
- link_list(fd, &arm->bonebase);
- arm->edbo = NULL;
+ link_list(fd, &arm->bonebase);
+ arm->edbo = NULL;
- arm->adt = newdataadr(fd, arm->adt);
- direct_link_animdata(fd, arm->adt);
+ arm->adt = newdataadr(fd, arm->adt);
+ direct_link_animdata(fd, arm->adt);
- for (bone = arm->bonebase.first; bone; bone = bone->next) {
- direct_link_bones(fd, bone);
- }
+ for (bone = arm->bonebase.first; bone; bone = bone->next) {
+ direct_link_bones(fd, bone);
+ }
- arm->act_bone = newdataadr(fd, arm->act_bone);
- arm->act_edbone = NULL;
+ arm->act_bone = newdataadr(fd, arm->act_bone);
+ arm->act_edbone = NULL;
}
/** \} */
@@ -3944,36 +3988,36 @@ static void direct_link_armature(FileData *fd, bArmature *arm)
static void lib_link_camera(FileData *fd, Main *main)
{
- for (Camera *ca = main->cameras.first; ca; ca = ca->id.next) {
- if (ca->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(ca->id.properties, fd);
- lib_link_animdata(fd, &ca->id, ca->adt);
+ for (Camera *ca = main->cameras.first; ca; ca = ca->id.next) {
+ if (ca->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(ca->id.properties, fd);
+ lib_link_animdata(fd, &ca->id, ca->adt);
- ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX deprecated - old animation system
+ ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX deprecated - old animation system
- ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob);
+ ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob);
- for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
- bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima);
- bgpic->clip = newlibadr_us(fd, ca->id.lib, bgpic->clip);
- }
+ for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
+ bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima);
+ bgpic->clip = newlibadr_us(fd, ca->id.lib, bgpic->clip);
+ }
- ca->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ ca->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_camera(FileData *fd, Camera *ca)
{
- ca->adt = newdataadr(fd, ca->adt);
- direct_link_animdata(fd, ca->adt);
+ ca->adt = newdataadr(fd, ca->adt);
+ direct_link_animdata(fd, ca->adt);
- link_list(fd, &ca->bg_images);
+ link_list(fd, &ca->bg_images);
- for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
- bgpic->iuser.ok = 1;
- bgpic->iuser.scene = NULL;
- }
+ for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
+ bgpic->iuser.ok = 1;
+ bgpic->iuser.scene = NULL;
+ }
}
/** \} */
@@ -3984,39 +4028,39 @@ static void direct_link_camera(FileData *fd, Camera *ca)
static void lib_link_light(FileData *fd, Main *main)
{
- for (Light *la = main->lights.first; la; la = la->id.next) {
- if (la->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(la->id.properties, fd);
- lib_link_animdata(fd, &la->id, la->adt);
+ for (Light *la = main->lights.first; la; la = la->id.next) {
+ if (la->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(la->id.properties, fd);
+ lib_link_animdata(fd, &la->id, la->adt);
- la->ipo = newlibadr_us(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system
+ la->ipo = newlibadr_us(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system
- if (la->nodetree) {
- lib_link_ntree(fd, &la->id, la->nodetree);
- la->nodetree->id.lib = la->id.lib;
- }
+ if (la->nodetree) {
+ lib_link_ntree(fd, &la->id, la->nodetree);
+ la->nodetree->id.lib = la->id.lib;
+ }
- la->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ la->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_light(FileData *fd, Light *la)
{
- la->adt = newdataadr(fd, la->adt);
- direct_link_animdata(fd, la->adt);
+ la->adt = newdataadr(fd, la->adt);
+ direct_link_animdata(fd, la->adt);
- la->curfalloff = newdataadr(fd, la->curfalloff);
- if (la->curfalloff)
- direct_link_curvemapping(fd, la->curfalloff);
+ la->curfalloff = newdataadr(fd, la->curfalloff);
+ if (la->curfalloff)
+ direct_link_curvemapping(fd, la->curfalloff);
- la->nodetree = newdataadr(fd, la->nodetree);
- if (la->nodetree) {
- direct_link_id(fd, &la->nodetree->id);
- direct_link_nodetree(fd, la->nodetree);
- }
+ la->nodetree = newdataadr(fd, la->nodetree);
+ if (la->nodetree) {
+ direct_link_id(fd, &la->nodetree->id);
+ direct_link_nodetree(fd, la->nodetree);
+ }
- la->preview = direct_link_preview_image(fd, la->preview);
+ la->preview = direct_link_preview_image(fd, la->preview);
}
/** \} */
@@ -4027,77 +4071,77 @@ static void direct_link_light(FileData *fd, Light *la)
void blo_do_versions_key_uidgen(Key *key)
{
- KeyBlock *block;
+ KeyBlock *block;
- key->uidgen = 1;
- for (block = key->block.first; block; block = block->next) {
- block->uid = key->uidgen++;
- }
+ key->uidgen = 1;
+ for (block = key->block.first; block; block = block->next) {
+ block->uid = key->uidgen++;
+ }
}
static void lib_link_key(FileData *fd, Main *main)
{
- for (Key *key = main->shapekeys.first; key; key = key->id.next) {
- BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
+ for (Key *key = main->shapekeys.first; key; key = key->id.next) {
+ BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
- if (key->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(key->id.properties, fd);
- lib_link_animdata(fd, &key->id, key->adt);
+ if (key->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(key->id.properties, fd);
+ lib_link_animdata(fd, &key->id, key->adt);
- key->ipo = newlibadr_us(fd, key->id.lib, key->ipo); // XXX deprecated - old animation system
- key->from = newlibadr(fd, key->id.lib, key->from);
+ key->ipo = newlibadr_us(fd, key->id.lib, key->ipo); // XXX deprecated - old animation system
+ key->from = newlibadr(fd, key->id.lib, key->from);
- key->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ key->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
{
- int elemsize, a, b;
- char *data;
+ int elemsize, a, b;
+ char *data;
- elemsize = key->elemsize;
- data = kb->data;
+ elemsize = key->elemsize;
+ data = kb->data;
- for (a = 0; a < kb->totelem; a++) {
- const char *cp = key->elemstr;
- char *poin = data;
+ for (a = 0; a < kb->totelem; a++) {
+ const char *cp = key->elemstr;
+ char *poin = data;
- while (cp[0]) { /* cp[0] == amount */
- switch (cp[1]) { /* cp[1] = type */
- case IPO_FLOAT:
- case IPO_BPOINT:
- case IPO_BEZTRIPLE:
- b = cp[0];
- BLI_endian_switch_float_array((float *)poin, b);
- poin += sizeof(float) * b;
- break;
- }
+ while (cp[0]) { /* cp[0] == amount */
+ switch (cp[1]) { /* cp[1] = type */
+ case IPO_FLOAT:
+ case IPO_BPOINT:
+ case IPO_BEZTRIPLE:
+ b = cp[0];
+ BLI_endian_switch_float_array((float *)poin, b);
+ poin += sizeof(float) * b;
+ break;
+ }
- cp += 2;
- }
- data += elemsize;
- }
+ cp += 2;
+ }
+ data += elemsize;
+ }
}
static void direct_link_key(FileData *fd, Key *key)
{
- KeyBlock *kb;
+ KeyBlock *kb;
- link_list(fd, &(key->block));
+ link_list(fd, &(key->block));
- key->adt = newdataadr(fd, key->adt);
- direct_link_animdata(fd, key->adt);
+ key->adt = newdataadr(fd, key->adt);
+ direct_link_animdata(fd, key->adt);
- key->refkey = newdataadr(fd, key->refkey);
+ key->refkey = newdataadr(fd, key->refkey);
- for (kb = key->block.first; kb; kb = kb->next) {
- kb->data = newdataadr(fd, kb->data);
+ for (kb = key->block.first; kb; kb = kb->next) {
+ kb->data = newdataadr(fd, kb->data);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN)
- switch_endian_keyblock(key, kb);
- }
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN)
+ switch_endian_keyblock(key, kb);
+ }
}
/** \} */
@@ -4108,37 +4152,37 @@ static void direct_link_key(FileData *fd, Key *key)
static void lib_link_mball(FileData *fd, Main *main)
{
- for (MetaBall *mb = main->metaballs.first; mb; mb = mb->id.next) {
- if (mb->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(mb->id.properties, fd);
- lib_link_animdata(fd, &mb->id, mb->adt);
+ for (MetaBall *mb = main->metaballs.first; mb; mb = mb->id.next) {
+ if (mb->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(mb->id.properties, fd);
+ lib_link_animdata(fd, &mb->id, mb->adt);
- for (int a = 0; a < mb->totcol; a++) {
- mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]);
- }
+ for (int a = 0; a < mb->totcol; a++) {
+ mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]);
+ }
- mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system
+ mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system
- mb->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ mb->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_mball(FileData *fd, MetaBall *mb)
{
- mb->adt = newdataadr(fd, mb->adt);
- direct_link_animdata(fd, mb->adt);
+ mb->adt = newdataadr(fd, mb->adt);
+ direct_link_animdata(fd, mb->adt);
- mb->mat = newdataadr(fd, mb->mat);
- test_pointer_array(fd, (void **)&mb->mat);
+ mb->mat = newdataadr(fd, mb->mat);
+ test_pointer_array(fd, (void **)&mb->mat);
- link_list(fd, &(mb->elems));
+ link_list(fd, &(mb->elems));
- BLI_listbase_clear(&mb->disp);
- mb->editelems = NULL;
-/* mb->edit_elems.first= mb->edit_elems.last= NULL;*/
- mb->lastelem = NULL;
- mb->batch_cache = NULL;
+ BLI_listbase_clear(&mb->disp);
+ mb->editelems = NULL;
+ /* mb->edit_elems.first= mb->edit_elems.last= NULL;*/
+ mb->lastelem = NULL;
+ mb->batch_cache = NULL;
}
/** \} */
@@ -4149,39 +4193,39 @@ static void direct_link_mball(FileData *fd, MetaBall *mb)
static void lib_link_world(FileData *fd, Main *main)
{
- for (World *wrld = main->worlds.first; wrld; wrld = wrld->id.next) {
- if (wrld->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(wrld->id.properties, fd);
- lib_link_animdata(fd, &wrld->id, wrld->adt);
+ for (World *wrld = main->worlds.first; wrld; wrld = wrld->id.next) {
+ if (wrld->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(wrld->id.properties, fd);
+ lib_link_animdata(fd, &wrld->id, wrld->adt);
- wrld->ipo = newlibadr_us(fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system
+ wrld->ipo = newlibadr_us(
+ fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system
- if (wrld->nodetree) {
- lib_link_ntree(fd, &wrld->id, wrld->nodetree);
- wrld->nodetree->id.lib = wrld->id.lib;
- }
+ if (wrld->nodetree) {
+ lib_link_ntree(fd, &wrld->id, wrld->nodetree);
+ wrld->nodetree->id.lib = wrld->id.lib;
+ }
- wrld->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ wrld->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_world(FileData *fd, World *wrld)
{
- wrld->adt = newdataadr(fd, wrld->adt);
- direct_link_animdata(fd, wrld->adt);
+ wrld->adt = newdataadr(fd, wrld->adt);
+ direct_link_animdata(fd, wrld->adt);
- wrld->nodetree = newdataadr(fd, wrld->nodetree);
- if (wrld->nodetree) {
- direct_link_id(fd, &wrld->nodetree->id);
- direct_link_nodetree(fd, wrld->nodetree);
- }
+ wrld->nodetree = newdataadr(fd, wrld->nodetree);
+ if (wrld->nodetree) {
+ direct_link_id(fd, &wrld->nodetree->id);
+ direct_link_nodetree(fd, wrld->nodetree);
+ }
- wrld->preview = direct_link_preview_image(fd, wrld->preview);
- BLI_listbase_clear(&wrld->gpumaterial);
+ wrld->preview = direct_link_preview_image(fd, wrld->preview);
+ BLI_listbase_clear(&wrld->gpumaterial);
}
-
/* ************ READ VFONT ***************** */
/** \} */
@@ -4192,20 +4236,20 @@ static void direct_link_world(FileData *fd, World *wrld)
static void lib_link_vfont(FileData *fd, Main *main)
{
- for (VFont *vf = main->fonts.first; vf; vf = vf->id.next) {
- if (vf->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(vf->id.properties, fd);
+ for (VFont *vf = main->fonts.first; vf; vf = vf->id.next) {
+ if (vf->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(vf->id.properties, fd);
- vf->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ vf->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_vfont(FileData *fd, VFont *vf)
{
- vf->data = NULL;
- vf->temp_pf = NULL;
- vf->packedfile = direct_link_packedfile(fd, vf->packedfile);
+ vf->data = NULL;
+ vf->temp_pf = NULL;
+ vf->packedfile = direct_link_packedfile(fd, vf->packedfile);
}
/** \} */
@@ -4216,48 +4260,48 @@ static void direct_link_vfont(FileData *fd, VFont *vf)
static void lib_link_text(FileData *fd, Main *main)
{
- for (Text *text = main->texts.first; text; text = text->id.next) {
- if (text->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(text->id.properties, fd);
+ for (Text *text = main->texts.first; text; text = text->id.next) {
+ if (text->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(text->id.properties, fd);
- text->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ text->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_text(FileData *fd, Text *text)
{
- TextLine *ln;
+ TextLine *ln;
- text->name = newdataadr(fd, text->name);
+ text->name = newdataadr(fd, text->name);
- text->compiled = NULL;
+ text->compiled = NULL;
#if 0
- if (text->flags & TXT_ISEXT) {
- BKE_text_reload(text);
- }
- /* else { */
+ if (text->flags & TXT_ISEXT) {
+ BKE_text_reload(text);
+ }
+ /* else { */
#endif
- link_list(fd, &text->lines);
+ link_list(fd, &text->lines);
- text->curl = newdataadr(fd, text->curl);
- text->sell = newdataadr(fd, text->sell);
+ text->curl = newdataadr(fd, text->curl);
+ text->sell = newdataadr(fd, text->sell);
- for (ln = text->lines.first; ln; ln = ln->next) {
- ln->line = newdataadr(fd, ln->line);
- ln->format = NULL;
+ for (ln = text->lines.first; ln; ln = ln->next) {
+ ln->line = newdataadr(fd, ln->line);
+ ln->format = NULL;
- if (ln->len != (int)strlen(ln->line)) {
- printf("Error loading text, line lengths differ\n");
- ln->len = strlen(ln->line);
- }
- }
+ if (ln->len != (int)strlen(ln->line)) {
+ printf("Error loading text, line lengths differ\n");
+ ln->len = strlen(ln->line);
+ }
+ }
- text->flags = (text->flags) & ~TXT_ISEXT;
+ text->flags = (text->flags) & ~TXT_ISEXT;
- id_us_ensure_real(&text->id);
+ id_us_ensure_real(&text->id);
}
/** \} */
@@ -4268,71 +4312,71 @@ static void direct_link_text(FileData *fd, Text *text)
static void lib_link_image(FileData *fd, Main *main)
{
- for (Image *ima = main->images.first; ima; ima = ima->id.next) {
- if (ima->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(ima->id.properties, fd);
+ for (Image *ima = main->images.first; ima; ima = ima->id.next) {
+ if (ima->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(ima->id.properties, fd);
- ima->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ ima->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_image(FileData *fd, Image *ima)
{
- ImagePackedFile *imapf;
-
- /* for undo system, pointers could be restored */
- if (fd->imamap)
- ima->cache = newimaadr(fd, ima->cache);
- else
- ima->cache = NULL;
-
- /* if not restored, we keep the binded opengl index */
- if (!ima->cache) {
- ima->gpuflag = 0;
- for (int i = 0; i < TEXTARGET_COUNT; i++) {
- ima->gputexture[i] = NULL;
- }
- ima->rr = NULL;
- }
- else {
- for (int i = 0; i < TEXTARGET_COUNT; i++) {
- ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
- }
- ima->rr = newimaadr(fd, ima->rr);
- }
-
- /* undo system, try to restore render buffers */
- link_list(fd, &(ima->renderslots));
- if (fd->imamap) {
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
- slot->render = newimaadr(fd, slot->render);
- }
- }
- else {
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
- slot->render = NULL;
- }
- ima->last_render_slot = ima->render_slot;
- }
-
- link_list(fd, &(ima->views));
- link_list(fd, &(ima->packedfiles));
-
- if (ima->packedfiles.first) {
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
- imapf->packedfile = direct_link_packedfile(fd, imapf->packedfile);
- }
- ima->packedfile = NULL;
- }
- else {
- ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
- }
-
- BLI_listbase_clear(&ima->anims);
- ima->preview = direct_link_preview_image(fd, ima->preview);
- ima->stereo3d_format = newdataadr(fd, ima->stereo3d_format);
- ima->ok = 1;
+ ImagePackedFile *imapf;
+
+ /* for undo system, pointers could be restored */
+ if (fd->imamap)
+ ima->cache = newimaadr(fd, ima->cache);
+ else
+ ima->cache = NULL;
+
+ /* if not restored, we keep the binded opengl index */
+ if (!ima->cache) {
+ ima->gpuflag = 0;
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ ima->gputexture[i] = NULL;
+ }
+ ima->rr = NULL;
+ }
+ else {
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
+ }
+ ima->rr = newimaadr(fd, ima->rr);
+ }
+
+ /* undo system, try to restore render buffers */
+ link_list(fd, &(ima->renderslots));
+ if (fd->imamap) {
+ LISTBASE_FOREACH (RenderSlot *, slot, &ima->renderslots) {
+ slot->render = newimaadr(fd, slot->render);
+ }
+ }
+ else {
+ LISTBASE_FOREACH (RenderSlot *, slot, &ima->renderslots) {
+ slot->render = NULL;
+ }
+ ima->last_render_slot = ima->render_slot;
+ }
+
+ link_list(fd, &(ima->views));
+ link_list(fd, &(ima->packedfiles));
+
+ if (ima->packedfiles.first) {
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ imapf->packedfile = direct_link_packedfile(fd, imapf->packedfile);
+ }
+ ima->packedfile = NULL;
+ }
+ else {
+ ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
+ }
+
+ BLI_listbase_clear(&ima->anims);
+ ima->preview = direct_link_preview_image(fd, ima->preview);
+ ima->stereo3d_format = newdataadr(fd, ima->stereo3d_format);
+ ima->ok = 1;
}
/** \} */
@@ -4343,96 +4387,97 @@ static void direct_link_image(FileData *fd, Image *ima)
static void lib_link_curve(FileData *fd, Main *main)
{
- for (Curve *cu = main->curves.first; cu; cu = cu->id.next) {
- if (cu->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(cu->id.properties, fd);
- lib_link_animdata(fd, &cu->id, cu->adt);
+ for (Curve *cu = main->curves.first; cu; cu = cu->id.next) {
+ if (cu->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(cu->id.properties, fd);
+ lib_link_animdata(fd, &cu->id, cu->adt);
- for (int a = 0; a < cu->totcol; a++) {
- cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]);
- }
+ for (int a = 0; a < cu->totcol; a++) {
+ cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]);
+ }
- cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj);
- cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
- cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
- cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
- cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
- cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
- cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
+ cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj);
+ cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
+ cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
+ cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
+ cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
+ cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
+ cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
- cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system
- cu->key = newlibadr_us(fd, cu->id.lib, cu->key);
+ cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system
+ cu->key = newlibadr_us(fd, cu->id.lib, cu->key);
- cu->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ cu->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
-
static void switch_endian_knots(Nurb *nu)
{
- if (nu->knotsu) {
- BLI_endian_switch_float_array(nu->knotsu, KNOTSU(nu));
- }
- if (nu->knotsv) {
- BLI_endian_switch_float_array(nu->knotsv, KNOTSV(nu));
- }
+ if (nu->knotsu) {
+ BLI_endian_switch_float_array(nu->knotsu, KNOTSU(nu));
+ }
+ if (nu->knotsv) {
+ BLI_endian_switch_float_array(nu->knotsv, KNOTSV(nu));
+ }
}
static void direct_link_curve(FileData *fd, Curve *cu)
{
- Nurb *nu;
- TextBox *tb;
-
- cu->adt = newdataadr(fd, cu->adt);
- direct_link_animdata(fd, cu->adt);
-
- /* Protect against integer overflow vulnerability. */
- CLAMP(cu->len_wchar, 0, INT_MAX - 4);
-
- cu->mat = newdataadr(fd, cu->mat);
- test_pointer_array(fd, (void **)&cu->mat);
- cu->str = newdataadr(fd, cu->str);
- cu->strinfo = newdataadr(fd, cu->strinfo);
- cu->tb = newdataadr(fd, cu->tb);
-
- if (cu->vfont == NULL) {
- link_list(fd, &(cu->nurb));
- }
- else {
- cu->nurb.first = cu->nurb.last = NULL;
-
- tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
- if (cu->tb) {
- memcpy(tb, cu->tb, cu->totbox * sizeof(TextBox));
- MEM_freeN(cu->tb);
- cu->tb = tb;
- }
- else {
- cu->totbox = 1;
- cu->actbox = 1;
- cu->tb = tb;
- cu->tb[0].w = cu->linewidth;
- }
- if (cu->wordspace == 0.0f) cu->wordspace = 1.0f;
- }
-
- cu->editnurb = NULL;
- cu->editfont = NULL;
- cu->batch_cache = NULL;
-
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- nu->bezt = newdataadr(fd, nu->bezt);
- nu->bp = newdataadr(fd, nu->bp);
- nu->knotsu = newdataadr(fd, nu->knotsu);
- nu->knotsv = newdataadr(fd, nu->knotsv);
- if (cu->vfont == NULL) nu->charidx = 0;
-
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- switch_endian_knots(nu);
- }
- }
- cu->bb = NULL;
+ Nurb *nu;
+ TextBox *tb;
+
+ cu->adt = newdataadr(fd, cu->adt);
+ direct_link_animdata(fd, cu->adt);
+
+ /* Protect against integer overflow vulnerability. */
+ CLAMP(cu->len_wchar, 0, INT_MAX - 4);
+
+ cu->mat = newdataadr(fd, cu->mat);
+ test_pointer_array(fd, (void **)&cu->mat);
+ cu->str = newdataadr(fd, cu->str);
+ cu->strinfo = newdataadr(fd, cu->strinfo);
+ cu->tb = newdataadr(fd, cu->tb);
+
+ if (cu->vfont == NULL) {
+ link_list(fd, &(cu->nurb));
+ }
+ else {
+ cu->nurb.first = cu->nurb.last = NULL;
+
+ tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
+ if (cu->tb) {
+ memcpy(tb, cu->tb, cu->totbox * sizeof(TextBox));
+ MEM_freeN(cu->tb);
+ cu->tb = tb;
+ }
+ else {
+ cu->totbox = 1;
+ cu->actbox = 1;
+ cu->tb = tb;
+ cu->tb[0].w = cu->linewidth;
+ }
+ if (cu->wordspace == 0.0f)
+ cu->wordspace = 1.0f;
+ }
+
+ cu->editnurb = NULL;
+ cu->editfont = NULL;
+ cu->batch_cache = NULL;
+
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ nu->bezt = newdataadr(fd, nu->bezt);
+ nu->bp = newdataadr(fd, nu->bp);
+ nu->knotsu = newdataadr(fd, nu->knotsu);
+ nu->knotsv = newdataadr(fd, nu->knotsv);
+ if (cu->vfont == NULL)
+ nu->charidx = 0;
+
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ switch_endian_knots(nu);
+ }
+ }
+ cu->bb = NULL;
}
/** \} */
@@ -4443,41 +4488,41 @@ static void direct_link_curve(FileData *fd, Curve *cu)
static void lib_link_texture(FileData *fd, Main *main)
{
- for (Tex *tex = main->textures.first; tex; tex = tex->id.next) {
- if (tex->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(tex->id.properties, fd);
- lib_link_animdata(fd, &tex->id, tex->adt);
+ for (Tex *tex = main->textures.first; tex; tex = tex->id.next) {
+ if (tex->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(tex->id.properties, fd);
+ lib_link_animdata(fd, &tex->id, tex->adt);
- tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
- tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system
+ tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
+ tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system
- if (tex->nodetree) {
- lib_link_ntree(fd, &tex->id, tex->nodetree);
- tex->nodetree->id.lib = tex->id.lib;
- }
+ if (tex->nodetree) {
+ lib_link_ntree(fd, &tex->id, tex->nodetree);
+ tex->nodetree->id.lib = tex->id.lib;
+ }
- tex->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ tex->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_texture(FileData *fd, Tex *tex)
{
- tex->adt = newdataadr(fd, tex->adt);
- direct_link_animdata(fd, tex->adt);
+ tex->adt = newdataadr(fd, tex->adt);
+ direct_link_animdata(fd, tex->adt);
- tex->coba = newdataadr(fd, tex->coba);
+ tex->coba = newdataadr(fd, tex->coba);
- tex->nodetree = newdataadr(fd, tex->nodetree);
- if (tex->nodetree) {
- direct_link_id(fd, &tex->nodetree->id);
- direct_link_nodetree(fd, tex->nodetree);
- }
+ tex->nodetree = newdataadr(fd, tex->nodetree);
+ if (tex->nodetree) {
+ direct_link_id(fd, &tex->nodetree->id);
+ direct_link_nodetree(fd, tex->nodetree);
+ }
- tex->preview = direct_link_preview_image(fd, tex->preview);
+ tex->preview = direct_link_preview_image(fd, tex->preview);
- tex->iuser.ok = 1;
- tex->iuser.scene = NULL;
+ tex->iuser.ok = 1;
+ tex->iuser.scene = NULL;
}
/** \} */
@@ -4488,51 +4533,51 @@ static void direct_link_texture(FileData *fd, Tex *tex)
static void lib_link_material(FileData *fd, Main *main)
{
- for (Material *ma = main->materials.first; ma; ma = ma->id.next) {
- if (ma->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(ma->id.properties, fd);
- lib_link_animdata(fd, &ma->id, ma->adt);
+ for (Material *ma = main->materials.first; ma; ma = ma->id.next) {
+ if (ma->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(ma->id.properties, fd);
+ lib_link_animdata(fd, &ma->id, ma->adt);
- ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system
+ ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system
- if (ma->nodetree) {
- lib_link_ntree(fd, &ma->id, ma->nodetree);
- ma->nodetree->id.lib = ma->id.lib;
- }
+ if (ma->nodetree) {
+ lib_link_ntree(fd, &ma->id, ma->nodetree);
+ ma->nodetree->id.lib = ma->id.lib;
+ }
- /* relink grease pencil settings */
- if (ma->gp_style != NULL) {
- MaterialGPencilStyle *gp_style = ma->gp_style;
- if (gp_style->sima != NULL) {
- gp_style->sima = newlibadr_us(fd, ma->id.lib, gp_style->sima);
- }
- if (gp_style->ima != NULL) {
- gp_style->ima = newlibadr_us(fd, ma->id.lib, gp_style->ima);
- }
- }
+ /* relink grease pencil settings */
+ if (ma->gp_style != NULL) {
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ if (gp_style->sima != NULL) {
+ gp_style->sima = newlibadr_us(fd, ma->id.lib, gp_style->sima);
+ }
+ if (gp_style->ima != NULL) {
+ gp_style->ima = newlibadr_us(fd, ma->id.lib, gp_style->ima);
+ }
+ }
- ma->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ ma->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_material(FileData *fd, Material *ma)
{
- ma->adt = newdataadr(fd, ma->adt);
- direct_link_animdata(fd, ma->adt);
+ ma->adt = newdataadr(fd, ma->adt);
+ direct_link_animdata(fd, ma->adt);
- ma->texpaintslot = NULL;
+ ma->texpaintslot = NULL;
- ma->nodetree = newdataadr(fd, ma->nodetree);
- if (ma->nodetree) {
- direct_link_id(fd, &ma->nodetree->id);
- direct_link_nodetree(fd, ma->nodetree);
- }
+ ma->nodetree = newdataadr(fd, ma->nodetree);
+ if (ma->nodetree) {
+ direct_link_id(fd, &ma->nodetree->id);
+ direct_link_nodetree(fd, ma->nodetree);
+ }
- ma->preview = direct_link_preview_image(fd, ma->preview);
- BLI_listbase_clear(&ma->gpumaterial);
+ ma->preview = direct_link_preview_image(fd, ma->preview);
+ BLI_listbase_clear(&ma->gpumaterial);
- ma->gp_style = newdataadr(fd, ma->gp_style);
+ ma->gp_style = newdataadr(fd, ma->gp_style);
}
/** \} */
@@ -4543,336 +4588,341 @@ static void direct_link_material(FileData *fd, Material *ma)
/* update this also to writefile.c */
static const char *ptcache_data_struct[] = {
- "", // BPHYS_DATA_INDEX
- "", // BPHYS_DATA_LOCATION
- "", // BPHYS_DATA_VELOCITY
- "", // BPHYS_DATA_ROTATION
- "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
- "", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
- "BoidData", // case BPHYS_DATA_BOIDS:
+ "", // BPHYS_DATA_INDEX
+ "", // BPHYS_DATA_LOCATION
+ "", // BPHYS_DATA_VELOCITY
+ "", // BPHYS_DATA_ROTATION
+ "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
+ "", // BPHYS_DATA_SIZE:
+ "", // BPHYS_DATA_TIMES:
+ "BoidData", // case BPHYS_DATA_BOIDS:
};
static void direct_link_pointcache_cb(FileData *fd, void *data)
{
- PTCacheMem *pm = data;
- PTCacheExtra *extra;
- int i;
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
- pm->data[i] = newdataadr(fd, pm->data[i]);
+ PTCacheMem *pm = data;
+ PTCacheExtra *extra;
+ int i;
+ for (i = 0; i < BPHYS_TOT_DATA; i++) {
+ pm->data[i] = newdataadr(fd, pm->data[i]);
- /* the cache saves non-struct data without DNA */
- if (pm->data[i] && ptcache_data_struct[i][0] == '\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
- int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int); /* data_size returns bytes */
- int *poin = pm->data[i];
+ /* the cache saves non-struct data without DNA */
+ if (pm->data[i] && ptcache_data_struct[i][0] == '\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
+ int tot = (BKE_ptcache_data_size(i) * pm->totpoint) /
+ sizeof(int); /* data_size returns bytes */
+ int *poin = pm->data[i];
- BLI_endian_switch_int32_array(poin, tot);
- }
- }
+ BLI_endian_switch_int32_array(poin, tot);
+ }
+ }
- link_list(fd, &pm->extradata);
+ link_list(fd, &pm->extradata);
- for (extra = pm->extradata.first; extra; extra = extra->next)
- extra->data = newdataadr(fd, extra->data);
+ for (extra = pm->extradata.first; extra; extra = extra->next)
+ extra->data = newdataadr(fd, extra->data);
}
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
- if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
- }
- else
- BLI_listbase_clear(&cache->mem_cache);
-
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe = 0;
- cache->edit = NULL;
- cache->free_edit = NULL;
- cache->cached_frames = NULL;
- cache->cached_frames_len = 0;
-}
-
-static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache, int force_disk)
-{
- if (ptcaches->first) {
- PointCache *cache = NULL;
- link_list(fd, ptcaches);
- for (cache = ptcaches->first; cache; cache = cache->next) {
- direct_link_pointcache(fd, cache);
- if (force_disk) {
- cache->flag |= PTCACHE_DISK_CACHE;
- cache->step = 1;
- }
- }
-
- *ocache = newdataadr(fd, *ocache);
- }
- else if (*ocache) {
- /* old "single" caches need to be linked too */
- *ocache = newdataadr(fd, *ocache);
- direct_link_pointcache(fd, *ocache);
- if (force_disk) {
- (*ocache)->flag |= PTCACHE_DISK_CACHE;
- (*ocache)->step = 1;
- }
-
- ptcaches->first = ptcaches->last = *ocache;
- }
+ if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
+ link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
+ }
+ else
+ BLI_listbase_clear(&cache->mem_cache);
+
+ cache->flag &= ~PTCACHE_SIMULATION_VALID;
+ cache->simframe = 0;
+ cache->edit = NULL;
+ cache->free_edit = NULL;
+ cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
+}
+
+static void direct_link_pointcache_list(FileData *fd,
+ ListBase *ptcaches,
+ PointCache **ocache,
+ int force_disk)
+{
+ if (ptcaches->first) {
+ PointCache *cache = NULL;
+ link_list(fd, ptcaches);
+ for (cache = ptcaches->first; cache; cache = cache->next) {
+ direct_link_pointcache(fd, cache);
+ if (force_disk) {
+ cache->flag |= PTCACHE_DISK_CACHE;
+ cache->step = 1;
+ }
+ }
+
+ *ocache = newdataadr(fd, *ocache);
+ }
+ else if (*ocache) {
+ /* old "single" caches need to be linked too */
+ *ocache = newdataadr(fd, *ocache);
+ direct_link_pointcache(fd, *ocache);
+ if (force_disk) {
+ (*ocache)->flag |= PTCACHE_DISK_CACHE;
+ (*ocache)->step = 1;
+ }
+
+ ptcaches->first = ptcaches->last = *ocache;
+ }
}
static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
{
- if (pd && pd->tex)
- pd->tex = newlibadr_us(fd, id->lib, pd->tex);
- if (pd && pd->f_source)
- pd->f_source = newlibadr(fd, id->lib, pd->f_source);
+ if (pd && pd->tex)
+ pd->tex = newlibadr_us(fd, id->lib, pd->tex);
+ if (pd && pd->f_source)
+ pd->f_source = newlibadr(fd, id->lib, pd->f_source);
}
static void lib_link_particlesettings(FileData *fd, Main *main)
{
- for (ParticleSettings *part = main->particles.first; part; part = part->id.next) {
- if (part->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(part->id.properties, fd);
- lib_link_animdata(fd, &part->id, part->adt);
-
- part->ipo = newlibadr_us(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system
-
- part->instance_object = newlibadr(fd, part->id.lib, part->instance_object);
- part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection);
- part->eff_group = newlibadr(fd, part->id.lib, part->eff_group);
- part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob);
- part->collision_group = newlibadr(fd, part->id.lib, part->collision_group);
-
- lib_link_partdeflect(fd, &part->id, part->pd);
- lib_link_partdeflect(fd, &part->id, part->pd2);
-
- if (part->effector_weights) {
- part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
- }
- else {
- part->effector_weights = BKE_effector_add_weights(part->eff_group);
- }
-
- if (part->instance_weights.first && part->instance_collection) {
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
- dw->ob = newlibadr(fd, part->id.lib, dw->ob);
- }
- }
- else {
- BLI_listbase_clear(&part->instance_weights);
- }
-
- if (part->boids) {
- BoidState *state = part->boids->states.first;
- BoidRule *rule;
- for (; state; state = state->next) {
- rule = state->rules.first;
- for (; rule; rule = rule->next) {
- switch (rule->type) {
- case eBoidRuleType_Goal:
- case eBoidRuleType_Avoid:
- {
- BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
- brga->ob = newlibadr(fd, part->id.lib, brga->ob);
- break;
- }
- case eBoidRuleType_FollowLeader:
- {
- BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
- brfl->ob = newlibadr(fd, part->id.lib, brfl->ob);
- break;
- }
- }
- }
- }
- }
-
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = part->mtex[a];
- if (mtex) {
- mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, part->id.lib, mtex->object);
- }
- }
-
- part->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ for (ParticleSettings *part = main->particles.first; part; part = part->id.next) {
+ if (part->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(part->id.properties, fd);
+ lib_link_animdata(fd, &part->id, part->adt);
+
+ part->ipo = newlibadr_us(
+ fd, part->id.lib, part->ipo); // XXX deprecated - old animation system
+
+ part->instance_object = newlibadr(fd, part->id.lib, part->instance_object);
+ part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection);
+ part->eff_group = newlibadr(fd, part->id.lib, part->eff_group);
+ part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob);
+ part->collision_group = newlibadr(fd, part->id.lib, part->collision_group);
+
+ lib_link_partdeflect(fd, &part->id, part->pd);
+ lib_link_partdeflect(fd, &part->id, part->pd2);
+
+ if (part->effector_weights) {
+ part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
+ }
+ else {
+ part->effector_weights = BKE_effector_add_weights(part->eff_group);
+ }
+
+ if (part->instance_weights.first && part->instance_collection) {
+ for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+ }
+ }
+ else {
+ BLI_listbase_clear(&part->instance_weights);
+ }
+
+ if (part->boids) {
+ BoidState *state = part->boids->states.first;
+ BoidRule *rule;
+ for (; state; state = state->next) {
+ rule = state->rules.first;
+ for (; rule; rule = rule->next) {
+ switch (rule->type) {
+ case eBoidRuleType_Goal:
+ case eBoidRuleType_Avoid: {
+ BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
+ brga->ob = newlibadr(fd, part->id.lib, brga->ob);
+ break;
+ }
+ case eBoidRuleType_FollowLeader: {
+ BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
+ brfl->ob = newlibadr(fd, part->id.lib, brfl->ob);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ for (int a = 0; a < MAX_MTEX; a++) {
+ MTex *mtex = part->mtex[a];
+ if (mtex) {
+ mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex);
+ mtex->object = newlibadr(fd, part->id.lib, mtex->object);
+ }
+ }
+
+ part->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_partdeflect(PartDeflect *pd)
{
- if (pd) pd->rng = NULL;
+ if (pd)
+ pd->rng = NULL;
}
static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
{
- int a;
+ int a;
- part->adt = newdataadr(fd, part->adt);
- part->pd = newdataadr(fd, part->pd);
- part->pd2 = newdataadr(fd, part->pd2);
+ part->adt = newdataadr(fd, part->adt);
+ part->pd = newdataadr(fd, part->pd);
+ part->pd2 = newdataadr(fd, part->pd2);
- direct_link_animdata(fd, part->adt);
- direct_link_partdeflect(part->pd);
- direct_link_partdeflect(part->pd2);
+ direct_link_animdata(fd, part->adt);
+ direct_link_partdeflect(part->pd);
+ direct_link_partdeflect(part->pd2);
- part->clumpcurve = newdataadr(fd, part->clumpcurve);
- if (part->clumpcurve)
- direct_link_curvemapping(fd, part->clumpcurve);
- part->roughcurve = newdataadr(fd, part->roughcurve);
- if (part->roughcurve)
- direct_link_curvemapping(fd, part->roughcurve);
- part->twistcurve = newdataadr(fd, part->twistcurve);
- if (part->twistcurve)
- direct_link_curvemapping(fd, part->twistcurve);
+ part->clumpcurve = newdataadr(fd, part->clumpcurve);
+ if (part->clumpcurve)
+ direct_link_curvemapping(fd, part->clumpcurve);
+ part->roughcurve = newdataadr(fd, part->roughcurve);
+ if (part->roughcurve)
+ direct_link_curvemapping(fd, part->roughcurve);
+ part->twistcurve = newdataadr(fd, part->twistcurve);
+ if (part->twistcurve)
+ direct_link_curvemapping(fd, part->twistcurve);
- part->effector_weights = newdataadr(fd, part->effector_weights);
- if (!part->effector_weights)
- part->effector_weights = BKE_effector_add_weights(part->eff_group);
+ part->effector_weights = newdataadr(fd, part->effector_weights);
+ if (!part->effector_weights)
+ part->effector_weights = BKE_effector_add_weights(part->eff_group);
- link_list(fd, &part->instance_weights);
+ link_list(fd, &part->instance_weights);
- part->boids = newdataadr(fd, part->boids);
- part->fluid = newdataadr(fd, part->fluid);
+ part->boids = newdataadr(fd, part->boids);
+ part->fluid = newdataadr(fd, part->fluid);
- if (part->boids) {
- BoidState *state;
- link_list(fd, &part->boids->states);
+ if (part->boids) {
+ BoidState *state;
+ link_list(fd, &part->boids->states);
- for (state = part->boids->states.first; state; state = state->next) {
- link_list(fd, &state->rules);
- link_list(fd, &state->conditions);
- link_list(fd, &state->actions);
- }
- }
- for (a = 0; a < MAX_MTEX; a++) {
- part->mtex[a] = newdataadr(fd, part->mtex[a]);
- }
+ for (state = part->boids->states.first; state; state = state->next) {
+ link_list(fd, &state->rules);
+ link_list(fd, &state->conditions);
+ link_list(fd, &state->actions);
+ }
+ }
+ for (a = 0; a < MAX_MTEX; a++) {
+ part->mtex[a] = newdataadr(fd, part->mtex[a]);
+ }
- /* Protect against integer overflow vulnerability. */
- CLAMP(part->trail_count, 1, 100000);
+ /* Protect against integer overflow vulnerability. */
+ CLAMP(part->trail_count, 1, 100000);
}
static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles)
{
- ParticleSystem *psys, *psysnext;
-
- for (psys = particles->first; psys; psys = psysnext) {
- psysnext = psys->next;
-
- psys->part = newlibadr_us(fd, id->lib, psys->part);
- if (psys->part) {
- ParticleTarget *pt = psys->targets.first;
-
- for (; pt; pt = pt->next)
- pt->ob = newlibadr(fd, id->lib, pt->ob);
-
- psys->parent = newlibadr(fd, id->lib, psys->parent);
- psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
-
- if (psys->clmd) {
- /* XXX - from reading existing code this seems correct but intended usage of
- * pointcache /w cloth should be added in 'ParticleSystem' - campbell */
- psys->clmd->point_cache = psys->pointcache;
- psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
- psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
- psys->clmd->modifier.error = NULL;
- }
- }
- else {
- /* particle modifier must be removed before particle system */
- ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- BLI_remlink(&ob->modifiers, psmd);
- modifier_free((ModifierData *)psmd);
-
- BLI_remlink(particles, psys);
- MEM_freeN(psys);
- }
- }
+ ParticleSystem *psys, *psysnext;
+
+ for (psys = particles->first; psys; psys = psysnext) {
+ psysnext = psys->next;
+
+ psys->part = newlibadr_us(fd, id->lib, psys->part);
+ if (psys->part) {
+ ParticleTarget *pt = psys->targets.first;
+
+ for (; pt; pt = pt->next)
+ pt->ob = newlibadr(fd, id->lib, pt->ob);
+
+ psys->parent = newlibadr(fd, id->lib, psys->parent);
+ psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
+
+ if (psys->clmd) {
+ /* XXX - from reading existing code this seems correct but intended usage of
+ * pointcache /w cloth should be added in 'ParticleSystem' - campbell */
+ psys->clmd->point_cache = psys->pointcache;
+ psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
+ psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
+ psys->clmd->modifier.error = NULL;
+ }
+ }
+ else {
+ /* particle modifier must be removed before particle system */
+ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ BLI_remlink(&ob->modifiers, psmd);
+ modifier_free((ModifierData *)psmd);
+
+ BLI_remlink(particles, psys);
+ MEM_freeN(psys);
+ }
+ }
}
static void direct_link_particlesystems(FileData *fd, ListBase *particles)
{
- ParticleSystem *psys;
- ParticleData *pa;
- int a;
-
- for (psys = particles->first; psys; psys = psys->next) {
- psys->particles = newdataadr(fd, psys->particles);
-
- if (psys->particles && psys->particles->hair) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
- pa->hair = newdataadr(fd, pa->hair);
- }
-
- if (psys->particles && psys->particles->keys) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
- pa->keys = NULL;
- pa->totkey = 0;
- }
-
- psys->flag &= ~PSYS_KEYED;
- }
-
- if (psys->particles && psys->particles->boid) {
- pa = psys->particles;
- pa->boid = newdataadr(fd, pa->boid);
- pa->boid->ground = NULL; /* This is purely runtime data, but still can be an issue if left dangling. */
- for (a = 1, pa++; a < psys->totpart; a++, pa++) {
- pa->boid = (pa - 1)->boid + 1;
- pa->boid->ground = NULL;
- }
- }
- else if (psys->particles) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
- pa->boid = NULL;
- }
-
- psys->fluid_springs = newdataadr(fd, psys->fluid_springs);
-
- psys->child = newdataadr(fd, psys->child);
- psys->effectors = NULL;
-
- link_list(fd, &psys->targets);
-
- psys->edit = NULL;
- psys->free_edit = NULL;
- psys->pathcache = NULL;
- psys->childcache = NULL;
- BLI_listbase_clear(&psys->pathcachebufs);
- BLI_listbase_clear(&psys->childcachebufs);
- psys->pdd = NULL;
-
- if (psys->clmd) {
- psys->clmd = newdataadr(fd, psys->clmd);
- psys->clmd->clothObject = NULL;
- psys->clmd->hairdata = NULL;
-
- psys->clmd->sim_parms = newdataadr(fd, psys->clmd->sim_parms);
- psys->clmd->coll_parms = newdataadr(fd, psys->clmd->coll_parms);
-
- if (psys->clmd->sim_parms) {
- psys->clmd->sim_parms->effector_weights = NULL;
- if (psys->clmd->sim_parms->presets > 10)
- psys->clmd->sim_parms->presets = 0;
- }
-
- psys->hair_in_mesh = psys->hair_out_mesh = NULL;
- psys->clmd->solver_result = NULL;
- }
-
- direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache, 0);
- if (psys->clmd) {
- psys->clmd->point_cache = psys->pointcache;
- }
-
- psys->tree = NULL;
- psys->bvhtree = NULL;
-
- psys->orig_psys = NULL;
- psys->batch_cache = NULL;
- }
- return;
+ ParticleSystem *psys;
+ ParticleData *pa;
+ int a;
+
+ for (psys = particles->first; psys; psys = psys->next) {
+ psys->particles = newdataadr(fd, psys->particles);
+
+ if (psys->particles && psys->particles->hair) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
+ pa->hair = newdataadr(fd, pa->hair);
+ }
+
+ if (psys->particles && psys->particles->keys) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
+ pa->keys = NULL;
+ pa->totkey = 0;
+ }
+
+ psys->flag &= ~PSYS_KEYED;
+ }
+
+ if (psys->particles && psys->particles->boid) {
+ pa = psys->particles;
+ pa->boid = newdataadr(fd, pa->boid);
+ pa->boid->ground =
+ NULL; /* This is purely runtime data, but still can be an issue if left dangling. */
+ for (a = 1, pa++; a < psys->totpart; a++, pa++) {
+ pa->boid = (pa - 1)->boid + 1;
+ pa->boid->ground = NULL;
+ }
+ }
+ else if (psys->particles) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
+ pa->boid = NULL;
+ }
+
+ psys->fluid_springs = newdataadr(fd, psys->fluid_springs);
+
+ psys->child = newdataadr(fd, psys->child);
+ psys->effectors = NULL;
+
+ link_list(fd, &psys->targets);
+
+ psys->edit = NULL;
+ psys->free_edit = NULL;
+ psys->pathcache = NULL;
+ psys->childcache = NULL;
+ BLI_listbase_clear(&psys->pathcachebufs);
+ BLI_listbase_clear(&psys->childcachebufs);
+ psys->pdd = NULL;
+
+ if (psys->clmd) {
+ psys->clmd = newdataadr(fd, psys->clmd);
+ psys->clmd->clothObject = NULL;
+ psys->clmd->hairdata = NULL;
+
+ psys->clmd->sim_parms = newdataadr(fd, psys->clmd->sim_parms);
+ psys->clmd->coll_parms = newdataadr(fd, psys->clmd->coll_parms);
+
+ if (psys->clmd->sim_parms) {
+ psys->clmd->sim_parms->effector_weights = NULL;
+ if (psys->clmd->sim_parms->presets > 10)
+ psys->clmd->sim_parms->presets = 0;
+ }
+
+ psys->hair_in_mesh = psys->hair_out_mesh = NULL;
+ psys->clmd->solver_result = NULL;
+ }
+
+ direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache, 0);
+ if (psys->clmd) {
+ psys->clmd->point_cache = psys->pointcache;
+ }
+
+ psys->tree = NULL;
+ psys->bvhtree = NULL;
+
+ psys->orig_psys = NULL;
+ psys->batch_cache = NULL;
+ }
+ return;
}
/** \} */
@@ -4883,265 +4933,265 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
static void lib_link_mesh(FileData *fd, Main *main)
{
- Mesh *me;
-
- for (me = main->meshes.first; me; me = me->id.next) {
- if (me->id.tag & LIB_TAG_NEED_LINK) {
- int i;
-
- /* Link ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_LibLinkProperty(me->id.properties, fd);
- lib_link_animdata(fd, &me->id, me->adt);
-
- /* this check added for python created meshes */
- if (me->mat) {
- for (i = 0; i < me->totcol; i++) {
- me->mat[i] = newlibadr_us(fd, me->id.lib, me->mat[i]);
- }
- }
- else {
- me->totcol = 0;
- }
-
- me->ipo = newlibadr_us(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys
- me->key = newlibadr_us(fd, me->id.lib, me->key);
- me->texcomesh = newlibadr_us(fd, me->id.lib, me->texcomesh);
- }
- }
-
- for (me = main->meshes.first; me; me = me->id.next) {
- if (me->id.tag & LIB_TAG_NEED_LINK) {
- /*check if we need to convert mfaces to mpolys*/
- if (me->totface && !me->totpoly) {
- /* temporarily switch main so that reading from
- * external CustomData works */
- Main *gmain = G_MAIN;
- G_MAIN = main;
-
- BKE_mesh_do_versions_convert_mfaces_to_mpolys(me);
-
- G_MAIN = gmain;
- }
-
- /*
- * Re-tessellate, even if the polys were just created from tessfaces, this
- * is important because it:
- * - fill the CD_ORIGINDEX layer
- * - gives consistency of tessface between loading from a file and
- * converting an edited BMesh back into a mesh (i.e. it replaces
- * quad tessfaces in a loaded mesh immediately, instead of lazily
- * waiting until edit mode has been entered/exited, making it easier
- * to recognize problems that would otherwise only show up after edits).
- */
+ Mesh *me;
+
+ for (me = main->meshes.first; me; me = me->id.next) {
+ if (me->id.tag & LIB_TAG_NEED_LINK) {
+ int i;
+
+ /* Link ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_LibLinkProperty(me->id.properties, fd);
+ lib_link_animdata(fd, &me->id, me->adt);
+
+ /* this check added for python created meshes */
+ if (me->mat) {
+ for (i = 0; i < me->totcol; i++) {
+ me->mat[i] = newlibadr_us(fd, me->id.lib, me->mat[i]);
+ }
+ }
+ else {
+ me->totcol = 0;
+ }
+
+ me->ipo = newlibadr_us(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys
+ me->key = newlibadr_us(fd, me->id.lib, me->key);
+ me->texcomesh = newlibadr_us(fd, me->id.lib, me->texcomesh);
+ }
+ }
+
+ for (me = main->meshes.first; me; me = me->id.next) {
+ if (me->id.tag & LIB_TAG_NEED_LINK) {
+ /*check if we need to convert mfaces to mpolys*/
+ if (me->totface && !me->totpoly) {
+ /* temporarily switch main so that reading from
+ * external CustomData works */
+ Main *gmain = G_MAIN;
+ G_MAIN = main;
+
+ BKE_mesh_do_versions_convert_mfaces_to_mpolys(me);
+
+ G_MAIN = gmain;
+ }
+
+ /*
+ * Re-tessellate, even if the polys were just created from tessfaces, this
+ * is important because it:
+ * - fill the CD_ORIGINDEX layer
+ * - gives consistency of tessface between loading from a file and
+ * converting an edited BMesh back into a mesh (i.e. it replaces
+ * quad tessfaces in a loaded mesh immediately, instead of lazily
+ * waiting until edit mode has been entered/exited, making it easier
+ * to recognize problems that would otherwise only show up after edits).
+ */
#ifdef USE_TESSFACE_DEFAULT
- BKE_mesh_tessface_calc(me);
+ BKE_mesh_tessface_calc(me);
#else
- BKE_mesh_tessface_clear(me);
+ BKE_mesh_tessface_clear(me);
#endif
- me->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ me->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts)
{
- int i;
-
- if (mdverts == NULL) {
- return;
- }
-
- for (i = count; i > 0; i--, mdverts++) {
- /*convert to vgroup allocation system*/
- MDeformWeight *dw;
- if (mdverts->dw && (dw = newdataadr(fd, mdverts->dw))) {
- const ssize_t dw_len = mdverts->totweight * sizeof(MDeformWeight);
- void *dw_tmp = MEM_mallocN(dw_len, "direct_link_dverts");
- memcpy(dw_tmp, dw, dw_len);
- mdverts->dw = dw_tmp;
- MEM_freeN(dw);
- }
- else {
- mdverts->dw = NULL;
- mdverts->totweight = 0;
- }
- }
+ int i;
+
+ if (mdverts == NULL) {
+ return;
+ }
+
+ for (i = count; i > 0; i--, mdverts++) {
+ /*convert to vgroup allocation system*/
+ MDeformWeight *dw;
+ if (mdverts->dw && (dw = newdataadr(fd, mdverts->dw))) {
+ const ssize_t dw_len = mdverts->totweight * sizeof(MDeformWeight);
+ void *dw_tmp = MEM_mallocN(dw_len, "direct_link_dverts");
+ memcpy(dw_tmp, dw, dw_len);
+ mdverts->dw = dw_tmp;
+ MEM_freeN(dw);
+ }
+ else {
+ mdverts->dw = NULL;
+ mdverts->totweight = 0;
+ }
+ }
}
static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int external)
{
- if (mdisps) {
- int i;
-
- for (i = 0; i < count; ++i) {
- mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
- mdisps[i].hidden = newdataadr(fd, mdisps[i].hidden);
-
- if (mdisps[i].totdisp && !mdisps[i].level) {
- /* this calculation is only correct for loop mdisps;
- * if loading pre-BMesh face mdisps this will be
- * overwritten with the correct value in
- * bm_corners_to_loops() */
- float gridsize = sqrtf(mdisps[i].totdisp);
- mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1;
- }
-
- if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps)) {
- /* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
- /* this does swap for data written at write_mdisps() - readfile.c */
- BLI_endian_switch_float_array(*mdisps[i].disps, mdisps[i].totdisp * 3);
- }
- if (!external && !mdisps[i].disps)
- mdisps[i].totdisp = 0;
- }
- }
+ if (mdisps) {
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
+ mdisps[i].hidden = newdataadr(fd, mdisps[i].hidden);
+
+ if (mdisps[i].totdisp && !mdisps[i].level) {
+ /* this calculation is only correct for loop mdisps;
+ * if loading pre-BMesh face mdisps this will be
+ * overwritten with the correct value in
+ * bm_corners_to_loops() */
+ float gridsize = sqrtf(mdisps[i].totdisp);
+ mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1;
+ }
+
+ if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps)) {
+ /* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
+ /* this does swap for data written at write_mdisps() - readfile.c */
+ BLI_endian_switch_float_array(*mdisps[i].disps, mdisps[i].totdisp * 3);
+ }
+ if (!external && !mdisps[i].disps)
+ mdisps[i].totdisp = 0;
+ }
+ }
}
static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask *grid_paint_mask)
{
- if (grid_paint_mask) {
- int i;
+ if (grid_paint_mask) {
+ int i;
- for (i = 0; i < count; ++i) {
- GridPaintMask *gpm = &grid_paint_mask[i];
- if (gpm->data)
- gpm->data = newdataadr(fd, gpm->data);
- }
- }
+ for (i = 0; i < count; ++i) {
+ GridPaintMask *gpm = &grid_paint_mask[i];
+ if (gpm->data)
+ gpm->data = newdataadr(fd, gpm->data);
+ }
+ }
}
/*this isn't really a public api function, so prototyped here*/
static void direct_link_customdata(FileData *fd, CustomData *data, int count)
{
- int i = 0;
+ int i = 0;
- data->layers = newdataadr(fd, data->layers);
+ data->layers = newdataadr(fd, data->layers);
- /* annoying workaround for bug [#31079] loading legacy files with
- * no polygons _but_ have stale customdata */
- if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) {
- CustomData_reset(data);
- return;
- }
+ /* annoying workaround for bug [#31079] loading legacy files with
+ * no polygons _but_ have stale customdata */
+ if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) {
+ CustomData_reset(data);
+ return;
+ }
- data->external = newdataadr(fd, data->external);
+ data->external = newdataadr(fd, data->external);
- while (i < data->totlayer) {
- CustomDataLayer *layer = &data->layers[i];
+ while (i < data->totlayer) {
+ CustomDataLayer *layer = &data->layers[i];
- if (layer->flag & CD_FLAG_EXTERNAL)
- layer->flag &= ~CD_FLAG_IN_MEMORY;
+ if (layer->flag & CD_FLAG_EXTERNAL)
+ layer->flag &= ~CD_FLAG_IN_MEMORY;
- layer->flag &= ~CD_FLAG_NOFREE;
+ layer->flag &= ~CD_FLAG_NOFREE;
- if (CustomData_verify_versions(data, i)) {
- layer->data = newdataadr(fd, layer->data);
- if (layer->type == CD_MDISPS)
- direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
- else if (layer->type == CD_GRID_PAINT_MASK)
- direct_link_grid_paint_mask(fd, count, layer->data);
- i++;
- }
- }
+ if (CustomData_verify_versions(data, i)) {
+ layer->data = newdataadr(fd, layer->data);
+ if (layer->type == CD_MDISPS)
+ direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
+ else if (layer->type == CD_GRID_PAINT_MASK)
+ direct_link_grid_paint_mask(fd, count, layer->data);
+ i++;
+ }
+ }
- CustomData_update_typemap(data);
+ CustomData_update_typemap(data);
}
static void direct_link_mesh(FileData *fd, Mesh *mesh)
{
- mesh->mat = newdataadr(fd, mesh->mat);
- test_pointer_array(fd, (void **)&mesh->mat);
-
- mesh->mvert = newdataadr(fd, mesh->mvert);
- mesh->medge = newdataadr(fd, mesh->medge);
- mesh->mface = newdataadr(fd, mesh->mface);
- mesh->mloop = newdataadr(fd, mesh->mloop);
- mesh->mpoly = newdataadr(fd, mesh->mpoly);
- mesh->tface = newdataadr(fd, mesh->tface);
- mesh->mtface = newdataadr(fd, mesh->mtface);
- mesh->mcol = newdataadr(fd, mesh->mcol);
- mesh->dvert = newdataadr(fd, mesh->dvert);
- mesh->mloopcol = newdataadr(fd, mesh->mloopcol);
- mesh->mloopuv = newdataadr(fd, mesh->mloopuv);
- mesh->mselect = newdataadr(fd, mesh->mselect);
-
- /* animdata */
- mesh->adt = newdataadr(fd, mesh->adt);
- direct_link_animdata(fd, mesh->adt);
-
- /* normally direct_link_dverts should be called in direct_link_customdata,
- * but for backwards compat in do_versions to work we do it here */
- direct_link_dverts(fd, mesh->totvert, mesh->dvert);
-
- direct_link_customdata(fd, &mesh->vdata, mesh->totvert);
- direct_link_customdata(fd, &mesh->edata, mesh->totedge);
- direct_link_customdata(fd, &mesh->fdata, mesh->totface);
- direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
- direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
-
- mesh->bb = NULL;
- mesh->edit_mesh = NULL;
- BKE_mesh_runtime_reset(mesh);
-
- /* happens with old files */
- if (mesh->mselect == NULL) {
- mesh->totselect = 0;
- }
-
- /* Multires data */
- mesh->mr = newdataadr(fd, mesh->mr);
- if (mesh->mr) {
- MultiresLevel *lvl;
-
- link_list(fd, &mesh->mr->levels);
- lvl = mesh->mr->levels.first;
-
- direct_link_customdata(fd, &mesh->mr->vdata, lvl->totvert);
- direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
- direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
-
- mesh->mr->edge_flags = newdataadr(fd, mesh->mr->edge_flags);
- mesh->mr->edge_creases = newdataadr(fd, mesh->mr->edge_creases);
-
- mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
-
- /* If mesh has the same number of vertices as the
- * highest multires level, load the current mesh verts
- * into multires and discard the old data. Needed
- * because some saved files either do not have a verts
- * array, or the verts array contains out-of-date
- * data. */
- if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
- if (mesh->mr->verts)
- MEM_freeN(mesh->mr->verts);
- mesh->mr->verts = MEM_dupallocN(mesh->mvert);
- }
-
- for (; lvl; lvl = lvl->next) {
- lvl->verts = newdataadr(fd, lvl->verts);
- lvl->faces = newdataadr(fd, lvl->faces);
- lvl->edges = newdataadr(fd, lvl->edges);
- lvl->colfaces = newdataadr(fd, lvl->colfaces);
- }
- }
-
- /* if multires is present but has no valid vertex data,
- * there's no way to recover it; silently remove multires */
- if (mesh->mr && !mesh->mr->verts) {
- multires_free(mesh->mr);
- mesh->mr = NULL;
- }
-
- if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
- TFace *tf = mesh->tface;
- int i;
-
- for (i = 0; i < mesh->totface; i++, tf++) {
- BLI_endian_switch_uint32_array(tf->col, 4);
- }
- }
+ mesh->mat = newdataadr(fd, mesh->mat);
+ test_pointer_array(fd, (void **)&mesh->mat);
+
+ mesh->mvert = newdataadr(fd, mesh->mvert);
+ mesh->medge = newdataadr(fd, mesh->medge);
+ mesh->mface = newdataadr(fd, mesh->mface);
+ mesh->mloop = newdataadr(fd, mesh->mloop);
+ mesh->mpoly = newdataadr(fd, mesh->mpoly);
+ mesh->tface = newdataadr(fd, mesh->tface);
+ mesh->mtface = newdataadr(fd, mesh->mtface);
+ mesh->mcol = newdataadr(fd, mesh->mcol);
+ mesh->dvert = newdataadr(fd, mesh->dvert);
+ mesh->mloopcol = newdataadr(fd, mesh->mloopcol);
+ mesh->mloopuv = newdataadr(fd, mesh->mloopuv);
+ mesh->mselect = newdataadr(fd, mesh->mselect);
+
+ /* animdata */
+ mesh->adt = newdataadr(fd, mesh->adt);
+ direct_link_animdata(fd, mesh->adt);
+
+ /* normally direct_link_dverts should be called in direct_link_customdata,
+ * but for backwards compat in do_versions to work we do it here */
+ direct_link_dverts(fd, mesh->totvert, mesh->dvert);
+
+ direct_link_customdata(fd, &mesh->vdata, mesh->totvert);
+ direct_link_customdata(fd, &mesh->edata, mesh->totedge);
+ direct_link_customdata(fd, &mesh->fdata, mesh->totface);
+ direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
+ direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
+
+ mesh->bb = NULL;
+ mesh->edit_mesh = NULL;
+ BKE_mesh_runtime_reset(mesh);
+
+ /* happens with old files */
+ if (mesh->mselect == NULL) {
+ mesh->totselect = 0;
+ }
+
+ /* Multires data */
+ mesh->mr = newdataadr(fd, mesh->mr);
+ if (mesh->mr) {
+ MultiresLevel *lvl;
+
+ link_list(fd, &mesh->mr->levels);
+ lvl = mesh->mr->levels.first;
+
+ direct_link_customdata(fd, &mesh->mr->vdata, lvl->totvert);
+ direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
+ direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
+
+ mesh->mr->edge_flags = newdataadr(fd, mesh->mr->edge_flags);
+ mesh->mr->edge_creases = newdataadr(fd, mesh->mr->edge_creases);
+
+ mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
+
+ /* If mesh has the same number of vertices as the
+ * highest multires level, load the current mesh verts
+ * into multires and discard the old data. Needed
+ * because some saved files either do not have a verts
+ * array, or the verts array contains out-of-date
+ * data. */
+ if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
+ if (mesh->mr->verts)
+ MEM_freeN(mesh->mr->verts);
+ mesh->mr->verts = MEM_dupallocN(mesh->mvert);
+ }
+
+ for (; lvl; lvl = lvl->next) {
+ lvl->verts = newdataadr(fd, lvl->verts);
+ lvl->faces = newdataadr(fd, lvl->faces);
+ lvl->edges = newdataadr(fd, lvl->edges);
+ lvl->colfaces = newdataadr(fd, lvl->colfaces);
+ }
+ }
+
+ /* if multires is present but has no valid vertex data,
+ * there's no way to recover it; silently remove multires */
+ if (mesh->mr && !mesh->mr->verts) {
+ multires_free(mesh->mr);
+ mesh->mr = NULL;
+ }
+
+ if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
+ TFace *tf = mesh->tface;
+ int i;
+
+ for (i = 0; i < mesh->totface; i++, tf++) {
+ BLI_endian_switch_uint32_array(tf->col, 4);
+ }
+ }
}
/** \} */
@@ -5152,31 +5202,31 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
static void lib_link_latt(FileData *fd, Main *main)
{
- for (Lattice *lt = main->lattices.first; lt; lt = lt->id.next) {
- if (lt->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(lt->id.properties, fd);
- lib_link_animdata(fd, &lt->id, lt->adt);
+ for (Lattice *lt = main->lattices.first; lt; lt = lt->id.next) {
+ if (lt->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(lt->id.properties, fd);
+ lib_link_animdata(fd, &lt->id, lt->adt);
- lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system
- lt->key = newlibadr_us(fd, lt->id.lib, lt->key);
+ lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system
+ lt->key = newlibadr_us(fd, lt->id.lib, lt->key);
- lt->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ lt->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_latt(FileData *fd, Lattice *lt)
{
- lt->def = newdataadr(fd, lt->def);
+ lt->def = newdataadr(fd, lt->def);
- lt->dvert = newdataadr(fd, lt->dvert);
- direct_link_dverts(fd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
+ lt->dvert = newdataadr(fd, lt->dvert);
+ direct_link_dverts(fd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
- lt->editlatt = NULL;
- lt->batch_cache = NULL;
+ lt->editlatt = NULL;
+ lt->batch_cache = NULL;
- lt->adt = newdataadr(fd, lt->adt);
- direct_link_animdata(fd, lt->adt);
+ lt->adt = newdataadr(fd, lt->adt);
+ direct_link_animdata(fd, lt->adt);
}
/** \} */
@@ -5185,879 +5235,887 @@ static void direct_link_latt(FileData *fd, Lattice *lt)
/** \name Read ID: Object
* \{ */
-static void lib_link_modifiers_common(
- void *userData, Object *ob, ID **idpoin, int cb_flag)
+static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, int cb_flag)
{
- FileData *fd = userData;
+ FileData *fd = userData;
- *idpoin = newlibadr(fd, ob->id.lib, *idpoin);
- if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
- id_us_plus_no_lib(*idpoin);
- }
+ *idpoin = newlibadr(fd, ob->id.lib, *idpoin);
+ if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
+ id_us_plus_no_lib(*idpoin);
+ }
}
static void lib_link_modifiers(FileData *fd, Object *ob)
{
- modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
-
- /* If linking from a library, clear 'local' static override flag. */
- if (ob->id.lib != NULL) {
- for (ModifierData *mod = ob->modifiers.first; mod != NULL; mod = mod->next) {
- mod->flag &= ~eModifierFlag_StaticOverride_Local;
- }
- }
+ modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ /* If linking from a library, clear 'local' static override flag. */
+ if (ob->id.lib != NULL) {
+ for (ModifierData *mod = ob->modifiers.first; mod != NULL; mod = mod->next) {
+ mod->flag &= ~eModifierFlag_StaticOverride_Local;
+ }
+ }
}
static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
{
- BKE_gpencil_modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ BKE_gpencil_modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
- /* If linking from a library, clear 'local' static override flag. */
- if (ob->id.lib != NULL) {
- for (GpencilModifierData *mod = ob->greasepencil_modifiers.first; mod != NULL; mod = mod->next) {
- mod->flag &= ~eGpencilModifierFlag_StaticOverride_Local;
- }
- }
+ /* If linking from a library, clear 'local' static override flag. */
+ if (ob->id.lib != NULL) {
+ for (GpencilModifierData *mod = ob->greasepencil_modifiers.first; mod != NULL;
+ mod = mod->next) {
+ mod->flag &= ~eGpencilModifierFlag_StaticOverride_Local;
+ }
+ }
}
static void lib_link_shaderfxs(FileData *fd, Object *ob)
{
- BKE_shaderfx_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ BKE_shaderfx_foreachIDLink(ob, lib_link_modifiers_common, fd);
- /* If linking from a library, clear 'local' static override flag. */
- if (ob->id.lib != NULL) {
- for (ShaderFxData *fx = ob->shader_fx.first; fx != NULL; fx = fx->next) {
- fx->flag &= ~eShaderFxFlag_StaticOverride_Local;
- }
- }
+ /* If linking from a library, clear 'local' static override flag. */
+ if (ob->id.lib != NULL) {
+ for (ShaderFxData *fx = ob->shader_fx.first; fx != NULL; fx = fx->next) {
+ fx->flag &= ~eShaderFxFlag_StaticOverride_Local;
+ }
+ }
}
static void lib_link_object(FileData *fd, Main *main)
{
- bool warn = false;
-
- for (Object *ob = main->objects.first; ob; ob = ob->id.next) {
- if (ob->id.tag & LIB_TAG_NEED_LINK) {
- int a;
-
- IDP_LibLinkProperty(ob->id.properties, fd);
- lib_link_animdata(fd, &ob->id, ob->adt);
-
-// XXX deprecated - old animation system <<<
- ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo);
- ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
-// >>> XXX deprecated - old animation system
-
- ob->parent = newlibadr(fd, ob->id.lib, ob->parent);
- ob->track = newlibadr(fd, ob->id.lib, ob->track);
- ob->poselib = newlibadr_us(fd, ob->id.lib, ob->poselib);
-
- /* 2.8x drops support for non-empty dupli instances. */
- if (ob->type == OB_EMPTY) {
- ob->instance_collection = newlibadr_us(fd, ob->id.lib, ob->instance_collection);
- }
- else {
- ob->instance_collection = NULL;
- ob->transflag &= ~OB_DUPLICOLLECTION;
- }
-
- ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy);
- if (ob->proxy) {
- /* paranoia check, actually a proxy_from pointer should never be written... */
- if (ob->proxy->id.lib == NULL) {
- ob->proxy->proxy_from = NULL;
- ob->proxy = NULL;
-
- if (ob->id.lib)
- printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
- else
- printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
- }
- else {
- /* this triggers object_update to always use a copy */
- ob->proxy->proxy_from = ob;
- }
- }
- ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group);
-
- void *poin = ob->data;
- ob->data = newlibadr_us(fd, ob->id.lib, ob->data);
-
- if (ob->data == NULL && poin != NULL) {
- if (ob->id.lib)
- printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
- else
- printf("Object %s lost data.\n", ob->id.name + 2);
-
- ob->type = OB_EMPTY;
- warn = true;
-
- if (ob->pose) {
- /* we can't call #BKE_pose_free() here because of library linking
- * freeing will recurse down into every pose constraints ID pointers
- * which are not always valid, so for now free directly and suffer
- * some leaked memory rather then crashing immediately
- * while bad this _is_ an exceptional case - campbell */
+ bool warn = false;
+
+ for (Object *ob = main->objects.first; ob; ob = ob->id.next) {
+ if (ob->id.tag & LIB_TAG_NEED_LINK) {
+ int a;
+
+ IDP_LibLinkProperty(ob->id.properties, fd);
+ lib_link_animdata(fd, &ob->id, ob->adt);
+
+ // XXX deprecated - old animation system <<<
+ ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo);
+ ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
+ // >>> XXX deprecated - old animation system
+
+ ob->parent = newlibadr(fd, ob->id.lib, ob->parent);
+ ob->track = newlibadr(fd, ob->id.lib, ob->track);
+ ob->poselib = newlibadr_us(fd, ob->id.lib, ob->poselib);
+
+ /* 2.8x drops support for non-empty dupli instances. */
+ if (ob->type == OB_EMPTY) {
+ ob->instance_collection = newlibadr_us(fd, ob->id.lib, ob->instance_collection);
+ }
+ else {
+ ob->instance_collection = NULL;
+ ob->transflag &= ~OB_DUPLICOLLECTION;
+ }
+
+ ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy);
+ if (ob->proxy) {
+ /* paranoia check, actually a proxy_from pointer should never be written... */
+ if (ob->proxy->id.lib == NULL) {
+ ob->proxy->proxy_from = NULL;
+ ob->proxy = NULL;
+
+ if (ob->id.lib)
+ printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
+ else
+ printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
+ }
+ else {
+ /* this triggers object_update to always use a copy */
+ ob->proxy->proxy_from = ob;
+ }
+ }
+ ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group);
+
+ void *poin = ob->data;
+ ob->data = newlibadr_us(fd, ob->id.lib, ob->data);
+
+ if (ob->data == NULL && poin != NULL) {
+ if (ob->id.lib)
+ printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
+ else
+ printf("Object %s lost data.\n", ob->id.name + 2);
+
+ ob->type = OB_EMPTY;
+ warn = true;
+
+ if (ob->pose) {
+ /* we can't call #BKE_pose_free() here because of library linking
+ * freeing will recurse down into every pose constraints ID pointers
+ * which are not always valid, so for now free directly and suffer
+ * some leaked memory rather then crashing immediately
+ * while bad this _is_ an exceptional case - campbell */
#if 0
- BKE_pose_free(ob->pose);
+ BKE_pose_free(ob->pose);
#else
- MEM_freeN(ob->pose);
+ MEM_freeN(ob->pose);
#endif
- ob->pose = NULL;
- ob->mode &= ~OB_MODE_POSE;
- }
- }
- for (a = 0; a < ob->totcol; a++)
- ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]);
-
- /* When the object is local and the data is library its possible
- * the material list size gets out of sync. [#22663] */
- if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
- const short *totcol_data = give_totcolp(ob);
- /* Only expand so as not to loose any object materials that might be set. */
- if (totcol_data && (*totcol_data > ob->totcol)) {
- /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
- BKE_material_resize_object(main, ob, *totcol_data, false);
- }
- }
-
- ob->gpd = newlibadr_us(fd, ob->id.lib, ob->gpd);
-
- ob->id.tag &= ~LIB_TAG_NEED_LINK;
- /* if id.us==0 a new base will be created later on */
-
- /* WARNING! Also check expand_object(), should reflect the stuff below. */
- lib_link_pose(fd, main, ob, ob->pose);
- lib_link_constraints(fd, &ob->id, &ob->constraints);
-
-// XXX deprecated - old animation system <<<
- lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
- lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
-// >>> XXX deprecated - old animation system
-
- for (PartEff *paf = ob->effect.first; paf; paf = paf->next) {
- if (paf->type == EFF_PARTICLE) {
- paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
- }
- }
-
- {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
-
- if (fluidmd && fluidmd->fss)
- fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system
- }
-
- {
- SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
-
- if (smd && (smd->type == MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */
- }
- }
-
- /* texture field */
- if (ob->pd)
- lib_link_partdeflect(fd, &ob->id, ob->pd);
-
- if (ob->soft) {
- ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group);
-
- ob->soft->effector_weights->group = newlibadr(fd, ob->id.lib, ob->soft->effector_weights->group);
- }
-
- lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
- lib_link_modifiers(fd, ob);
- lib_link_gpencil_modifiers(fd, ob);
- lib_link_shaderfxs(fd, ob);
-
- if (ob->rigidbody_constraint) {
- ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
- ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2);
- }
-
- {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- level->source = newlibadr(fd, ob->id.lib, level->source);
-
- if (!level->source && level == ob->lodlevels.first)
- level->source = ob;
- }
- }
- }
- }
-
- if (warn) {
- BKE_report(fd->reports, RPT_WARNING, "Warning in console");
- }
+ ob->pose = NULL;
+ ob->mode &= ~OB_MODE_POSE;
+ }
+ }
+ for (a = 0; a < ob->totcol; a++)
+ ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]);
+
+ /* When the object is local and the data is library its possible
+ * the material list size gets out of sync. [#22663] */
+ if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
+ const short *totcol_data = give_totcolp(ob);
+ /* Only expand so as not to loose any object materials that might be set. */
+ if (totcol_data && (*totcol_data > ob->totcol)) {
+ /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
+ BKE_material_resize_object(main, ob, *totcol_data, false);
+ }
+ }
+
+ ob->gpd = newlibadr_us(fd, ob->id.lib, ob->gpd);
+
+ ob->id.tag &= ~LIB_TAG_NEED_LINK;
+ /* if id.us==0 a new base will be created later on */
+
+ /* WARNING! Also check expand_object(), should reflect the stuff below. */
+ lib_link_pose(fd, main, ob, ob->pose);
+ lib_link_constraints(fd, &ob->id, &ob->constraints);
+
+ // XXX deprecated - old animation system <<<
+ lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
+ lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
+ // >>> XXX deprecated - old animation system
+
+ for (PartEff *paf = ob->effect.first; paf; paf = paf->next) {
+ if (paf->type == EFF_PARTICLE) {
+ paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
+ }
+ }
+
+ {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
+ ob, eModifierType_Fluidsim);
+
+ if (fluidmd && fluidmd->fss)
+ fluidmd->fss->ipo = newlibadr_us(
+ fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system
+ }
+
+ {
+ SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob,
+ eModifierType_Smoke);
+
+ if (smd && (smd->type == MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ smd->domain->flags |=
+ MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */
+ }
+ }
+
+ /* texture field */
+ if (ob->pd)
+ lib_link_partdeflect(fd, &ob->id, ob->pd);
+
+ if (ob->soft) {
+ ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group);
+
+ ob->soft->effector_weights->group = newlibadr(
+ fd, ob->id.lib, ob->soft->effector_weights->group);
+ }
+
+ lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
+ lib_link_modifiers(fd, ob);
+ lib_link_gpencil_modifiers(fd, ob);
+ lib_link_shaderfxs(fd, ob);
+
+ if (ob->rigidbody_constraint) {
+ ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
+ ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2);
+ }
+
+ {
+ LodLevel *level;
+ for (level = ob->lodlevels.first; level; level = level->next) {
+ level->source = newlibadr(fd, ob->id.lib, level->source);
+
+ if (!level->source && level == ob->lodlevels.first)
+ level->source = ob;
+ }
+ }
+ }
+ }
+
+ if (warn) {
+ BKE_report(fd->reports, RPT_WARNING, "Warning in console");
+ }
}
/* direct data for cache */
static void direct_link_motionpath(FileData *fd, bMotionPath *mpath)
{
- /* sanity check */
- if (mpath == NULL)
- return;
+ /* sanity check */
+ if (mpath == NULL)
+ return;
- /* relink points cache */
- mpath->points = newdataadr(fd, mpath->points);
+ /* relink points cache */
+ mpath->points = newdataadr(fd, mpath->points);
- mpath->points_vbo = NULL;
- mpath->batch_line = NULL;
- mpath->batch_points = NULL;
+ mpath->points_vbo = NULL;
+ mpath->batch_line = NULL;
+ mpath->batch_points = NULL;
}
static void direct_link_pose(FileData *fd, bPose *pose)
{
- bPoseChannel *pchan;
+ bPoseChannel *pchan;
- if (!pose)
- return;
+ if (!pose)
+ return;
- link_list(fd, &pose->chanbase);
- link_list(fd, &pose->agroups);
+ link_list(fd, &pose->chanbase);
+ link_list(fd, &pose->agroups);
- pose->chanhash = NULL;
- pose->chan_array = NULL;
+ pose->chanhash = NULL;
+ pose->chan_array = NULL;
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- pchan->bone = NULL;
- pchan->parent = newdataadr(fd, pchan->parent);
- pchan->child = newdataadr(fd, pchan->child);
- pchan->custom_tx = newdataadr(fd, pchan->custom_tx);
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ pchan->bone = NULL;
+ pchan->parent = newdataadr(fd, pchan->parent);
+ pchan->child = newdataadr(fd, pchan->child);
+ pchan->custom_tx = newdataadr(fd, pchan->custom_tx);
- pchan->bbone_prev = newdataadr(fd, pchan->bbone_prev);
- pchan->bbone_next = newdataadr(fd, pchan->bbone_next);
+ pchan->bbone_prev = newdataadr(fd, pchan->bbone_prev);
+ pchan->bbone_next = newdataadr(fd, pchan->bbone_next);
- direct_link_constraints(fd, &pchan->constraints);
+ direct_link_constraints(fd, &pchan->constraints);
- pchan->prop = newdataadr(fd, pchan->prop);
- IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ pchan->prop = newdataadr(fd, pchan->prop);
+ IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- pchan->mpath = newdataadr(fd, pchan->mpath);
- if (pchan->mpath)
- direct_link_motionpath(fd, pchan->mpath);
+ pchan->mpath = newdataadr(fd, pchan->mpath);
+ if (pchan->mpath)
+ direct_link_motionpath(fd, pchan->mpath);
- BLI_listbase_clear(&pchan->iktree);
- BLI_listbase_clear(&pchan->siktree);
+ BLI_listbase_clear(&pchan->iktree);
+ BLI_listbase_clear(&pchan->siktree);
- /* in case this value changes in future, clamp else we get undefined behavior */
- CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
+ /* in case this value changes in future, clamp else we get undefined behavior */
+ CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
- pchan->draw_data = NULL;
- memset(&pchan->runtime, 0, sizeof(pchan->runtime));
- }
- pose->ikdata = NULL;
- if (pose->ikparam != NULL) {
- pose->ikparam = newdataadr(fd, pose->ikparam);
- }
+ pchan->draw_data = NULL;
+ memset(&pchan->runtime, 0, sizeof(pchan->runtime));
+ }
+ pose->ikdata = NULL;
+ if (pose->ikparam != NULL) {
+ pose->ikparam = newdataadr(fd, pose->ikparam);
+ }
}
static void direct_link_modifiers(FileData *fd, ListBase *lb)
{
- ModifierData *md;
-
- link_list(fd, lb);
-
- for (md = lb->first; md; md = md->next) {
- md->error = NULL;
- md->runtime = NULL;
-
- /* if modifiers disappear, or for upward compatibility */
- if (NULL == modifierType_getInfo(md->type))
- md->type = eModifierType_None;
-
- if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
-
- smd->emCache = smd->mCache = NULL;
- }
- else if (md->type == eModifierType_Armature) {
- ArmatureModifierData *amd = (ArmatureModifierData *)md;
-
- amd->prevCos = NULL;
- }
- else if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- clmd->clothObject = NULL;
- clmd->hairdata = NULL;
-
- clmd->sim_parms = newdataadr(fd, clmd->sim_parms);
- clmd->coll_parms = newdataadr(fd, clmd->coll_parms);
-
- direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
-
- if (clmd->sim_parms) {
- if (clmd->sim_parms->presets > 10)
- clmd->sim_parms->presets = 0;
-
- clmd->sim_parms->reset = 0;
-
- clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
-
- if (!clmd->sim_parms->effector_weights) {
- clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
- }
- }
-
- clmd->solver_result = NULL;
- }
- else if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
-
- fluidmd->fss = newdataadr(fd, fluidmd->fss);
- if (fluidmd->fss) {
- fluidmd->fss->fmd = fluidmd;
- fluidmd->fss->meshVelocities = NULL;
- }
- }
- else if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
-
- if (smd->type == MOD_SMOKE_TYPE_DOMAIN) {
- smd->flow = NULL;
- smd->coll = NULL;
- smd->domain = newdataadr(fd, smd->domain);
- smd->domain->smd = smd;
-
- smd->domain->fluid = NULL;
- smd->domain->fluid_mutex = BLI_rw_mutex_alloc();
- smd->domain->wt = NULL;
- smd->domain->shadow = NULL;
- smd->domain->tex = NULL;
- smd->domain->tex_shadow = NULL;
- smd->domain->tex_flame = NULL;
- smd->domain->tex_flame_coba = NULL;
- smd->domain->tex_coba = NULL;
- smd->domain->tex_field = NULL;
- smd->domain->tex_velocity_x = NULL;
- smd->domain->tex_velocity_y = NULL;
- smd->domain->tex_velocity_z = NULL;
- smd->domain->tex_wt = NULL;
- smd->domain->coba = newdataadr(fd, smd->domain->coba);
-
- smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
- if (!smd->domain->effector_weights)
- smd->domain->effector_weights = BKE_effector_add_weights(NULL);
-
- direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
-
- /* Smoke uses only one cache from now on, so store pointer convert */
- if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
- if (smd->domain->point_cache[1]) {
- PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
- if (cache->flag & PTCACHE_FAKE_SMOKE) {
- /* Smoke was already saved in "new format" and this cache is a fake one. */
- }
- else {
- printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
- }
- BKE_ptcache_free(cache);
- }
- BLI_listbase_clear(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1] = NULL;
- }
- }
- else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
- smd->domain = NULL;
- smd->coll = NULL;
- smd->flow = newdataadr(fd, smd->flow);
- smd->flow->smd = smd;
- smd->flow->mesh = NULL;
- smd->flow->verts_old = NULL;
- smd->flow->numverts = 0;
- smd->flow->psys = newdataadr(fd, smd->flow->psys);
- }
- else if (smd->type == MOD_SMOKE_TYPE_COLL) {
- smd->flow = NULL;
- smd->domain = NULL;
- smd->coll = newdataadr(fd, smd->coll);
- if (smd->coll) {
- smd->coll->smd = smd;
- smd->coll->verts_old = NULL;
- smd->coll->numverts = 0;
- smd->coll->mesh = NULL;
- }
- else {
- smd->type = 0;
- smd->flow = NULL;
- smd->domain = NULL;
- smd->coll = NULL;
- }
- }
- }
- else if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-
- if (pmd->canvas) {
- pmd->canvas = newdataadr(fd, pmd->canvas);
- pmd->canvas->pmd = pmd;
- pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
-
- if (pmd->canvas->surfaces.first) {
- DynamicPaintSurface *surface;
- link_list(fd, &pmd->canvas->surfaces);
-
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
- surface->canvas = pmd->canvas;
- surface->data = NULL;
- direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
-
- if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
- surface->effector_weights = BKE_effector_add_weights(NULL);
- }
- }
- }
- if (pmd->brush) {
- pmd->brush = newdataadr(fd, pmd->brush);
- pmd->brush->pmd = pmd;
- pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
- pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
- pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
- }
- }
- else if (md->type == eModifierType_Collision) {
- CollisionModifierData *collmd = (CollisionModifierData *)md;
+ ModifierData *md;
+
+ link_list(fd, lb);
+
+ for (md = lb->first; md; md = md->next) {
+ md->error = NULL;
+ md->runtime = NULL;
+
+ /* if modifiers disappear, or for upward compatibility */
+ if (NULL == modifierType_getInfo(md->type))
+ md->type = eModifierType_None;
+
+ if (md->type == eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
+
+ smd->emCache = smd->mCache = NULL;
+ }
+ else if (md->type == eModifierType_Armature) {
+ ArmatureModifierData *amd = (ArmatureModifierData *)md;
+
+ amd->prevCos = NULL;
+ }
+ else if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ clmd->clothObject = NULL;
+ clmd->hairdata = NULL;
+
+ clmd->sim_parms = newdataadr(fd, clmd->sim_parms);
+ clmd->coll_parms = newdataadr(fd, clmd->coll_parms);
+
+ direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
+
+ if (clmd->sim_parms) {
+ if (clmd->sim_parms->presets > 10)
+ clmd->sim_parms->presets = 0;
+
+ clmd->sim_parms->reset = 0;
+
+ clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
+
+ if (!clmd->sim_parms->effector_weights) {
+ clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
+ }
+ }
+
+ clmd->solver_result = NULL;
+ }
+ else if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
+
+ fluidmd->fss = newdataadr(fd, fluidmd->fss);
+ if (fluidmd->fss) {
+ fluidmd->fss->fmd = fluidmd;
+ fluidmd->fss->meshVelocities = NULL;
+ }
+ }
+ else if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+
+ if (smd->type == MOD_SMOKE_TYPE_DOMAIN) {
+ smd->flow = NULL;
+ smd->coll = NULL;
+ smd->domain = newdataadr(fd, smd->domain);
+ smd->domain->smd = smd;
+
+ smd->domain->fluid = NULL;
+ smd->domain->fluid_mutex = BLI_rw_mutex_alloc();
+ smd->domain->wt = NULL;
+ smd->domain->shadow = NULL;
+ smd->domain->tex = NULL;
+ smd->domain->tex_shadow = NULL;
+ smd->domain->tex_flame = NULL;
+ smd->domain->tex_flame_coba = NULL;
+ smd->domain->tex_coba = NULL;
+ smd->domain->tex_field = NULL;
+ smd->domain->tex_velocity_x = NULL;
+ smd->domain->tex_velocity_y = NULL;
+ smd->domain->tex_velocity_z = NULL;
+ smd->domain->tex_wt = NULL;
+ smd->domain->coba = newdataadr(fd, smd->domain->coba);
+
+ smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
+ if (!smd->domain->effector_weights)
+ smd->domain->effector_weights = BKE_effector_add_weights(NULL);
+
+ direct_link_pointcache_list(
+ fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
+
+ /* Smoke uses only one cache from now on, so store pointer convert */
+ if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
+ if (smd->domain->point_cache[1]) {
+ PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
+ if (cache->flag & PTCACHE_FAKE_SMOKE) {
+ /* Smoke was already saved in "new format" and this cache is a fake one. */
+ }
+ else {
+ printf(
+ "High resolution smoke cache not available due to pointcache update. Please "
+ "reset the simulation.\n");
+ }
+ BKE_ptcache_free(cache);
+ }
+ BLI_listbase_clear(&smd->domain->ptcaches[1]);
+ smd->domain->point_cache[1] = NULL;
+ }
+ }
+ else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
+ smd->domain = NULL;
+ smd->coll = NULL;
+ smd->flow = newdataadr(fd, smd->flow);
+ smd->flow->smd = smd;
+ smd->flow->mesh = NULL;
+ smd->flow->verts_old = NULL;
+ smd->flow->numverts = 0;
+ smd->flow->psys = newdataadr(fd, smd->flow->psys);
+ }
+ else if (smd->type == MOD_SMOKE_TYPE_COLL) {
+ smd->flow = NULL;
+ smd->domain = NULL;
+ smd->coll = newdataadr(fd, smd->coll);
+ if (smd->coll) {
+ smd->coll->smd = smd;
+ smd->coll->verts_old = NULL;
+ smd->coll->numverts = 0;
+ smd->coll->mesh = NULL;
+ }
+ else {
+ smd->type = 0;
+ smd->flow = NULL;
+ smd->domain = NULL;
+ smd->coll = NULL;
+ }
+ }
+ }
+ else if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+
+ if (pmd->canvas) {
+ pmd->canvas = newdataadr(fd, pmd->canvas);
+ pmd->canvas->pmd = pmd;
+ pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
+
+ if (pmd->canvas->surfaces.first) {
+ DynamicPaintSurface *surface;
+ link_list(fd, &pmd->canvas->surfaces);
+
+ for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ surface->canvas = pmd->canvas;
+ surface->data = NULL;
+ direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
+
+ if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
+ surface->effector_weights = BKE_effector_add_weights(NULL);
+ }
+ }
+ }
+ if (pmd->brush) {
+ pmd->brush = newdataadr(fd, pmd->brush);
+ pmd->brush->pmd = pmd;
+ pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
+ pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
+ pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
+ }
+ }
+ else if (md->type == eModifierType_Collision) {
+ CollisionModifierData *collmd = (CollisionModifierData *)md;
#if 0
- // TODO: CollisionModifier should use pointcache
- // + have proper reset events before enabling this
- collmd->x = newdataadr(fd, collmd->x);
- collmd->xnew = newdataadr(fd, collmd->xnew);
- collmd->mfaces = newdataadr(fd, collmd->mfaces);
-
- collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x");
- collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew");
- collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v");
+ // TODO: CollisionModifier should use pointcache
+ // + have proper reset events before enabling this
+ collmd->x = newdataadr(fd, collmd->x);
+ collmd->xnew = newdataadr(fd, collmd->xnew);
+ collmd->mfaces = newdataadr(fd, collmd->mfaces);
+
+ collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x");
+ collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew");
+ collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v");
#endif
- collmd->x = NULL;
- collmd->xnew = NULL;
- collmd->current_x = NULL;
- collmd->current_xnew = NULL;
- collmd->current_v = NULL;
- collmd->time_x = collmd->time_xnew = -1000;
- collmd->mvert_num = 0;
- collmd->tri_num = 0;
- collmd->is_static = false;
- collmd->bvhtree = NULL;
- collmd->tri = NULL;
-
- }
- else if (md->type == eModifierType_Surface) {
- SurfaceModifierData *surmd = (SurfaceModifierData *)md;
-
- surmd->mesh = NULL;
- surmd->bvhtree = NULL;
- surmd->x = NULL;
- surmd->v = NULL;
- surmd->numverts = 0;
- }
- else if (md->type == eModifierType_Hook) {
- HookModifierData *hmd = (HookModifierData *)md;
-
- hmd->indexar = newdataadr(fd, hmd->indexar);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_int32_array(hmd->indexar, hmd->totindex);
- }
-
- hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
- if (hmd->curfalloff) {
- direct_link_curvemapping(fd, hmd->curfalloff);
- }
- }
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
-
- psmd->mesh_final = NULL;
- psmd->mesh_original = NULL;
- psmd->psys = newdataadr(fd, psmd->psys);
- psmd->flag &= ~eParticleSystemFlag_psys_updated;
- psmd->flag |= eParticleSystemFlag_file_loaded;
- }
- else if (md->type == eModifierType_Explode) {
- ExplodeModifierData *psmd = (ExplodeModifierData *)md;
-
- psmd->facepa = NULL;
- }
- else if (md->type == eModifierType_MeshDeform) {
- MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
-
- mmd->bindinfluences = newdataadr(fd, mmd->bindinfluences);
- mmd->bindoffsets = newdataadr(fd, mmd->bindoffsets);
- mmd->bindcagecos = newdataadr(fd, mmd->bindcagecos);
- mmd->dyngrid = newdataadr(fd, mmd->dyngrid);
- mmd->dyninfluences = newdataadr(fd, mmd->dyninfluences);
- mmd->dynverts = newdataadr(fd, mmd->dynverts);
-
- mmd->bindweights = newdataadr(fd, mmd->bindweights);
- mmd->bindcos = newdataadr(fd, mmd->bindcos);
-
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- if (mmd->bindoffsets) BLI_endian_switch_int32_array(mmd->bindoffsets, mmd->totvert + 1);
- if (mmd->bindcagecos) BLI_endian_switch_float_array(mmd->bindcagecos, mmd->totcagevert * 3);
- if (mmd->dynverts) BLI_endian_switch_int32_array(mmd->dynverts, mmd->totvert);
- if (mmd->bindweights) BLI_endian_switch_float_array(mmd->bindweights, mmd->totvert);
- if (mmd->bindcos) BLI_endian_switch_float_array(mmd->bindcos, mmd->totcagevert * 3);
- }
- }
- else if (md->type == eModifierType_Ocean) {
- OceanModifierData *omd = (OceanModifierData *)md;
- omd->oceancache = NULL;
- omd->ocean = NULL;
- }
- else if (md->type == eModifierType_Warp) {
- WarpModifierData *tmd = (WarpModifierData *)md;
-
- tmd->curfalloff = newdataadr(fd, tmd->curfalloff);
- if (tmd->curfalloff)
- direct_link_curvemapping(fd, tmd->curfalloff);
- }
- else if (md->type == eModifierType_WeightVGEdit) {
- WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
-
- wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
- if (wmd->cmap_curve)
- direct_link_curvemapping(fd, wmd->cmap_curve);
- }
- else if (md->type == eModifierType_LaplacianDeform) {
- LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
-
- lmd->vertexco = newdataadr(fd, lmd->vertexco);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_float_array(lmd->vertexco, lmd->total_verts * 3);
- }
- lmd->cache_system = NULL;
- }
- else if (md->type == eModifierType_CorrectiveSmooth) {
- CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
-
- if (csmd->bind_coords) {
- csmd->bind_coords = newdataadr(fd, csmd->bind_coords);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_float_array((float *)csmd->bind_coords, csmd->bind_coords_num * 3);
- }
- }
-
- /* runtime only */
- csmd->delta_cache = NULL;
- csmd->delta_cache_num = 0;
- }
- else if (md->type == eModifierType_MeshSequenceCache) {
- MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
- msmcd->reader = NULL;
- }
- else if (md->type == eModifierType_SurfaceDeform) {
- SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
-
- smd->verts = newdataadr(fd, smd->verts);
-
- if (smd->verts) {
- for (int i = 0; i < smd->numverts; i++) {
- smd->verts[i].binds = newdataadr(fd, smd->verts[i].binds);
-
- if (smd->verts[i].binds) {
- for (int j = 0; j < smd->verts[i].numbinds; j++) {
- smd->verts[i].binds[j].vert_inds = newdataadr(fd, smd->verts[i].binds[j].vert_inds);
- smd->verts[i].binds[j].vert_weights = newdataadr(fd, smd->verts[i].binds[j].vert_weights);
-
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- if (smd->verts[i].binds[j].vert_inds)
- BLI_endian_switch_uint32_array(
- smd->verts[i].binds[j].vert_inds, smd->verts[i].binds[j].numverts);
-
- if (smd->verts[i].binds[j].vert_weights) {
- if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
- smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI)
- {
- BLI_endian_switch_float_array(
- smd->verts[i].binds[j].vert_weights, 3);
- }
- else {
- BLI_endian_switch_float_array(
- smd->verts[i].binds[j].vert_weights, smd->verts[i].binds[j].numverts);
- }
- }
- }
- }
- }
- }
- }
- }
- }
+ collmd->x = NULL;
+ collmd->xnew = NULL;
+ collmd->current_x = NULL;
+ collmd->current_xnew = NULL;
+ collmd->current_v = NULL;
+ collmd->time_x = collmd->time_xnew = -1000;
+ collmd->mvert_num = 0;
+ collmd->tri_num = 0;
+ collmd->is_static = false;
+ collmd->bvhtree = NULL;
+ collmd->tri = NULL;
+ }
+ else if (md->type == eModifierType_Surface) {
+ SurfaceModifierData *surmd = (SurfaceModifierData *)md;
+
+ surmd->mesh = NULL;
+ surmd->bvhtree = NULL;
+ surmd->x = NULL;
+ surmd->v = NULL;
+ surmd->numverts = 0;
+ }
+ else if (md->type == eModifierType_Hook) {
+ HookModifierData *hmd = (HookModifierData *)md;
+
+ hmd->indexar = newdataadr(fd, hmd->indexar);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_int32_array(hmd->indexar, hmd->totindex);
+ }
+
+ hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
+ if (hmd->curfalloff) {
+ direct_link_curvemapping(fd, hmd->curfalloff);
+ }
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+
+ psmd->mesh_final = NULL;
+ psmd->mesh_original = NULL;
+ psmd->psys = newdataadr(fd, psmd->psys);
+ psmd->flag &= ~eParticleSystemFlag_psys_updated;
+ psmd->flag |= eParticleSystemFlag_file_loaded;
+ }
+ else if (md->type == eModifierType_Explode) {
+ ExplodeModifierData *psmd = (ExplodeModifierData *)md;
+
+ psmd->facepa = NULL;
+ }
+ else if (md->type == eModifierType_MeshDeform) {
+ MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
+
+ mmd->bindinfluences = newdataadr(fd, mmd->bindinfluences);
+ mmd->bindoffsets = newdataadr(fd, mmd->bindoffsets);
+ mmd->bindcagecos = newdataadr(fd, mmd->bindcagecos);
+ mmd->dyngrid = newdataadr(fd, mmd->dyngrid);
+ mmd->dyninfluences = newdataadr(fd, mmd->dyninfluences);
+ mmd->dynverts = newdataadr(fd, mmd->dynverts);
+
+ mmd->bindweights = newdataadr(fd, mmd->bindweights);
+ mmd->bindcos = newdataadr(fd, mmd->bindcos);
+
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ if (mmd->bindoffsets)
+ BLI_endian_switch_int32_array(mmd->bindoffsets, mmd->totvert + 1);
+ if (mmd->bindcagecos)
+ BLI_endian_switch_float_array(mmd->bindcagecos, mmd->totcagevert * 3);
+ if (mmd->dynverts)
+ BLI_endian_switch_int32_array(mmd->dynverts, mmd->totvert);
+ if (mmd->bindweights)
+ BLI_endian_switch_float_array(mmd->bindweights, mmd->totvert);
+ if (mmd->bindcos)
+ BLI_endian_switch_float_array(mmd->bindcos, mmd->totcagevert * 3);
+ }
+ }
+ else if (md->type == eModifierType_Ocean) {
+ OceanModifierData *omd = (OceanModifierData *)md;
+ omd->oceancache = NULL;
+ omd->ocean = NULL;
+ }
+ else if (md->type == eModifierType_Warp) {
+ WarpModifierData *tmd = (WarpModifierData *)md;
+
+ tmd->curfalloff = newdataadr(fd, tmd->curfalloff);
+ if (tmd->curfalloff)
+ direct_link_curvemapping(fd, tmd->curfalloff);
+ }
+ else if (md->type == eModifierType_WeightVGEdit) {
+ WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
+
+ wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
+ if (wmd->cmap_curve)
+ direct_link_curvemapping(fd, wmd->cmap_curve);
+ }
+ else if (md->type == eModifierType_LaplacianDeform) {
+ LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
+
+ lmd->vertexco = newdataadr(fd, lmd->vertexco);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array(lmd->vertexco, lmd->total_verts * 3);
+ }
+ lmd->cache_system = NULL;
+ }
+ else if (md->type == eModifierType_CorrectiveSmooth) {
+ CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
+
+ if (csmd->bind_coords) {
+ csmd->bind_coords = newdataadr(fd, csmd->bind_coords);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array((float *)csmd->bind_coords, csmd->bind_coords_num * 3);
+ }
+ }
+
+ /* runtime only */
+ csmd->delta_cache = NULL;
+ csmd->delta_cache_num = 0;
+ }
+ else if (md->type == eModifierType_MeshSequenceCache) {
+ MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
+ msmcd->reader = NULL;
+ }
+ else if (md->type == eModifierType_SurfaceDeform) {
+ SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
+
+ smd->verts = newdataadr(fd, smd->verts);
+
+ if (smd->verts) {
+ for (int i = 0; i < smd->numverts; i++) {
+ smd->verts[i].binds = newdataadr(fd, smd->verts[i].binds);
+
+ if (smd->verts[i].binds) {
+ for (int j = 0; j < smd->verts[i].numbinds; j++) {
+ smd->verts[i].binds[j].vert_inds = newdataadr(fd, smd->verts[i].binds[j].vert_inds);
+ smd->verts[i].binds[j].vert_weights = newdataadr(
+ fd, smd->verts[i].binds[j].vert_weights);
+
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ if (smd->verts[i].binds[j].vert_inds)
+ BLI_endian_switch_uint32_array(smd->verts[i].binds[j].vert_inds,
+ smd->verts[i].binds[j].numverts);
+
+ if (smd->verts[i].binds[j].vert_weights) {
+ if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
+ smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
+ BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights, 3);
+ }
+ else {
+ BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights,
+ smd->verts[i].binds[j].numverts);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
{
- GpencilModifierData *md;
-
- link_list(fd, lb);
+ GpencilModifierData *md;
- for (md = lb->first; md; md = md->next) {
- md->error = NULL;
+ link_list(fd, lb);
- /* if modifiers disappear, or for upward compatibility */
- if (NULL == BKE_gpencil_modifierType_getInfo(md->type))
- md->type = eModifierType_None;
+ for (md = lb->first; md; md = md->next) {
+ md->error = NULL;
- if (md->type == eGpencilModifierType_Lattice) {
- LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
- gpmd->cache_data = NULL;
- }
- else if (md->type == eGpencilModifierType_Hook) {
- HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
+ /* if modifiers disappear, or for upward compatibility */
+ if (NULL == BKE_gpencil_modifierType_getInfo(md->type))
+ md->type = eModifierType_None;
- hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
- if (hmd->curfalloff) {
- direct_link_curvemapping(fd, hmd->curfalloff);
- }
- }
- else if (md->type == eGpencilModifierType_Thick) {
- ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+ if (md->type == eGpencilModifierType_Lattice) {
+ LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
+ gpmd->cache_data = NULL;
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
- gpmd->curve_thickness = newdataadr(fd, gpmd->curve_thickness);
- if (gpmd->curve_thickness) {
- direct_link_curvemapping(fd, gpmd->curve_thickness);
- /* initialize the curve. Maybe this could be moved to modififer logic */
- curvemapping_initialize(gpmd->curve_thickness);
- }
- }
+ hmd->curfalloff = newdataadr(fd, hmd->curfalloff);
+ if (hmd->curfalloff) {
+ direct_link_curvemapping(fd, hmd->curfalloff);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
- }
+ gpmd->curve_thickness = newdataadr(fd, gpmd->curve_thickness);
+ if (gpmd->curve_thickness) {
+ direct_link_curvemapping(fd, gpmd->curve_thickness);
+ /* initialize the curve. Maybe this could be moved to modififer logic */
+ curvemapping_initialize(gpmd->curve_thickness);
+ }
+ }
+ }
}
static void direct_link_shaderfxs(FileData *fd, ListBase *lb)
{
- ShaderFxData *fx;
+ ShaderFxData *fx;
- link_list(fd, lb);
+ link_list(fd, lb);
- for (fx = lb->first; fx; fx = fx->next) {
- fx->error = NULL;
+ for (fx = lb->first; fx; fx = fx->next) {
+ fx->error = NULL;
- /* if shader disappear, or for upward compatibility */
- if (NULL == BKE_shaderfxType_getInfo(fx->type))
- fx->type = eShaderFxType_None;
-
- }
+ /* if shader disappear, or for upward compatibility */
+ if (NULL == BKE_shaderfxType_getInfo(fx->type))
+ fx->type = eShaderFxType_None;
+ }
}
static void direct_link_object(FileData *fd, Object *ob)
{
- PartEff *paf;
-
- /* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */
- ob->proxy_from = NULL;
-
- /* loading saved files with editmode enabled works, but for undo we like
- * to stay in object mode during undo presses so keep editmode disabled.
- *
- * Also when linking in a file don't allow edit and pose modes.
- * See [#34776, #42780] for more information.
- */
- if (fd->memfile || (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT))) {
- ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
- if (!fd->memfile) {
- ob->mode &= ~OB_MODE_POSE;
- }
- }
-
- ob->adt = newdataadr(fd, ob->adt);
- direct_link_animdata(fd, ob->adt);
-
- ob->pose = newdataadr(fd, ob->pose);
- direct_link_pose(fd, ob->pose);
-
- ob->mpath = newdataadr(fd, ob->mpath);
- if (ob->mpath)
- direct_link_motionpath(fd, ob->mpath);
-
- link_list(fd, &ob->defbase);
- link_list(fd, &ob->fmaps);
-// XXX deprecated - old animation system <<<
- direct_link_nlastrips(fd, &ob->nlastrips);
- link_list(fd, &ob->constraintChannels);
-// >>> XXX deprecated - old animation system
-
- ob->mat = newdataadr(fd, ob->mat);
- test_pointer_array(fd, (void **)&ob->mat);
- ob->matbits = newdataadr(fd, ob->matbits);
-
- /* do it here, below old data gets converted */
- direct_link_modifiers(fd, &ob->modifiers);
- direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers);
- direct_link_shaderfxs(fd, &ob->shader_fx);
-
- link_list(fd, &ob->effect);
- paf = ob->effect.first;
- while (paf) {
- if (paf->type == EFF_PARTICLE) {
- paf->keys = NULL;
- }
- if (paf->type == EFF_WAVE) {
- WaveEff *wav = (WaveEff *)paf;
- PartEff *next = paf->next;
- WaveModifierData *wmd = (WaveModifierData *)modifier_new(eModifierType_Wave);
-
- wmd->damp = wav->damp;
- wmd->flag = wav->flag;
- wmd->height = wav->height;
- wmd->lifetime = wav->lifetime;
- wmd->narrow = wav->narrow;
- wmd->speed = wav->speed;
- wmd->startx = wav->startx;
- wmd->starty = wav->startx;
- wmd->timeoffs = wav->timeoffs;
- wmd->width = wav->width;
-
- BLI_addtail(&ob->modifiers, wmd);
-
- BLI_remlink(&ob->effect, paf);
- MEM_freeN(paf);
-
- paf = next;
- continue;
- }
- if (paf->type == EFF_BUILD) {
- BuildEff *baf = (BuildEff *)paf;
- PartEff *next = paf->next;
- BuildModifierData *bmd = (BuildModifierData *)modifier_new(eModifierType_Build);
-
- bmd->start = baf->sfra;
- bmd->length = baf->len;
- bmd->randomize = 0;
- bmd->seed = 1;
-
- BLI_addtail(&ob->modifiers, bmd);
-
- BLI_remlink(&ob->effect, paf);
- MEM_freeN(paf);
-
- paf = next;
- continue;
- }
- paf = paf->next;
- }
-
- ob->pd = newdataadr(fd, ob->pd);
- direct_link_partdeflect(ob->pd);
- ob->soft = newdataadr(fd, ob->soft);
- if (ob->soft) {
- SoftBody *sb = ob->soft;
-
- sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
- sb->bspring = NULL;
- sb->scratch = NULL;
- /* although not used anymore */
- /* still have to be loaded to be compatible with old files */
- sb->keys = newdataadr(fd, sb->keys);
- test_pointer_array(fd, (void **)&sb->keys);
- if (sb->keys) {
- int a;
- for (a = 0; a < sb->totkey; a++) {
- sb->keys[a] = newdataadr(fd, sb->keys[a]);
- }
- }
-
- sb->effector_weights = newdataadr(fd, sb->effector_weights);
- if (!sb->effector_weights)
- sb->effector_weights = BKE_effector_add_weights(NULL);
-
- sb->shared = newdataadr(fd, sb->shared);
- if (sb->shared == NULL) {
- /* Link deprecated caches if they exist, so we can use them for versioning.
- * We should only do this when sb->shared == NULL, because those pointers
- * are always set (for compatibility with older Blenders). We mustn't link
- * the same pointcache twice. */
- direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, false);
- }
- else {
- /* link caches */
- direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false);
- }
- }
- ob->fluidsimSettings = newdataadr(fd, ob->fluidsimSettings); /* NT */
-
- ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
- if (ob->rigidbody_object) {
- RigidBodyOb *rbo = ob->rigidbody_object;
- /* Allocate runtime-only struct */
- rbo->shared = MEM_callocN(sizeof(*rbo->shared), "RigidBodyObShared");
- }
- ob->rigidbody_constraint = newdataadr(fd, ob->rigidbody_constraint);
- if (ob->rigidbody_constraint)
- ob->rigidbody_constraint->physics_constraint = NULL;
-
- link_list(fd, &ob->particlesystem);
- direct_link_particlesystems(fd, &ob->particlesystem);
-
- direct_link_constraints(fd, &ob->constraints);
-
- link_list(fd, &ob->hooks);
- while (ob->hooks.first) {
- ObHook *hook = ob->hooks.first;
- HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook);
-
- hook->indexar = newdataadr(fd, hook->indexar);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_int32_array(hook->indexar, hook->totindex);
- }
-
- /* Do conversion here because if we have loaded
- * a hook we need to make sure it gets converted
- * and freed, regardless of version.
- */
- copy_v3_v3(hmd->cent, hook->cent);
- hmd->falloff = hook->falloff;
- hmd->force = hook->force;
- hmd->indexar = hook->indexar;
- hmd->object = hook->parent;
- memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv));
- hmd->totindex = hook->totindex;
-
- BLI_addhead(&ob->modifiers, hmd);
- BLI_remlink(&ob->hooks, hook);
-
- modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
-
- MEM_freeN(hook);
- }
-
- ob->iuser = newdataadr(fd, ob->iuser);
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE && !ob->iuser) {
- BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
- }
-
- ob->derivedDeform = NULL;
- ob->derivedFinal = NULL;
- BKE_object_runtime_reset(ob);
- link_list(fd, &ob->pc_ids);
-
- /* in case this value changes in future, clamp else we get undefined behavior */
- CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
-
- if (ob->sculpt) {
- ob->sculpt = NULL;
- /* Only create data on undo, otherwise rely on editor mode switching. */
- if (fd->memfile && (ob->mode & OB_MODE_ALL_SCULPT)) {
- BKE_object_sculpt_data_create(ob);
- }
- }
-
- link_list(fd, &ob->lodlevels);
- ob->currentlod = ob->lodlevels.first;
-
- ob->preview = direct_link_preview_image(fd, ob->preview);
+ PartEff *paf;
+
+ /* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */
+ ob->proxy_from = NULL;
+
+ /* loading saved files with editmode enabled works, but for undo we like
+ * to stay in object mode during undo presses so keep editmode disabled.
+ *
+ * Also when linking in a file don't allow edit and pose modes.
+ * See [#34776, #42780] for more information.
+ */
+ if (fd->memfile || (ob->id.tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT))) {
+ ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
+ if (!fd->memfile) {
+ ob->mode &= ~OB_MODE_POSE;
+ }
+ }
+
+ ob->adt = newdataadr(fd, ob->adt);
+ direct_link_animdata(fd, ob->adt);
+
+ ob->pose = newdataadr(fd, ob->pose);
+ direct_link_pose(fd, ob->pose);
+
+ ob->mpath = newdataadr(fd, ob->mpath);
+ if (ob->mpath)
+ direct_link_motionpath(fd, ob->mpath);
+
+ link_list(fd, &ob->defbase);
+ link_list(fd, &ob->fmaps);
+ // XXX deprecated - old animation system <<<
+ direct_link_nlastrips(fd, &ob->nlastrips);
+ link_list(fd, &ob->constraintChannels);
+ // >>> XXX deprecated - old animation system
+
+ ob->mat = newdataadr(fd, ob->mat);
+ test_pointer_array(fd, (void **)&ob->mat);
+ ob->matbits = newdataadr(fd, ob->matbits);
+
+ /* do it here, below old data gets converted */
+ direct_link_modifiers(fd, &ob->modifiers);
+ direct_link_gpencil_modifiers(fd, &ob->greasepencil_modifiers);
+ direct_link_shaderfxs(fd, &ob->shader_fx);
+
+ link_list(fd, &ob->effect);
+ paf = ob->effect.first;
+ while (paf) {
+ if (paf->type == EFF_PARTICLE) {
+ paf->keys = NULL;
+ }
+ if (paf->type == EFF_WAVE) {
+ WaveEff *wav = (WaveEff *)paf;
+ PartEff *next = paf->next;
+ WaveModifierData *wmd = (WaveModifierData *)modifier_new(eModifierType_Wave);
+
+ wmd->damp = wav->damp;
+ wmd->flag = wav->flag;
+ wmd->height = wav->height;
+ wmd->lifetime = wav->lifetime;
+ wmd->narrow = wav->narrow;
+ wmd->speed = wav->speed;
+ wmd->startx = wav->startx;
+ wmd->starty = wav->startx;
+ wmd->timeoffs = wav->timeoffs;
+ wmd->width = wav->width;
+
+ BLI_addtail(&ob->modifiers, wmd);
+
+ BLI_remlink(&ob->effect, paf);
+ MEM_freeN(paf);
+
+ paf = next;
+ continue;
+ }
+ if (paf->type == EFF_BUILD) {
+ BuildEff *baf = (BuildEff *)paf;
+ PartEff *next = paf->next;
+ BuildModifierData *bmd = (BuildModifierData *)modifier_new(eModifierType_Build);
+
+ bmd->start = baf->sfra;
+ bmd->length = baf->len;
+ bmd->randomize = 0;
+ bmd->seed = 1;
+
+ BLI_addtail(&ob->modifiers, bmd);
+
+ BLI_remlink(&ob->effect, paf);
+ MEM_freeN(paf);
+
+ paf = next;
+ continue;
+ }
+ paf = paf->next;
+ }
+
+ ob->pd = newdataadr(fd, ob->pd);
+ direct_link_partdeflect(ob->pd);
+ ob->soft = newdataadr(fd, ob->soft);
+ if (ob->soft) {
+ SoftBody *sb = ob->soft;
+
+ sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
+ sb->bspring = NULL;
+ sb->scratch = NULL;
+ /* although not used anymore */
+ /* still have to be loaded to be compatible with old files */
+ sb->keys = newdataadr(fd, sb->keys);
+ test_pointer_array(fd, (void **)&sb->keys);
+ if (sb->keys) {
+ int a;
+ for (a = 0; a < sb->totkey; a++) {
+ sb->keys[a] = newdataadr(fd, sb->keys[a]);
+ }
+ }
+
+ sb->effector_weights = newdataadr(fd, sb->effector_weights);
+ if (!sb->effector_weights)
+ sb->effector_weights = BKE_effector_add_weights(NULL);
+
+ sb->shared = newdataadr(fd, sb->shared);
+ if (sb->shared == NULL) {
+ /* Link deprecated caches if they exist, so we can use them for versioning.
+ * We should only do this when sb->shared == NULL, because those pointers
+ * are always set (for compatibility with older Blenders). We mustn't link
+ * the same pointcache twice. */
+ direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, false);
+ }
+ else {
+ /* link caches */
+ direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false);
+ }
+ }
+ ob->fluidsimSettings = newdataadr(fd, ob->fluidsimSettings); /* NT */
+
+ ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
+ if (ob->rigidbody_object) {
+ RigidBodyOb *rbo = ob->rigidbody_object;
+ /* Allocate runtime-only struct */
+ rbo->shared = MEM_callocN(sizeof(*rbo->shared), "RigidBodyObShared");
+ }
+ ob->rigidbody_constraint = newdataadr(fd, ob->rigidbody_constraint);
+ if (ob->rigidbody_constraint)
+ ob->rigidbody_constraint->physics_constraint = NULL;
+
+ link_list(fd, &ob->particlesystem);
+ direct_link_particlesystems(fd, &ob->particlesystem);
+
+ direct_link_constraints(fd, &ob->constraints);
+
+ link_list(fd, &ob->hooks);
+ while (ob->hooks.first) {
+ ObHook *hook = ob->hooks.first;
+ HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook);
+
+ hook->indexar = newdataadr(fd, hook->indexar);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_int32_array(hook->indexar, hook->totindex);
+ }
+
+ /* Do conversion here because if we have loaded
+ * a hook we need to make sure it gets converted
+ * and freed, regardless of version.
+ */
+ copy_v3_v3(hmd->cent, hook->cent);
+ hmd->falloff = hook->falloff;
+ hmd->force = hook->force;
+ hmd->indexar = hook->indexar;
+ hmd->object = hook->parent;
+ memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv));
+ hmd->totindex = hook->totindex;
+
+ BLI_addhead(&ob->modifiers, hmd);
+ BLI_remlink(&ob->hooks, hook);
+
+ modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
+
+ MEM_freeN(hook);
+ }
+
+ ob->iuser = newdataadr(fd, ob->iuser);
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE && !ob->iuser) {
+ BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
+ }
+
+ ob->derivedDeform = NULL;
+ ob->derivedFinal = NULL;
+ BKE_object_runtime_reset(ob);
+ link_list(fd, &ob->pc_ids);
+
+ /* in case this value changes in future, clamp else we get undefined behavior */
+ CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
+
+ if (ob->sculpt) {
+ ob->sculpt = NULL;
+ /* Only create data on undo, otherwise rely on editor mode switching. */
+ if (fd->memfile && (ob->mode & OB_MODE_ALL_SCULPT)) {
+ BKE_object_sculpt_data_create(ob);
+ }
+ }
+
+ link_list(fd, &ob->lodlevels);
+ ob->currentlod = ob->lodlevels.first;
+
+ ob->preview = direct_link_preview_image(fd, ob->preview);
}
static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *view_settings)
{
- view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping);
+ view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping);
- if (view_settings->curve_mapping)
- direct_link_curvemapping(fd, view_settings->curve_mapping);
+ if (view_settings->curve_mapping)
+ direct_link_curvemapping(fd, view_settings->curve_mapping);
}
/** \} */
@@ -6068,92 +6126,94 @@ static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *vi
static void direct_link_layer_collections(FileData *fd, ListBase *lb, bool master)
{
- link_list(fd, lb);
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ link_list(fd, lb);
+ for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
#ifdef USE_COLLECTION_COMPAT_28
- lc->scene_collection = newdataadr(fd, lc->scene_collection);
+ lc->scene_collection = newdataadr(fd, lc->scene_collection);
#endif
- /* Master collection is not a real datablock. */
- if (master) {
- lc->collection = newdataadr(fd, lc->collection);
- }
+ /* Master collection is not a real datablock. */
+ if (master) {
+ lc->collection = newdataadr(fd, lc->collection);
+ }
- direct_link_layer_collections(fd, &lc->layer_collections, false);
- }
+ direct_link_layer_collections(fd, &lc->layer_collections, false);
+ }
}
static void direct_link_view_layer(FileData *fd, ViewLayer *view_layer)
{
- view_layer->stats = NULL;
- link_list(fd, &view_layer->object_bases);
- view_layer->basact = newdataadr(fd, view_layer->basact);
+ view_layer->stats = NULL;
+ link_list(fd, &view_layer->object_bases);
+ view_layer->basact = newdataadr(fd, view_layer->basact);
- direct_link_layer_collections(fd, &view_layer->layer_collections, true);
- view_layer->active_collection = newdataadr(fd, view_layer->active_collection);
+ direct_link_layer_collections(fd, &view_layer->layer_collections, true);
+ view_layer->active_collection = newdataadr(fd, view_layer->active_collection);
- view_layer->id_properties = newdataadr(fd, view_layer->id_properties);
- IDP_DirectLinkGroup_OrFree(&view_layer->id_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ view_layer->id_properties = newdataadr(fd, view_layer->id_properties);
+ IDP_DirectLinkGroup_OrFree(&view_layer->id_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- link_list(fd, &(view_layer->freestyle_config.modules));
- link_list(fd, &(view_layer->freestyle_config.linesets));
+ link_list(fd, &(view_layer->freestyle_config.modules));
+ link_list(fd, &(view_layer->freestyle_config.linesets));
- BLI_listbase_clear(&view_layer->drawdata);
- view_layer->object_bases_array = NULL;
- view_layer->object_bases_hash = NULL;
+ BLI_listbase_clear(&view_layer->drawdata);
+ view_layer->object_bases_array = NULL;
+ view_layer->object_bases_hash = NULL;
}
-static void lib_link_layer_collection(FileData *fd, Library *lib, LayerCollection *layer_collection, bool master)
+static void lib_link_layer_collection(FileData *fd,
+ Library *lib,
+ LayerCollection *layer_collection,
+ bool master)
{
- /* Master collection is not a real datablock. */
- if (!master) {
- layer_collection->collection = newlibadr(fd, lib, layer_collection->collection);
- }
+ /* Master collection is not a real datablock. */
+ if (!master) {
+ layer_collection->collection = newlibadr(fd, lib, layer_collection->collection);
+ }
- for (LayerCollection *layer_collection_nested = layer_collection->layer_collections.first;
- layer_collection_nested != NULL;
- layer_collection_nested = layer_collection_nested->next)
- {
- lib_link_layer_collection(fd, lib, layer_collection_nested, false);
- }
+ for (LayerCollection *layer_collection_nested = layer_collection->layer_collections.first;
+ layer_collection_nested != NULL;
+ layer_collection_nested = layer_collection_nested->next) {
+ lib_link_layer_collection(fd, lib, layer_collection_nested, false);
+ }
}
static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer)
{
- for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; fmc = fmc->next) {
- fmc->script = newlibadr(fd, lib, fmc->script);
- }
+ for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc;
+ fmc = fmc->next) {
+ fmc->script = newlibadr(fd, lib, fmc->script);
+ }
- for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
- fls->linestyle = newlibadr_us(fd, lib, fls->linestyle);
- fls->group = newlibadr_us(fd, lib, fls->group);
- }
+ for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
+ fls->linestyle = newlibadr_us(fd, lib, fls->linestyle);
+ fls->group = newlibadr_us(fd, lib, fls->group);
+ }
- for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) {
- base_next = base->next;
+ for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) {
+ base_next = base->next;
- /* we only bump the use count for the collection objects */
- base->object = newlibadr(fd, lib, base->object);
+ /* we only bump the use count for the collection objects */
+ base->object = newlibadr(fd, lib, base->object);
- if (base->object == NULL) {
- /* Free in case linked object got lost. */
- BLI_freelinkN(&view_layer->object_bases, base);
- if (view_layer->basact == base) {
- view_layer->basact = NULL;
- }
- }
- }
+ if (base->object == NULL) {
+ /* Free in case linked object got lost. */
+ BLI_freelinkN(&view_layer->object_bases, base);
+ if (view_layer->basact == base) {
+ view_layer->basact = NULL;
+ }
+ }
+ }
- for (LayerCollection *layer_collection = view_layer->layer_collections.first;
- layer_collection != NULL;
- layer_collection = layer_collection->next)
- {
- lib_link_layer_collection(fd, lib, layer_collection, true);
- }
+ for (LayerCollection *layer_collection = view_layer->layer_collections.first;
+ layer_collection != NULL;
+ layer_collection = layer_collection->next) {
+ lib_link_layer_collection(fd, lib, layer_collection, true);
+ }
- view_layer->mat_override = newlibadr_us(fd, lib, view_layer->mat_override);
+ view_layer->mat_override = newlibadr_us(fd, lib, view_layer->mat_override);
- IDP_LibLinkProperty(view_layer->id_properties, fd);
+ IDP_LibLinkProperty(view_layer->id_properties, fd);
}
/** \} */
@@ -6165,100 +6225,100 @@ static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_laye
#ifdef USE_COLLECTION_COMPAT_28
static void direct_link_scene_collection(FileData *fd, SceneCollection *sc)
{
- link_list(fd, &sc->objects);
- link_list(fd, &sc->scene_collections);
+ link_list(fd, &sc->objects);
+ link_list(fd, &sc->scene_collections);
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
- direct_link_scene_collection(fd, nsc);
- }
+ for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ direct_link_scene_collection(fd, nsc);
+ }
}
static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc)
{
- for (LinkData *link = sc->objects.first; link; link = link->next) {
- link->data = newlibadr_us(fd, lib, link->data);
- BLI_assert(link->data);
- }
+ for (LinkData *link = sc->objects.first; link; link = link->next) {
+ link->data = newlibadr_us(fd, lib, link->data);
+ BLI_assert(link->data);
+ }
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
- lib_link_scene_collection(fd, lib, nsc);
- }
+ for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ lib_link_scene_collection(fd, lib, nsc);
+ }
}
#endif
static void direct_link_collection(FileData *fd, Collection *collection)
{
- link_list(fd, &collection->gobject);
- link_list(fd, &collection->children);
+ link_list(fd, &collection->gobject);
+ link_list(fd, &collection->children);
- collection->preview = direct_link_preview_image(fd, collection->preview);
+ collection->preview = direct_link_preview_image(fd, collection->preview);
- collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
- BLI_listbase_clear(&collection->object_cache);
- BLI_listbase_clear(&collection->parents);
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ BLI_listbase_clear(&collection->object_cache);
+ BLI_listbase_clear(&collection->parents);
#ifdef USE_COLLECTION_COMPAT_28
- /* This runs before the very first doversion. */
- collection->collection = newdataadr(fd, collection->collection);
- if (collection->collection != NULL) {
- direct_link_scene_collection(fd, collection->collection);
- }
-
- collection->view_layer = newdataadr(fd, collection->view_layer);
- if (collection->view_layer != NULL) {
- direct_link_view_layer(fd, collection->view_layer);
- }
+ /* This runs before the very first doversion. */
+ collection->collection = newdataadr(fd, collection->collection);
+ if (collection->collection != NULL) {
+ direct_link_scene_collection(fd, collection->collection);
+ }
+
+ collection->view_layer = newdataadr(fd, collection->view_layer);
+ if (collection->view_layer != NULL) {
+ direct_link_view_layer(fd, collection->view_layer);
+ }
#endif
}
static void lib_link_collection_data(FileData *fd, Library *lib, Collection *collection)
{
- for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
- cob_next = cob->next;
- cob->ob = newlibadr_us(fd, lib, cob->ob);
+ for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
+ cob_next = cob->next;
+ cob->ob = newlibadr_us(fd, lib, cob->ob);
- if (cob->ob == NULL) {
- BLI_freelinkN(&collection->gobject, cob);
- }
- }
+ if (cob->ob == NULL) {
+ BLI_freelinkN(&collection->gobject, cob);
+ }
+ }
- for (CollectionChild *child = collection->children.first, *child_next = NULL; child; child = child_next) {
- child_next = child->next;
- child->collection = newlibadr_us(fd, lib, child->collection);
+ for (CollectionChild *child = collection->children.first, *child_next = NULL; child;
+ child = child_next) {
+ child_next = child->next;
+ child->collection = newlibadr_us(fd, lib, child->collection);
- if (child->collection == NULL ||
- BKE_collection_find_cycle(collection, child->collection))
- {
- BLI_freelinkN(&collection->children, child);
- }
- else {
- CollectionParent *cparent = MEM_callocN(sizeof(CollectionParent), "CollectionParent");
- cparent->collection = collection;
- BLI_addtail(&child->collection->parents, cparent);
- }
- }
+ if (child->collection == NULL || BKE_collection_find_cycle(collection, child->collection)) {
+ BLI_freelinkN(&collection->children, child);
+ }
+ else {
+ CollectionParent *cparent = MEM_callocN(sizeof(CollectionParent), "CollectionParent");
+ cparent->collection = collection;
+ BLI_addtail(&child->collection->parents, cparent);
+ }
+ }
}
static void lib_link_collection(FileData *fd, Main *main)
{
- for (Collection *collection = main->collections.first; collection; collection = collection->id.next) {
- if (collection->id.tag & LIB_TAG_NEED_LINK) {
- collection->id.tag &= ~LIB_TAG_NEED_LINK;
- IDP_LibLinkProperty(collection->id.properties, fd);
+ for (Collection *collection = main->collections.first; collection;
+ collection = collection->id.next) {
+ if (collection->id.tag & LIB_TAG_NEED_LINK) {
+ collection->id.tag &= ~LIB_TAG_NEED_LINK;
+ IDP_LibLinkProperty(collection->id.properties, fd);
#ifdef USE_COLLECTION_COMPAT_28
- if (collection->collection) {
- lib_link_scene_collection(fd, collection->id.lib, collection->collection);
- }
+ if (collection->collection) {
+ lib_link_scene_collection(fd, collection->id.lib, collection->collection);
+ }
- if (collection->view_layer) {
- lib_link_view_layer(fd, collection->id.lib, collection->view_layer);
- }
+ if (collection->view_layer) {
+ lib_link_view_layer(fd, collection->id.lib, collection->view_layer);
+ }
#endif
- lib_link_collection_data(fd, collection->id.lib, collection);
- }
- }
+ lib_link_collection_data(fd, collection->id.lib, collection);
+ }
+ }
}
/** \} */
@@ -6270,73 +6330,74 @@ static void lib_link_collection(FileData *fd, Main *main)
/* patch for missing scene IDs, can't be in do-versions */
static void composite_patch(bNodeTree *ntree, Scene *scene)
{
- bNode *node;
+ bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id == NULL && node->type == CMP_NODE_R_LAYERS)
- node->id = &scene->id;
- }
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->id == NULL && node->type == CMP_NODE_R_LAYERS)
+ node->id = &scene->id;
+ }
}
static void link_paint(FileData *fd, Scene *sce, Paint *p)
{
- if (p) {
- p->brush = newlibadr_us(fd, sce->id.lib, p->brush);
- for (int i = 0; i < p->tool_slots_len; i++) {
- if (p->tool_slots[i].brush != NULL) {
- p->tool_slots[i].brush = newlibadr_us(fd, sce->id.lib, p->tool_slots[i].brush);
- }
- }
- p->palette = newlibadr_us(fd, sce->id.lib, p->palette);
- p->paint_cursor = NULL;
+ if (p) {
+ p->brush = newlibadr_us(fd, sce->id.lib, p->brush);
+ for (int i = 0; i < p->tool_slots_len; i++) {
+ if (p->tool_slots[i].brush != NULL) {
+ p->tool_slots[i].brush = newlibadr_us(fd, sce->id.lib, p->tool_slots[i].brush);
+ }
+ }
+ p->palette = newlibadr_us(fd, sce->id.lib, p->palette);
+ p->paint_cursor = NULL;
- BKE_paint_runtime_init(sce->toolsettings, p);
- }
+ BKE_paint_runtime_init(sce->toolsettings, p);
+ }
}
static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb)
{
- SequenceModifierData *smd;
+ SequenceModifierData *smd;
- for (smd = lb->first; smd; smd = smd->next) {
- if (smd->mask_id)
- smd->mask_id = newlibadr_us(fd, scene->id.lib, smd->mask_id);
- }
+ for (smd = lb->first; smd; smd = smd->next) {
+ if (smd->mask_id)
+ smd->mask_id = newlibadr_us(fd, scene->id.lib, smd->mask_id);
+ }
}
static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lctex)
{
- lctex->tex = NULL;
+ lctex->tex = NULL;
- if (lctex->data) {
- lctex->data = newdataadr(fd, lctex->data);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] * lctex->tex_size[2];
+ if (lctex->data) {
+ lctex->data = newdataadr(fd, lctex->data);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] *
+ lctex->tex_size[2];
- if (lctex->data_type == LIGHTCACHETEX_FLOAT) {
- BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
- }
- else if (lctex->data_type == LIGHTCACHETEX_UINT) {
- BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint));
- }
- }
- }
+ if (lctex->data_type == LIGHTCACHETEX_FLOAT) {
+ BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
+ }
+ else if (lctex->data_type == LIGHTCACHETEX_UINT) {
+ BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint));
+ }
+ }
+ }
}
static void direct_link_lightcache(FileData *fd, LightCache *cache)
{
- direct_link_lightcache_texture(fd, &cache->cube_tx);
- direct_link_lightcache_texture(fd, &cache->grid_tx);
+ direct_link_lightcache_texture(fd, &cache->cube_tx);
+ direct_link_lightcache_texture(fd, &cache->grid_tx);
- if (cache->cube_mips) {
- cache->cube_mips = newdataadr(fd, cache->cube_mips);
- for (int i = 0; i < cache->mips_len; ++i) {
- direct_link_lightcache_texture(fd, &cache->cube_mips[i]);
- }
- }
+ if (cache->cube_mips) {
+ cache->cube_mips = newdataadr(fd, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; ++i) {
+ direct_link_lightcache_texture(fd, &cache->cube_mips[i]);
+ }
+ }
- cache->cube_data = newdataadr(fd, cache->cube_data);
- cache->grid_data = newdataadr(fd, cache->grid_data);
+ cache->cube_data = newdataadr(fd, cache->cube_data);
+ cache->grid_data = newdataadr(fd, cache->grid_data);
}
/* check for cyclic set-scene,
@@ -6349,584 +6410,603 @@ static void direct_link_lightcache(FileData *fd, LightCache *cache)
*/
static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
{
- Scene *sce_iter;
- int a;
+ Scene *sce_iter;
+ int a;
- if (sce->set == NULL) return 1;
+ if (sce->set == NULL)
+ return 1;
- for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
- if (sce_iter->id.tag & LIB_TAG_NEED_LINK) {
- return 1;
- }
+ for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
+ if (sce_iter->id.tag & LIB_TAG_NEED_LINK) {
+ return 1;
+ }
- if (a > totscene) {
- sce->set = NULL;
- return 0;
- }
- }
+ if (a > totscene) {
+ sce->set = NULL;
+ return 0;
+ }
+ }
- return 1;
+ return 1;
}
#endif
static void lib_link_scene(FileData *fd, Main *main)
{
#ifdef USE_SETSCENE_CHECK
- bool need_check_set = false;
- int totscene = 0;
+ bool need_check_set = false;
+ int totscene = 0;
#endif
- for (Scene *sce = main->scenes.first; sce; sce = sce->id.next) {
- if (sce->id.tag & LIB_TAG_NEED_LINK) {
- /* Link ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_LibLinkProperty(sce->id.properties, fd);
- lib_link_animdata(fd, &sce->id, sce->adt);
-
- lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
-
- sce->camera = newlibadr(fd, sce->id.lib, sce->camera);
- sce->world = newlibadr_us(fd, sce->id.lib, sce->world);
- sce->set = newlibadr(fd, sce->id.lib, sce->set);
- sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd);
-
- link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
- link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
- link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
- link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
- link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
- link_paint(fd, sce, &sce->toolsettings->gp_paint->paint);
-
- if (sce->toolsettings->sculpt)
- sce->toolsettings->sculpt->gravity_object =
- newlibadr(fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
-
- if (sce->toolsettings->imapaint.stencil)
- sce->toolsettings->imapaint.stencil =
- newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.stencil);
-
- if (sce->toolsettings->imapaint.clone)
- sce->toolsettings->imapaint.clone =
- newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.clone);
-
- if (sce->toolsettings->imapaint.canvas)
- sce->toolsettings->imapaint.canvas =
- newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
-
- sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object);
-
- sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr(fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object);
-
- for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) {
- base_legacy_next = base_legacy->next;
-
- base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object);
-
- if (base_legacy->object == NULL) {
- blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"),
- sce->id.name + 2);
- BLI_remlink(&sce->base, base_legacy);
- if (base_legacy == sce->basact) sce->basact = NULL;
- MEM_freeN(base_legacy);
- }
- }
-
- Sequence *seq;
- SEQ_BEGIN (sce->ed, seq)
- {
- IDP_LibLinkProperty(seq->prop, fd);
-
- if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system
- seq->scene_sound = NULL;
- if (seq->scene) {
- seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
- if (seq->scene) {
- seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(sce, seq);
- }
- }
- if (seq->clip) {
- seq->clip = newlibadr_us(fd, sce->id.lib, seq->clip);
- }
- if (seq->mask) {
- seq->mask = newlibadr_us(fd, sce->id.lib, seq->mask);
- }
- if (seq->scene_camera) {
- seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera);
- }
- if (seq->sound) {
- seq->scene_sound = NULL;
- if (seq->type == SEQ_TYPE_SOUND_HD) {
- seq->type = SEQ_TYPE_SOUND_RAM;
- }
- else {
- seq->sound = newlibadr(fd, sce->id.lib, seq->sound);
- }
- if (seq->sound) {
- id_us_plus_no_lib((ID *)seq->sound);
- seq->scene_sound = BKE_sound_add_scene_sound_defaults(sce, seq);
- }
- }
- if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *t = seq->effectdata;
- t->text_font = newlibadr_us(fd, sce->id.lib, t->text_font);
- }
- BLI_listbase_clear(&seq->anims);
-
- lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
- } SEQ_END;
-
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
- if (marker->camera) {
- marker->camera = newlibadr(fd, sce->id.lib, marker->camera);
- }
- }
-
- BKE_sequencer_update_muting(sce->ed);
- BKE_sequencer_update_sound_bounds_all(sce);
-
-
- /* rigidbody world relies on it's linked collections */
- if (sce->rigidbody_world) {
- RigidBodyWorld *rbw = sce->rigidbody_world;
- if (rbw->group)
- rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
- if (rbw->constraints)
- rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints);
- if (rbw->effector_weights)
- rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group);
- }
-
- if (sce->nodetree) {
- lib_link_ntree(fd, &sce->id, sce->nodetree);
- sce->nodetree->id.lib = sce->id.lib;
- composite_patch(sce->nodetree, sce);
- }
-
- for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) {
- srl->mat_override = newlibadr_us(fd, sce->id.lib, srl->mat_override);
- for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
- fmc->script = newlibadr(fd, sce->id.lib, fmc->script);
- }
- for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
- fls->linestyle = newlibadr_us(fd, sce->id.lib, fls->linestyle);
- fls->group = newlibadr_us(fd, sce->id.lib, fls->group);
- }
- }
- /* Motion Tracking */
- sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip);
+ for (Scene *sce = main->scenes.first; sce; sce = sce->id.next) {
+ if (sce->id.tag & LIB_TAG_NEED_LINK) {
+ /* Link ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_LibLinkProperty(sce->id.properties, fd);
+ lib_link_animdata(fd, &sce->id, sce->adt);
+
+ lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
+
+ sce->camera = newlibadr(fd, sce->id.lib, sce->camera);
+ sce->world = newlibadr_us(fd, sce->id.lib, sce->world);
+ sce->set = newlibadr(fd, sce->id.lib, sce->set);
+ sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd);
+
+ link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
+ link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
+ link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
+ link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
+ link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
+ link_paint(fd, sce, &sce->toolsettings->gp_paint->paint);
+
+ if (sce->toolsettings->sculpt)
+ sce->toolsettings->sculpt->gravity_object = newlibadr(
+ fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
+
+ if (sce->toolsettings->imapaint.stencil)
+ sce->toolsettings->imapaint.stencil = newlibadr_us(
+ fd, sce->id.lib, sce->toolsettings->imapaint.stencil);
+
+ if (sce->toolsettings->imapaint.clone)
+ sce->toolsettings->imapaint.clone = newlibadr_us(
+ fd, sce->id.lib, sce->toolsettings->imapaint.clone);
+
+ if (sce->toolsettings->imapaint.canvas)
+ sce->toolsettings->imapaint.canvas = newlibadr_us(
+ fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
+
+ sce->toolsettings->particle.shape_object = newlibadr(
+ fd, sce->id.lib, sce->toolsettings->particle.shape_object);
+
+ sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr(
+ fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object);
+
+ for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy;
+ base_legacy = base_legacy_next) {
+ base_legacy_next = base_legacy->next;
+
+ base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object);
+
+ if (base_legacy->object == NULL) {
+ blo_reportf_wrap(fd->reports,
+ RPT_WARNING,
+ TIP_("LIB: object lost from scene: '%s'"),
+ sce->id.name + 2);
+ BLI_remlink(&sce->base, base_legacy);
+ if (base_legacy == sce->basact)
+ sce->basact = NULL;
+ MEM_freeN(base_legacy);
+ }
+ }
+
+ Sequence *seq;
+ SEQ_BEGIN (sce->ed, seq) {
+ IDP_LibLinkProperty(seq->prop, fd);
+
+ if (seq->ipo)
+ seq->ipo = newlibadr_us(
+ fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system
+ seq->scene_sound = NULL;
+ if (seq->scene) {
+ seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
+ if (seq->scene) {
+ seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(sce, seq);
+ }
+ }
+ if (seq->clip) {
+ seq->clip = newlibadr_us(fd, sce->id.lib, seq->clip);
+ }
+ if (seq->mask) {
+ seq->mask = newlibadr_us(fd, sce->id.lib, seq->mask);
+ }
+ if (seq->scene_camera) {
+ seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera);
+ }
+ if (seq->sound) {
+ seq->scene_sound = NULL;
+ if (seq->type == SEQ_TYPE_SOUND_HD) {
+ seq->type = SEQ_TYPE_SOUND_RAM;
+ }
+ else {
+ seq->sound = newlibadr(fd, sce->id.lib, seq->sound);
+ }
+ if (seq->sound) {
+ id_us_plus_no_lib((ID *)seq->sound);
+ seq->scene_sound = BKE_sound_add_scene_sound_defaults(sce, seq);
+ }
+ }
+ if (seq->type == SEQ_TYPE_TEXT) {
+ TextVars *t = seq->effectdata;
+ t->text_font = newlibadr_us(fd, sce->id.lib, t->text_font);
+ }
+ BLI_listbase_clear(&seq->anims);
+
+ lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
+ }
+ SEQ_END;
+
+ for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ if (marker->camera) {
+ marker->camera = newlibadr(fd, sce->id.lib, marker->camera);
+ }
+ }
+
+ BKE_sequencer_update_muting(sce->ed);
+ BKE_sequencer_update_sound_bounds_all(sce);
+
+ /* rigidbody world relies on it's linked collections */
+ if (sce->rigidbody_world) {
+ RigidBodyWorld *rbw = sce->rigidbody_world;
+ if (rbw->group)
+ rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
+ if (rbw->constraints)
+ rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints);
+ if (rbw->effector_weights)
+ rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group);
+ }
+
+ if (sce->nodetree) {
+ lib_link_ntree(fd, &sce->id, sce->nodetree);
+ sce->nodetree->id.lib = sce->id.lib;
+ composite_patch(sce->nodetree, sce);
+ }
+
+ for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) {
+ srl->mat_override = newlibadr_us(fd, sce->id.lib, srl->mat_override);
+ for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc;
+ fmc = fmc->next) {
+ fmc->script = newlibadr(fd, sce->id.lib, fmc->script);
+ }
+ for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
+ fls->linestyle = newlibadr_us(fd, sce->id.lib, fls->linestyle);
+ fls->group = newlibadr_us(fd, sce->id.lib, fls->group);
+ }
+ }
+ /* Motion Tracking */
+ sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip);
#ifdef USE_COLLECTION_COMPAT_28
- if (sce->collection) {
- lib_link_scene_collection(fd, sce->id.lib, sce->collection);
- }
+ if (sce->collection) {
+ lib_link_scene_collection(fd, sce->id.lib, sce->collection);
+ }
#endif
- if (sce->master_collection) {
- lib_link_collection_data(fd, sce->id.lib, sce->master_collection);
- }
+ if (sce->master_collection) {
+ lib_link_collection_data(fd, sce->id.lib, sce->master_collection);
+ }
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- lib_link_view_layer(fd, sce->id.lib, view_layer);
- }
+ for (ViewLayer *view_layer = sce->view_layers.first; view_layer;
+ view_layer = view_layer->next) {
+ lib_link_view_layer(fd, sce->id.lib, view_layer);
+ }
- if (sce->r.bake.cage_object) {
- sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object);
- }
+ if (sce->r.bake.cage_object) {
+ sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object);
+ }
#ifdef USE_SETSCENE_CHECK
- if (sce->set != NULL) {
- /* link flag for scenes with set would be reset later,
- * so this way we only check cyclic for newly linked scenes.
- */
- need_check_set = true;
- }
- else {
- /* postpone un-setting the flag until we've checked the set-scene */
- sce->id.tag &= ~LIB_TAG_NEED_LINK;
- }
+ if (sce->set != NULL) {
+ /* link flag for scenes with set would be reset later,
+ * so this way we only check cyclic for newly linked scenes.
+ */
+ need_check_set = true;
+ }
+ else {
+ /* postpone un-setting the flag until we've checked the set-scene */
+ sce->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
#else
- sce->id.tag &= ~LIB_TAG_NEED_LINK;
+ sce->id.tag &= ~LIB_TAG_NEED_LINK;
#endif
- }
+ }
#ifdef USE_SETSCENE_CHECK
- totscene++;
+ totscene++;
#endif
- }
+ }
#ifdef USE_SETSCENE_CHECK
- if (need_check_set) {
- for (Scene *sce = main->scenes.first; sce; sce = sce->id.next) {
- if (sce->id.tag & LIB_TAG_NEED_LINK) {
- sce->id.tag &= ~LIB_TAG_NEED_LINK;
- if (!scene_validate_setscene__liblink(sce, totscene)) {
- printf("Found cyclic background scene when linking %s\n", sce->id.name + 2);
- }
- }
- }
- }
+ if (need_check_set) {
+ for (Scene *sce = main->scenes.first; sce; sce = sce->id.next) {
+ if (sce->id.tag & LIB_TAG_NEED_LINK) {
+ sce->id.tag &= ~LIB_TAG_NEED_LINK;
+ if (!scene_validate_setscene__liblink(sce, totscene)) {
+ printf("Found cyclic background scene when linking %s\n", sce->id.name + 2);
+ }
+ }
+ }
+ }
#endif
}
#undef USE_SETSCENE_CHECK
-
static void link_recurs_seq(FileData *fd, ListBase *lb)
{
- Sequence *seq;
+ Sequence *seq;
- link_list(fd, lb);
+ link_list(fd, lb);
- for (seq = lb->first; seq; seq = seq->next) {
- if (seq->seqbase.first)
- link_recurs_seq(fd, &seq->seqbase);
- }
+ for (seq = lb->first; seq; seq = seq->next) {
+ if (seq->seqbase.first)
+ link_recurs_seq(fd, &seq->seqbase);
+ }
}
static void direct_link_paint(FileData *fd, const Scene *scene, Paint *p)
{
- if (p->num_input_samples < 1)
- p->num_input_samples = 1;
+ if (p->num_input_samples < 1)
+ p->num_input_samples = 1;
- p->cavity_curve = newdataadr(fd, p->cavity_curve);
- if (p->cavity_curve)
- direct_link_curvemapping(fd, p->cavity_curve);
- else
- BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
+ p->cavity_curve = newdataadr(fd, p->cavity_curve);
+ if (p->cavity_curve)
+ direct_link_curvemapping(fd, p->cavity_curve);
+ else
+ BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
- p->tool_slots = newdataadr(fd, p->tool_slots);
+ p->tool_slots = newdataadr(fd, p->tool_slots);
- BKE_paint_runtime_init(scene->toolsettings, p);
+ BKE_paint_runtime_init(scene->toolsettings, p);
}
static void direct_link_paint_helper(FileData *fd, const Scene *scene, Paint **paint)
{
- /* TODO. is this needed */
- (*paint) = newdataadr(fd, (*paint));
+ /* TODO. is this needed */
+ (*paint) = newdataadr(fd, (*paint));
- if (*paint) {
- direct_link_paint(fd, scene, *paint);
- }
+ if (*paint) {
+ direct_link_paint(fd, scene, *paint);
+ }
}
static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
{
- SequenceModifierData *smd;
+ SequenceModifierData *smd;
- link_list(fd, lb);
+ link_list(fd, lb);
- for (smd = lb->first; smd; smd = smd->next) {
- if (smd->mask_sequence)
- smd->mask_sequence = newdataadr(fd, smd->mask_sequence);
+ for (smd = lb->first; smd; smd = smd->next) {
+ if (smd->mask_sequence)
+ smd->mask_sequence = newdataadr(fd, smd->mask_sequence);
- if (smd->type == seqModifierType_Curves) {
- CurvesModifierData *cmd = (CurvesModifierData *)smd;
+ if (smd->type == seqModifierType_Curves) {
+ CurvesModifierData *cmd = (CurvesModifierData *)smd;
- direct_link_curvemapping(fd, &cmd->curve_mapping);
- }
- else if (smd->type == seqModifierType_HueCorrect) {
- HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
+ direct_link_curvemapping(fd, &cmd->curve_mapping);
+ }
+ else if (smd->type == seqModifierType_HueCorrect) {
+ HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
- direct_link_curvemapping(fd, &hcmd->curve_mapping);
- }
- }
+ direct_link_curvemapping(fd, &hcmd->curve_mapping);
+ }
+ }
}
static void direct_link_scene(FileData *fd, Scene *sce)
{
- Editing *ed;
- Sequence *seq;
- MetaStack *ms;
- RigidBodyWorld *rbw;
- ViewLayer *view_layer;
- SceneRenderLayer *srl;
-
- sce->depsgraph_hash = NULL;
- sce->fps_info = NULL;
-
- memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
- memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
-
- BKE_sound_create_scene(sce);
-
- /* set users to one by default, not in lib-link, this will increase it for compo nodes */
- id_us_ensure_real(&sce->id);
-
- link_list(fd, &(sce->base));
-
- sce->adt = newdataadr(fd, sce->adt);
- direct_link_animdata(fd, sce->adt);
-
- link_list(fd, &sce->keyingsets);
- direct_link_keyingsets(fd, &sce->keyingsets);
-
- sce->basact = newdataadr(fd, sce->basact);
-
- sce->toolsettings = newdataadr(fd, sce->toolsettings);
- if (sce->toolsettings) {
- direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->sculpt);
- direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->vpaint);
- direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->wpaint);
- direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->uvsculpt);
- direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->gp_paint);
-
- direct_link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
-
- sce->toolsettings->imapaint.paintcursor = NULL;
- sce->toolsettings->particle.paintcursor = NULL;
- sce->toolsettings->particle.scene = NULL;
- sce->toolsettings->particle.object = NULL;
- sce->toolsettings->gp_sculpt.paintcursor = NULL;
-
- /* relink grease pencil interpolation curves */
- sce->toolsettings->gp_interpolate.custom_ipo = newdataadr(fd, sce->toolsettings->gp_interpolate.custom_ipo);
- if (sce->toolsettings->gp_interpolate.custom_ipo) {
- direct_link_curvemapping(fd, sce->toolsettings->gp_interpolate.custom_ipo);
- }
- /* relink grease pencil multiframe falloff curve */
- sce->toolsettings->gp_sculpt.cur_falloff = newdataadr(fd, sce->toolsettings->gp_sculpt.cur_falloff);
- if (sce->toolsettings->gp_sculpt.cur_falloff) {
- direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_falloff);
- }
- /* relink grease pencil primitive curve */
- sce->toolsettings->gp_sculpt.cur_primitive = newdataadr(fd, sce->toolsettings->gp_sculpt.cur_primitive);
- if (sce->toolsettings->gp_sculpt.cur_primitive) {
- direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_primitive);
- }
- }
-
- if (sce->ed) {
- ListBase *old_seqbasep = &sce->ed->seqbase;
-
- ed = sce->ed = newdataadr(fd, sce->ed);
-
- ed->act_seq = newdataadr(fd, ed->act_seq);
-
- /* recursive link sequences, lb will be correctly initialized */
- link_recurs_seq(fd, &ed->seqbase);
-
- SEQ_BEGIN(ed, seq)
- {
- seq->seq1 = newdataadr(fd, seq->seq1);
- seq->seq2 = newdataadr(fd, seq->seq2);
- seq->seq3 = newdataadr(fd, seq->seq3);
-
- /* a patch: after introduction of effects with 3 input strips */
- if (seq->seq3 == NULL) seq->seq3 = seq->seq2;
-
- seq->effectdata = newdataadr(fd, seq->effectdata);
- seq->stereo3d_format = newdataadr(fd, seq->stereo3d_format);
-
- if (seq->type & SEQ_TYPE_EFFECT)
- seq->flag |= SEQ_EFFECT_NOT_LOADED;
-
- if (seq->type == SEQ_TYPE_SPEED) {
- SpeedControlVars *s = seq->effectdata;
- s->frameMap = NULL;
- }
-
- if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *t = seq->effectdata;
- t->text_blf_id = SEQ_FONT_NOT_LOADED;
- }
-
- seq->prop = newdataadr(fd, seq->prop);
- IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-
- seq->strip = newdataadr(fd, seq->strip);
- if (seq->strip && seq->strip->done == 0) {
- seq->strip->done = true;
-
- if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- seq->strip->stripdata = newdataadr(fd, seq->strip->stripdata);
- }
- else {
- seq->strip->stripdata = NULL;
- }
- if (seq->flag & SEQ_USE_CROP) {
- seq->strip->crop = newdataadr(fd, seq->strip->crop);
- }
- else {
- seq->strip->crop = NULL;
- }
- if (seq->flag & SEQ_USE_TRANSFORM) {
- seq->strip->transform = newdataadr(fd, seq->strip->transform);
- }
- else {
- seq->strip->transform = NULL;
- }
- if (seq->flag & SEQ_USE_PROXY) {
- seq->strip->proxy = newdataadr(fd, seq->strip->proxy);
- if (seq->strip->proxy) {
- seq->strip->proxy->anim = NULL;
- }
- else {
- BKE_sequencer_proxy_set(seq, true);
- }
- }
- else {
- seq->strip->proxy = NULL;
- }
-
- /* need to load color balance to it could be converted to modifier */
- seq->strip->color_balance = newdataadr(fd, seq->strip->color_balance);
- }
-
- direct_link_sequence_modifiers(fd, &seq->modifiers);
- } SEQ_END;
-
- /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
- {
- Sequence temp;
- void *poin;
- intptr_t offset;
-
- offset = ((intptr_t)&(temp.seqbase)) - ((intptr_t)&temp);
-
- /* root pointer */
- if (ed->seqbasep == old_seqbasep) {
- ed->seqbasep = &ed->seqbase;
- }
- else {
- poin = POINTER_OFFSET(ed->seqbasep, -offset);
-
- poin = newdataadr(fd, poin);
- if (poin)
- ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- else
- ed->seqbasep = &ed->seqbase;
- }
- /* stack */
- link_list(fd, &(ed->metastack));
-
- for (ms = ed->metastack.first; ms; ms = ms->next) {
- ms->parseq = newdataadr(fd, ms->parseq);
-
- if (ms->oldbasep == old_seqbasep)
- ms->oldbasep = &ed->seqbase;
- else {
- poin = POINTER_OFFSET(ms->oldbasep, -offset);
- poin = newdataadr(fd, poin);
- if (poin)
- ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- else
- ms->oldbasep = &ed->seqbase;
- }
- }
- }
- }
-
- sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
- if (sce->r.avicodecdata) {
- sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
- sce->r.avicodecdata->lpParms = newdataadr(fd, sce->r.avicodecdata->lpParms);
- }
- if (sce->r.ffcodecdata.properties) {
- sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
- IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
-
- link_list(fd, &(sce->markers));
- link_list(fd, &(sce->transform_spaces));
- link_list(fd, &(sce->r.layers));
- link_list(fd, &(sce->r.views));
-
-
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
- srl->prop = newdataadr(fd, srl->prop);
- IDP_DirectLinkGroup_OrFree(&srl->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- link_list(fd, &(srl->freestyleConfig.modules));
- link_list(fd, &(srl->freestyleConfig.linesets));
- }
-
- sce->nodetree = newdataadr(fd, sce->nodetree);
- if (sce->nodetree) {
- direct_link_id(fd, &sce->nodetree->id);
- direct_link_nodetree(fd, sce->nodetree);
- }
-
- direct_link_view_settings(fd, &sce->view_settings);
-
- sce->rigidbody_world = newdataadr(fd, sce->rigidbody_world);
- rbw = sce->rigidbody_world;
- if (rbw) {
- rbw->shared = newdataadr(fd, rbw->shared);
-
- if (rbw->shared == NULL) {
- /* Link deprecated caches if they exist, so we can use them for versioning.
- * We should only do this when rbw->shared == NULL, because those pointers
- * are always set (for compatibility with older Blenders). We mustn't link
- * the same pointcache twice. */
- direct_link_pointcache_list(fd, &rbw->ptcaches, &rbw->pointcache, false);
-
- /* make sure simulation starts from the beginning after loading file */
- if (rbw->pointcache) {
- rbw->ltime = (float)rbw->pointcache->startframe;
- }
- }
- else {
- /* must nullify the reference to physics sim object, since it no-longer exist
- * (and will need to be recalculated)
- */
- rbw->shared->physics_world = NULL;
-
- /* link caches */
- direct_link_pointcache_list(fd, &rbw->shared->ptcaches, &rbw->shared->pointcache, false);
-
- /* make sure simulation starts from the beginning after loading file */
- if (rbw->shared->pointcache) {
- rbw->ltime = (float)rbw->shared->pointcache->startframe;
- }
- }
- rbw->objects = NULL;
- rbw->numbodies = 0;
-
- /* set effector weights */
- rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
- if (!rbw->effector_weights)
- rbw->effector_weights = BKE_effector_add_weights(NULL);
- }
-
- sce->preview = direct_link_preview_image(fd, sce->preview);
-
- direct_link_curvemapping(fd, &sce->r.mblur_shutter_curve);
+ Editing *ed;
+ Sequence *seq;
+ MetaStack *ms;
+ RigidBodyWorld *rbw;
+ ViewLayer *view_layer;
+ SceneRenderLayer *srl;
+
+ sce->depsgraph_hash = NULL;
+ sce->fps_info = NULL;
+
+ memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
+ memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
+
+ BKE_sound_create_scene(sce);
+
+ /* set users to one by default, not in lib-link, this will increase it for compo nodes */
+ id_us_ensure_real(&sce->id);
+
+ link_list(fd, &(sce->base));
+
+ sce->adt = newdataadr(fd, sce->adt);
+ direct_link_animdata(fd, sce->adt);
+
+ link_list(fd, &sce->keyingsets);
+ direct_link_keyingsets(fd, &sce->keyingsets);
+
+ sce->basact = newdataadr(fd, sce->basact);
+
+ sce->toolsettings = newdataadr(fd, sce->toolsettings);
+ if (sce->toolsettings) {
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->sculpt);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->vpaint);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->wpaint);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->uvsculpt);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->gp_paint);
+
+ direct_link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
+
+ sce->toolsettings->imapaint.paintcursor = NULL;
+ sce->toolsettings->particle.paintcursor = NULL;
+ sce->toolsettings->particle.scene = NULL;
+ sce->toolsettings->particle.object = NULL;
+ sce->toolsettings->gp_sculpt.paintcursor = NULL;
+
+ /* relink grease pencil interpolation curves */
+ sce->toolsettings->gp_interpolate.custom_ipo = newdataadr(
+ fd, sce->toolsettings->gp_interpolate.custom_ipo);
+ if (sce->toolsettings->gp_interpolate.custom_ipo) {
+ direct_link_curvemapping(fd, sce->toolsettings->gp_interpolate.custom_ipo);
+ }
+ /* relink grease pencil multiframe falloff curve */
+ sce->toolsettings->gp_sculpt.cur_falloff = newdataadr(
+ fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ if (sce->toolsettings->gp_sculpt.cur_falloff) {
+ direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ }
+ /* relink grease pencil primitive curve */
+ sce->toolsettings->gp_sculpt.cur_primitive = newdataadr(
+ fd, sce->toolsettings->gp_sculpt.cur_primitive);
+ if (sce->toolsettings->gp_sculpt.cur_primitive) {
+ direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_primitive);
+ }
+ }
+
+ if (sce->ed) {
+ ListBase *old_seqbasep = &sce->ed->seqbase;
+
+ ed = sce->ed = newdataadr(fd, sce->ed);
+
+ ed->act_seq = newdataadr(fd, ed->act_seq);
+
+ /* recursive link sequences, lb will be correctly initialized */
+ link_recurs_seq(fd, &ed->seqbase);
+
+ SEQ_BEGIN (ed, seq) {
+ seq->seq1 = newdataadr(fd, seq->seq1);
+ seq->seq2 = newdataadr(fd, seq->seq2);
+ seq->seq3 = newdataadr(fd, seq->seq3);
+
+ /* a patch: after introduction of effects with 3 input strips */
+ if (seq->seq3 == NULL)
+ seq->seq3 = seq->seq2;
+
+ seq->effectdata = newdataadr(fd, seq->effectdata);
+ seq->stereo3d_format = newdataadr(fd, seq->stereo3d_format);
+
+ if (seq->type & SEQ_TYPE_EFFECT)
+ seq->flag |= SEQ_EFFECT_NOT_LOADED;
+
+ if (seq->type == SEQ_TYPE_SPEED) {
+ SpeedControlVars *s = seq->effectdata;
+ s->frameMap = NULL;
+ }
+
+ if (seq->type == SEQ_TYPE_TEXT) {
+ TextVars *t = seq->effectdata;
+ t->text_blf_id = SEQ_FONT_NOT_LOADED;
+ }
+
+ seq->prop = newdataadr(fd, seq->prop);
+ IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+
+ seq->strip = newdataadr(fd, seq->strip);
+ if (seq->strip && seq->strip->done == 0) {
+ seq->strip->done = true;
+
+ if (ELEM(seq->type,
+ SEQ_TYPE_IMAGE,
+ SEQ_TYPE_MOVIE,
+ SEQ_TYPE_SOUND_RAM,
+ SEQ_TYPE_SOUND_HD)) {
+ seq->strip->stripdata = newdataadr(fd, seq->strip->stripdata);
+ }
+ else {
+ seq->strip->stripdata = NULL;
+ }
+ if (seq->flag & SEQ_USE_CROP) {
+ seq->strip->crop = newdataadr(fd, seq->strip->crop);
+ }
+ else {
+ seq->strip->crop = NULL;
+ }
+ if (seq->flag & SEQ_USE_TRANSFORM) {
+ seq->strip->transform = newdataadr(fd, seq->strip->transform);
+ }
+ else {
+ seq->strip->transform = NULL;
+ }
+ if (seq->flag & SEQ_USE_PROXY) {
+ seq->strip->proxy = newdataadr(fd, seq->strip->proxy);
+ if (seq->strip->proxy) {
+ seq->strip->proxy->anim = NULL;
+ }
+ else {
+ BKE_sequencer_proxy_set(seq, true);
+ }
+ }
+ else {
+ seq->strip->proxy = NULL;
+ }
+
+ /* need to load color balance to it could be converted to modifier */
+ seq->strip->color_balance = newdataadr(fd, seq->strip->color_balance);
+ }
+
+ direct_link_sequence_modifiers(fd, &seq->modifiers);
+ }
+ SEQ_END;
+
+ /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
+ {
+ Sequence temp;
+ void *poin;
+ intptr_t offset;
+
+ offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp);
+
+ /* root pointer */
+ if (ed->seqbasep == old_seqbasep) {
+ ed->seqbasep = &ed->seqbase;
+ }
+ else {
+ poin = POINTER_OFFSET(ed->seqbasep, -offset);
+
+ poin = newdataadr(fd, poin);
+ if (poin)
+ ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
+ else
+ ed->seqbasep = &ed->seqbase;
+ }
+ /* stack */
+ link_list(fd, &(ed->metastack));
+
+ for (ms = ed->metastack.first; ms; ms = ms->next) {
+ ms->parseq = newdataadr(fd, ms->parseq);
+
+ if (ms->oldbasep == old_seqbasep)
+ ms->oldbasep = &ed->seqbase;
+ else {
+ poin = POINTER_OFFSET(ms->oldbasep, -offset);
+ poin = newdataadr(fd, poin);
+ if (poin)
+ ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
+ else
+ ms->oldbasep = &ed->seqbase;
+ }
+ }
+ }
+ }
+
+ sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
+ if (sce->r.avicodecdata) {
+ sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
+ sce->r.avicodecdata->lpParms = newdataadr(fd, sce->r.avicodecdata->lpParms);
+ }
+ if (sce->r.ffcodecdata.properties) {
+ sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
+ IDP_DirectLinkGroup_OrFree(
+ &sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+
+ link_list(fd, &(sce->markers));
+ link_list(fd, &(sce->transform_spaces));
+ link_list(fd, &(sce->r.layers));
+ link_list(fd, &(sce->r.views));
+
+ for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ srl->prop = newdataadr(fd, srl->prop);
+ IDP_DirectLinkGroup_OrFree(&srl->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ link_list(fd, &(srl->freestyleConfig.modules));
+ link_list(fd, &(srl->freestyleConfig.linesets));
+ }
+
+ sce->nodetree = newdataadr(fd, sce->nodetree);
+ if (sce->nodetree) {
+ direct_link_id(fd, &sce->nodetree->id);
+ direct_link_nodetree(fd, sce->nodetree);
+ }
+
+ direct_link_view_settings(fd, &sce->view_settings);
+
+ sce->rigidbody_world = newdataadr(fd, sce->rigidbody_world);
+ rbw = sce->rigidbody_world;
+ if (rbw) {
+ rbw->shared = newdataadr(fd, rbw->shared);
+
+ if (rbw->shared == NULL) {
+ /* Link deprecated caches if they exist, so we can use them for versioning.
+ * We should only do this when rbw->shared == NULL, because those pointers
+ * are always set (for compatibility with older Blenders). We mustn't link
+ * the same pointcache twice. */
+ direct_link_pointcache_list(fd, &rbw->ptcaches, &rbw->pointcache, false);
+
+ /* make sure simulation starts from the beginning after loading file */
+ if (rbw->pointcache) {
+ rbw->ltime = (float)rbw->pointcache->startframe;
+ }
+ }
+ else {
+ /* must nullify the reference to physics sim object, since it no-longer exist
+ * (and will need to be recalculated)
+ */
+ rbw->shared->physics_world = NULL;
+
+ /* link caches */
+ direct_link_pointcache_list(fd, &rbw->shared->ptcaches, &rbw->shared->pointcache, false);
+
+ /* make sure simulation starts from the beginning after loading file */
+ if (rbw->shared->pointcache) {
+ rbw->ltime = (float)rbw->shared->pointcache->startframe;
+ }
+ }
+ rbw->objects = NULL;
+ rbw->numbodies = 0;
+
+ /* set effector weights */
+ rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
+ if (!rbw->effector_weights)
+ rbw->effector_weights = BKE_effector_add_weights(NULL);
+ }
+
+ sce->preview = direct_link_preview_image(fd, sce->preview);
+
+ direct_link_curvemapping(fd, &sce->r.mblur_shutter_curve);
#ifdef USE_COLLECTION_COMPAT_28
- /* this runs before the very first doversion */
- if (sce->collection) {
- sce->collection = newdataadr(fd, sce->collection);
- direct_link_scene_collection(fd, sce->collection);
- }
+ /* this runs before the very first doversion */
+ if (sce->collection) {
+ sce->collection = newdataadr(fd, sce->collection);
+ direct_link_scene_collection(fd, sce->collection);
+ }
#endif
- if (sce->master_collection) {
- sce->master_collection = newdataadr(fd, sce->master_collection);
- /* Needed because this is an ID outside of Main. */
- direct_link_id(fd, &sce->master_collection->id);
- direct_link_collection(fd, sce->master_collection);
- }
-
- /* insert into global old-new map for reading without UI (link_global accesses it again) */
- link_glob_list(fd, &sce->view_layers);
- for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- direct_link_view_layer(fd, view_layer);
- }
-
- if (fd->memfile) {
- /* If it's undo try to recover the cache. */
- if (fd->scenemap) sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
- else sce->eevee.light_cache = NULL;
- }
- else {
- /* else try to read the cache from file. */
- sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
- if (sce->eevee.light_cache) {
- direct_link_lightcache(fd, sce->eevee.light_cache);
- }
- }
-
- sce->layer_properties = newdataadr(fd, sce->layer_properties);
- IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ if (sce->master_collection) {
+ sce->master_collection = newdataadr(fd, sce->master_collection);
+ /* Needed because this is an ID outside of Main. */
+ direct_link_id(fd, &sce->master_collection->id);
+ direct_link_collection(fd, sce->master_collection);
+ }
+
+ /* insert into global old-new map for reading without UI (link_global accesses it again) */
+ link_glob_list(fd, &sce->view_layers);
+ for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ direct_link_view_layer(fd, view_layer);
+ }
+
+ if (fd->memfile) {
+ /* If it's undo try to recover the cache. */
+ if (fd->scenemap)
+ sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
+ else
+ sce->eevee.light_cache = NULL;
+ }
+ else {
+ /* else try to read the cache from file. */
+ sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
+ if (sce->eevee.light_cache) {
+ direct_link_lightcache(fd, sce->eevee.light_cache);
+ }
+ }
+
+ sce->layer_properties = newdataadr(fd, sce->layer_properties);
+ IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
/** \} */
@@ -6938,94 +7018,94 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* relink's grease pencil data's refs */
static void lib_link_gpencil(FileData *fd, Main *main)
{
- /* Relink all datablock linked by GP datablock */
- for (bGPdata *gpd = main->gpencils.first; gpd; gpd = gpd->id.next) {
- if (gpd->id.tag & LIB_TAG_NEED_LINK) {
- /* Layers */
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* Layer -> Parent References */
- gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
- }
+ /* Relink all datablock linked by GP datablock */
+ for (bGPdata *gpd = main->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (gpd->id.tag & LIB_TAG_NEED_LINK) {
+ /* Layers */
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* Layer -> Parent References */
+ gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
+ }
- /* Datablock Stuff */
- IDP_LibLinkProperty(gpd->id.properties, fd);
- lib_link_animdata(fd, &gpd->id, gpd->adt);
+ /* Datablock Stuff */
+ IDP_LibLinkProperty(gpd->id.properties, fd);
+ lib_link_animdata(fd, &gpd->id, gpd->adt);
- /* materials */
- for (int a = 0; a < gpd->totcol; a++) {
- gpd->mat[a] = newlibadr_us(fd, gpd->id.lib, gpd->mat[a]);
- }
+ /* materials */
+ for (int a = 0; a < gpd->totcol; a++) {
+ gpd->mat[a] = newlibadr_us(fd, gpd->id.lib, gpd->mat[a]);
+ }
- gpd->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ gpd->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/* relinks grease-pencil data - used for direct_link and old file linkage */
static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
{
- bGPDlayer *gpl;
- bGPDframe *gpf;
- bGPDstroke *gps;
- bGPDpalette *palette;
+ bGPDlayer *gpl;
+ bGPDframe *gpf;
+ bGPDstroke *gps;
+ bGPDpalette *palette;
- /* we must firstly have some grease-pencil data to link! */
- if (gpd == NULL)
- return;
+ /* we must firstly have some grease-pencil data to link! */
+ if (gpd == NULL)
+ return;
- /* relink animdata */
- gpd->adt = newdataadr(fd, gpd->adt);
- direct_link_animdata(fd, gpd->adt);
+ /* relink animdata */
+ gpd->adt = newdataadr(fd, gpd->adt);
+ direct_link_animdata(fd, gpd->adt);
- /* init stroke buffer */
- gpd->runtime.sbuffer = NULL;
- gpd->runtime.sbuffer_size = 0;
- gpd->runtime.tot_cp_points = 0;
+ /* init stroke buffer */
+ gpd->runtime.sbuffer = NULL;
+ gpd->runtime.sbuffer_size = 0;
+ gpd->runtime.tot_cp_points = 0;
- /* relink palettes (old palettes deprecated, only to convert old files) */
- link_list(fd, &gpd->palettes);
- if (gpd->palettes.first != NULL) {
- for (palette = gpd->palettes.first; palette; palette = palette->next) {
- link_list(fd, &palette->colors);
- }
- }
+ /* relink palettes (old palettes deprecated, only to convert old files) */
+ link_list(fd, &gpd->palettes);
+ if (gpd->palettes.first != NULL) {
+ for (palette = gpd->palettes.first; palette; palette = palette->next) {
+ link_list(fd, &palette->colors);
+ }
+ }
- /* materials */
- gpd->mat = newdataadr(fd, gpd->mat);
- test_pointer_array(fd, (void **)&gpd->mat);
+ /* materials */
+ gpd->mat = newdataadr(fd, gpd->mat);
+ test_pointer_array(fd, (void **)&gpd->mat);
- /* relink layers */
- link_list(fd, &gpd->layers);
+ /* relink layers */
+ link_list(fd, &gpd->layers);
- for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* relink frames */
- link_list(fd, &gpl->frames);
+ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* relink frames */
+ link_list(fd, &gpl->frames);
- gpl->actframe = newdataadr(fd, gpl->actframe);
+ gpl->actframe = newdataadr(fd, gpl->actframe);
- gpl->runtime.icon_id = 0;
+ gpl->runtime.icon_id = 0;
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- /* relink strokes (and their points) */
- link_list(fd, &gpf->strokes);
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ /* relink strokes (and their points) */
+ link_list(fd, &gpf->strokes);
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- /* relink stroke points array */
- gps->points = newdataadr(fd, gps->points);
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* relink stroke points array */
+ gps->points = newdataadr(fd, gps->points);
- /* relink weight data */
- if (gps->dvert) {
- gps->dvert = newdataadr(fd, gps->dvert);
- direct_link_dverts(fd, gps->totpoints, gps->dvert);
- }
+ /* relink weight data */
+ if (gps->dvert) {
+ gps->dvert = newdataadr(fd, gps->dvert);
+ direct_link_dverts(fd, gps->totpoints, gps->dvert);
+ }
- /* the triangulation is not saved, so need to be recalculated */
- gps->triangles = NULL;
- gps->tot_triangles = 0;
- gps->flag |= GP_STROKE_RECALC_GEOMETRY;
- }
- }
- }
+ /* the triangulation is not saved, so need to be recalculated */
+ gps->triangles = NULL;
+ gps->tot_triangles = 0;
+ gps->flag |= GP_STROKE_RECALC_GEOMETRY;
+ }
+ }
+ }
}
/** \} */
@@ -7036,505 +7116,494 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
static void direct_link_panel_list(FileData *fd, ListBase *lb)
{
- link_list(fd, lb);
+ link_list(fd, lb);
- for (Panel *pa = lb->first; pa; pa = pa->next) {
- pa->paneltab = newdataadr(fd, pa->paneltab);
- pa->runtime_flag = 0;
- pa->activedata = NULL;
- pa->type = NULL;
- direct_link_panel_list(fd, &pa->children);
- }
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ pa->paneltab = newdataadr(fd, pa->paneltab);
+ pa->runtime_flag = 0;
+ pa->activedata = NULL;
+ pa->type = NULL;
+ direct_link_panel_list(fd, &pa->children);
+ }
}
static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
{
- uiList *ui_list;
-
- direct_link_panel_list(fd, &ar->panels);
-
- link_list(fd, &ar->panels_category_active);
-
- link_list(fd, &ar->ui_lists);
-
- for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
- ui_list->type = NULL;
- ui_list->dyn_data = NULL;
- ui_list->properties = newdataadr(fd, ui_list->properties);
- IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
-
- link_list(fd, &ar->ui_previews);
-
- if (spacetype == SPACE_EMPTY) {
- /* unkown space type, don't leak regiondata */
- ar->regiondata = NULL;
- }
- else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
- /* Runtime data, don't use. */
- ar->regiondata = NULL;
- }
- else {
- ar->regiondata = newdataadr(fd, ar->regiondata);
- if (ar->regiondata) {
- if (spacetype == SPACE_VIEW3D) {
- RegionView3D *rv3d = ar->regiondata;
-
- rv3d->localvd = newdataadr(fd, rv3d->localvd);
- rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
-
- rv3d->depths = NULL;
- rv3d->render_engine = NULL;
- rv3d->sms = NULL;
- rv3d->smooth_timer = NULL;
- }
- }
- }
-
- ar->v2d.tab_offset = NULL;
- ar->v2d.tab_num = 0;
- ar->v2d.tab_cur = 0;
- ar->v2d.sms = NULL;
- ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */
- BLI_listbase_clear(&ar->panels_category);
- BLI_listbase_clear(&ar->handlers);
- BLI_listbase_clear(&ar->uiblocks);
- ar->headerstr = NULL;
- ar->visible = 0;
- ar->type = NULL;
- ar->do_draw = 0;
- ar->gizmo_map = NULL;
- ar->regiontimer = NULL;
- ar->draw_buffer = NULL;
- memset(&ar->drawrct, 0, sizeof(ar->drawrct));
+ uiList *ui_list;
+
+ direct_link_panel_list(fd, &ar->panels);
+
+ link_list(fd, &ar->panels_category_active);
+
+ link_list(fd, &ar->ui_lists);
+
+ for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ ui_list->type = NULL;
+ ui_list->dyn_data = NULL;
+ ui_list->properties = newdataadr(fd, ui_list->properties);
+ IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+
+ link_list(fd, &ar->ui_previews);
+
+ if (spacetype == SPACE_EMPTY) {
+ /* unkown space type, don't leak regiondata */
+ ar->regiondata = NULL;
+ }
+ else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+ /* Runtime data, don't use. */
+ ar->regiondata = NULL;
+ }
+ else {
+ ar->regiondata = newdataadr(fd, ar->regiondata);
+ if (ar->regiondata) {
+ if (spacetype == SPACE_VIEW3D) {
+ RegionView3D *rv3d = ar->regiondata;
+
+ rv3d->localvd = newdataadr(fd, rv3d->localvd);
+ rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
+
+ rv3d->depths = NULL;
+ rv3d->render_engine = NULL;
+ rv3d->sms = NULL;
+ rv3d->smooth_timer = NULL;
+ }
+ }
+ }
+
+ ar->v2d.tab_offset = NULL;
+ ar->v2d.tab_num = 0;
+ ar->v2d.tab_cur = 0;
+ ar->v2d.sms = NULL;
+ ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */
+ BLI_listbase_clear(&ar->panels_category);
+ BLI_listbase_clear(&ar->handlers);
+ BLI_listbase_clear(&ar->uiblocks);
+ ar->headerstr = NULL;
+ ar->visible = 0;
+ ar->type = NULL;
+ ar->do_draw = 0;
+ ar->gizmo_map = NULL;
+ ar->regiontimer = NULL;
+ ar->draw_buffer = NULL;
+ memset(&ar->drawrct, 0, sizeof(ar->drawrct));
}
static void direct_link_area(FileData *fd, ScrArea *area)
{
- SpaceLink *sl;
- ARegion *ar;
-
- link_list(fd, &(area->spacedata));
- link_list(fd, &(area->regionbase));
-
- BLI_listbase_clear(&area->handlers);
- area->type = NULL; /* spacetype callbacks */
- area->butspacetype = SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */
- area->region_active_win = -1;
-
- area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
-
- area->global = newdataadr(fd, area->global);
-
- /* if we do not have the spacetype registered we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(area->spacetype)) {
- area->butspacetype = area->spacetype; /* Hint for versioning code to replace deprecated space types. */
- area->spacetype = SPACE_EMPTY;
- }
-
- for (ar = area->regionbase.first; ar; ar = ar->next) {
- direct_link_region(fd, ar, area->spacetype);
- }
-
- /* accident can happen when read/save new file with older version */
- /* 2.50: we now always add spacedata for info */
- if (area->spacedata.first == NULL) {
- SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
- area->spacetype = sinfo->spacetype = SPACE_INFO;
- BLI_addtail(&area->spacedata, sinfo);
- }
- /* add local view3d too */
- else if (area->spacetype == SPACE_VIEW3D) {
- blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
- }
-
- for (sl = area->spacedata.first; sl; sl = sl->next) {
- link_list(fd, &(sl->regionbase));
-
- /* if we do not have the spacetype registered we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(sl->spacetype))
- sl->spacetype = SPACE_EMPTY;
-
- for (ar = sl->regionbase.first; ar; ar = ar->next)
- direct_link_region(fd, ar, sl->spacetype);
-
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- v3d->flag |= V3D_INVALID_BACKBUF;
-
- if (v3d->gpd) {
- v3d->gpd = newdataadr(fd, v3d->gpd);
- direct_link_gpencil(fd, v3d->gpd);
- }
- v3d->localvd = newdataadr(fd, v3d->localvd);
- v3d->runtime.properties_storage = NULL;
-
- /* render can be quite heavy, set to solid on load */
- if (v3d->shading.type == OB_RENDER) {
- v3d->shading.type = OB_SOLID;
- }
- v3d->shading.prev_type = OB_SOLID;
-
- if (v3d->fx_settings.dof)
- v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
- if (v3d->fx_settings.ssao)
- v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
-
- blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
-
- sipo->ads = newdataadr(fd, sipo->ads);
- BLI_listbase_clear(&sipo->runtime.ghost_curves);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
-
- snla->ads = newdataadr(fd, snla->ads);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
-
- /* use newdataadr_no_us and do not free old memory avoiding double
- * frees and use of freed memory. this could happen because of a
- * bug fixed in revision 58959 where the treestore memory address
- * was not unique */
- TreeStore *ts = newdataadr_no_us(fd, soops->treestore);
- soops->treestore = NULL;
- if (ts) {
- TreeStoreElem *elems = newdataadr_no_us(fd, ts->data);
-
- soops->treestore = BLI_mempool_create(
- sizeof(TreeStoreElem), ts->usedelem,
- 512, BLI_MEMPOOL_ALLOW_ITER);
- if (ts->usedelem && elems) {
- int i;
- for (i = 0; i < ts->usedelem; i++) {
- TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
- *new_elem = elems[i];
- }
- }
- /* we only saved what was used */
- soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
- }
- soops->treehash = NULL;
- soops->tree.first = soops->tree.last = NULL;
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->iuser.scene = NULL;
- sima->iuser.ok = 1;
- sima->scopes.waveform_1 = NULL;
- sima->scopes.waveform_2 = NULL;
- sima->scopes.waveform_3 = NULL;
- sima->scopes.vecscope = NULL;
- sima->scopes.ok = 0;
-
- /* WARNING: gpencil data is no longer stored directly in sima after 2.5
- * so sacrifice a few old files for now to avoid crashes with new files!
- * committed: r28002 */
+ SpaceLink *sl;
+ ARegion *ar;
+
+ link_list(fd, &(area->spacedata));
+ link_list(fd, &(area->regionbase));
+
+ BLI_listbase_clear(&area->handlers);
+ area->type = NULL; /* spacetype callbacks */
+ area->butspacetype =
+ SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */
+ area->region_active_win = -1;
+
+ area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
+
+ area->global = newdataadr(fd, area->global);
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(area->spacetype)) {
+ area->butspacetype =
+ area->spacetype; /* Hint for versioning code to replace deprecated space types. */
+ area->spacetype = SPACE_EMPTY;
+ }
+
+ for (ar = area->regionbase.first; ar; ar = ar->next) {
+ direct_link_region(fd, ar, area->spacetype);
+ }
+
+ /* accident can happen when read/save new file with older version */
+ /* 2.50: we now always add spacedata for info */
+ if (area->spacedata.first == NULL) {
+ SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
+ area->spacetype = sinfo->spacetype = SPACE_INFO;
+ BLI_addtail(&area->spacedata, sinfo);
+ }
+ /* add local view3d too */
+ else if (area->spacetype == SPACE_VIEW3D) {
+ blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
+ }
+
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
+ link_list(fd, &(sl->regionbase));
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(sl->spacetype))
+ sl->spacetype = SPACE_EMPTY;
+
+ for (ar = sl->regionbase.first; ar; ar = ar->next)
+ direct_link_region(fd, ar, sl->spacetype);
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ v3d->flag |= V3D_INVALID_BACKBUF;
+
+ if (v3d->gpd) {
+ v3d->gpd = newdataadr(fd, v3d->gpd);
+ direct_link_gpencil(fd, v3d->gpd);
+ }
+ v3d->localvd = newdataadr(fd, v3d->localvd);
+ v3d->runtime.properties_storage = NULL;
+
+ /* render can be quite heavy, set to solid on load */
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = OB_SOLID;
+ }
+ v3d->shading.prev_type = OB_SOLID;
+
+ if (v3d->fx_settings.dof)
+ v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
+ if (v3d->fx_settings.ssao)
+ v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
+
+ blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
+ }
+ else if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+
+ sipo->ads = newdataadr(fd, sipo->ads);
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ snla->ads = newdataadr(fd, snla->ads);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *soops = (SpaceOutliner *)sl;
+
+ /* use newdataadr_no_us and do not free old memory avoiding double
+ * frees and use of freed memory. this could happen because of a
+ * bug fixed in revision 58959 where the treestore memory address
+ * was not unique */
+ TreeStore *ts = newdataadr_no_us(fd, soops->treestore);
+ soops->treestore = NULL;
+ if (ts) {
+ TreeStoreElem *elems = newdataadr_no_us(fd, ts->data);
+
+ soops->treestore = BLI_mempool_create(
+ sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
+ if (ts->usedelem && elems) {
+ int i;
+ for (i = 0; i < ts->usedelem; i++) {
+ TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
+ *new_elem = elems[i];
+ }
+ }
+ /* we only saved what was used */
+ soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ }
+ soops->treehash = NULL;
+ soops->tree.first = soops->tree.last = NULL;
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->iuser.scene = NULL;
+ sima->iuser.ok = 1;
+ sima->scopes.waveform_1 = NULL;
+ sima->scopes.waveform_2 = NULL;
+ sima->scopes.waveform_3 = NULL;
+ sima->scopes.vecscope = NULL;
+ sima->scopes.ok = 0;
+
+ /* WARNING: gpencil data is no longer stored directly in sima after 2.5
+ * so sacrifice a few old files for now to avoid crashes with new files!
+ * committed: r28002 */
#if 0
- sima->gpd = newdataadr(fd, sima->gpd);
- if (sima->gpd)
- direct_link_gpencil(fd, sima->gpd);
+ sima->gpd = newdataadr(fd, sima->gpd);
+ if (sima->gpd)
+ direct_link_gpencil(fd, sima->gpd);
#endif
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
-
- if (snode->gpd) {
- snode->gpd = newdataadr(fd, snode->gpd);
- direct_link_gpencil(fd, snode->gpd);
- }
-
- link_list(fd, &snode->treepath);
- snode->edittree = NULL;
- snode->iofsd = NULL;
- BLI_listbase_clear(&snode->linkdrag);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText *)sl;
-
- st->drawcache = NULL;
- st->scroll_accum[0] = 0.0f;
- st->scroll_accum[1] = 0.0f;
- }
- else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* grease pencil data is not a direct data and can't be linked from direct_link*
- * functions, it should be linked from lib_link* functions instead
- *
- * otherwise it'll lead to lost grease data on open because it'll likely be
- * read from file after all other users of grease pencil and newdataadr would
- * simple return NULL here (sergey)
- */
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ if (snode->gpd) {
+ snode->gpd = newdataadr(fd, snode->gpd);
+ direct_link_gpencil(fd, snode->gpd);
+ }
+
+ link_list(fd, &snode->treepath);
+ snode->edittree = NULL;
+ snode->iofsd = NULL;
+ BLI_listbase_clear(&snode->linkdrag);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st = (SpaceText *)sl;
+
+ st->drawcache = NULL;
+ st->scroll_accum[0] = 0.0f;
+ st->scroll_accum[1] = 0.0f;
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* grease pencil data is not a direct data and can't be linked from direct_link*
+ * functions, it should be linked from lib_link* functions instead
+ *
+ * otherwise it'll lead to lost grease data on open because it'll likely be
+ * read from file after all other users of grease pencil and newdataadr would
+ * simple return NULL here (sergey)
+ */
#if 0
- if (sseq->gpd) {
- sseq->gpd = newdataadr(fd, sseq->gpd);
- direct_link_gpencil(fd, sseq->gpd);
- }
+ if (sseq->gpd) {
+ sseq->gpd = newdataadr(fd, sseq->gpd);
+ direct_link_gpencil(fd, sseq->gpd);
+ }
#endif
- sseq->scopes.reference_ibuf = NULL;
- sseq->scopes.zebra_ibuf = NULL;
- sseq->scopes.waveform_ibuf = NULL;
- sseq->scopes.sep_waveform_ibuf = NULL;
- sseq->scopes.vector_ibuf = NULL;
- sseq->scopes.histogram_ibuf = NULL;
- sseq->compositor = NULL;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
-
- sbuts->path = NULL;
- sbuts->texuser = NULL;
- sbuts->mainbo = sbuts->mainb;
- sbuts->mainbuser = sbuts->mainb;
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *sconsole = (SpaceConsole *)sl;
- ConsoleLine *cl, *cl_next;
-
- link_list(fd, &sconsole->scrollback);
- link_list(fd, &sconsole->history);
-
- //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
- // cl->line= newdataadr(fd, cl->line);
-
- /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
- * from left to right. the right-most expression sets the result of the comma
- * expression as a whole*/
- for (cl = sconsole->history.first; cl; cl = cl_next) {
- cl_next = cl->next;
- cl->line = newdataadr(fd, cl->line);
- if (cl->line) {
- /* the allocted length is not written, so reset here */
- cl->len_alloc = cl->len + 1;
- }
- else {
- BLI_remlink(&sconsole->history, cl);
- MEM_freeN(cl);
- }
- }
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- /* this sort of info is probably irrelevant for reloading...
- * plus, it isn't saved to files yet!
- */
- sfile->folders_prev = sfile->folders_next = NULL;
- sfile->files = NULL;
- sfile->layout = NULL;
- sfile->op = NULL;
- sfile->previews_timer = NULL;
- sfile->params = newdataadr(fd, sfile->params);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- sclip->scopes.track_search = NULL;
- sclip->scopes.track_preview = NULL;
- sclip->scopes.ok = 0;
- }
- }
-
- BLI_listbase_clear(&area->actionzones);
-
- area->v1 = newdataadr(fd, area->v1);
- area->v2 = newdataadr(fd, area->v2);
- area->v3 = newdataadr(fd, area->v3);
- area->v4 = newdataadr(fd, area->v4);
+ sseq->scopes.reference_ibuf = NULL;
+ sseq->scopes.zebra_ibuf = NULL;
+ sseq->scopes.waveform_ibuf = NULL;
+ sseq->scopes.sep_waveform_ibuf = NULL;
+ sseq->scopes.vector_ibuf = NULL;
+ sseq->scopes.histogram_ibuf = NULL;
+ sseq->compositor = NULL;
+ }
+ else if (sl->spacetype == SPACE_PROPERTIES) {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+
+ sbuts->path = NULL;
+ sbuts->texuser = NULL;
+ sbuts->mainbo = sbuts->mainb;
+ sbuts->mainbuser = sbuts->mainb;
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *sconsole = (SpaceConsole *)sl;
+ ConsoleLine *cl, *cl_next;
+
+ link_list(fd, &sconsole->scrollback);
+ link_list(fd, &sconsole->history);
+
+ //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
+ // cl->line= newdataadr(fd, cl->line);
+
+ /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
+ * from left to right. the right-most expression sets the result of the comma
+ * expression as a whole*/
+ for (cl = sconsole->history.first; cl; cl = cl_next) {
+ cl_next = cl->next;
+ cl->line = newdataadr(fd, cl->line);
+ if (cl->line) {
+ /* the allocted length is not written, so reset here */
+ cl->len_alloc = cl->len + 1;
+ }
+ else {
+ BLI_remlink(&sconsole->history, cl);
+ MEM_freeN(cl);
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ /* this sort of info is probably irrelevant for reloading...
+ * plus, it isn't saved to files yet!
+ */
+ sfile->folders_prev = sfile->folders_next = NULL;
+ sfile->files = NULL;
+ sfile->layout = NULL;
+ sfile->op = NULL;
+ sfile->previews_timer = NULL;
+ sfile->params = newdataadr(fd, sfile->params);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ sclip->scopes.track_search = NULL;
+ sclip->scopes.track_preview = NULL;
+ sclip->scopes.ok = 0;
+ }
+ }
+
+ BLI_listbase_clear(&area->actionzones);
+
+ area->v1 = newdataadr(fd, area->v1);
+ area->v2 = newdataadr(fd, area->v2);
+ area->v3 = newdataadr(fd, area->v3);
+ area->v4 = newdataadr(fd, area->v4);
}
static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
{
- area->full = newlibadr(fd, parent_id->lib, area->full);
-
- memset(&area->runtime, 0x0, sizeof(area->runtime));
-
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D *)sl;
-
- v3d->camera = newlibadr(fd, parent_id->lib, v3d->camera);
- v3d->ob_centre = newlibadr(fd, parent_id->lib, v3d->ob_centre);
-
- if (v3d->localvd) {
- v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
- }
- break;
- }
- case SPACE_GRAPH:
- {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- bDopeSheet *ads = sipo->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
- }
- break;
- }
- case SPACE_PROPERTIES:
- {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid);
- if (sbuts->pinid == NULL) {
- sbuts->flag &= ~SB_PIN_CONTEXT;
- }
- break;
- }
- case SPACE_FILE:
- break;
- case SPACE_ACTION:
- {
- SpaceAction *saction = (SpaceAction *)sl;
- bDopeSheet *ads = &saction->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
- }
-
- saction->action = newlibadr(fd, parent_id->lib, saction->action);
- break;
- }
- case SPACE_IMAGE:
- {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image);
- sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask);
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd);
- break;
- }
- case SPACE_SEQ:
- {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd);
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- bDopeSheet *ads = snla->ads;
-
- if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
- }
- break;
- }
- case SPACE_TEXT:
- {
- SpaceText *st = (SpaceText *)sl;
-
- st->text = newlibadr(fd, parent_id->lib, st->text);
- break;
- }
- case SPACE_SCRIPT:
- {
- SpaceScript *scpt = (SpaceScript *)sl;
- /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
- if (scpt->script) {
- scpt->script = newlibadr(fd, parent_id->lib, scpt->script);
- if (scpt->script) {
- SCRIPT_SET_NULL(scpt->script);
- }
- }
- break;
- }
- case SPACE_OUTLINER:
- {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
-
- if (so->treestore) {
- TreeStoreElem *tselem;
- BLI_mempool_iter iter;
-
- BLI_mempool_iternew(so->treestore, &iter);
- while ((tselem = BLI_mempool_iterstep(&iter))) {
- tselem->id = newlibadr(fd, NULL, tselem->id);
- }
- if (so->treehash) {
- /* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
- }
- }
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path, *path_next;
- bNodeTree *ntree;
-
- /* node tree can be stored locally in id too, link this first */
- snode->id = newlibadr(fd, parent_id->lib, snode->id);
- snode->from = newlibadr(fd, parent_id->lib, snode->from);
-
- ntree = snode->id ? ntreeFromID(snode->id) : NULL;
- snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree);
-
- for (path = snode->treepath.first; path; path = path->next) {
- if (path == snode->treepath.first) {
- /* first nodetree in path is same as snode->nodetree */
- path->nodetree = snode->nodetree;
- }
- else
- path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree);
-
- if (!path->nodetree)
- break;
- }
-
- /* remaining path entries are invalid, remove */
- for (; path; path = path_next) {
- path_next = path->next;
-
- BLI_remlink(&snode->treepath, path);
- MEM_freeN(path);
- }
-
- /* edittree is just the last in the path,
- * set this directly since the path may have been shortened above */
- if (snode->treepath.last) {
- path = snode->treepath.last;
- snode->edittree = path->nodetree;
- }
- else {
- snode->edittree = NULL;
- }
- break;
- }
- case SPACE_CLIP:
- {
- SpaceClip *sclip = (SpaceClip *)sl;
- sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip);
- sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask);
- break;
- }
- default:
- break;
- }
- }
+ area->full = newlibadr(fd, parent_id->lib, area->full);
+
+ memset(&area->runtime, 0x0, sizeof(area->runtime));
+
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+
+ v3d->camera = newlibadr(fd, parent_id->lib, v3d->camera);
+ v3d->ob_centre = newlibadr(fd, parent_id->lib, v3d->ob_centre);
+
+ if (v3d->localvd) {
+ v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
+ }
+ break;
+ }
+ case SPACE_GRAPH: {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ bDopeSheet *ads = sipo->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_PROPERTIES: {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+ sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid);
+ if (sbuts->pinid == NULL) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
+ break;
+ }
+ case SPACE_FILE:
+ break;
+ case SPACE_ACTION: {
+ SpaceAction *saction = (SpaceAction *)sl;
+ bDopeSheet *ads = &saction->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+
+ saction->action = newlibadr(fd, parent_id->lib, saction->action);
+ break;
+ }
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image);
+ sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask);
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd);
+ break;
+ }
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd);
+ break;
+ }
+ case SPACE_NLA: {
+ SpaceNla *snla = (SpaceNla *)sl;
+ bDopeSheet *ads = snla->ads;
+
+ if (ads) {
+ ads->source = newlibadr(fd, parent_id->lib, ads->source);
+ ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_TEXT: {
+ SpaceText *st = (SpaceText *)sl;
+
+ st->text = newlibadr(fd, parent_id->lib, st->text);
+ break;
+ }
+ case SPACE_SCRIPT: {
+ SpaceScript *scpt = (SpaceScript *)sl;
+ /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
+ if (scpt->script) {
+ scpt->script = newlibadr(fd, parent_id->lib, scpt->script);
+ if (scpt->script) {
+ SCRIPT_SET_NULL(scpt->script);
+ }
+ }
+ break;
+ }
+ case SPACE_OUTLINER: {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+ so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
+
+ if (so->treestore) {
+ TreeStoreElem *tselem;
+ BLI_mempool_iter iter;
+
+ BLI_mempool_iternew(so->treestore, &iter);
+ while ((tselem = BLI_mempool_iterstep(&iter))) {
+ tselem->id = newlibadr(fd, NULL, tselem->id);
+ }
+ if (so->treehash) {
+ /* rebuild hash table, because it depends on ids too */
+ so->storeflag |= SO_TREESTORE_REBUILD;
+ }
+ }
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path, *path_next;
+ bNodeTree *ntree;
+
+ /* node tree can be stored locally in id too, link this first */
+ snode->id = newlibadr(fd, parent_id->lib, snode->id);
+ snode->from = newlibadr(fd, parent_id->lib, snode->from);
+
+ ntree = snode->id ? ntreeFromID(snode->id) : NULL;
+ snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree);
+
+ for (path = snode->treepath.first; path; path = path->next) {
+ if (path == snode->treepath.first) {
+ /* first nodetree in path is same as snode->nodetree */
+ path->nodetree = snode->nodetree;
+ }
+ else
+ path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree);
+
+ if (!path->nodetree)
+ break;
+ }
+
+ /* remaining path entries are invalid, remove */
+ for (; path; path = path_next) {
+ path_next = path->next;
+
+ BLI_remlink(&snode->treepath, path);
+ MEM_freeN(path);
+ }
+
+ /* edittree is just the last in the path,
+ * set this directly since the path may have been shortened above */
+ if (snode->treepath.last) {
+ path = snode->treepath.last;
+ snode->edittree = path->nodetree;
+ }
+ else {
+ snode->edittree = NULL;
+ }
+ break;
+ }
+ case SPACE_CLIP: {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip);
+ sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask);
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
/**
@@ -7542,27 +7611,27 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
*/
static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map)
{
- link_list(fd, &area_map->vertbase);
- link_list(fd, &area_map->edgebase);
- link_list(fd, &area_map->areabase);
- for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
- direct_link_area(fd, area);
- }
+ link_list(fd, &area_map->vertbase);
+ link_list(fd, &area_map->edgebase);
+ link_list(fd, &area_map->areabase);
+ for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ direct_link_area(fd, area);
+ }
- /* edges */
- for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
- se->v1 = newdataadr(fd, se->v1);
- se->v2 = newdataadr(fd, se->v2);
- BKE_screen_sort_scrvert(&se->v1, &se->v2);
+ /* edges */
+ for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
+ se->v1 = newdataadr(fd, se->v1);
+ se->v2 = newdataadr(fd, se->v2);
+ BKE_screen_sort_scrvert(&se->v1, &se->v2);
- if (se->v1 == NULL) {
- BLI_remlink(&area_map->edgebase, se);
+ if (se->v1 == NULL) {
+ BLI_remlink(&area_map->edgebase, se);
- return false;
- }
- }
+ return false;
+ }
+ }
- return true;
+ return true;
}
/** \} */
@@ -7573,100 +7642,100 @@ static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map)
static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
{
- wmWindow *win;
+ wmWindow *win;
- id_us_ensure_real(&wm->id);
- link_list(fd, &wm->windows);
+ id_us_ensure_real(&wm->id);
+ link_list(fd, &wm->windows);
- for (win = wm->windows.first; win; win = win->next) {
- win->parent = newdataadr(fd, win->parent);
+ for (win = wm->windows.first; win; win = win->next) {
+ win->parent = newdataadr(fd, win->parent);
- WorkSpaceInstanceHook *hook = win->workspace_hook;
- win->workspace_hook = newdataadr(fd, hook);
+ WorkSpaceInstanceHook *hook = win->workspace_hook;
+ win->workspace_hook = newdataadr(fd, hook);
- /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
- oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
+ /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
+ oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
- direct_link_area_map(fd, &win->global_areas);
+ direct_link_area_map(fd, &win->global_areas);
- win->ghostwin = NULL;
- win->gpuctx = NULL;
- win->eventstate = NULL;
- win->cursor_keymap_status = NULL;
- win->tweak = NULL;
+ win->ghostwin = NULL;
+ win->gpuctx = NULL;
+ win->eventstate = NULL;
+ win->cursor_keymap_status = NULL;
+ win->tweak = NULL;
#ifdef WIN32
- win->ime_data = NULL;
+ win->ime_data = NULL;
#endif
- BLI_listbase_clear(&win->queue);
- BLI_listbase_clear(&win->handlers);
- BLI_listbase_clear(&win->modalhandlers);
- BLI_listbase_clear(&win->gesture);
+ BLI_listbase_clear(&win->queue);
+ BLI_listbase_clear(&win->handlers);
+ BLI_listbase_clear(&win->modalhandlers);
+ BLI_listbase_clear(&win->gesture);
- win->active = 0;
+ win->active = 0;
- win->cursor = 0;
- win->lastcursor = 0;
- win->modalcursor = 0;
- win->grabcursor = 0;
- win->addmousemove = true;
- win->stereo3d_format = newdataadr(fd, win->stereo3d_format);
+ win->cursor = 0;
+ win->lastcursor = 0;
+ win->modalcursor = 0;
+ win->grabcursor = 0;
+ win->addmousemove = true;
+ win->stereo3d_format = newdataadr(fd, win->stereo3d_format);
- /* multiview always fallback to anaglyph at file opening
- * otherwise quadbuffer saved files can break Blender */
- if (win->stereo3d_format) {
- win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH;
- }
- }
+ /* multiview always fallback to anaglyph at file opening
+ * otherwise quadbuffer saved files can break Blender */
+ if (win->stereo3d_format) {
+ win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH;
+ }
+ }
- BLI_listbase_clear(&wm->timers);
- BLI_listbase_clear(&wm->operators);
- BLI_listbase_clear(&wm->paintcursors);
- BLI_listbase_clear(&wm->queue);
- BKE_reports_init(&wm->reports, RPT_STORE);
+ BLI_listbase_clear(&wm->timers);
+ BLI_listbase_clear(&wm->operators);
+ BLI_listbase_clear(&wm->paintcursors);
+ BLI_listbase_clear(&wm->queue);
+ BKE_reports_init(&wm->reports, RPT_STORE);
- BLI_listbase_clear(&wm->keyconfigs);
- wm->defaultconf = NULL;
- wm->addonconf = NULL;
- wm->userconf = NULL;
- wm->undo_stack = NULL;
+ BLI_listbase_clear(&wm->keyconfigs);
+ wm->defaultconf = NULL;
+ wm->addonconf = NULL;
+ wm->userconf = NULL;
+ wm->undo_stack = NULL;
- wm->message_bus = NULL;
+ wm->message_bus = NULL;
- BLI_listbase_clear(&wm->jobs);
- BLI_listbase_clear(&wm->drags);
+ BLI_listbase_clear(&wm->jobs);
+ BLI_listbase_clear(&wm->drags);
- wm->windrawable = NULL;
- wm->winactive = NULL;
- wm->initialized = 0;
- wm->op_undo_depth = 0;
- wm->is_interface_locked = 0;
+ wm->windrawable = NULL;
+ wm->winactive = NULL;
+ wm->initialized = 0;
+ wm->op_undo_depth = 0;
+ wm->is_interface_locked = 0;
}
static void lib_link_windowmanager(FileData *fd, Main *main)
{
- wmWindowManager *wm;
- wmWindow *win;
+ wmWindowManager *wm;
+ wmWindow *win;
- for (wm = main->wm.first; wm; wm = wm->id.next) {
- if (wm->id.tag & LIB_TAG_NEED_LINK) {
- /* Note: WM IDProperties are never written to file, hence no need to read/link them here. */
- for (win = wm->windows.first; win; win = win->next) {
- if (win->workspace_hook) { /* NULL for old files */
- lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id);
- }
- win->scene = newlibadr(fd, wm->id.lib, win->scene);
- /* deprecated, but needed for versioning (will be NULL'ed then) */
- win->screen = newlibadr(fd, NULL, win->screen);
+ for (wm = main->wm.first; wm; wm = wm->id.next) {
+ if (wm->id.tag & LIB_TAG_NEED_LINK) {
+ /* Note: WM IDProperties are never written to file, hence no need to read/link them here. */
+ for (win = wm->windows.first; win; win = win->next) {
+ if (win->workspace_hook) { /* NULL for old files */
+ lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id);
+ }
+ win->scene = newlibadr(fd, wm->id.lib, win->scene);
+ /* deprecated, but needed for versioning (will be NULL'ed then) */
+ win->screen = newlibadr(fd, NULL, win->screen);
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
- lib_link_area(fd, &wm->id, area);
- }
- }
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ lib_link_area(fd, &wm->id, area);
+ }
+ }
- wm->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ wm->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/** \} */
@@ -7679,40 +7748,40 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
* check lib pointers in call below */
static void lib_link_screen(FileData *fd, Main *main)
{
- for (bScreen *sc = main->screens.first; sc; sc = sc->id.next) {
- if (sc->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(sc->id.properties, fd);
+ for (bScreen *sc = main->screens.first; sc; sc = sc->id.next) {
+ if (sc->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(sc->id.properties, fd);
- /* deprecated, but needed for versioning (will be NULL'ed then) */
- sc->scene = newlibadr(fd, sc->id.lib, sc->scene);
+ /* deprecated, but needed for versioning (will be NULL'ed then) */
+ sc->scene = newlibadr(fd, sc->id.lib, sc->scene);
- sc->animtimer = NULL; /* saved in rare cases */
- sc->tool_tip = NULL;
- sc->scrubbing = false;
+ sc->animtimer = NULL; /* saved in rare cases */
+ sc->tool_tip = NULL;
+ sc->scrubbing = false;
- for (ScrArea *area = sc->areabase.first; area; area = area->next) {
- lib_link_area(fd, &sc->id, area);
- }
- sc->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ for (ScrArea *area = sc->areabase.first; area; area = area->next) {
+ lib_link_area(fd, &sc->id, area);
+ }
+ sc->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/* how to handle user count on pointer restore */
typedef enum ePointerUserMode {
- USER_IGNORE = 0, /* ignore user count */
- USER_REAL = 1, /* ensure at least one real user (fake user ignored) */
+ USER_IGNORE = 0, /* ignore user count */
+ USER_REAL = 1, /* ensure at least one real user (fake user ignored) */
} ePointerUserMode;
static void restore_pointer_user(ID *id, ID *newid, ePointerUserMode user)
{
- BLI_assert(STREQ(newid->name + 2, id->name + 2));
- BLI_assert(newid->lib == id->lib);
- UNUSED_VARS_NDEBUG(id);
+ BLI_assert(STREQ(newid->name + 2, id->name + 2));
+ BLI_assert(newid->lib == id->lib);
+ UNUSED_VARS_NDEBUG(id);
- if (user == USER_REAL) {
- id_us_ensure_real(newid);
- }
+ if (user == USER_REAL) {
+ id_us_ensure_real(newid);
+ }
}
#ifndef USE_GHASH_RESTORE_POINTER
@@ -7723,22 +7792,22 @@ static void restore_pointer_user(ID *id, ID *newid, ePointerUserMode user)
*/
static void *restore_pointer_by_name_main(Main *mainp, ID *id, ePointerUserMode user)
{
- if (id) {
- ListBase *lb = which_libbase(mainp, GS(id->name));
- if (lb) { /* there's still risk of checking corrupt mem (freed Ids in oops) */
- ID *idn = lb->first;
- for (; idn; idn = idn->next) {
- if (STREQ(idn->name + 2, id->name + 2)) {
- if (idn->lib == id->lib) {
- restore_pointer_user(id, idn, user);
- break;
- }
- }
- }
- return idn;
- }
- }
- return NULL;
+ if (id) {
+ ListBase *lb = which_libbase(mainp, GS(id->name));
+ if (lb) { /* there's still risk of checking corrupt mem (freed Ids in oops) */
+ ID *idn = lb->first;
+ for (; idn; idn = idn->next) {
+ if (STREQ(idn->name + 2, id->name + 2)) {
+ if (idn->lib == id->lib) {
+ restore_pointer_user(id, idn, user);
+ break;
+ }
+ }
+ }
+ return idn;
+ }
+ }
+ return NULL;
}
#endif
@@ -7755,392 +7824,408 @@ static void *restore_pointer_by_name_main(Main *mainp, ID *id, ePointerUserMode
static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user)
{
#ifdef USE_GHASH_RESTORE_POINTER
- if (id) {
- /* use fast lookup when available */
- ID *idn = BKE_main_idmap_lookup_id(id_map, id);
- if (idn) {
- restore_pointer_user(id, idn, user);
- }
- return idn;
- }
- return NULL;
+ if (id) {
+ /* use fast lookup when available */
+ ID *idn = BKE_main_idmap_lookup_id(id_map, id);
+ if (idn) {
+ restore_pointer_user(id, idn, user);
+ }
+ return idn;
+ }
+ return NULL;
#else
- Main *mainp = BKE_main_idmap_main_get(id_map);
- return restore_pointer_by_name_main(mainp, id, user);
+ Main *mainp = BKE_main_idmap_main_get(id_map);
+ return restore_pointer_by_name_main(mainp, id, user);
#endif
}
static void lib_link_seq_clipboard_pt_restore(ID *id, struct IDNameLib_Map *id_map)
{
- if (id) {
- /* clipboard must ensure this */
- BLI_assert(id->newid != NULL);
- id->newid = restore_pointer_by_name(id_map, id->newid, USER_REAL);
- }
+ if (id) {
+ /* clipboard must ensure this */
+ BLI_assert(id->newid != NULL);
+ id->newid = restore_pointer_by_name(id_map, id->newid, USER_REAL);
+ }
}
static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
{
- struct IDNameLib_Map *id_map = arg_pt;
+ struct IDNameLib_Map *id_map = arg_pt;
- lib_link_seq_clipboard_pt_restore((ID *)seq->scene, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->clip, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->mask, id_map);
- lib_link_seq_clipboard_pt_restore((ID *)seq->sound, id_map);
- return 1;
+ lib_link_seq_clipboard_pt_restore((ID *)seq->scene, id_map);
+ lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, id_map);
+ lib_link_seq_clipboard_pt_restore((ID *)seq->clip, id_map);
+ lib_link_seq_clipboard_pt_restore((ID *)seq->mask, id_map);
+ lib_link_seq_clipboard_pt_restore((ID *)seq->sound, id_map);
+ return 1;
}
static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
{
- /* update IDs stored in sequencer clipboard */
- BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
+ /* update IDs stored in sequencer clipboard */
+ BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
}
static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, ViewLayer *view_layer)
{
- bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
-
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- if (v3d->camera == NULL || v3d->scenelock) {
- v3d->camera = scene->camera;
- }
-
- if (v3d->localvd) {
- Base *base = NULL;
-
- v3d->localvd->camera = scene->camera;
-
- /* Localview can become invalid during undo/redo steps, so we exit it when no could be found. */
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if (base->local_view_bits & v3d->local_view_uuid) {
- break;
- }
- }
- if (base == NULL) {
- MEM_freeN(v3d->localvd);
- v3d->localvd = NULL;
- v3d->local_view_uuid = 0;
-
- /* Regionbase storage is different depending if the space is active. */
- ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d = ar->regiondata;
- if (rv3d->localvd) {
- MEM_freeN(rv3d->localvd);
- rv3d->localvd = NULL;
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main *newmain, WorkSpaceLayout *layout)
-{
- bScreen *screen = BKE_workspace_layout_screen_get(layout);
-
- /* avoid conflicts with 2.8x branch */
- {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- ARegion *ar;
-
- v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL);
- v3d->ob_centre = restore_pointer_by_name(id_map, (ID *)v3d->ob_centre, USER_REAL);
-
- /* Free render engines for now. */
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d = ar->regiondata;
- if (rv3d && rv3d->render_engine) {
- RE_engine_free(rv3d->render_engine);
- rv3d->render_engine = NULL;
- }
- }
- }
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- bDopeSheet *ads = sipo->ads;
-
- if (ads) {
- ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
-
- if (ads->filter_grp)
- ads->filter_grp = restore_pointer_by_name(id_map, (ID *)ads->filter_grp, USER_IGNORE);
- }
-
- /* force recalc of list of channels (i.e. includes calculating F-Curve colors)
- * thus preventing the "black curves" problem post-undo
- */
- sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- sbuts->pinid = restore_pointer_by_name(id_map, sbuts->pinid, USER_IGNORE);
- if (sbuts->pinid == NULL) {
- sbuts->flag &= ~SB_PIN_CONTEXT;
- }
-
- /* TODO: restore path pointers: T40046
- * (complicated because this contains data pointers too, not just ID)*/
- MEM_SAFE_FREE(sbuts->path);
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
- sfile->op = NULL;
- sfile->previews_timer = NULL;
- }
- else if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
-
- saction->action = restore_pointer_by_name(id_map, (ID *)saction->action, USER_REAL);
- saction->ads.source = restore_pointer_by_name(id_map, (ID *)saction->ads.source, USER_REAL);
-
- if (saction->ads.filter_grp)
- saction->ads.filter_grp = restore_pointer_by_name(id_map, (ID *)saction->ads.filter_grp, USER_IGNORE);
-
-
- /* force recalc of list of channels, potentially updating the active action
- * while we're at it (as it can only be updated that way) [#28962]
- */
- saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->image = restore_pointer_by_name(id_map, (ID *)sima->image, USER_REAL);
-
- /* this will be freed, not worth attempting to find same scene,
- * since it gets initialized later */
- sima->iuser.scene = NULL;
+ bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ if (v3d->camera == NULL || v3d->scenelock) {
+ v3d->camera = scene->camera;
+ }
+
+ if (v3d->localvd) {
+ Base *base = NULL;
+
+ v3d->localvd->camera = scene->camera;
+
+ /* Localview can become invalid during undo/redo steps, so we exit it when no could be found. */
+ for (base = view_layer->object_bases.first; base; base = base->next) {
+ if (base->local_view_bits & v3d->local_view_uuid) {
+ break;
+ }
+ }
+ if (base == NULL) {
+ MEM_freeN(v3d->localvd);
+ v3d->localvd = NULL;
+ v3d->local_view_uuid = 0;
+
+ /* Regionbase storage is different depending if the space is active. */
+ ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
+ &sl->regionbase;
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d->localvd) {
+ MEM_freeN(rv3d->localvd);
+ rv3d->localvd = NULL;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
+ Main *newmain,
+ WorkSpaceLayout *layout)
+{
+ bScreen *screen = BKE_workspace_layout_screen_get(layout);
+
+ /* avoid conflicts with 2.8x branch */
+ {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ ARegion *ar;
+
+ v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL);
+ v3d->ob_centre = restore_pointer_by_name(id_map, (ID *)v3d->ob_centre, USER_REAL);
+
+ /* Free render engines for now. */
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d && rv3d->render_engine) {
+ RE_engine_free(rv3d->render_engine);
+ rv3d->render_engine = NULL;
+ }
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ bDopeSheet *ads = sipo->ads;
+
+ if (ads) {
+ ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
+
+ if (ads->filter_grp)
+ ads->filter_grp = restore_pointer_by_name(
+ id_map, (ID *)ads->filter_grp, USER_IGNORE);
+ }
+
+ /* force recalc of list of channels (i.e. includes calculating F-Curve colors)
+ * thus preventing the "black curves" problem post-undo
+ */
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
+ }
+ else if (sl->spacetype == SPACE_PROPERTIES) {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+ sbuts->pinid = restore_pointer_by_name(id_map, sbuts->pinid, USER_IGNORE);
+ if (sbuts->pinid == NULL) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
+
+ /* TODO: restore path pointers: T40046
+ * (complicated because this contains data pointers too, not just ID)*/
+ MEM_SAFE_FREE(sbuts->path);
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+ sfile->op = NULL;
+ sfile->previews_timer = NULL;
+ }
+ else if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)sl;
+
+ saction->action = restore_pointer_by_name(id_map, (ID *)saction->action, USER_REAL);
+ saction->ads.source = restore_pointer_by_name(
+ id_map, (ID *)saction->ads.source, USER_REAL);
+
+ if (saction->ads.filter_grp)
+ saction->ads.filter_grp = restore_pointer_by_name(
+ id_map, (ID *)saction->ads.filter_grp, USER_IGNORE);
+
+ /* force recalc of list of channels, potentially updating the active action
+ * while we're at it (as it can only be updated that way) [#28962]
+ */
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->image = restore_pointer_by_name(id_map, (ID *)sima->image, USER_REAL);
+
+ /* this will be freed, not worth attempting to find same scene,
+ * since it gets initialized later */
+ sima->iuser.scene = NULL;
#if 0
- /* Those are allocated and freed by space code, no need to handle them here. */
- MEM_SAFE_FREE(sima->scopes.waveform_1);
- MEM_SAFE_FREE(sima->scopes.waveform_2);
- MEM_SAFE_FREE(sima->scopes.waveform_3);
- MEM_SAFE_FREE(sima->scopes.vecscope);
+ /* Those are allocated and freed by space code, no need to handle them here. */
+ MEM_SAFE_FREE(sima->scopes.waveform_1);
+ MEM_SAFE_FREE(sima->scopes.waveform_2);
+ MEM_SAFE_FREE(sima->scopes.waveform_3);
+ MEM_SAFE_FREE(sima->scopes.vecscope);
#endif
- sima->scopes.ok = 0;
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so assume that here we're doing for undo only...
- */
- sima->gpd = restore_pointer_by_name(id_map, (ID *)sima->gpd, USER_REAL);
- sima->mask_info.mask = restore_pointer_by_name(id_map, (ID *)sima->mask_info.mask, USER_REAL);
- }
- else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so assume that here we're doing for undo only...
- */
- sseq->gpd = restore_pointer_by_name(id_map, (ID *)sseq->gpd, USER_REAL);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
- bDopeSheet *ads = snla->ads;
-
- if (ads) {
- ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
-
- if (ads->filter_grp)
- ads->filter_grp = restore_pointer_by_name(id_map, (ID *)ads->filter_grp, USER_IGNORE);
- }
- }
- else if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText *)sl;
-
- st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_REAL);
- if (st->text == NULL) st->text = newmain->texts.first;
- }
- else if (sl->spacetype == SPACE_SCRIPT) {
- SpaceScript *scpt = (SpaceScript *)sl;
-
- scpt->script = restore_pointer_by_name(id_map, (ID *)scpt->script, USER_REAL);
-
- /*sc->script = NULL; - 2.45 set to null, better re-run the script */
- if (scpt->script) {
- SCRIPT_SET_NULL(scpt->script);
- }
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
-
- so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE);
-
- if (so->treestore) {
- TreeStoreElem *tselem;
- BLI_mempool_iter iter;
-
- BLI_mempool_iternew(so->treestore, &iter);
- while ((tselem = BLI_mempool_iterstep(&iter))) {
- /* Do not try to restore pointers to drivers/sequence/etc., can crash in undo case! */
- if (TSE_IS_REAL_ID(tselem)) {
- tselem->id = restore_pointer_by_name(id_map, tselem->id, USER_IGNORE);
- }
- else {
- tselem->id = NULL;
- }
- }
- if (so->treehash) {
- /* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
- }
- }
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path, *path_next;
- bNodeTree *ntree;
-
- /* node tree can be stored locally in id too, link this first */
- snode->id = restore_pointer_by_name(id_map, snode->id, USER_REAL);
- snode->from = restore_pointer_by_name(id_map, snode->from, USER_IGNORE);
-
- ntree = snode->id ? ntreeFromID(snode->id) : NULL;
- snode->nodetree = ntree ? ntree : restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL);
-
- for (path = snode->treepath.first; path; path = path->next) {
- if (path == snode->treepath.first) {
- /* first nodetree in path is same as snode->nodetree */
- path->nodetree = snode->nodetree;
- }
- else
- path->nodetree = restore_pointer_by_name(id_map, (ID *)path->nodetree, USER_REAL);
-
- if (!path->nodetree)
- break;
- }
-
- /* remaining path entries are invalid, remove */
- for (; path; path = path_next) {
- path_next = path->next;
-
- BLI_remlink(&snode->treepath, path);
- MEM_freeN(path);
- }
-
- /* edittree is just the last in the path,
- * set this directly since the path may have been shortened above */
- if (snode->treepath.last) {
- path = snode->treepath.last;
- snode->edittree = path->nodetree;
- }
- else
- snode->edittree = NULL;
- }
- else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- sclip->clip = restore_pointer_by_name(id_map, (ID *)sclip->clip, USER_REAL);
- sclip->mask_info.mask = restore_pointer_by_name(id_map, (ID *)sclip->mask_info.mask, USER_REAL);
-
- sclip->scopes.ok = 0;
- }
- }
- }
- }
+ sima->scopes.ok = 0;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so assume that here we're doing for undo only...
+ */
+ sima->gpd = restore_pointer_by_name(id_map, (ID *)sima->gpd, USER_REAL);
+ sima->mask_info.mask = restore_pointer_by_name(
+ id_map, (ID *)sima->mask_info.mask, USER_REAL);
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so assume that here we're doing for undo only...
+ */
+ sseq->gpd = restore_pointer_by_name(id_map, (ID *)sseq->gpd, USER_REAL);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+ bDopeSheet *ads = snla->ads;
+
+ if (ads) {
+ ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
+
+ if (ads->filter_grp)
+ ads->filter_grp = restore_pointer_by_name(
+ id_map, (ID *)ads->filter_grp, USER_IGNORE);
+ }
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st = (SpaceText *)sl;
+
+ st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_REAL);
+ if (st->text == NULL)
+ st->text = newmain->texts.first;
+ }
+ else if (sl->spacetype == SPACE_SCRIPT) {
+ SpaceScript *scpt = (SpaceScript *)sl;
+
+ scpt->script = restore_pointer_by_name(id_map, (ID *)scpt->script, USER_REAL);
+
+ /*sc->script = NULL; - 2.45 set to null, better re-run the script */
+ if (scpt->script) {
+ SCRIPT_SET_NULL(scpt->script);
+ }
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+
+ so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE);
+
+ if (so->treestore) {
+ TreeStoreElem *tselem;
+ BLI_mempool_iter iter;
+
+ BLI_mempool_iternew(so->treestore, &iter);
+ while ((tselem = BLI_mempool_iterstep(&iter))) {
+ /* Do not try to restore pointers to drivers/sequence/etc., can crash in undo case! */
+ if (TSE_IS_REAL_ID(tselem)) {
+ tselem->id = restore_pointer_by_name(id_map, tselem->id, USER_IGNORE);
+ }
+ else {
+ tselem->id = NULL;
+ }
+ }
+ if (so->treehash) {
+ /* rebuild hash table, because it depends on ids too */
+ so->storeflag |= SO_TREESTORE_REBUILD;
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path, *path_next;
+ bNodeTree *ntree;
+
+ /* node tree can be stored locally in id too, link this first */
+ snode->id = restore_pointer_by_name(id_map, snode->id, USER_REAL);
+ snode->from = restore_pointer_by_name(id_map, snode->from, USER_IGNORE);
+
+ ntree = snode->id ? ntreeFromID(snode->id) : NULL;
+ snode->nodetree = ntree ?
+ ntree :
+ restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL);
+
+ for (path = snode->treepath.first; path; path = path->next) {
+ if (path == snode->treepath.first) {
+ /* first nodetree in path is same as snode->nodetree */
+ path->nodetree = snode->nodetree;
+ }
+ else
+ path->nodetree = restore_pointer_by_name(id_map, (ID *)path->nodetree, USER_REAL);
+
+ if (!path->nodetree)
+ break;
+ }
+
+ /* remaining path entries are invalid, remove */
+ for (; path; path = path_next) {
+ path_next = path->next;
+
+ BLI_remlink(&snode->treepath, path);
+ MEM_freeN(path);
+ }
+
+ /* edittree is just the last in the path,
+ * set this directly since the path may have been shortened above */
+ if (snode->treepath.last) {
+ path = snode->treepath.last;
+ snode->edittree = path->nodetree;
+ }
+ else
+ snode->edittree = NULL;
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ sclip->clip = restore_pointer_by_name(id_map, (ID *)sclip->clip, USER_REAL);
+ sclip->mask_info.mask = restore_pointer_by_name(
+ id_map, (ID *)sclip->mask_info.mask, USER_REAL);
+
+ sclip->scopes.ok = 0;
+ }
+ }
+ }
+ }
}
/**
* Used to link a file (without UI) to the current UI.
* Note that it assumes the old pointers in UI are still valid, so old Main is not freed.
*/
-void blo_lib_link_restore(Main *oldmain, Main *newmain, wmWindowManager *curwm, Scene *curscene, ViewLayer *cur_view_layer)
+void blo_lib_link_restore(Main *oldmain,
+ Main *newmain,
+ wmWindowManager *curwm,
+ Scene *curscene,
+ ViewLayer *cur_view_layer)
{
- struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain, true, oldmain);
+ struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain, true, oldmain);
- for (WorkSpace *workspace = newmain->workspaces.first; workspace; workspace = workspace->id.next) {
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
+ for (WorkSpace *workspace = newmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
- lib_link_workspace_layout_restore(id_map, newmain, layout);
- }
- }
+ for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ lib_link_workspace_layout_restore(id_map, newmain, layout);
+ }
+ }
- for (wmWindow *win = curwm->windows.first; win; win = win->next) {
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- ID *workspace_id = (ID *)workspace;
- Scene *oldscene = win->scene;
+ for (wmWindow *win = curwm->windows.first; win; win = win->next) {
+ WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
+ ID *workspace_id = (ID *)workspace;
+ Scene *oldscene = win->scene;
- workspace = restore_pointer_by_name(id_map, workspace_id, USER_REAL);
- BKE_workspace_active_set(win->workspace_hook, workspace);
- win->scene = restore_pointer_by_name(id_map, (ID *)win->scene, USER_REAL);
- if (win->scene == NULL) {
- win->scene = curscene;
- }
- if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) {
- STRNCPY(win->view_layer_name, cur_view_layer->name);
- }
- BKE_workspace_active_set(win->workspace_hook, workspace);
+ workspace = restore_pointer_by_name(id_map, workspace_id, USER_REAL);
+ BKE_workspace_active_set(win->workspace_hook, workspace);
+ win->scene = restore_pointer_by_name(id_map, (ID *)win->scene, USER_REAL);
+ if (win->scene == NULL) {
+ win->scene = curscene;
+ }
+ if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) {
+ STRNCPY(win->view_layer_name, cur_view_layer->name);
+ }
+ BKE_workspace_active_set(win->workspace_hook, workspace);
- /* keep cursor location through undo */
- memcpy(&win->scene->cursor, &oldscene->cursor, sizeof(win->scene->cursor));
+ /* keep cursor location through undo */
+ memcpy(&win->scene->cursor, &oldscene->cursor, sizeof(win->scene->cursor));
- lib_link_window_scene_data_restore(win, win->scene, cur_view_layer);
+ lib_link_window_scene_data_restore(win, win->scene, cur_view_layer);
- BLI_assert(win->screen == NULL);
- }
+ BLI_assert(win->screen == NULL);
+ }
- /* update IDs stored in all possible clipboards */
- lib_link_clipboard_restore(id_map);
+ /* update IDs stored in all possible clipboards */
+ lib_link_clipboard_restore(id_map);
- BKE_main_idmap_destroy(id_map);
+ BKE_main_idmap_destroy(id_map);
}
/* for the saved 2.50 files without regiondata */
/* and as patch for 2.48 and older */
void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
{
- ARegion *ar;
+ ARegion *ar;
- for (ar = regions->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW && ar->regiondata == NULL) {
- RegionView3D *rv3d;
+ for (ar = regions->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW && ar->regiondata == NULL) {
+ RegionView3D *rv3d;
- rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
- rv3d->persp = (char)v3d->persp;
- rv3d->view = (char)v3d->view;
- rv3d->dist = v3d->dist;
- copy_v3_v3(rv3d->ofs, v3d->ofs);
- copy_qt_qt(rv3d->viewquat, v3d->viewquat);
- }
- }
+ rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
+ rv3d->persp = (char)v3d->persp;
+ rv3d->view = (char)v3d->view;
+ rv3d->dist = v3d->dist;
+ copy_v3_v3(rv3d->ofs, v3d->ofs);
+ copy_qt_qt(rv3d->viewquat, v3d->viewquat);
+ }
+ }
- /* this was not initialized correct always */
- if (v3d->gridsubdiv == 0)
- v3d->gridsubdiv = 10;
+ /* this was not initialized correct always */
+ if (v3d->gridsubdiv == 0)
+ v3d->gridsubdiv = 10;
}
static bool direct_link_screen(FileData *fd, bScreen *sc)
{
- bool wrong_id = false;
+ bool wrong_id = false;
- sc->regionbase.first = sc->regionbase.last = NULL;
- sc->context = NULL;
- sc->active_region = NULL;
+ sc->regionbase.first = sc->regionbase.last = NULL;
+ sc->context = NULL;
+ sc->active_region = NULL;
- sc->preview = direct_link_preview_image(fd, sc->preview);
+ sc->preview = direct_link_preview_image(fd, sc->preview);
- if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) {
- printf("Error reading Screen %s... removing it.\n", sc->id.name + 2);
- wrong_id = true;
- }
+ if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) {
+ printf("Error reading Screen %s... removing it.\n", sc->id.name + 2);
+ wrong_id = true;
+ }
- return wrong_id;
+ return wrong_id;
}
/** \} */
@@ -8149,90 +8234,91 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
/** \name Read ID: Library
* \{ */
-
static void direct_link_library(FileData *fd, Library *lib, Main *main)
{
- Main *newmain;
+ Main *newmain;
- /* check if the library was already read */
- for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
- if (newmain->curlib) {
- if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
- blo_reportf_wrap(fd->reports, RPT_WARNING,
- TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
- lib->name, lib->filepath);
+ /* check if the library was already read */
+ for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
+ if (newmain->curlib) {
+ if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
+ blo_reportf_wrap(fd->reports,
+ RPT_WARNING,
+ TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
+ lib->name,
+ lib->filepath);
- change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib);
-/* change_link_placeholder_to_real_ID_pointer_fd(fd, lib, newmain->curlib); */
+ change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib);
+ /* change_link_placeholder_to_real_ID_pointer_fd(fd, lib, newmain->curlib); */
- BLI_remlink(&main->libraries, lib);
- MEM_freeN(lib);
+ BLI_remlink(&main->libraries, lib);
+ MEM_freeN(lib);
- /* Now, since Blender always expect **latest** Main pointer from fd->mainlist to be the active library
- * Main pointer, where to add all non-library data-blocks found in file next, we have to switch that
- * 'dupli' found Main to latest position in the list!
- * Otherwise, you get weird disappearing linked data on a rather inconsistent basis.
- * See also T53977 for reproducible case. */
- BLI_remlink(fd->mainlist, newmain);
- BLI_addtail(fd->mainlist, newmain);
+ /* Now, since Blender always expect **latest** Main pointer from fd->mainlist to be the active library
+ * Main pointer, where to add all non-library data-blocks found in file next, we have to switch that
+ * 'dupli' found Main to latest position in the list!
+ * Otherwise, you get weird disappearing linked data on a rather inconsistent basis.
+ * See also T53977 for reproducible case. */
+ BLI_remlink(fd->mainlist, newmain);
+ BLI_addtail(fd->mainlist, newmain);
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- /* make sure we have full path in lib->filepath */
- BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
- BLI_cleanup_path(fd->relabase, lib->filepath);
+ /* make sure we have full path in lib->filepath */
+ BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
+ BLI_cleanup_path(fd->relabase, lib->filepath);
-// printf("direct_link_library: name %s\n", lib->name);
-// printf("direct_link_library: filepath %s\n", lib->filepath);
+ // printf("direct_link_library: name %s\n", lib->name);
+ // printf("direct_link_library: filepath %s\n", lib->filepath);
- lib->packedfile = direct_link_packedfile(fd, lib->packedfile);
+ lib->packedfile = direct_link_packedfile(fd, lib->packedfile);
- /* new main */
- newmain = BKE_main_new();
- BLI_addtail(fd->mainlist, newmain);
- newmain->curlib = lib;
+ /* new main */
+ newmain = BKE_main_new();
+ BLI_addtail(fd->mainlist, newmain);
+ newmain->curlib = lib;
- lib->parent = NULL;
+ lib->parent = NULL;
}
static void lib_link_library(FileData *UNUSED(fd), Main *main)
{
- Library *lib;
- for (lib = main->libraries.first; lib; lib = lib->id.next) {
- id_us_ensure_real(&lib->id);
- }
+ Library *lib;
+ for (lib = main->libraries.first; lib; lib = lib->id.next) {
+ id_us_ensure_real(&lib->id);
+ }
}
/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */
static void fix_relpaths_library(const char *basepath, Main *main)
{
- Library *lib;
- /* BLO_read_from_memory uses a blank filename */
- if (basepath == NULL || basepath[0] == '\0') {
- for (lib = main->libraries.first; lib; lib = lib->id.next) {
- /* when loading a linked lib into a file which has not been saved,
- * there is nothing we can be relative to, so instead we need to make
- * it absolute. This can happen when appending an object with a relative
- * link into an unsaved blend file. See [#27405].
- * The remap relative option will make it relative again on save - campbell */
- if (BLI_path_is_rel(lib->name)) {
- BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
- }
- }
- }
- else {
- for (lib = main->libraries.first; lib; lib = lib->id.next) {
- /* Libraries store both relative and abs paths, recreate relative paths,
- * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
- if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */
- BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
- BLI_path_rel(lib->name, basepath);
- }
- }
- }
+ Library *lib;
+ /* BLO_read_from_memory uses a blank filename */
+ if (basepath == NULL || basepath[0] == '\0') {
+ for (lib = main->libraries.first; lib; lib = lib->id.next) {
+ /* when loading a linked lib into a file which has not been saved,
+ * there is nothing we can be relative to, so instead we need to make
+ * it absolute. This can happen when appending an object with a relative
+ * link into an unsaved blend file. See [#27405].
+ * The remap relative option will make it relative again on save - campbell */
+ if (BLI_path_is_rel(lib->name)) {
+ BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ }
+ }
+ }
+ else {
+ for (lib = main->libraries.first; lib; lib = lib->id.next) {
+ /* Libraries store both relative and abs paths, recreate relative paths,
+ * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
+ if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */
+ BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ BLI_path_rel(lib->name, basepath);
+ }
+ }
+ }
}
/** \} */
@@ -8243,22 +8329,22 @@ static void fix_relpaths_library(const char *basepath, Main *main)
static void lib_link_lightprobe(FileData *fd, Main *main)
{
- for (LightProbe *prb = main->lightprobes.first; prb; prb = prb->id.next) {
- if (prb->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(prb->id.properties, fd);
- lib_link_animdata(fd, &prb->id, prb->adt);
+ for (LightProbe *prb = main->lightprobes.first; prb; prb = prb->id.next) {
+ if (prb->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(prb->id.properties, fd);
+ lib_link_animdata(fd, &prb->id, prb->adt);
- prb->visibility_grp = newlibadr(fd, prb->id.lib, prb->visibility_grp);
+ prb->visibility_grp = newlibadr(fd, prb->id.lib, prb->visibility_grp);
- prb->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ prb->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_lightprobe(FileData *fd, LightProbe *prb)
{
- prb->adt = newdataadr(fd, prb->adt);
- direct_link_animdata(fd, prb->adt);
+ prb->adt = newdataadr(fd, prb->adt);
+ direct_link_animdata(fd, prb->adt);
}
/** \} */
@@ -8269,26 +8355,26 @@ static void direct_link_lightprobe(FileData *fd, LightProbe *prb)
static void lib_link_speaker(FileData *fd, Main *main)
{
- for (Speaker *spk = main->speakers.first; spk; spk = spk->id.next) {
- if (spk->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(spk->id.properties, fd);
- lib_link_animdata(fd, &spk->id, spk->adt);
+ for (Speaker *spk = main->speakers.first; spk; spk = spk->id.next) {
+ if (spk->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(spk->id.properties, fd);
+ lib_link_animdata(fd, &spk->id, spk->adt);
- spk->sound = newlibadr_us(fd, spk->id.lib, spk->sound);
+ spk->sound = newlibadr_us(fd, spk->id.lib, spk->sound);
- spk->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ spk->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_speaker(FileData *fd, Speaker *spk)
{
- spk->adt = newdataadr(fd, spk->adt);
- direct_link_animdata(fd, spk->adt);
+ spk->adt = newdataadr(fd, spk->adt);
+ direct_link_animdata(fd, spk->adt);
#if 0
- spk->sound = newdataadr(fd, spk->sound);
- direct_link_sound(fd, spk->sound);
+ spk->sound = newdataadr(fd, spk->sound);
+ direct_link_sound(fd, spk->sound);
#endif
}
@@ -8300,48 +8386,49 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
static void direct_link_sound(FileData *fd, bSound *sound)
{
- sound->tags = 0;
- sound->handle = NULL;
- sound->playback_handle = NULL;
+ sound->tags = 0;
+ sound->handle = NULL;
+ sound->playback_handle = NULL;
- /* versioning stuff, if there was a cache, then we enable caching: */
- if (sound->cache) {
- sound->flags |= SOUND_FLAGS_CACHING;
- sound->cache = NULL;
- }
+ /* versioning stuff, if there was a cache, then we enable caching: */
+ if (sound->cache) {
+ sound->flags |= SOUND_FLAGS_CACHING;
+ sound->cache = NULL;
+ }
- if (fd->soundmap) {
- sound->waveform = newsoundadr(fd, sound->waveform);
- sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
- }
- else {
- sound->waveform = NULL;
- }
+ if (fd->soundmap) {
+ sound->waveform = newsoundadr(fd, sound->waveform);
+ sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
+ }
+ else {
+ sound->waveform = NULL;
+ }
- if (sound->spinlock) {
- sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
- BLI_spin_init(sound->spinlock);
- }
- /* clear waveform loading flag */
- sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
+ if (sound->spinlock) {
+ sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound->spinlock);
+ }
+ /* clear waveform loading flag */
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
- sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
- sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
+ sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
+ sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
}
static void lib_link_sound(FileData *fd, Main *main)
{
- for (bSound *sound = main->sounds.first; sound; sound = sound->id.next) {
- if (sound->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(sound->id.properties, fd);
+ for (bSound *sound = main->sounds.first; sound; sound = sound->id.next) {
+ if (sound->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(sound->id.properties, fd);
- sound->ipo = newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system
+ sound->ipo = newlibadr_us(
+ fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system
- BKE_sound_load(main, sound);
+ BKE_sound_load(main, sound);
- sound->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ sound->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/** \} */
@@ -8350,124 +8437,126 @@ static void lib_link_sound(FileData *fd, Main *main)
/** \name Read ID: Movie Clip
* \{ */
-static void direct_link_movieReconstruction(FileData *fd, MovieTrackingReconstruction *reconstruction)
+static void direct_link_movieReconstruction(FileData *fd,
+ MovieTrackingReconstruction *reconstruction)
{
- reconstruction->cameras = newdataadr(fd, reconstruction->cameras);
+ reconstruction->cameras = newdataadr(fd, reconstruction->cameras);
}
static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase)
{
- MovieTrackingTrack *track;
+ MovieTrackingTrack *track;
- link_list(fd, tracksbase);
+ link_list(fd, tracksbase);
- for (track = tracksbase->first; track; track = track->next) {
- track->markers = newdataadr(fd, track->markers);
- }
+ for (track = tracksbase->first; track; track = track->next) {
+ track->markers = newdataadr(fd, track->markers);
+ }
}
static void direct_link_moviePlaneTracks(FileData *fd, ListBase *plane_tracks_base)
{
- MovieTrackingPlaneTrack *plane_track;
+ MovieTrackingPlaneTrack *plane_track;
- link_list(fd, plane_tracks_base);
+ link_list(fd, plane_tracks_base);
- for (plane_track = plane_tracks_base->first;
- plane_track;
- plane_track = plane_track->next)
- {
- int i;
+ for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
+ int i;
- plane_track->point_tracks = newdataadr(fd, plane_track->point_tracks);
- test_pointer_array(fd, (void **)&plane_track->point_tracks);
- for (i = 0; i < plane_track->point_tracksnr; i++) {
- plane_track->point_tracks[i] = newdataadr(fd, plane_track->point_tracks[i]);
- }
+ plane_track->point_tracks = newdataadr(fd, plane_track->point_tracks);
+ test_pointer_array(fd, (void **)&plane_track->point_tracks);
+ for (i = 0; i < plane_track->point_tracksnr; i++) {
+ plane_track->point_tracks[i] = newdataadr(fd, plane_track->point_tracks[i]);
+ }
- plane_track->markers = newdataadr(fd, plane_track->markers);
- }
+ plane_track->markers = newdataadr(fd, plane_track->markers);
+ }
}
static void direct_link_movieclip(FileData *fd, MovieClip *clip)
{
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object;
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *object;
- clip->adt = newdataadr(fd, clip->adt);
+ clip->adt = newdataadr(fd, clip->adt);
- if (fd->movieclipmap) clip->cache = newmclipadr(fd, clip->cache);
- else clip->cache = NULL;
+ if (fd->movieclipmap)
+ clip->cache = newmclipadr(fd, clip->cache);
+ else
+ clip->cache = NULL;
- if (fd->movieclipmap) clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
- else clip->tracking.camera.intrinsics = NULL;
+ if (fd->movieclipmap)
+ clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
+ else
+ clip->tracking.camera.intrinsics = NULL;
- direct_link_movieTracks(fd, &tracking->tracks);
- direct_link_moviePlaneTracks(fd, &tracking->plane_tracks);
- direct_link_movieReconstruction(fd, &tracking->reconstruction);
+ direct_link_movieTracks(fd, &tracking->tracks);
+ direct_link_moviePlaneTracks(fd, &tracking->plane_tracks);
+ direct_link_movieReconstruction(fd, &tracking->reconstruction);
- clip->tracking.act_track = newdataadr(fd, clip->tracking.act_track);
- clip->tracking.act_plane_track = newdataadr(fd, clip->tracking.act_plane_track);
+ clip->tracking.act_track = newdataadr(fd, clip->tracking.act_track);
+ clip->tracking.act_plane_track = newdataadr(fd, clip->tracking.act_plane_track);
- clip->anim = NULL;
- clip->tracking_context = NULL;
- clip->tracking.stats = NULL;
+ clip->anim = NULL;
+ clip->tracking_context = NULL;
+ clip->tracking.stats = NULL;
- /* Needed for proper versioning, will be NULL for all newer files anyway. */
- clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track);
+ /* Needed for proper versioning, will be NULL for all newer files anyway. */
+ clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track);
- clip->tracking.dopesheet.ok = 0;
- BLI_listbase_clear(&clip->tracking.dopesheet.channels);
- BLI_listbase_clear(&clip->tracking.dopesheet.coverage_segments);
+ clip->tracking.dopesheet.ok = 0;
+ BLI_listbase_clear(&clip->tracking.dopesheet.channels);
+ BLI_listbase_clear(&clip->tracking.dopesheet.coverage_segments);
- link_list(fd, &tracking->objects);
+ link_list(fd, &tracking->objects);
- for (object = tracking->objects.first; object; object = object->next) {
- direct_link_movieTracks(fd, &object->tracks);
- direct_link_moviePlaneTracks(fd, &object->plane_tracks);
- direct_link_movieReconstruction(fd, &object->reconstruction);
- }
+ for (object = tracking->objects.first; object; object = object->next) {
+ direct_link_movieTracks(fd, &object->tracks);
+ direct_link_moviePlaneTracks(fd, &object->plane_tracks);
+ direct_link_movieReconstruction(fd, &object->reconstruction);
+ }
}
static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase)
{
- MovieTrackingTrack *track;
+ MovieTrackingTrack *track;
- for (track = tracksbase->first; track; track = track->next) {
- track->gpd = newlibadr_us(fd, clip->id.lib, track->gpd);
- }
+ for (track = tracksbase->first; track; track = track->next) {
+ track->gpd = newlibadr_us(fd, clip->id.lib, track->gpd);
+ }
}
static void lib_link_moviePlaneTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase)
{
- MovieTrackingPlaneTrack *plane_track;
+ MovieTrackingPlaneTrack *plane_track;
- for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) {
- plane_track->image = newlibadr_us(fd, clip->id.lib, plane_track->image);
- }
+ for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) {
+ plane_track->image = newlibadr_us(fd, clip->id.lib, plane_track->image);
+ }
}
static void lib_link_movieclip(FileData *fd, Main *main)
{
- for (MovieClip *clip = main->movieclips.first; clip; clip = clip->id.next) {
- if (clip->id.tag & LIB_TAG_NEED_LINK) {
- MovieTracking *tracking = &clip->tracking;
+ for (MovieClip *clip = main->movieclips.first; clip; clip = clip->id.next) {
+ if (clip->id.tag & LIB_TAG_NEED_LINK) {
+ MovieTracking *tracking = &clip->tracking;
- IDP_LibLinkProperty(clip->id.properties, fd);
- lib_link_animdata(fd, &clip->id, clip->adt);
+ IDP_LibLinkProperty(clip->id.properties, fd);
+ lib_link_animdata(fd, &clip->id, clip->adt);
- clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd);
+ clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd);
- lib_link_movieTracks(fd, clip, &tracking->tracks);
- lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks);
+ lib_link_movieTracks(fd, clip, &tracking->tracks);
+ lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks);
- for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) {
- lib_link_movieTracks(fd, clip, &object->tracks);
- lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks);
- }
+ for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) {
+ lib_link_movieTracks(fd, clip, &object->tracks);
+ lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks);
+ }
- clip->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ clip->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/** \} */
@@ -8478,97 +8567,95 @@ static void lib_link_movieclip(FileData *fd, Main *main)
static void direct_link_mask(FileData *fd, Mask *mask)
{
- MaskLayer *masklay;
-
- mask->adt = newdataadr(fd, mask->adt);
+ MaskLayer *masklay;
- link_list(fd, &mask->masklayers);
+ mask->adt = newdataadr(fd, mask->adt);
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- MaskLayerShape *masklay_shape;
+ link_list(fd, &mask->masklayers);
- /* can't use newdataadr since it's a pointer within an array */
- MaskSplinePoint *act_point_search = NULL;
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+ MaskLayerShape *masklay_shape;
- link_list(fd, &masklay->splines);
+ /* can't use newdataadr since it's a pointer within an array */
+ MaskSplinePoint *act_point_search = NULL;
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- MaskSplinePoint *points_old = spline->points;
- int i;
+ link_list(fd, &masklay->splines);
- spline->points = newdataadr(fd, spline->points);
+ for (spline = masklay->splines.first; spline; spline = spline->next) {
+ MaskSplinePoint *points_old = spline->points;
+ int i;
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point = &spline->points[i];
+ spline->points = newdataadr(fd, spline->points);
- if (point->tot_uw)
- point->uw = newdataadr(fd, point->uw);
- }
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
- /* detect active point */
- if ((act_point_search == NULL) &&
- (masklay->act_point >= points_old) &&
- (masklay->act_point < points_old + spline->tot_point))
- {
- act_point_search = &spline->points[masklay->act_point - points_old];
- }
- }
+ if (point->tot_uw)
+ point->uw = newdataadr(fd, point->uw);
+ }
- link_list(fd, &masklay->splines_shapes);
+ /* detect active point */
+ if ((act_point_search == NULL) && (masklay->act_point >= points_old) &&
+ (masklay->act_point < points_old + spline->tot_point)) {
+ act_point_search = &spline->points[masklay->act_point - points_old];
+ }
+ }
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
- masklay_shape->data = newdataadr(fd, masklay_shape->data);
+ link_list(fd, &masklay->splines_shapes);
- if (masklay_shape->tot_vert) {
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- BLI_endian_switch_float_array(
- masklay_shape->data,
- masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE);
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
+ masklay_shape = masklay_shape->next) {
+ masklay_shape->data = newdataadr(fd, masklay_shape->data);
- }
- }
- }
+ if (masklay_shape->tot_vert) {
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array(masklay_shape->data,
+ masklay_shape->tot_vert * sizeof(float) *
+ MASK_OBJECT_SHAPE_ELEM_SIZE);
+ }
+ }
+ }
- masklay->act_spline = newdataadr(fd, masklay->act_spline);
- masklay->act_point = act_point_search;
- }
+ masklay->act_spline = newdataadr(fd, masklay->act_spline);
+ masklay->act_point = act_point_search;
+ }
}
static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
{
- parent->id = newlibadr_us(fd, mask->id.lib, parent->id);
+ parent->id = newlibadr_us(fd, mask->id.lib, parent->id);
}
static void lib_link_mask(FileData *fd, Main *main)
{
- for (Mask *mask = main->masks.first; mask; mask = mask->id.next) {
- if (mask->id.tag & LIB_TAG_NEED_LINK) {
- IDP_LibLinkProperty(mask->id.properties, fd);
- lib_link_animdata(fd, &mask->id, mask->adt);
+ for (Mask *mask = main->masks.first; mask; mask = mask->id.next) {
+ if (mask->id.tag & LIB_TAG_NEED_LINK) {
+ IDP_LibLinkProperty(mask->id.properties, fd);
+ lib_link_animdata(fd, &mask->id, mask->adt);
- for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
+ for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
- spline = masklay->splines.first;
- while (spline) {
- int i;
+ spline = masklay->splines.first;
+ while (spline) {
+ int i;
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point = &spline->points[i];
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
- lib_link_mask_parent(fd, mask, &point->parent);
- }
+ lib_link_mask_parent(fd, mask, &point->parent);
+ }
- lib_link_mask_parent(fd, mask, &spline->parent);
+ lib_link_mask_parent(fd, mask, &spline->parent);
- spline = spline->next;
- }
- }
+ spline = spline->next;
+ }
+ }
- mask->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ mask->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
/* ************ READ LINE STYLE ***************** */
@@ -8581,267 +8668,254 @@ static void lib_link_mask(FileData *fd, Main *main)
static void lib_link_linestyle(FileData *fd, Main *main)
{
- for (FreestyleLineStyle *linestyle = main->linestyles.first; linestyle; linestyle = linestyle->id.next) {
- if (linestyle->id.tag & LIB_TAG_NEED_LINK) {
- LineStyleModifier *m;
-
- IDP_LibLinkProperty(linestyle->id.properties, fd);
- lib_link_animdata(fd, &linestyle->id, linestyle->adt);
-
- for (m = linestyle->color_modifiers.first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
- cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
- break;
- }
- }
- }
- for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
- am->target = newlibadr(fd, linestyle->id.lib, am->target);
- break;
- }
- }
- }
- for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
- tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
- break;
- }
- }
- }
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = linestyle->mtex[a];
- if (mtex) {
- mtex->tex = newlibadr_us(fd, linestyle->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object);
- }
- }
- if (linestyle->nodetree) {
- lib_link_ntree(fd, &linestyle->id, linestyle->nodetree);
- linestyle->nodetree->id.lib = linestyle->id.lib;
- }
-
- linestyle->id.tag &= ~LIB_TAG_NEED_LINK;
- }
- }
+ for (FreestyleLineStyle *linestyle = main->linestyles.first; linestyle;
+ linestyle = linestyle->id.next) {
+ if (linestyle->id.tag & LIB_TAG_NEED_LINK) {
+ LineStyleModifier *m;
+
+ IDP_LibLinkProperty(linestyle->id.properties, fd);
+ lib_link_animdata(fd, &linestyle->id, linestyle->adt);
+
+ for (m = linestyle->color_modifiers.first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleColorModifier_DistanceFromObject *cm =
+ (LineStyleColorModifier_DistanceFromObject *)m;
+ cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
+ break;
+ }
+ }
+ }
+ for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleAlphaModifier_DistanceFromObject *am =
+ (LineStyleAlphaModifier_DistanceFromObject *)m;
+ am->target = newlibadr(fd, linestyle->id.lib, am->target);
+ break;
+ }
+ }
+ }
+ for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleThicknessModifier_DistanceFromObject *tm =
+ (LineStyleThicknessModifier_DistanceFromObject *)m;
+ tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
+ break;
+ }
+ }
+ }
+ for (int a = 0; a < MAX_MTEX; a++) {
+ MTex *mtex = linestyle->mtex[a];
+ if (mtex) {
+ mtex->tex = newlibadr_us(fd, linestyle->id.lib, mtex->tex);
+ mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object);
+ }
+ }
+ if (linestyle->nodetree) {
+ lib_link_ntree(fd, &linestyle->id, linestyle->nodetree);
+ linestyle->nodetree->id.lib = linestyle->id.lib;
+ }
+
+ linestyle->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
}
static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier)
{
- switch (modifier->type) {
- case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_MATERIAL:
- {
- LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_TANGENT:
- {
- LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_NOISE:
- {
- LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- break;
- }
- }
+ switch (modifier->type) {
+ case LS_MODIFIER_ALONG_STROKE: {
+ LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA: {
+ LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)
+ modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)
+ modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_MATERIAL: {
+ LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_TANGENT: {
+ LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_NOISE: {
+ LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_CREASE_ANGLE: {
+ LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ case LS_MODIFIER_CURVATURE_3D: {
+ LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
+ break;
+ }
+ }
}
static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier *modifier)
{
- switch (modifier->type) {
- case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_MATERIAL:
- {
- LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_TANGENT:
- {
- LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_NOISE:
- {
- LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- }
+ switch (modifier->type) {
+ case LS_MODIFIER_ALONG_STROKE: {
+ LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA: {
+ LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)
+ modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)
+ modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_MATERIAL: {
+ LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_TANGENT: {
+ LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_NOISE: {
+ LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_CREASE_ANGLE: {
+ LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_CURVATURE_3D: {
+ LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ }
}
static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModifier *modifier)
{
- switch (modifier->type) {
- case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_MATERIAL:
- {
- LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_TANGENT:
- {
- LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- break;
- }
- }
-}
-
-static void direct_link_linestyle_geometry_modifier(FileData *UNUSED(fd), LineStyleModifier *UNUSED(modifier))
+ switch (modifier->type) {
+ case LS_MODIFIER_ALONG_STROKE: {
+ LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)
+ modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA: {
+ LineStyleThicknessModifier_DistanceFromCamera *m =
+ (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
+ LineStyleThicknessModifier_DistanceFromObject *m =
+ (LineStyleThicknessModifier_DistanceFromObject *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_MATERIAL: {
+ LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_TANGENT: {
+ LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_CREASE_ANGLE: {
+ LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)
+ modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ case LS_MODIFIER_CURVATURE_3D: {
+ LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)
+ modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
+ break;
+ }
+ }
+}
+
+static void direct_link_linestyle_geometry_modifier(FileData *UNUSED(fd),
+ LineStyleModifier *UNUSED(modifier))
{
}
static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
{
- int a;
- LineStyleModifier *modifier;
-
- linestyle->adt = newdataadr(fd, linestyle->adt);
- direct_link_animdata(fd, linestyle->adt);
- link_list(fd, &linestyle->color_modifiers);
- for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next)
- direct_link_linestyle_color_modifier(fd, modifier);
- link_list(fd, &linestyle->alpha_modifiers);
- for (modifier = linestyle->alpha_modifiers.first; modifier; modifier = modifier->next)
- direct_link_linestyle_alpha_modifier(fd, modifier);
- link_list(fd, &linestyle->thickness_modifiers);
- for (modifier = linestyle->thickness_modifiers.first; modifier; modifier = modifier->next)
- direct_link_linestyle_thickness_modifier(fd, modifier);
- link_list(fd, &linestyle->geometry_modifiers);
- for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next)
- direct_link_linestyle_geometry_modifier(fd, modifier);
- for (a = 0; a < MAX_MTEX; a++) {
- linestyle->mtex[a] = newdataadr(fd, linestyle->mtex[a]);
- }
- linestyle->nodetree = newdataadr(fd, linestyle->nodetree);
- if (linestyle->nodetree) {
- direct_link_id(fd, &linestyle->nodetree->id);
- direct_link_nodetree(fd, linestyle->nodetree);
- }
+ int a;
+ LineStyleModifier *modifier;
+
+ linestyle->adt = newdataadr(fd, linestyle->adt);
+ direct_link_animdata(fd, linestyle->adt);
+ link_list(fd, &linestyle->color_modifiers);
+ for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next)
+ direct_link_linestyle_color_modifier(fd, modifier);
+ link_list(fd, &linestyle->alpha_modifiers);
+ for (modifier = linestyle->alpha_modifiers.first; modifier; modifier = modifier->next)
+ direct_link_linestyle_alpha_modifier(fd, modifier);
+ link_list(fd, &linestyle->thickness_modifiers);
+ for (modifier = linestyle->thickness_modifiers.first; modifier; modifier = modifier->next)
+ direct_link_linestyle_thickness_modifier(fd, modifier);
+ link_list(fd, &linestyle->geometry_modifiers);
+ for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next)
+ direct_link_linestyle_geometry_modifier(fd, modifier);
+ for (a = 0; a < MAX_MTEX; a++) {
+ linestyle->mtex[a] = newdataadr(fd, linestyle->mtex[a]);
+ }
+ linestyle->nodetree = newdataadr(fd, linestyle->nodetree);
+ if (linestyle->nodetree) {
+ direct_link_id(fd, &linestyle->nodetree->id);
+ direct_link_nodetree(fd, linestyle->nodetree);
+ }
}
/* ************** GENERAL & MAIN ******************** */
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -8850,308 +8924,346 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
static const char *dataname(short id_code)
{
- switch (id_code) {
- case ID_OB: return "Data from OB";
- case ID_ME: return "Data from ME";
- case ID_IP: return "Data from IP";
- case ID_SCE: return "Data from SCE";
- case ID_MA: return "Data from MA";
- case ID_TE: return "Data from TE";
- case ID_CU: return "Data from CU";
- case ID_GR: return "Data from GR";
- case ID_AR: return "Data from AR";
- case ID_AC: return "Data from AC";
- case ID_LI: return "Data from LI";
- case ID_MB: return "Data from MB";
- case ID_IM: return "Data from IM";
- case ID_LT: return "Data from LT";
- case ID_LA: return "Data from LA";
- case ID_CA: return "Data from CA";
- case ID_KE: return "Data from KE";
- case ID_WO: return "Data from WO";
- case ID_SCR: return "Data from SCR";
- case ID_VF: return "Data from VF";
- case ID_TXT: return "Data from TXT";
- case ID_SPK: return "Data from SPK";
- case ID_LP: return "Data from LP";
- case ID_SO: return "Data from SO";
- case ID_NT: return "Data from NT";
- case ID_BR: return "Data from BR";
- case ID_PA: return "Data from PA";
- case ID_PAL: return "Data from PAL";
- case ID_PC: return "Data from PCRV";
- case ID_GD: return "Data from GD";
- case ID_WM: return "Data from WM";
- case ID_MC: return "Data from MC";
- case ID_MSK: return "Data from MSK";
- case ID_LS: return "Data from LS";
- case ID_CF: return "Data from CF";
- case ID_WS: return "Data from WS";
- }
- return "Data from Lib Block";
-
+ switch (id_code) {
+ case ID_OB:
+ return "Data from OB";
+ case ID_ME:
+ return "Data from ME";
+ case ID_IP:
+ return "Data from IP";
+ case ID_SCE:
+ return "Data from SCE";
+ case ID_MA:
+ return "Data from MA";
+ case ID_TE:
+ return "Data from TE";
+ case ID_CU:
+ return "Data from CU";
+ case ID_GR:
+ return "Data from GR";
+ case ID_AR:
+ return "Data from AR";
+ case ID_AC:
+ return "Data from AC";
+ case ID_LI:
+ return "Data from LI";
+ case ID_MB:
+ return "Data from MB";
+ case ID_IM:
+ return "Data from IM";
+ case ID_LT:
+ return "Data from LT";
+ case ID_LA:
+ return "Data from LA";
+ case ID_CA:
+ return "Data from CA";
+ case ID_KE:
+ return "Data from KE";
+ case ID_WO:
+ return "Data from WO";
+ case ID_SCR:
+ return "Data from SCR";
+ case ID_VF:
+ return "Data from VF";
+ case ID_TXT:
+ return "Data from TXT";
+ case ID_SPK:
+ return "Data from SPK";
+ case ID_LP:
+ return "Data from LP";
+ case ID_SO:
+ return "Data from SO";
+ case ID_NT:
+ return "Data from NT";
+ case ID_BR:
+ return "Data from BR";
+ case ID_PA:
+ return "Data from PA";
+ case ID_PAL:
+ return "Data from PAL";
+ case ID_PC:
+ return "Data from PCRV";
+ case ID_GD:
+ return "Data from GD";
+ case ID_WM:
+ return "Data from WM";
+ case ID_MC:
+ return "Data from MC";
+ case ID_MSK:
+ return "Data from MSK";
+ case ID_LS:
+ return "Data from LS";
+ case ID_CF:
+ return "Data from CF";
+ case ID_WS:
+ return "Data from WS";
+ }
+ return "Data from Lib Block";
}
static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *allocname)
{
- bhead = blo_bhead_next(fd, bhead);
+ bhead = blo_bhead_next(fd, bhead);
- while (bhead && bhead->code == DATA) {
- void *data;
+ while (bhead && bhead->code == DATA) {
+ void *data;
#if 0
- /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
- short *sp = fd->filesdna->structs[bhead->SDNAnr];
- char *tmp = malloc(100);
- allocname = fd->filesdna->types[sp[0]];
- strcpy(tmp, allocname);
- data = read_struct(fd, bhead, tmp);
+ /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
+ short *sp = fd->filesdna->structs[bhead->SDNAnr];
+ char *tmp = malloc(100);
+ allocname = fd->filesdna->types[sp[0]];
+ strcpy(tmp, allocname);
+ data = read_struct(fd, bhead, tmp);
#else
- data = read_struct(fd, bhead, allocname);
+ data = read_struct(fd, bhead, allocname);
#endif
- if (data) {
- oldnewmap_insert(fd->datamap, bhead->old, data, 0);
- }
+ if (data) {
+ oldnewmap_insert(fd->datamap, bhead->old, data, 0);
+ }
- bhead = blo_bhead_next(fd, bhead);
- }
+ bhead = blo_bhead_next(fd, bhead);
+ }
- return bhead;
+ return bhead;
}
static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int tag, ID **r_id)
{
- /* this routine reads a libblock and its direct data. Use link functions to connect it all
- */
- ID *id;
- ListBase *lb;
- const char *allocname;
- bool wrong_id = false;
-
- /* In undo case, most libs and linked data should be kept as is from previous state (see BLO_read_from_memfile).
- * However, some needed by the snapshot being read may have been removed in previous one, and would go missing.
- * This leads e.g. to disappearing objects in some undo/redo case, see T34446.
- * That means we have to carefully check whether current lib or libdata already exits in old main, if it does
- * we merely copy it over into new main area, otherwise we have to do a full read of that bhead... */
- if (fd->memfile && ELEM(bhead->code, ID_LI, ID_LINK_PLACEHOLDER)) {
- const char *idname = blo_bhead_id_name(fd, bhead);
-
- DEBUG_PRINTF("Checking %s...\n", idname);
-
- if (bhead->code == ID_LI) {
- Main *libmain = fd->old_mainlist->first;
- /* Skip oldmain itself... */
- for (libmain = libmain->next; libmain; libmain = libmain->next) {
- DEBUG_PRINTF("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>");
- if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) {
- Main *oldmain = fd->old_mainlist->first;
- DEBUG_PRINTF("FOUND!\n");
- /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later
- * a missing ID_LINK_PLACEHOLDER, we need to get the correct lib it is linked to!
- * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */
- BLI_remlink(fd->old_mainlist, libmain);
- BLI_remlink_safe(&oldmain->libraries, libmain->curlib);
- BLI_addtail(fd->mainlist, libmain);
- BLI_addtail(&main->libraries, libmain->curlib);
-
- if (r_id) {
- *r_id = NULL; /* Just in case... */
- }
- return blo_bhead_next(fd, bhead);
- }
- DEBUG_PRINTF("nothing...\n");
- }
- }
- else {
- DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>");
- if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
- DEBUG_PRINTF("FOUND!\n");
- /* Even though we found our linked ID, there is no guarantee its address is still the same... */
- if (id != bhead->old) {
- oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name));
- }
-
- /* No need to do anything else for ID_LINK_PLACEHOLDER, it's assumed already present in its lib's main... */
- if (r_id) {
- *r_id = NULL; /* Just in case... */
- }
- return blo_bhead_next(fd, bhead);
- }
- DEBUG_PRINTF("nothing...\n");
- }
- }
-
- /* read libblock */
- id = read_struct(fd, bhead, "lib block");
-
- if (id) {
- const short idcode = GS(id->name);
- /* do after read_struct, for dna reconstruct */
- lb = which_libbase(main, idcode);
- if (lb) {
- oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_LINK_PLACEHOLDER check */
- BLI_addtail(lb, id);
- }
- else {
- /* unknown ID type */
- printf("%s: unknown id code '%c%c'\n", __func__, (idcode & 0xff), (idcode >> 8));
- MEM_freeN(id);
- id = NULL;
- }
- }
-
- if (r_id)
- *r_id = id;
- if (!id)
- return blo_bhead_next(fd, bhead);
-
- id->lib = main->curlib;
- id->us = ID_FAKE_USERS(id);
- id->icon_id = 0;
- id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */
- id->orig_id = NULL;
- id->recalc = 0;
-
- /* this case cannot be direct_linked: it's just the ID part */
- if (bhead->code == ID_LINK_PLACEHOLDER) {
- /* That way, we know which datablock needs do_versions (required currently for linking). */
- id->tag = tag | LIB_TAG_NEED_LINK | LIB_TAG_NEW;
-
- return blo_bhead_next(fd, bhead);
- }
-
- /* need a name for the mallocN, just for debugging and sane prints on leaks */
- allocname = dataname(GS(id->name));
-
- /* read all data into fd->datamap */
- bhead = read_data_into_oldnewmap(fd, bhead, allocname);
-
- /* init pointers direct data */
- direct_link_id(fd, id);
-
- /* That way, we know which datablock needs do_versions (required currently for linking). */
- /* Note: doing this after driect_link_id(), which resets that field. */
- id->tag = tag | LIB_TAG_NEED_LINK | LIB_TAG_NEW;
-
- switch (GS(id->name)) {
- case ID_WM:
- direct_link_windowmanager(fd, (wmWindowManager *)id);
- break;
- case ID_SCR:
- wrong_id = direct_link_screen(fd, (bScreen *)id);
- break;
- case ID_SCE:
- direct_link_scene(fd, (Scene *)id);
- break;
- case ID_OB:
- direct_link_object(fd, (Object *)id);
- break;
- case ID_ME:
- direct_link_mesh(fd, (Mesh *)id);
- break;
- case ID_CU:
- direct_link_curve(fd, (Curve *)id);
- break;
- case ID_MB:
- direct_link_mball(fd, (MetaBall *)id);
- break;
- case ID_MA:
- direct_link_material(fd, (Material *)id);
- break;
- case ID_TE:
- direct_link_texture(fd, (Tex *)id);
- break;
- case ID_IM:
- direct_link_image(fd, (Image *)id);
- break;
- case ID_LA:
- direct_link_light(fd, (Light *)id);
- break;
- case ID_VF:
- direct_link_vfont(fd, (VFont *)id);
- break;
- case ID_TXT:
- direct_link_text(fd, (Text *)id);
- break;
- case ID_IP:
- direct_link_ipo(fd, (Ipo *)id);
- break;
- case ID_KE:
- direct_link_key(fd, (Key *)id);
- break;
- case ID_LT:
- direct_link_latt(fd, (Lattice *)id);
- break;
- case ID_WO:
- direct_link_world(fd, (World *)id);
- break;
- case ID_LI:
- direct_link_library(fd, (Library *)id, main);
- break;
- case ID_CA:
- direct_link_camera(fd, (Camera *)id);
- break;
- case ID_SPK:
- direct_link_speaker(fd, (Speaker *)id);
- break;
- case ID_SO:
- direct_link_sound(fd, (bSound *)id);
- break;
- case ID_LP:
- direct_link_lightprobe(fd, (LightProbe *)id);
- break;
- case ID_GR:
- direct_link_collection(fd, (Collection *)id);
- break;
- case ID_AR:
- direct_link_armature(fd, (bArmature *)id);
- break;
- case ID_AC:
- direct_link_action(fd, (bAction *)id);
- break;
- case ID_NT:
- direct_link_nodetree(fd, (bNodeTree *)id);
- break;
- case ID_BR:
- direct_link_brush(fd, (Brush *)id);
- break;
- case ID_PA:
- direct_link_particlesettings(fd, (ParticleSettings *)id);
- break;
- case ID_GD:
- direct_link_gpencil(fd, (bGPdata *)id);
- break;
- case ID_MC:
- direct_link_movieclip(fd, (MovieClip *)id);
- break;
- case ID_MSK:
- direct_link_mask(fd, (Mask *)id);
- break;
- case ID_LS:
- direct_link_linestyle(fd, (FreestyleLineStyle *)id);
- break;
- case ID_PAL:
- direct_link_palette(fd, (Palette *)id);
- break;
- case ID_PC:
- direct_link_paint_curve(fd, (PaintCurve *)id);
- break;
- case ID_CF:
- direct_link_cachefile(fd, (CacheFile *)id);
- break;
- case ID_WS:
- direct_link_workspace(fd, (WorkSpace *)id, main);
- break;
- }
-
- oldnewmap_free_unused(fd->datamap);
- oldnewmap_clear(fd->datamap);
-
- if (wrong_id) {
- BKE_id_free(main, id);
- }
-
- return (bhead);
+ /* this routine reads a libblock and its direct data. Use link functions to connect it all
+ */
+ ID *id;
+ ListBase *lb;
+ const char *allocname;
+ bool wrong_id = false;
+
+ /* In undo case, most libs and linked data should be kept as is from previous state (see BLO_read_from_memfile).
+ * However, some needed by the snapshot being read may have been removed in previous one, and would go missing.
+ * This leads e.g. to disappearing objects in some undo/redo case, see T34446.
+ * That means we have to carefully check whether current lib or libdata already exits in old main, if it does
+ * we merely copy it over into new main area, otherwise we have to do a full read of that bhead... */
+ if (fd->memfile && ELEM(bhead->code, ID_LI, ID_LINK_PLACEHOLDER)) {
+ const char *idname = blo_bhead_id_name(fd, bhead);
+
+ DEBUG_PRINTF("Checking %s...\n", idname);
+
+ if (bhead->code == ID_LI) {
+ Main *libmain = fd->old_mainlist->first;
+ /* Skip oldmain itself... */
+ for (libmain = libmain->next; libmain; libmain = libmain->next) {
+ DEBUG_PRINTF("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>");
+ if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) {
+ Main *oldmain = fd->old_mainlist->first;
+ DEBUG_PRINTF("FOUND!\n");
+ /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later
+ * a missing ID_LINK_PLACEHOLDER, we need to get the correct lib it is linked to!
+ * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */
+ BLI_remlink(fd->old_mainlist, libmain);
+ BLI_remlink_safe(&oldmain->libraries, libmain->curlib);
+ BLI_addtail(fd->mainlist, libmain);
+ BLI_addtail(&main->libraries, libmain->curlib);
+
+ if (r_id) {
+ *r_id = NULL; /* Just in case... */
+ }
+ return blo_bhead_next(fd, bhead);
+ }
+ DEBUG_PRINTF("nothing...\n");
+ }
+ }
+ else {
+ DEBUG_PRINTF("... in %s (%s): ",
+ main->curlib ? main->curlib->id.name : "<NULL>",
+ main->curlib ? main->curlib->name : "<NULL>");
+ if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
+ DEBUG_PRINTF("FOUND!\n");
+ /* Even though we found our linked ID, there is no guarantee its address is still the same... */
+ if (id != bhead->old) {
+ oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name));
+ }
+
+ /* No need to do anything else for ID_LINK_PLACEHOLDER, it's assumed already present in its lib's main... */
+ if (r_id) {
+ *r_id = NULL; /* Just in case... */
+ }
+ return blo_bhead_next(fd, bhead);
+ }
+ DEBUG_PRINTF("nothing...\n");
+ }
+ }
+
+ /* read libblock */
+ id = read_struct(fd, bhead, "lib block");
+
+ if (id) {
+ const short idcode = GS(id->name);
+ /* do after read_struct, for dna reconstruct */
+ lb = which_libbase(main, idcode);
+ if (lb) {
+ oldnewmap_insert(
+ fd->libmap, bhead->old, id, bhead->code); /* for ID_LINK_PLACEHOLDER check */
+ BLI_addtail(lb, id);
+ }
+ else {
+ /* unknown ID type */
+ printf("%s: unknown id code '%c%c'\n", __func__, (idcode & 0xff), (idcode >> 8));
+ MEM_freeN(id);
+ id = NULL;
+ }
+ }
+
+ if (r_id)
+ *r_id = id;
+ if (!id)
+ return blo_bhead_next(fd, bhead);
+
+ id->lib = main->curlib;
+ id->us = ID_FAKE_USERS(id);
+ id->icon_id = 0;
+ id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */
+ id->orig_id = NULL;
+ id->recalc = 0;
+
+ /* this case cannot be direct_linked: it's just the ID part */
+ if (bhead->code == ID_LINK_PLACEHOLDER) {
+ /* That way, we know which datablock needs do_versions (required currently for linking). */
+ id->tag = tag | LIB_TAG_NEED_LINK | LIB_TAG_NEW;
+
+ return blo_bhead_next(fd, bhead);
+ }
+
+ /* need a name for the mallocN, just for debugging and sane prints on leaks */
+ allocname = dataname(GS(id->name));
+
+ /* read all data into fd->datamap */
+ bhead = read_data_into_oldnewmap(fd, bhead, allocname);
+
+ /* init pointers direct data */
+ direct_link_id(fd, id);
+
+ /* That way, we know which datablock needs do_versions (required currently for linking). */
+ /* Note: doing this after driect_link_id(), which resets that field. */
+ id->tag = tag | LIB_TAG_NEED_LINK | LIB_TAG_NEW;
+
+ switch (GS(id->name)) {
+ case ID_WM:
+ direct_link_windowmanager(fd, (wmWindowManager *)id);
+ break;
+ case ID_SCR:
+ wrong_id = direct_link_screen(fd, (bScreen *)id);
+ break;
+ case ID_SCE:
+ direct_link_scene(fd, (Scene *)id);
+ break;
+ case ID_OB:
+ direct_link_object(fd, (Object *)id);
+ break;
+ case ID_ME:
+ direct_link_mesh(fd, (Mesh *)id);
+ break;
+ case ID_CU:
+ direct_link_curve(fd, (Curve *)id);
+ break;
+ case ID_MB:
+ direct_link_mball(fd, (MetaBall *)id);
+ break;
+ case ID_MA:
+ direct_link_material(fd, (Material *)id);
+ break;
+ case ID_TE:
+ direct_link_texture(fd, (Tex *)id);
+ break;
+ case ID_IM:
+ direct_link_image(fd, (Image *)id);
+ break;
+ case ID_LA:
+ direct_link_light(fd, (Light *)id);
+ break;
+ case ID_VF:
+ direct_link_vfont(fd, (VFont *)id);
+ break;
+ case ID_TXT:
+ direct_link_text(fd, (Text *)id);
+ break;
+ case ID_IP:
+ direct_link_ipo(fd, (Ipo *)id);
+ break;
+ case ID_KE:
+ direct_link_key(fd, (Key *)id);
+ break;
+ case ID_LT:
+ direct_link_latt(fd, (Lattice *)id);
+ break;
+ case ID_WO:
+ direct_link_world(fd, (World *)id);
+ break;
+ case ID_LI:
+ direct_link_library(fd, (Library *)id, main);
+ break;
+ case ID_CA:
+ direct_link_camera(fd, (Camera *)id);
+ break;
+ case ID_SPK:
+ direct_link_speaker(fd, (Speaker *)id);
+ break;
+ case ID_SO:
+ direct_link_sound(fd, (bSound *)id);
+ break;
+ case ID_LP:
+ direct_link_lightprobe(fd, (LightProbe *)id);
+ break;
+ case ID_GR:
+ direct_link_collection(fd, (Collection *)id);
+ break;
+ case ID_AR:
+ direct_link_armature(fd, (bArmature *)id);
+ break;
+ case ID_AC:
+ direct_link_action(fd, (bAction *)id);
+ break;
+ case ID_NT:
+ direct_link_nodetree(fd, (bNodeTree *)id);
+ break;
+ case ID_BR:
+ direct_link_brush(fd, (Brush *)id);
+ break;
+ case ID_PA:
+ direct_link_particlesettings(fd, (ParticleSettings *)id);
+ break;
+ case ID_GD:
+ direct_link_gpencil(fd, (bGPdata *)id);
+ break;
+ case ID_MC:
+ direct_link_movieclip(fd, (MovieClip *)id);
+ break;
+ case ID_MSK:
+ direct_link_mask(fd, (Mask *)id);
+ break;
+ case ID_LS:
+ direct_link_linestyle(fd, (FreestyleLineStyle *)id);
+ break;
+ case ID_PAL:
+ direct_link_palette(fd, (Palette *)id);
+ break;
+ case ID_PC:
+ direct_link_paint_curve(fd, (PaintCurve *)id);
+ break;
+ case ID_CF:
+ direct_link_cachefile(fd, (CacheFile *)id);
+ break;
+ case ID_WS:
+ direct_link_workspace(fd, (WorkSpace *)id, main);
+ break;
+ }
+
+ oldnewmap_free_unused(fd->datamap);
+ oldnewmap_clear(fd->datamap);
+
+ if (wrong_id) {
+ BKE_id_free(main, id);
+ }
+
+ return (bhead);
}
/** \} */
@@ -9164,55 +9276,56 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
/* also version info is written here */
static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
{
- FileGlobal *fg = read_struct(fd, bhead, "Global");
+ FileGlobal *fg = read_struct(fd, bhead, "Global");
- /* copy to bfd handle */
- bfd->main->subversionfile = fg->subversion;
- bfd->main->minversionfile = fg->minversion;
- bfd->main->minsubversionfile = fg->minsubversion;
- bfd->main->build_commit_timestamp = fg->build_commit_timestamp;
- BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash));
+ /* copy to bfd handle */
+ bfd->main->subversionfile = fg->subversion;
+ bfd->main->minversionfile = fg->minversion;
+ bfd->main->minsubversionfile = fg->minsubversion;
+ bfd->main->build_commit_timestamp = fg->build_commit_timestamp;
+ BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash));
- bfd->fileflags = fg->fileflags;
- bfd->globalf = fg->globalf;
- BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
+ bfd->fileflags = fg->fileflags;
+ bfd->globalf = fg->globalf;
+ BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
- /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */
- if (bfd->filename[0] == 0) {
- if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1))
- if ((G.fileflags & G_FILE_RECOVER) == 0)
- BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+ /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */
+ if (bfd->filename[0] == 0) {
+ if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1))
+ if ((G.fileflags & G_FILE_RECOVER) == 0)
+ BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
- /* early 2.50 version patch - filename not in FileGlobal struct at all */
- if (fd->fileversion <= 250)
- BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
- }
+ /* early 2.50 version patch - filename not in FileGlobal struct at all */
+ if (fd->fileversion <= 250)
+ BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+ }
- if (G.fileflags & G_FILE_RECOVER)
- BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
+ if (G.fileflags & G_FILE_RECOVER)
+ BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
- bfd->curscreen = fg->curscreen;
- bfd->curscene = fg->curscene;
- bfd->cur_view_layer = fg->cur_view_layer;
+ bfd->curscreen = fg->curscreen;
+ bfd->curscene = fg->curscene;
+ bfd->cur_view_layer = fg->cur_view_layer;
- MEM_freeN(fg);
+ MEM_freeN(fg);
- fd->globalf = bfd->globalf;
- fd->fileflags = bfd->fileflags;
+ fd->globalf = bfd->globalf;
+ fd->fileflags = bfd->fileflags;
- return blo_bhead_next(fd, bhead);
+ return blo_bhead_next(fd, bhead);
}
/* note, this has to be kept for reading older files... */
static void link_global(FileData *fd, BlendFileData *bfd)
{
- bfd->cur_view_layer = newglobadr(fd, bfd->cur_view_layer);
- bfd->curscreen = newlibadr(fd, NULL, bfd->curscreen);
- bfd->curscene = newlibadr(fd, NULL, bfd->curscene);
- // this happens in files older than 2.35
- if (bfd->curscene == NULL) {
- if (bfd->curscreen) bfd->curscene = bfd->curscreen->scene;
- }
+ bfd->cur_view_layer = newglobadr(fd, bfd->cur_view_layer);
+ bfd->curscreen = newlibadr(fd, NULL, bfd->curscreen);
+ bfd->curscene = newlibadr(fd, NULL, bfd->curscene);
+ // this happens in files older than 2.35
+ if (bfd->curscene == NULL) {
+ if (bfd->curscreen)
+ bfd->curscene = bfd->curscreen->scene;
+ }
}
/** \} */
@@ -9225,83 +9338,86 @@ static void link_global(FileData *fd, BlendFileData *bfd)
/* other initializers (such as theme color defaults) go to resources.c */
static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
{
- Main *bmain = bfd->main;
- UserDef *user = bfd->user;
+ Main *bmain = bfd->main;
+ UserDef *user = bfd->user;
- if (user == NULL) return;
+ if (user == NULL)
+ return;
- if (MAIN_VERSION_OLDER(bmain, 266, 4)) {
- bTheme *btheme;
+ if (MAIN_VERSION_OLDER(bmain, 266, 4)) {
+ bTheme *btheme;
- /* themes for Node and Sequence editor were not using grid color, but back. we copy this over then */
- for (btheme = user->themes.first; btheme; btheme = btheme->next) {
- copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back);
- copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back);
- }
- }
+ /* themes for Node and Sequence editor were not using grid color, but back. we copy this over then */
+ for (btheme = user->themes.first; btheme; btheme = btheme->next) {
+ copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back);
+ copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back);
+ }
+ }
- if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "WalkNavigation", "walk_navigation")) {
- user->walk_navigation.mouse_speed = 1.0f;
- user->walk_navigation.walk_speed = 2.5f; /* m/s */
- user->walk_navigation.walk_speed_factor = 5.0f;
- user->walk_navigation.view_height = 1.6f; /* m */
- user->walk_navigation.jump_height = 0.4f; /* m */
- user->walk_navigation.teleport_time = 0.2f; /* s */
- }
+ if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "WalkNavigation", "walk_navigation")) {
+ user->walk_navigation.mouse_speed = 1.0f;
+ user->walk_navigation.walk_speed = 2.5f; /* m/s */
+ user->walk_navigation.walk_speed_factor = 5.0f;
+ user->walk_navigation.view_height = 1.6f; /* m */
+ user->walk_navigation.jump_height = 0.4f; /* m */
+ user->walk_navigation.teleport_time = 0.2f; /* s */
+ }
- /* grease pencil multisamples */
- if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "gpencil_multisamples")) {
- user->gpencil_multisamples = 4;
- }
+ /* grease pencil multisamples */
+ if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "gpencil_multisamples")) {
+ user->gpencil_multisamples = 4;
+ }
- /* tablet pressure threshold */
- if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "float", "pressure_threshold_max")) {
- user->pressure_threshold_max = 1.0f;
- }
+ /* tablet pressure threshold */
+ if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "float", "pressure_threshold_max")) {
+ user->pressure_threshold_max = 1.0f;
+ }
}
static void do_versions(FileData *fd, Library *lib, Main *main)
{
- /* WATCH IT!!!: pointers from libdata have not been converted */
+ /* WATCH IT!!!: pointers from libdata have not been converted */
- if (G.debug & G_DEBUG) {
- char build_commit_datetime[32];
- time_t temp_time = main->build_commit_timestamp;
- struct tm *tm = (temp_time) ? gmtime(&temp_time) : NULL;
- if (LIKELY(tm)) {
- strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
- }
- else {
- BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime));
- }
+ if (G.debug & G_DEBUG) {
+ char build_commit_datetime[32];
+ time_t temp_time = main->build_commit_timestamp;
+ struct tm *tm = (temp_time) ? gmtime(&temp_time) : NULL;
+ if (LIKELY(tm)) {
+ strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
+ }
+ else {
+ BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime));
+ }
- printf("read file %s\n Version %d sub %d date %s hash %s\n",
- fd->relabase, main->versionfile, main->subversionfile,
- build_commit_datetime, main->build_hash);
- }
+ printf("read file %s\n Version %d sub %d date %s hash %s\n",
+ fd->relabase,
+ main->versionfile,
+ main->subversionfile,
+ build_commit_datetime,
+ main->build_hash);
+ }
- blo_do_versions_pre250(fd, lib, main);
- blo_do_versions_250(fd, lib, main);
- blo_do_versions_260(fd, lib, main);
- blo_do_versions_270(fd, lib, main);
- blo_do_versions_280(fd, lib, main);
+ blo_do_versions_pre250(fd, lib, main);
+ blo_do_versions_250(fd, lib, main);
+ blo_do_versions_260(fd, lib, main);
+ blo_do_versions_270(fd, lib, main);
+ blo_do_versions_280(fd, lib, main);
- /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
- /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
+ /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+ /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
- /* don't forget to set version number in BKE_blender_version.h! */
+ /* don't forget to set version number in BKE_blender_version.h! */
}
static void do_versions_after_linking(Main *main)
{
-// printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
-// main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
+ // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
+ // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
- do_versions_after_linking_270(main);
- do_versions_after_linking_280(main);
+ do_versions_after_linking_270(main);
+ do_versions_after_linking_280(main);
}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -9310,53 +9426,55 @@ static void do_versions_after_linking(Main *main)
static void lib_link_all(FileData *fd, Main *main)
{
- lib_link_id(fd, main);
-
- /* No load UI for undo memfiles */
- if (fd->memfile == NULL) {
- lib_link_windowmanager(fd, main);
- }
- /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */
- lib_link_screen(fd, main);
- lib_link_scene(fd, main);
- lib_link_object(fd, main);
- lib_link_mesh(fd, main);
- lib_link_curve(fd, main);
- lib_link_mball(fd, main);
- lib_link_material(fd, main);
- lib_link_texture(fd, main);
- lib_link_image(fd, main);
- lib_link_ipo(fd, main); /* XXX deprecated... still needs to be maintained for version patches still */
- lib_link_key(fd, main);
- lib_link_world(fd, main);
- lib_link_light(fd, main);
- lib_link_latt(fd, main);
- lib_link_text(fd, main);
- lib_link_camera(fd, main);
- lib_link_speaker(fd, main);
- lib_link_lightprobe(fd, main);
- lib_link_sound(fd, main);
- lib_link_collection(fd, main);
- lib_link_armature(fd, main);
- lib_link_action(fd, main);
- lib_link_vfont(fd, main);
- lib_link_nodetree(fd, main); /* has to be done after scene/materials, this will verify group nodes */
- lib_link_palette(fd, main);
- lib_link_brush(fd, main);
- lib_link_paint_curve(fd, main);
- lib_link_particlesettings(fd, main);
- lib_link_movieclip(fd, main);
- lib_link_mask(fd, main);
- lib_link_linestyle(fd, main);
- lib_link_gpencil(fd, main);
- lib_link_cachefiles(fd, main);
- lib_link_workspaces(fd, main);
-
- lib_link_library(fd, main); /* only init users */
-
- /* We could integrate that to mesh/curve/lattice lib_link, but this is really cheap process,
- * so simpler to just use it directly in this single call. */
- BLO_main_validate_shapekeys(main, NULL);
+ lib_link_id(fd, main);
+
+ /* No load UI for undo memfiles */
+ if (fd->memfile == NULL) {
+ lib_link_windowmanager(fd, main);
+ }
+ /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */
+ lib_link_screen(fd, main);
+ lib_link_scene(fd, main);
+ lib_link_object(fd, main);
+ lib_link_mesh(fd, main);
+ lib_link_curve(fd, main);
+ lib_link_mball(fd, main);
+ lib_link_material(fd, main);
+ lib_link_texture(fd, main);
+ lib_link_image(fd, main);
+ lib_link_ipo(
+ fd, main); /* XXX deprecated... still needs to be maintained for version patches still */
+ lib_link_key(fd, main);
+ lib_link_world(fd, main);
+ lib_link_light(fd, main);
+ lib_link_latt(fd, main);
+ lib_link_text(fd, main);
+ lib_link_camera(fd, main);
+ lib_link_speaker(fd, main);
+ lib_link_lightprobe(fd, main);
+ lib_link_sound(fd, main);
+ lib_link_collection(fd, main);
+ lib_link_armature(fd, main);
+ lib_link_action(fd, main);
+ lib_link_vfont(fd, main);
+ lib_link_nodetree(fd,
+ main); /* has to be done after scene/materials, this will verify group nodes */
+ lib_link_palette(fd, main);
+ lib_link_brush(fd, main);
+ lib_link_paint_curve(fd, main);
+ lib_link_particlesettings(fd, main);
+ lib_link_movieclip(fd, main);
+ lib_link_mask(fd, main);
+ lib_link_linestyle(fd, main);
+ lib_link_gpencil(fd, main);
+ lib_link_cachefiles(fd, main);
+ lib_link_workspaces(fd, main);
+
+ lib_link_library(fd, main); /* only init users */
+
+ /* We could integrate that to mesh/curve/lattice lib_link, but this is really cheap process,
+ * so simpler to just use it directly in this single call. */
+ BLO_main_validate_shapekeys(main, NULL);
}
/** \} */
@@ -9367,92 +9485,92 @@ static void lib_link_all(FileData *fd, Main *main)
static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
{
- kmi->properties = newdataadr(fd, kmi->properties);
- IDP_DirectLinkGroup_OrFree(&kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- kmi->ptr = NULL;
- kmi->flag &= ~KMI_UPDATE;
+ kmi->properties = newdataadr(fd, kmi->properties);
+ IDP_DirectLinkGroup_OrFree(&kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ kmi->ptr = NULL;
+ kmi->flag &= ~KMI_UPDATE;
}
static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
{
- UserDef *user;
- wmKeyMap *keymap;
- wmKeyMapItem *kmi;
- wmKeyMapDiffItem *kmdi;
- bAddon *addon;
+ UserDef *user;
+ wmKeyMap *keymap;
+ wmKeyMapItem *kmi;
+ wmKeyMapDiffItem *kmdi;
+ bAddon *addon;
- bfd->user = user = read_struct(fd, bhead, "user def");
+ bfd->user = user = read_struct(fd, bhead, "user def");
- /* User struct has separate do-version handling */
- user->versionfile = bfd->main->versionfile;
- user->subversionfile = bfd->main->subversionfile;
+ /* User struct has separate do-version handling */
+ user->versionfile = bfd->main->versionfile;
+ user->subversionfile = bfd->main->subversionfile;
- /* read all data into fd->datamap */
- bhead = read_data_into_oldnewmap(fd, bhead, "user def");
+ /* read all data into fd->datamap */
+ bhead = read_data_into_oldnewmap(fd, bhead, "user def");
- link_list(fd, &user->themes);
- link_list(fd, &user->user_keymaps);
- link_list(fd, &user->user_keyconfig_prefs);
- link_list(fd, &user->user_menus);
- link_list(fd, &user->addons);
- link_list(fd, &user->autoexec_paths);
+ link_list(fd, &user->themes);
+ link_list(fd, &user->user_keymaps);
+ link_list(fd, &user->user_keyconfig_prefs);
+ link_list(fd, &user->user_menus);
+ link_list(fd, &user->addons);
+ link_list(fd, &user->autoexec_paths);
- for (keymap = user->user_keymaps.first; keymap; keymap = keymap->next) {
- keymap->modal_items = NULL;
- keymap->poll = NULL;
- keymap->flag &= ~KEYMAP_UPDATE;
+ for (keymap = user->user_keymaps.first; keymap; keymap = keymap->next) {
+ keymap->modal_items = NULL;
+ keymap->poll = NULL;
+ keymap->flag &= ~KEYMAP_UPDATE;
- link_list(fd, &keymap->diff_items);
- link_list(fd, &keymap->items);
+ link_list(fd, &keymap->diff_items);
+ link_list(fd, &keymap->items);
- for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
- kmdi->remove_item = newdataadr(fd, kmdi->remove_item);
- kmdi->add_item = newdataadr(fd, kmdi->add_item);
+ for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ kmdi->remove_item = newdataadr(fd, kmdi->remove_item);
+ kmdi->add_item = newdataadr(fd, kmdi->add_item);
- if (kmdi->remove_item)
- direct_link_keymapitem(fd, kmdi->remove_item);
- if (kmdi->add_item)
- direct_link_keymapitem(fd, kmdi->add_item);
- }
+ if (kmdi->remove_item)
+ direct_link_keymapitem(fd, kmdi->remove_item);
+ if (kmdi->add_item)
+ direct_link_keymapitem(fd, kmdi->add_item);
+ }
- for (kmi = keymap->items.first; kmi; kmi = kmi->next)
- direct_link_keymapitem(fd, kmi);
- }
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next)
+ direct_link_keymapitem(fd, kmi);
+ }
- for (wmKeyConfigPref *kpt = user->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
- kpt->prop = newdataadr(fd, kpt->prop);
- IDP_DirectLinkGroup_OrFree(&kpt->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
+ for (wmKeyConfigPref *kpt = user->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
+ kpt->prop = newdataadr(fd, kpt->prop);
+ IDP_DirectLinkGroup_OrFree(&kpt->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
- for (bUserMenu *um = user->user_menus.first; um; um = um->next) {
- link_list(fd, &um->items);
- for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
- if (umi->type == USER_MENU_TYPE_OPERATOR) {
- bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
- umi_op->prop = newdataadr(fd, umi_op->prop);
- IDP_DirectLinkGroup_OrFree(&umi_op->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
- }
- }
+ for (bUserMenu *um = user->user_menus.first; um; um = um->next) {
+ link_list(fd, &um->items);
+ for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ if (umi->type == USER_MENU_TYPE_OPERATOR) {
+ bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
+ umi_op->prop = newdataadr(fd, umi_op->prop);
+ IDP_DirectLinkGroup_OrFree(&umi_op->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+ }
+ }
- for (addon = user->addons.first; addon; addon = addon->next) {
- addon->prop = newdataadr(fd, addon->prop);
- IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- }
+ for (addon = user->addons.first; addon; addon = addon->next) {
+ addon->prop = newdataadr(fd, addon->prop);
+ IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
- // XXX
- user->uifonts.first = user->uifonts.last = NULL;
+ // XXX
+ user->uifonts.first = user->uifonts.last = NULL;
- link_list(fd, &user->uistyles);
+ link_list(fd, &user->uistyles);
- /* Don't read the active app template, use the default one. */
- user->app_template[0] = '\0';
+ /* Don't read the active app template, use the default one. */
+ user->app_template[0] = '\0';
- /* free fd->datamap again */
- oldnewmap_free_unused(fd->datamap);
- oldnewmap_clear(fd->datamap);
+ /* free fd->datamap again */
+ oldnewmap_free_unused(fd->datamap);
+ oldnewmap_clear(fd->datamap);
- return bhead;
+ return bhead;
}
/** \} */
@@ -9463,136 +9581,138 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
{
- BHead *bhead = blo_bhead_first(fd);
- BlendFileData *bfd;
- ListBase mainlist = {NULL, NULL};
-
- bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata");
- bfd->main = BKE_main_new();
- BLI_addtail(&mainlist, bfd->main);
- fd->mainlist = &mainlist;
-
- bfd->main->versionfile = fd->fileversion;
-
- bfd->type = BLENFILETYPE_BLEND;
- BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
-
- if (G.background) {
- /* We only read & store .blend thumbnail in background mode
- * (because we cannot re-generate it, no OpenGL available).
- */
- const int *data = read_file_thumbnail(fd);
-
- if (data) {
- const int width = data[0];
- const int height = data[1];
- if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
- const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
- bfd->main->blen_thumb = MEM_mallocN(sz, __func__);
-
- BLI_assert((sz - sizeof(*bfd->main->blen_thumb)) ==
- (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*data) * 2)));
- bfd->main->blen_thumb->width = width;
- bfd->main->blen_thumb->height = height;
- memcpy(bfd->main->blen_thumb->rect, &data[2], sz - sizeof(*bfd->main->blen_thumb));
- }
- }
- }
-
- while (bhead) {
- switch (bhead->code) {
- case DATA:
- case DNA1:
- case TEST: /* used as preview since 2.5x */
- case REND:
- bhead = blo_bhead_next(fd, bhead);
- break;
- case GLOB:
- bhead = read_global(bfd, fd, bhead);
- break;
- case USER:
- if (fd->skip_flags & BLO_READ_SKIP_USERDEF) {
- bhead = blo_bhead_next(fd, bhead);
- }
- else {
- bhead = read_userdef(bfd, fd, bhead);
- }
- break;
- case ENDB:
- bhead = NULL;
- break;
-
- case ID_LINK_PLACEHOLDER:
- if (fd->skip_flags & BLO_READ_SKIP_DATA) {
- bhead = blo_bhead_next(fd, bhead);
- }
- else {
- /* Add link placeholder to the main of the library it belongs to.
- * The library is the most recently loaded ID_LI block, according
- * to the file format definition. So we can use the entry at the
- * end of mainlist, added in direct_link_library. */
- Main *libmain = mainlist.last;
- bhead = read_libblock(fd, libmain, bhead, LIB_TAG_ID_LINK_PLACEHOLDER | LIB_TAG_EXTERN, NULL);
- }
- break;
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
- case ID_SCRN:
- bhead->code = ID_SCR;
- /* pass on to default */
- ATTR_FALLTHROUGH;
- default:
- if (fd->skip_flags & BLO_READ_SKIP_DATA) {
- bhead = blo_bhead_next(fd, bhead);
- }
- else {
- bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL);
- }
- }
- }
-
- /* do before read_libraries, but skip undo case */
- if (fd->memfile == NULL) {
- do_versions(fd, NULL, bfd->main);
- do_versions_userdef(fd, bfd);
- }
-
- read_libraries(fd, &mainlist);
-
- blo_join_main(&mainlist);
-
- lib_link_all(fd, bfd->main);
-
- /* Skip in undo case. */
- if (fd->memfile == NULL) {
- /* Yep, second splitting... but this is a very cheap operation, so no big deal. */
- blo_split_main(&mainlist, bfd->main);
- for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) {
- BLI_assert(mainvar->versionfile != 0);
- do_versions_after_linking(mainvar);
- }
- blo_join_main(&mainlist);
- }
-
- BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false);
-
- /* Before static overrides, which needs typeinfo. */
- lib_verify_nodetree(bfd->main, true);
-
- /* Now that all our data-blocks are loaded, we can re-generate overrides from their references. */
- if (fd->memfile == NULL) {
- /* Do not apply in undo case! */
- BKE_main_override_static_update(bfd->main);
- }
-
- BKE_collections_after_lib_link(bfd->main);
-
- fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
-
- link_global(fd, bfd); /* as last */
-
- fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */
-
- return bfd;
+ BHead *bhead = blo_bhead_first(fd);
+ BlendFileData *bfd;
+ ListBase mainlist = {NULL, NULL};
+
+ bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata");
+ bfd->main = BKE_main_new();
+ BLI_addtail(&mainlist, bfd->main);
+ fd->mainlist = &mainlist;
+
+ bfd->main->versionfile = fd->fileversion;
+
+ bfd->type = BLENFILETYPE_BLEND;
+ BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
+
+ if (G.background) {
+ /* We only read & store .blend thumbnail in background mode
+ * (because we cannot re-generate it, no OpenGL available).
+ */
+ const int *data = read_file_thumbnail(fd);
+
+ if (data) {
+ const int width = data[0];
+ const int height = data[1];
+ if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
+ const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
+ bfd->main->blen_thumb = MEM_mallocN(sz, __func__);
+
+ BLI_assert((sz - sizeof(*bfd->main->blen_thumb)) ==
+ (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*data) * 2)));
+ bfd->main->blen_thumb->width = width;
+ bfd->main->blen_thumb->height = height;
+ memcpy(bfd->main->blen_thumb->rect, &data[2], sz - sizeof(*bfd->main->blen_thumb));
+ }
+ }
+ }
+
+ while (bhead) {
+ switch (bhead->code) {
+ case DATA:
+ case DNA1:
+ case TEST: /* used as preview since 2.5x */
+ case REND:
+ bhead = blo_bhead_next(fd, bhead);
+ break;
+ case GLOB:
+ bhead = read_global(bfd, fd, bhead);
+ break;
+ case USER:
+ if (fd->skip_flags & BLO_READ_SKIP_USERDEF) {
+ bhead = blo_bhead_next(fd, bhead);
+ }
+ else {
+ bhead = read_userdef(bfd, fd, bhead);
+ }
+ break;
+ case ENDB:
+ bhead = NULL;
+ break;
+
+ case ID_LINK_PLACEHOLDER:
+ if (fd->skip_flags & BLO_READ_SKIP_DATA) {
+ bhead = blo_bhead_next(fd, bhead);
+ }
+ else {
+ /* Add link placeholder to the main of the library it belongs to.
+ * The library is the most recently loaded ID_LI block, according
+ * to the file format definition. So we can use the entry at the
+ * end of mainlist, added in direct_link_library. */
+ Main *libmain = mainlist.last;
+ bhead = read_libblock(
+ fd, libmain, bhead, LIB_TAG_ID_LINK_PLACEHOLDER | LIB_TAG_EXTERN, NULL);
+ }
+ break;
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ case ID_SCRN:
+ bhead->code = ID_SCR;
+ /* pass on to default */
+ ATTR_FALLTHROUGH;
+ default:
+ if (fd->skip_flags & BLO_READ_SKIP_DATA) {
+ bhead = blo_bhead_next(fd, bhead);
+ }
+ else {
+ bhead = read_libblock(fd, bfd->main, bhead, LIB_TAG_LOCAL, NULL);
+ }
+ }
+ }
+
+ /* do before read_libraries, but skip undo case */
+ if (fd->memfile == NULL) {
+ do_versions(fd, NULL, bfd->main);
+ do_versions_userdef(fd, bfd);
+ }
+
+ read_libraries(fd, &mainlist);
+
+ blo_join_main(&mainlist);
+
+ lib_link_all(fd, bfd->main);
+
+ /* Skip in undo case. */
+ if (fd->memfile == NULL) {
+ /* Yep, second splitting... but this is a very cheap operation, so no big deal. */
+ blo_split_main(&mainlist, bfd->main);
+ for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) {
+ BLI_assert(mainvar->versionfile != 0);
+ do_versions_after_linking(mainvar);
+ }
+ blo_join_main(&mainlist);
+ }
+
+ BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false);
+
+ /* Before static overrides, which needs typeinfo. */
+ lib_verify_nodetree(bfd->main, true);
+
+ /* Now that all our data-blocks are loaded, we can re-generate overrides from their references. */
+ if (fd->memfile == NULL) {
+ /* Do not apply in undo case! */
+ BKE_main_override_static_update(bfd->main);
+ }
+
+ BKE_collections_after_lib_link(bfd->main);
+
+ fix_relpaths_library(fd->relabase,
+ bfd->main); /* make all relative paths, relative to the open blend file */
+
+ link_global(fd, bfd); /* as last */
+
+ fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */
+
+ return bfd;
}
/** \} */
@@ -9604,128 +9724,131 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
* \{ */
struct BHeadSort {
- BHead *bhead;
- const void *old;
+ BHead *bhead;
+ const void *old;
};
static int verg_bheadsort(const void *v1, const void *v2)
{
- const struct BHeadSort *x1 = v1, *x2 = v2;
+ const struct BHeadSort *x1 = v1, *x2 = v2;
- if (x1->old > x2->old) return 1;
- else if (x1->old < x2->old) return -1;
- return 0;
+ if (x1->old > x2->old)
+ return 1;
+ else if (x1->old < x2->old)
+ return -1;
+ return 0;
}
static void sort_bhead_old_map(FileData *fd)
{
- BHead *bhead;
- struct BHeadSort *bhs;
- int tot = 0;
+ BHead *bhead;
+ struct BHeadSort *bhs;
+ int tot = 0;
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead))
- tot++;
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead))
+ tot++;
- fd->tot_bheadmap = tot;
- if (tot == 0) return;
+ fd->tot_bheadmap = tot;
+ if (tot == 0)
+ return;
- bhs = fd->bheadmap = MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort");
+ bhs = fd->bheadmap = MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort");
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead), bhs++) {
- bhs->bhead = bhead;
- bhs->old = bhead->old;
- }
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead), bhs++) {
+ bhs->bhead = bhead;
+ bhs->old = bhead->old;
+ }
- qsort(fd->bheadmap, tot, sizeof(struct BHeadSort), verg_bheadsort);
+ qsort(fd->bheadmap, tot, sizeof(struct BHeadSort), verg_bheadsort);
}
static BHead *find_previous_lib(FileData *fd, BHead *bhead)
{
- /* skip library datablocks in undo, see comment in read_libblock */
- if (fd->memfile)
- return NULL;
+ /* skip library datablocks in undo, see comment in read_libblock */
+ if (fd->memfile)
+ return NULL;
- for (; bhead; bhead = blo_bhead_prev(fd, bhead)) {
- if (bhead->code == ID_LI)
- break;
- }
+ for (; bhead; bhead = blo_bhead_prev(fd, bhead)) {
+ if (bhead->code == ID_LI)
+ break;
+ }
- return bhead;
+ return bhead;
}
static BHead *find_bhead(FileData *fd, void *old)
{
#if 0
- BHead *bhead;
+ BHead *bhead;
#endif
- struct BHeadSort *bhs, bhs_s;
+ struct BHeadSort *bhs, bhs_s;
- if (!old)
- return NULL;
+ if (!old)
+ return NULL;
- if (fd->bheadmap == NULL)
- sort_bhead_old_map(fd);
+ if (fd->bheadmap == NULL)
+ sort_bhead_old_map(fd);
- bhs_s.old = old;
- bhs = bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort);
+ bhs_s.old = old;
+ bhs = bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort);
- if (bhs)
- return bhs->bhead;
+ if (bhs)
+ return bhs->bhead;
#if 0
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->old == old)
- return bhead;
- }
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->old == old)
+ return bhead;
+ }
#endif
- return NULL;
+ return NULL;
}
static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name)
{
#ifdef USE_GHASH_BHEAD
- char idname_full[MAX_ID_NAME];
+ char idname_full[MAX_ID_NAME];
- *((short *)idname_full) = idcode;
- BLI_strncpy(idname_full + 2, name, sizeof(idname_full) - 2);
+ *((short *)idname_full) = idcode;
+ BLI_strncpy(idname_full + 2, name, sizeof(idname_full) - 2);
- return BLI_ghash_lookup(fd->bhead_idname_hash, idname_full);
+ return BLI_ghash_lookup(fd->bhead_idname_hash, idname_full);
#else
- BHead *bhead;
-
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == idcode) {
- const char *idname_test = blo_bhead_id_name(fd, bhead);
- if (STREQ(idname_test + 2, name)) {
- return bhead;
- }
- }
- else if (bhead->code == ENDB) {
- break;
- }
- }
-
- return NULL;
+ BHead *bhead;
+
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == idcode) {
+ const char *idname_test = blo_bhead_id_name(fd, bhead);
+ if (STREQ(idname_test + 2, name)) {
+ return bhead;
+ }
+ }
+ else if (bhead->code == ENDB) {
+ break;
+ }
+ }
+
+ return NULL;
#endif
}
static BHead *find_bhead_from_idname(FileData *fd, const char *idname)
{
#ifdef USE_GHASH_BHEAD
- return BLI_ghash_lookup(fd->bhead_idname_hash, idname);
+ return BLI_ghash_lookup(fd->bhead_idname_hash, idname);
#else
- return find_bhead_from_code_name(fd, GS(idname), idname + 2);
+ return find_bhead_from_code_name(fd, GS(idname), idname + 2);
#endif
}
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
{
- const char *idname = blo_bhead_id_name(fd, bhead);
- /* which_libbase can be NULL, intentionally not using idname+2 */
- return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
+ const char *idname = blo_bhead_id_name(fd, bhead);
+ /* which_libbase can be NULL, intentionally not using idname+2 */
+ return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
}
/** \} */
@@ -9736,91 +9859,94 @@ static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
{
- FileData *fd = fdhandle;
-
- BHead *bhead = find_bhead(fd, old);
- if (bhead == NULL) {
- return;
- }
-
- if (bhead->code == ID_LINK_PLACEHOLDER) {
- /* Placeholder link to datablock in another library. */
- BHead *bheadlib = find_previous_lib(fd, bhead);
- if (bheadlib == NULL) {
- return;
- }
-
- Library *lib = read_struct(fd, bheadlib, "Library");
- Main *libmain = blo_find_main(fd, lib->name, fd->relabase);
-
- if (libmain->curlib == NULL) {
- const char *idname = blo_bhead_id_name(fd, bhead);
-
- blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
- idname, mainvar->curlib->filepath);
- return;
- }
-
- ID *id = is_yet_read(fd, libmain, bhead);
-
- if (id == NULL) {
- /* ID has not been read yet, add placeholder to the main of the
- * library it belongs to, so that it will be read later. */
- read_libblock(fd, libmain, bhead, LIB_TAG_ID_LINK_PLACEHOLDER | LIB_TAG_INDIRECT, NULL);
- // commented because this can print way too much
- // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name);
-
- /* for outliner dependency only */
- libmain->curlib->parent = mainvar->curlib;
- }
- else {
- /* "id" is either a placeholder or real ID that is already in the
- * main of the library (A) it belongs to. However it might have been
- * put there by another library (C) which only updated its own
- * fd->libmap. In that case we also need to update the fd->libmap
- * of the current library (B) so we can find it for lookups.
- *
- * An example of such a setup is:
- * (A) tree.blend: contains Tree object.
- * (B) forest.blend: contains Forest collection linking in Tree from tree.blend.
- * (C) shot.blend: links in both Tree from tree.blend and Forest from forest.blend.
- */
- oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
-
- /* If "id" is a real datablock and not a placeholder, we need to
- * update fd->libmap to replace ID_LINK_PLACEHOLDER with the real
- * ID_* code.
- *
- * When the real ID is read this replacement happens for all
- * libraries read so far, but not for libraries that have not been
- * read yet at that point. */
- change_link_placeholder_to_real_ID_pointer_fd(fd, bhead->old, id);
-
- // commented because this can print way too much
- // if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
- }
-
- MEM_freeN(lib);
- }
- else {
- /* Datablock in same library. */
- /* In 2.50+ file identifier for screens is patched, forward compatibility. */
- if (bhead->code == ID_SCRN) {
- bhead->code = ID_SCR;
- }
-
- ID *id = is_yet_read(fd, mainvar, bhead);
- if (id == NULL) {
- read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, NULL);
- }
- else {
- /* this is actually only needed on UI call? when ID was already read before, and another append
- * happens which invokes same ID... in that case the lookup table needs this entry */
- oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
- // commented because this can print way too much
- // if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
- }
- }
+ FileData *fd = fdhandle;
+
+ BHead *bhead = find_bhead(fd, old);
+ if (bhead == NULL) {
+ return;
+ }
+
+ if (bhead->code == ID_LINK_PLACEHOLDER) {
+ /* Placeholder link to datablock in another library. */
+ BHead *bheadlib = find_previous_lib(fd, bhead);
+ if (bheadlib == NULL) {
+ return;
+ }
+
+ Library *lib = read_struct(fd, bheadlib, "Library");
+ Main *libmain = blo_find_main(fd, lib->name, fd->relabase);
+
+ if (libmain->curlib == NULL) {
+ const char *idname = blo_bhead_id_name(fd, bhead);
+
+ blo_reportf_wrap(fd->reports,
+ RPT_WARNING,
+ TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
+ idname,
+ mainvar->curlib->filepath);
+ return;
+ }
+
+ ID *id = is_yet_read(fd, libmain, bhead);
+
+ if (id == NULL) {
+ /* ID has not been read yet, add placeholder to the main of the
+ * library it belongs to, so that it will be read later. */
+ read_libblock(fd, libmain, bhead, LIB_TAG_ID_LINK_PLACEHOLDER | LIB_TAG_INDIRECT, NULL);
+ // commented because this can print way too much
+ // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name);
+
+ /* for outliner dependency only */
+ libmain->curlib->parent = mainvar->curlib;
+ }
+ else {
+ /* "id" is either a placeholder or real ID that is already in the
+ * main of the library (A) it belongs to. However it might have been
+ * put there by another library (C) which only updated its own
+ * fd->libmap. In that case we also need to update the fd->libmap
+ * of the current library (B) so we can find it for lookups.
+ *
+ * An example of such a setup is:
+ * (A) tree.blend: contains Tree object.
+ * (B) forest.blend: contains Forest collection linking in Tree from tree.blend.
+ * (C) shot.blend: links in both Tree from tree.blend and Forest from forest.blend.
+ */
+ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
+
+ /* If "id" is a real datablock and not a placeholder, we need to
+ * update fd->libmap to replace ID_LINK_PLACEHOLDER with the real
+ * ID_* code.
+ *
+ * When the real ID is read this replacement happens for all
+ * libraries read so far, but not for libraries that have not been
+ * read yet at that point. */
+ change_link_placeholder_to_real_ID_pointer_fd(fd, bhead->old, id);
+
+ // commented because this can print way too much
+ // if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
+ }
+
+ MEM_freeN(lib);
+ }
+ else {
+ /* Datablock in same library. */
+ /* In 2.50+ file identifier for screens is patched, forward compatibility. */
+ if (bhead->code == ID_SCRN) {
+ bhead->code = ID_SCR;
+ }
+
+ ID *id = is_yet_read(fd, mainvar, bhead);
+ if (id == NULL) {
+ read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, NULL);
+ }
+ else {
+ /* this is actually only needed on UI call? when ID was already read before, and another append
+ * happens which invokes same ID... in that case the lookup table needs this entry */
+ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
+ // commented because this can print way too much
+ // if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
+ }
+ }
}
static BLOExpandDoitCallback expand_doit;
@@ -9828,818 +9954,834 @@ static BLOExpandDoitCallback expand_doit;
// XXX deprecated - old animation system
static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
{
- IpoCurve *icu;
- for (icu = ipo->curve.first; icu; icu = icu->next) {
- if (icu->driver)
- expand_doit(fd, mainvar, icu->driver->ob);
- }
+ IpoCurve *icu;
+ for (icu = ipo->curve.first; icu; icu = icu->next) {
+ if (icu->driver)
+ expand_doit(fd, mainvar, icu->driver->ob);
+ }
}
// XXX deprecated - old animation system
static void expand_constraint_channels(FileData *fd, Main *mainvar, ListBase *chanbase)
{
- bConstraintChannel *chan;
- for (chan = chanbase->first; chan; chan = chan->next) {
- expand_doit(fd, mainvar, chan->ipo);
- }
+ bConstraintChannel *chan;
+ for (chan = chanbase->first; chan; chan = chan->next) {
+ expand_doit(fd, mainvar, chan->ipo);
+ }
}
static void expand_id(FileData *fd, Main *mainvar, ID *id)
{
- if (id->override_static) {
- expand_doit(fd, mainvar, id->override_static->reference);
- expand_doit(fd, mainvar, id->override_static->storage);
- }
+ if (id->override_static) {
+ expand_doit(fd, mainvar, id->override_static->reference);
+ expand_doit(fd, mainvar, id->override_static->storage);
+ }
}
static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop)
{
- if (!prop)
- return;
-
- switch (prop->type) {
- case IDP_ID:
- expand_doit(fd, mainvar, IDP_Id(prop));
- break;
- case IDP_IDPARRAY:
- {
- IDProperty *idp_array = IDP_IDPArray(prop);
- for (int i = 0; i < prop->len; i++) {
- expand_idprops(fd, mainvar, &idp_array[i]);
- }
- break;
- }
- case IDP_GROUP:
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
- expand_idprops(fd, mainvar, loop);
- }
- break;
- }
+ if (!prop)
+ return;
+
+ switch (prop->type) {
+ case IDP_ID:
+ expand_doit(fd, mainvar, IDP_Id(prop));
+ break;
+ case IDP_IDPARRAY: {
+ IDProperty *idp_array = IDP_IDPArray(prop);
+ for (int i = 0; i < prop->len; i++) {
+ expand_idprops(fd, mainvar, &idp_array[i]);
+ }
+ break;
+ }
+ case IDP_GROUP:
+ for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ expand_idprops(fd, mainvar, loop);
+ }
+ break;
+ }
}
static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list)
{
- FModifier *fcm;
+ FModifier *fcm;
- for (fcm = list->first; fcm; fcm = fcm->next) {
- /* library data for specific F-Modifier types */
- switch (fcm->type) {
- case FMODIFIER_TYPE_PYTHON:
- {
- FMod_Python *data = (FMod_Python *)fcm->data;
+ for (fcm = list->first; fcm; fcm = fcm->next) {
+ /* library data for specific F-Modifier types */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_PYTHON: {
+ FMod_Python *data = (FMod_Python *)fcm->data;
- expand_doit(fd, mainvar, data->script);
+ expand_doit(fd, mainvar, data->script);
- break;
- }
- }
- }
+ break;
+ }
+ }
+ }
}
static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list)
{
- FCurve *fcu;
+ FCurve *fcu;
- for (fcu = list->first; fcu; fcu = fcu->next) {
- /* Driver targets if there is a driver */
- if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
+ for (fcu = list->first; fcu; fcu = fcu->next) {
+ /* Driver targets if there is a driver */
+ if (fcu->driver) {
+ ChannelDriver *driver = fcu->driver;
+ DriverVar *dvar;
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER_BEGIN(dvar)
- {
- // TODO: only expand those that are going to get used?
- expand_doit(fd, mainvar, dtar->id);
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ // TODO: only expand those that are going to get used?
+ expand_doit(fd, mainvar, dtar->id);
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
- /* F-Curve Modifiers */
- expand_fmodifiers(fd, mainvar, &fcu->modifiers);
- }
+ /* F-Curve Modifiers */
+ expand_fmodifiers(fd, mainvar, &fcu->modifiers);
+ }
}
static void expand_action(FileData *fd, Main *mainvar, bAction *act)
{
- bActionChannel *chan;
+ bActionChannel *chan;
- // XXX deprecated - old animation system --------------
- for (chan = act->chanbase.first; chan; chan = chan->next) {
- expand_doit(fd, mainvar, chan->ipo);
- expand_constraint_channels(fd, mainvar, &chan->constraintChannels);
- }
- // ---------------------------------------------------
+ // XXX deprecated - old animation system --------------
+ for (chan = act->chanbase.first; chan; chan = chan->next) {
+ expand_doit(fd, mainvar, chan->ipo);
+ expand_constraint_channels(fd, mainvar, &chan->constraintChannels);
+ }
+ // ---------------------------------------------------
- /* F-Curves in Action */
- expand_fcurves(fd, mainvar, &act->curves);
+ /* F-Curves in Action */
+ expand_fcurves(fd, mainvar, &act->curves);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
- if (marker->camera) {
- expand_doit(fd, mainvar, marker->camera);
- }
- }
+ for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ if (marker->camera) {
+ expand_doit(fd, mainvar, marker->camera);
+ }
+ }
}
static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
+ KeyingSet *ks;
+ KS_Path *ksp;
- /* expand the ID-pointers in KeyingSets's paths */
- for (ks = list->first; ks; ks = ks->next) {
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- expand_doit(fd, mainvar, ksp->id);
- }
- }
+ /* expand the ID-pointers in KeyingSets's paths */
+ for (ks = list->first; ks; ks = ks->next) {
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ expand_doit(fd, mainvar, ksp->id);
+ }
+ }
}
static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *list)
{
- NlaStrip *strip;
+ NlaStrip *strip;
- for (strip = list->first; strip; strip = strip->next) {
- /* check child strips */
- expand_animdata_nlastrips(fd, mainvar, &strip->strips);
+ for (strip = list->first; strip; strip = strip->next) {
+ /* check child strips */
+ expand_animdata_nlastrips(fd, mainvar, &strip->strips);
- /* check F-Curves */
- expand_fcurves(fd, mainvar, &strip->fcurves);
+ /* check F-Curves */
+ expand_fcurves(fd, mainvar, &strip->fcurves);
- /* check F-Modifiers */
- expand_fmodifiers(fd, mainvar, &strip->modifiers);
+ /* check F-Modifiers */
+ expand_fmodifiers(fd, mainvar, &strip->modifiers);
- /* relink referenced action */
- expand_doit(fd, mainvar, strip->act);
- }
+ /* relink referenced action */
+ expand_doit(fd, mainvar, strip->act);
+ }
}
static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
{
- NlaTrack *nlt;
+ NlaTrack *nlt;
- /* own action */
- expand_doit(fd, mainvar, adt->action);
- expand_doit(fd, mainvar, adt->tmpact);
+ /* own action */
+ expand_doit(fd, mainvar, adt->action);
+ expand_doit(fd, mainvar, adt->tmpact);
- /* drivers - assume that these F-Curves have driver data to be in this list... */
- expand_fcurves(fd, mainvar, &adt->drivers);
+ /* drivers - assume that these F-Curves have driver data to be in this list... */
+ expand_fcurves(fd, mainvar, &adt->drivers);
- /* nla-data - referenced actions */
- for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
- expand_animdata_nlastrips(fd, mainvar, &nlt->strips);
+ /* nla-data - referenced actions */
+ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
+ expand_animdata_nlastrips(fd, mainvar, &nlt->strips);
}
static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
{
- int a;
-
- expand_doit(fd, mainvar, part->instance_object);
- expand_doit(fd, mainvar, part->instance_collection);
- expand_doit(fd, mainvar, part->eff_group);
- expand_doit(fd, mainvar, part->bb_ob);
- expand_doit(fd, mainvar, part->collision_group);
-
- if (part->adt)
- expand_animdata(fd, mainvar, part->adt);
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- expand_doit(fd, mainvar, part->mtex[a]->tex);
- expand_doit(fd, mainvar, part->mtex[a]->object);
- }
- }
-
- if (part->effector_weights) {
- expand_doit(fd, mainvar, part->effector_weights->group);
- }
-
- if (part->pd) {
- expand_doit(fd, mainvar, part->pd->tex);
- expand_doit(fd, mainvar, part->pd->f_source);
- }
- if (part->pd2) {
- expand_doit(fd, mainvar, part->pd2->tex);
- expand_doit(fd, mainvar, part->pd2->f_source);
- }
-
- if (part->boids) {
- BoidState *state;
- BoidRule *rule;
-
- for (state = part->boids->states.first; state; state = state->next) {
- for (rule = state->rules.first; rule; rule = rule->next) {
- if (rule->type == eBoidRuleType_Avoid) {
- BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
- expand_doit(fd, mainvar, gabr->ob);
- }
- else if (rule->type == eBoidRuleType_FollowLeader) {
- BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
- expand_doit(fd, mainvar, flbr->ob);
- }
- }
- }
- }
-
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
- expand_doit(fd, mainvar, dw->ob);
- }
+ int a;
+
+ expand_doit(fd, mainvar, part->instance_object);
+ expand_doit(fd, mainvar, part->instance_collection);
+ expand_doit(fd, mainvar, part->eff_group);
+ expand_doit(fd, mainvar, part->bb_ob);
+ expand_doit(fd, mainvar, part->collision_group);
+
+ if (part->adt)
+ expand_animdata(fd, mainvar, part->adt);
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (part->mtex[a]) {
+ expand_doit(fd, mainvar, part->mtex[a]->tex);
+ expand_doit(fd, mainvar, part->mtex[a]->object);
+ }
+ }
+
+ if (part->effector_weights) {
+ expand_doit(fd, mainvar, part->effector_weights->group);
+ }
+
+ if (part->pd) {
+ expand_doit(fd, mainvar, part->pd->tex);
+ expand_doit(fd, mainvar, part->pd->f_source);
+ }
+ if (part->pd2) {
+ expand_doit(fd, mainvar, part->pd2->tex);
+ expand_doit(fd, mainvar, part->pd2->f_source);
+ }
+
+ if (part->boids) {
+ BoidState *state;
+ BoidRule *rule;
+
+ for (state = part->boids->states.first; state; state = state->next) {
+ for (rule = state->rules.first; rule; rule = rule->next) {
+ if (rule->type == eBoidRuleType_Avoid) {
+ BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
+ expand_doit(fd, mainvar, gabr->ob);
+ }
+ else if (rule->type == eBoidRuleType_FollowLeader) {
+ BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
+ expand_doit(fd, mainvar, flbr->ob);
+ }
+ }
+ }
+ }
+
+ for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ expand_doit(fd, mainvar, dw->ob);
+ }
}
static void expand_collection(FileData *fd, Main *mainvar, Collection *collection)
{
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
- expand_doit(fd, mainvar, cob->ob);
- }
+ for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ expand_doit(fd, mainvar, cob->ob);
+ }
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
- expand_doit(fd, mainvar, child->collection);
- }
+ for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ expand_doit(fd, mainvar, child->collection);
+ }
#ifdef USE_COLLECTION_COMPAT_28
- if (collection->collection != NULL) {
- expand_scene_collection(fd, mainvar, collection->collection);
- }
+ if (collection->collection != NULL) {
+ expand_scene_collection(fd, mainvar, collection->collection);
+ }
#endif
}
static void expand_key(FileData *fd, Main *mainvar, Key *key)
{
- expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
- if (key->adt)
- expand_animdata(fd, mainvar, key->adt);
+ if (key->adt)
+ expand_animdata(fd, mainvar, key->adt);
}
static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
+ bNode *node;
+ bNodeSocket *sock;
- if (ntree->adt)
- expand_animdata(fd, mainvar, ntree->adt);
+ if (ntree->adt)
+ expand_animdata(fd, mainvar, ntree->adt);
- if (ntree->gpd)
- expand_doit(fd, mainvar, ntree->gpd);
+ if (ntree->gpd)
+ expand_doit(fd, mainvar, ntree->gpd);
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id && node->type != CMP_NODE_R_LAYERS) {
- expand_doit(fd, mainvar, node->id);
- }
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->id && node->type != CMP_NODE_R_LAYERS) {
+ expand_doit(fd, mainvar, node->id);
+ }
- expand_idprops(fd, mainvar, node->prop);
+ expand_idprops(fd, mainvar, node->prop);
- for (sock = node->inputs.first; sock; sock = sock->next)
- expand_idprops(fd, mainvar, sock->prop);
- for (sock = node->outputs.first; sock; sock = sock->next)
- expand_idprops(fd, mainvar, sock->prop);
- }
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ expand_idprops(fd, mainvar, sock->prop);
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ expand_idprops(fd, mainvar, sock->prop);
+ }
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- expand_idprops(fd, mainvar, sock->prop);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- expand_idprops(fd, mainvar, sock->prop);
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ expand_idprops(fd, mainvar, sock->prop);
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ expand_idprops(fd, mainvar, sock->prop);
}
static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
{
- expand_doit(fd, mainvar, tex->ima);
- expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, tex->ima);
+ expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system
- if (tex->adt)
- expand_animdata(fd, mainvar, tex->adt);
+ if (tex->adt)
+ expand_animdata(fd, mainvar, tex->adt);
- if (tex->nodetree)
- expand_nodetree(fd, mainvar, tex->nodetree);
+ if (tex->nodetree)
+ expand_nodetree(fd, mainvar, tex->nodetree);
}
static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
{
- expand_doit(fd, mainvar, brush->mtex.tex);
- expand_doit(fd, mainvar, brush->mask_mtex.tex);
- expand_doit(fd, mainvar, brush->clone.image);
- expand_doit(fd, mainvar, brush->paint_curve);
- if (brush->gpencil_settings != NULL) {
- expand_doit(fd, mainvar, brush->gpencil_settings->material);
- }
+ expand_doit(fd, mainvar, brush->mtex.tex);
+ expand_doit(fd, mainvar, brush->mask_mtex.tex);
+ expand_doit(fd, mainvar, brush->clone.image);
+ expand_doit(fd, mainvar, brush->paint_curve);
+ if (brush->gpencil_settings != NULL) {
+ expand_doit(fd, mainvar, brush->gpencil_settings->material);
+ }
}
static void expand_material(FileData *fd, Main *mainvar, Material *ma)
{
- expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system
- if (ma->adt)
- expand_animdata(fd, mainvar, ma->adt);
+ if (ma->adt)
+ expand_animdata(fd, mainvar, ma->adt);
- if (ma->nodetree)
- expand_nodetree(fd, mainvar, ma->nodetree);
+ if (ma->nodetree)
+ expand_nodetree(fd, mainvar, ma->nodetree);
- if (ma->gp_style) {
- MaterialGPencilStyle *gp_style = ma->gp_style;
- expand_doit(fd, mainvar, gp_style->sima);
- expand_doit(fd, mainvar, gp_style->ima);
- }
+ if (ma->gp_style) {
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ expand_doit(fd, mainvar, gp_style->sima);
+ expand_doit(fd, mainvar, gp_style->ima);
+ }
}
static void expand_light(FileData *fd, Main *mainvar, Light *la)
{
- expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system
- if (la->adt)
- expand_animdata(fd, mainvar, la->adt);
+ if (la->adt)
+ expand_animdata(fd, mainvar, la->adt);
- if (la->nodetree)
- expand_nodetree(fd, mainvar, la->nodetree);
+ if (la->nodetree)
+ expand_nodetree(fd, mainvar, la->nodetree);
}
static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
{
- expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system
- expand_doit(fd, mainvar, lt->key);
+ expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, lt->key);
- if (lt->adt)
- expand_animdata(fd, mainvar, lt->adt);
+ if (lt->adt)
+ expand_animdata(fd, mainvar, lt->adt);
}
-
static void expand_world(FileData *fd, Main *mainvar, World *wrld)
{
- expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system
- if (wrld->adt)
- expand_animdata(fd, mainvar, wrld->adt);
+ if (wrld->adt)
+ expand_animdata(fd, mainvar, wrld->adt);
- if (wrld->nodetree)
- expand_nodetree(fd, mainvar, wrld->nodetree);
+ if (wrld->nodetree)
+ expand_nodetree(fd, mainvar, wrld->nodetree);
}
-
static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb)
{
- int a;
+ int a;
- for (a = 0; a < mb->totcol; a++) {
- expand_doit(fd, mainvar, mb->mat[a]);
- }
+ for (a = 0; a < mb->totcol; a++) {
+ expand_doit(fd, mainvar, mb->mat[a]);
+ }
- if (mb->adt)
- expand_animdata(fd, mainvar, mb->adt);
+ if (mb->adt)
+ expand_animdata(fd, mainvar, mb->adt);
}
static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
{
- int a;
+ int a;
- for (a = 0; a < cu->totcol; a++) {
- expand_doit(fd, mainvar, cu->mat[a]);
- }
+ for (a = 0; a < cu->totcol; a++) {
+ expand_doit(fd, mainvar, cu->mat[a]);
+ }
- expand_doit(fd, mainvar, cu->vfont);
- expand_doit(fd, mainvar, cu->vfontb);
- expand_doit(fd, mainvar, cu->vfonti);
- expand_doit(fd, mainvar, cu->vfontbi);
- expand_doit(fd, mainvar, cu->key);
- expand_doit(fd, mainvar, cu->ipo); // XXX deprecated - old animation system
- expand_doit(fd, mainvar, cu->bevobj);
- expand_doit(fd, mainvar, cu->taperobj);
- expand_doit(fd, mainvar, cu->textoncurve);
+ expand_doit(fd, mainvar, cu->vfont);
+ expand_doit(fd, mainvar, cu->vfontb);
+ expand_doit(fd, mainvar, cu->vfonti);
+ expand_doit(fd, mainvar, cu->vfontbi);
+ expand_doit(fd, mainvar, cu->key);
+ expand_doit(fd, mainvar, cu->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, cu->bevobj);
+ expand_doit(fd, mainvar, cu->taperobj);
+ expand_doit(fd, mainvar, cu->textoncurve);
- if (cu->adt)
- expand_animdata(fd, mainvar, cu->adt);
+ if (cu->adt)
+ expand_animdata(fd, mainvar, cu->adt);
}
static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
{
- int a;
+ int a;
- if (me->adt)
- expand_animdata(fd, mainvar, me->adt);
+ if (me->adt)
+ expand_animdata(fd, mainvar, me->adt);
- for (a = 0; a < me->totcol; a++) {
- expand_doit(fd, mainvar, me->mat[a]);
- }
+ for (a = 0; a < me->totcol; a++) {
+ expand_doit(fd, mainvar, me->mat[a]);
+ }
- expand_doit(fd, mainvar, me->key);
- expand_doit(fd, mainvar, me->texcomesh);
+ expand_doit(fd, mainvar, me->key);
+ expand_doit(fd, mainvar, me->texcomesh);
}
/* temp struct used to transport needed info to expand_constraint_cb() */
typedef struct tConstraintExpandData {
- FileData *fd;
- Main *mainvar;
+ FileData *fd;
+ Main *mainvar;
} tConstraintExpandData;
/* callback function used to expand constraint ID-links */
-static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *userdata)
+static void expand_constraint_cb(bConstraint *UNUSED(con),
+ ID **idpoin,
+ bool UNUSED(is_reference),
+ void *userdata)
{
- tConstraintExpandData *ced = (tConstraintExpandData *)userdata;
- expand_doit(ced->fd, ced->mainvar, *idpoin);
+ tConstraintExpandData *ced = (tConstraintExpandData *)userdata;
+ expand_doit(ced->fd, ced->mainvar, *idpoin);
}
static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
{
- tConstraintExpandData ced;
- bConstraint *curcon;
+ tConstraintExpandData ced;
+ bConstraint *curcon;
- /* relink all ID-blocks used by the constraints */
- ced.fd = fd;
- ced.mainvar = mainvar;
+ /* relink all ID-blocks used by the constraints */
+ ced.fd = fd;
+ ced.mainvar = mainvar;
- BKE_constraints_id_loop(lb, expand_constraint_cb, &ced);
+ BKE_constraints_id_loop(lb, expand_constraint_cb, &ced);
- /* deprecated manual expansion stuff */
- for (curcon = lb->first; curcon; curcon = curcon->next) {
- if (curcon->ipo)
- expand_doit(fd, mainvar, curcon->ipo); // XXX deprecated - old animation system
- }
+ /* deprecated manual expansion stuff */
+ for (curcon = lb->first; curcon; curcon = curcon->next) {
+ if (curcon->ipo)
+ expand_doit(fd, mainvar, curcon->ipo); // XXX deprecated - old animation system
+ }
}
static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
{
- bPoseChannel *chan;
+ bPoseChannel *chan;
- if (!pose)
- return;
+ if (!pose)
+ return;
- for (chan = pose->chanbase.first; chan; chan = chan->next) {
- expand_constraints(fd, mainvar, &chan->constraints);
- expand_idprops(fd, mainvar, chan->prop);
- expand_doit(fd, mainvar, chan->custom);
- }
+ for (chan = pose->chanbase.first; chan; chan = chan->next) {
+ expand_constraints(fd, mainvar, &chan->constraints);
+ expand_idprops(fd, mainvar, chan->prop);
+ expand_doit(fd, mainvar, chan->custom);
+ }
}
static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
{
- expand_idprops(fd, mainvar, bone->prop);
+ expand_idprops(fd, mainvar, bone->prop);
- for (Bone *curBone = bone->childbase.first; curBone; curBone = curBone->next) {
- expand_bones(fd, mainvar, curBone);
- }
+ for (Bone *curBone = bone->childbase.first; curBone; curBone = curBone->next) {
+ expand_bones(fd, mainvar, curBone);
+ }
}
static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
{
- if (arm->adt)
- expand_animdata(fd, mainvar, arm->adt);
+ if (arm->adt)
+ expand_animdata(fd, mainvar, arm->adt);
- for (Bone *curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
- expand_bones(fd, mainvar, curBone);
- }
+ for (Bone *curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
+ expand_bones(fd, mainvar, curBone);
+ }
}
-static void expand_object_expandModifiers(
- void *userData, Object *UNUSED(ob), ID **idpoin, int UNUSED(cb_flag))
+static void expand_object_expandModifiers(void *userData,
+ Object *UNUSED(ob),
+ ID **idpoin,
+ int UNUSED(cb_flag))
{
- struct { FileData *fd; Main *mainvar; } *data = userData;
+ struct {
+ FileData *fd;
+ Main *mainvar;
+ } *data = userData;
- FileData *fd = data->fd;
- Main *mainvar = data->mainvar;
+ FileData *fd = data->fd;
+ Main *mainvar = data->mainvar;
- expand_doit(fd, mainvar, *idpoin);
+ expand_doit(fd, mainvar, *idpoin);
}
static void expand_object(FileData *fd, Main *mainvar, Object *ob)
{
- ParticleSystem *psys;
- bActionStrip *strip;
- PartEff *paf;
- int a;
-
- expand_doit(fd, mainvar, ob->data);
-
- /* expand_object_expandModifier() */
- if (ob->modifiers.first) {
- struct { FileData *fd; Main *mainvar; } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
- }
-
- /* expand_object_expandModifier() */
- if (ob->greasepencil_modifiers.first) {
- struct { FileData *fd; Main *mainvar; } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- BKE_gpencil_modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
- }
-
- /* expand_object_expandShaderFx() */
- if (ob->shader_fx.first) {
- struct { FileData *fd; Main *mainvar; } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- BKE_shaderfx_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
- }
-
- expand_pose(fd, mainvar, ob->pose);
- expand_doit(fd, mainvar, ob->poselib);
- expand_constraints(fd, mainvar, &ob->constraints);
-
- expand_doit(fd, mainvar, ob->gpd);
-
-// XXX deprecated - old animation system (for version patching only)
- expand_doit(fd, mainvar, ob->ipo);
- expand_doit(fd, mainvar, ob->action);
-
- expand_constraint_channels(fd, mainvar, &ob->constraintChannels);
-
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- expand_doit(fd, mainvar, strip->object);
- expand_doit(fd, mainvar, strip->act);
- expand_doit(fd, mainvar, strip->ipo);
- }
-// XXX deprecated - old animation system (for version patching only)
-
- if (ob->adt)
- expand_animdata(fd, mainvar, ob->adt);
-
- for (a = 0; a < ob->totcol; a++) {
- expand_doit(fd, mainvar, ob->mat[a]);
- }
-
- paf = blo_do_version_give_parteff_245(ob);
- if (paf && paf->group)
- expand_doit(fd, mainvar, paf->group);
-
- if (ob->instance_collection)
- expand_doit(fd, mainvar, ob->instance_collection);
-
- if (ob->proxy)
- expand_doit(fd, mainvar, ob->proxy);
- if (ob->proxy_group)
- expand_doit(fd, mainvar, ob->proxy_group);
-
- for (psys = ob->particlesystem.first; psys; psys = psys->next)
- expand_doit(fd, mainvar, psys->part);
-
- if (ob->pd) {
- expand_doit(fd, mainvar, ob->pd->tex);
- expand_doit(fd, mainvar, ob->pd->f_source);
- }
-
- if (ob->soft) {
- expand_doit(fd, mainvar, ob->soft->collision_group);
-
- if (ob->soft->effector_weights) {
- expand_doit(fd, mainvar, ob->soft->effector_weights->group);
- }
- }
-
- if (ob->rigidbody_constraint) {
- expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1);
- expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2);
- }
-
- if (ob->currentlod) {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- expand_doit(fd, mainvar, level->source);
- }
- }
+ ParticleSystem *psys;
+ bActionStrip *strip;
+ PartEff *paf;
+ int a;
+
+ expand_doit(fd, mainvar, ob->data);
+
+ /* expand_object_expandModifier() */
+ if (ob->modifiers.first) {
+ struct {
+ FileData *fd;
+ Main *mainvar;
+ } data;
+ data.fd = fd;
+ data.mainvar = mainvar;
+
+ modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ }
+
+ /* expand_object_expandModifier() */
+ if (ob->greasepencil_modifiers.first) {
+ struct {
+ FileData *fd;
+ Main *mainvar;
+ } data;
+ data.fd = fd;
+ data.mainvar = mainvar;
+
+ BKE_gpencil_modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ }
+
+ /* expand_object_expandShaderFx() */
+ if (ob->shader_fx.first) {
+ struct {
+ FileData *fd;
+ Main *mainvar;
+ } data;
+ data.fd = fd;
+ data.mainvar = mainvar;
+
+ BKE_shaderfx_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ }
+
+ expand_pose(fd, mainvar, ob->pose);
+ expand_doit(fd, mainvar, ob->poselib);
+ expand_constraints(fd, mainvar, &ob->constraints);
+
+ expand_doit(fd, mainvar, ob->gpd);
+
+ // XXX deprecated - old animation system (for version patching only)
+ expand_doit(fd, mainvar, ob->ipo);
+ expand_doit(fd, mainvar, ob->action);
+
+ expand_constraint_channels(fd, mainvar, &ob->constraintChannels);
+
+ for (strip = ob->nlastrips.first; strip; strip = strip->next) {
+ expand_doit(fd, mainvar, strip->object);
+ expand_doit(fd, mainvar, strip->act);
+ expand_doit(fd, mainvar, strip->ipo);
+ }
+ // XXX deprecated - old animation system (for version patching only)
+
+ if (ob->adt)
+ expand_animdata(fd, mainvar, ob->adt);
+
+ for (a = 0; a < ob->totcol; a++) {
+ expand_doit(fd, mainvar, ob->mat[a]);
+ }
+
+ paf = blo_do_version_give_parteff_245(ob);
+ if (paf && paf->group)
+ expand_doit(fd, mainvar, paf->group);
+
+ if (ob->instance_collection)
+ expand_doit(fd, mainvar, ob->instance_collection);
+
+ if (ob->proxy)
+ expand_doit(fd, mainvar, ob->proxy);
+ if (ob->proxy_group)
+ expand_doit(fd, mainvar, ob->proxy_group);
+
+ for (psys = ob->particlesystem.first; psys; psys = psys->next)
+ expand_doit(fd, mainvar, psys->part);
+
+ if (ob->pd) {
+ expand_doit(fd, mainvar, ob->pd->tex);
+ expand_doit(fd, mainvar, ob->pd->f_source);
+ }
+
+ if (ob->soft) {
+ expand_doit(fd, mainvar, ob->soft->collision_group);
+
+ if (ob->soft->effector_weights) {
+ expand_doit(fd, mainvar, ob->soft->effector_weights->group);
+ }
+ }
+
+ if (ob->rigidbody_constraint) {
+ expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1);
+ expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2);
+ }
+
+ if (ob->currentlod) {
+ LodLevel *level;
+ for (level = ob->lodlevels.first; level; level = level->next) {
+ expand_doit(fd, mainvar, level->source);
+ }
+ }
}
#ifdef USE_COLLECTION_COMPAT_28
static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc)
{
- for (LinkData *link = sc->objects.first; link; link = link->next) {
- expand_doit(fd, mainvar, link->data);
- }
+ for (LinkData *link = sc->objects.first; link; link = link->next) {
+ expand_doit(fd, mainvar, link->data);
+ }
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
- expand_scene_collection(fd, mainvar, nsc);
- }
+ for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ expand_scene_collection(fd, mainvar, nsc);
+ }
}
#endif
static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
{
- SceneRenderLayer *srl;
- FreestyleModuleConfig *module;
- FreestyleLineSet *lineset;
-
- for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) {
- expand_doit(fd, mainvar, base_legacy->object);
- }
- expand_doit(fd, mainvar, sce->camera);
- expand_doit(fd, mainvar, sce->world);
-
- if (sce->adt)
- expand_animdata(fd, mainvar, sce->adt);
- expand_keyingsets(fd, mainvar, &sce->keyingsets);
-
- if (sce->set)
- expand_doit(fd, mainvar, sce->set);
-
- if (sce->nodetree)
- expand_nodetree(fd, mainvar, sce->nodetree);
-
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
- expand_doit(fd, mainvar, srl->mat_override);
- for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
- if (module->script)
- expand_doit(fd, mainvar, module->script);
- }
- for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
- if (lineset->group)
- expand_doit(fd, mainvar, lineset->group);
- expand_doit(fd, mainvar, lineset->linestyle);
- }
- }
-
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- expand_idprops(fd, mainvar, view_layer->id_properties);
-
- for (module = view_layer->freestyle_config.modules.first; module; module = module->next) {
- if (module->script) {
- expand_doit(fd, mainvar, module->script);
- }
- }
-
- for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
- if (lineset->group) {
- expand_doit(fd, mainvar, lineset->group);
- }
- expand_doit(fd, mainvar, lineset->linestyle);
- }
- }
-
- if (sce->gpd)
- expand_doit(fd, mainvar, sce->gpd);
-
- if (sce->ed) {
- Sequence *seq;
-
- SEQ_BEGIN(sce->ed, seq)
- {
- expand_idprops(fd, mainvar, seq->prop);
-
- if (seq->scene) expand_doit(fd, mainvar, seq->scene);
- if (seq->scene_camera) expand_doit(fd, mainvar, seq->scene_camera);
- if (seq->clip) expand_doit(fd, mainvar, seq->clip);
- if (seq->mask) expand_doit(fd, mainvar, seq->mask);
- if (seq->sound) expand_doit(fd, mainvar, seq->sound);
-
- if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
- TextVars *data = seq->effectdata;
- expand_doit(fd, mainvar, data->text_font);
- }
- } SEQ_END;
- }
-
- if (sce->rigidbody_world) {
- expand_doit(fd, mainvar, sce->rigidbody_world->group);
- expand_doit(fd, mainvar, sce->rigidbody_world->constraints);
- }
-
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
- if (marker->camera) {
- expand_doit(fd, mainvar, marker->camera);
- }
- }
-
- expand_doit(fd, mainvar, sce->clip);
+ SceneRenderLayer *srl;
+ FreestyleModuleConfig *module;
+ FreestyleLineSet *lineset;
+
+ for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) {
+ expand_doit(fd, mainvar, base_legacy->object);
+ }
+ expand_doit(fd, mainvar, sce->camera);
+ expand_doit(fd, mainvar, sce->world);
+
+ if (sce->adt)
+ expand_animdata(fd, mainvar, sce->adt);
+ expand_keyingsets(fd, mainvar, &sce->keyingsets);
+
+ if (sce->set)
+ expand_doit(fd, mainvar, sce->set);
+
+ if (sce->nodetree)
+ expand_nodetree(fd, mainvar, sce->nodetree);
+
+ for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ expand_doit(fd, mainvar, srl->mat_override);
+ for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
+ if (module->script)
+ expand_doit(fd, mainvar, module->script);
+ }
+ for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+ if (lineset->group)
+ expand_doit(fd, mainvar, lineset->group);
+ expand_doit(fd, mainvar, lineset->linestyle);
+ }
+ }
+
+ for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ expand_idprops(fd, mainvar, view_layer->id_properties);
+
+ for (module = view_layer->freestyle_config.modules.first; module; module = module->next) {
+ if (module->script) {
+ expand_doit(fd, mainvar, module->script);
+ }
+ }
+
+ for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
+ if (lineset->group) {
+ expand_doit(fd, mainvar, lineset->group);
+ }
+ expand_doit(fd, mainvar, lineset->linestyle);
+ }
+ }
+
+ if (sce->gpd)
+ expand_doit(fd, mainvar, sce->gpd);
+
+ if (sce->ed) {
+ Sequence *seq;
+
+ SEQ_BEGIN (sce->ed, seq) {
+ expand_idprops(fd, mainvar, seq->prop);
+
+ if (seq->scene)
+ expand_doit(fd, mainvar, seq->scene);
+ if (seq->scene_camera)
+ expand_doit(fd, mainvar, seq->scene_camera);
+ if (seq->clip)
+ expand_doit(fd, mainvar, seq->clip);
+ if (seq->mask)
+ expand_doit(fd, mainvar, seq->mask);
+ if (seq->sound)
+ expand_doit(fd, mainvar, seq->sound);
+
+ if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
+ TextVars *data = seq->effectdata;
+ expand_doit(fd, mainvar, data->text_font);
+ }
+ }
+ SEQ_END;
+ }
+
+ if (sce->rigidbody_world) {
+ expand_doit(fd, mainvar, sce->rigidbody_world->group);
+ expand_doit(fd, mainvar, sce->rigidbody_world->constraints);
+ }
+
+ for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ if (marker->camera) {
+ expand_doit(fd, mainvar, marker->camera);
+ }
+ }
+
+ expand_doit(fd, mainvar, sce->clip);
#ifdef USE_COLLECTION_COMPAT_28
- if (sce->collection) {
- expand_scene_collection(fd, mainvar, sce->collection);
- }
+ if (sce->collection) {
+ expand_scene_collection(fd, mainvar, sce->collection);
+ }
#endif
- if (sce->master_collection) {
- expand_collection(fd, mainvar, sce->master_collection);
- }
+ if (sce->master_collection) {
+ expand_collection(fd, mainvar, sce->master_collection);
+ }
- if (sce->r.bake.cage_object) {
- expand_doit(fd, mainvar, sce->r.bake.cage_object);
- }
+ if (sce->r.bake.cage_object) {
+ expand_doit(fd, mainvar, sce->r.bake.cage_object);
+ }
}
static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
{
- expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system
- if (ca->adt)
- expand_animdata(fd, mainvar, ca->adt);
+ if (ca->adt)
+ expand_animdata(fd, mainvar, ca->adt);
}
static void expand_cachefile(FileData *fd, Main *mainvar, CacheFile *cache_file)
{
- if (cache_file->adt) {
- expand_animdata(fd, mainvar, cache_file->adt);
- }
+ if (cache_file->adt) {
+ expand_animdata(fd, mainvar, cache_file->adt);
+ }
}
static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
{
- expand_doit(fd, mainvar, spk->sound);
+ expand_doit(fd, mainvar, spk->sound);
- if (spk->adt)
- expand_animdata(fd, mainvar, spk->adt);
+ if (spk->adt)
+ expand_animdata(fd, mainvar, spk->adt);
}
static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
{
- expand_doit(fd, mainvar, snd->ipo); // XXX deprecated - old animation system
+ expand_doit(fd, mainvar, snd->ipo); // XXX deprecated - old animation system
}
static void expand_lightprobe(FileData *fd, Main *mainvar, LightProbe *prb)
{
- if (prb->adt)
- expand_animdata(fd, mainvar, prb->adt);
+ if (prb->adt)
+ expand_animdata(fd, mainvar, prb->adt);
}
static void expand_movieclip(FileData *fd, Main *mainvar, MovieClip *clip)
{
- if (clip->adt)
- expand_animdata(fd, mainvar, clip->adt);
+ if (clip->adt)
+ expand_animdata(fd, mainvar, clip->adt);
}
static void expand_mask_parent(FileData *fd, Main *mainvar, MaskParent *parent)
{
- if (parent->id) {
- expand_doit(fd, mainvar, parent->id);
- }
+ if (parent->id) {
+ expand_doit(fd, mainvar, parent->id);
+ }
}
static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
{
- MaskLayer *mask_layer;
+ MaskLayer *mask_layer;
- if (mask->adt)
- expand_animdata(fd, mainvar, mask->adt);
+ if (mask->adt)
+ expand_animdata(fd, mainvar, mask->adt);
- for (mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- MaskSpline *spline;
+ for (mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ MaskSpline *spline;
- for (spline = mask_layer->splines.first; spline; spline = spline->next) {
- int i;
+ for (spline = mask_layer->splines.first; spline; spline = spline->next) {
+ int i;
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point = &spline->points[i];
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
- expand_mask_parent(fd, mainvar, &point->parent);
- }
+ expand_mask_parent(fd, mainvar, &point->parent);
+ }
- expand_mask_parent(fd, mainvar, &spline->parent);
- }
- }
+ expand_mask_parent(fd, mainvar, &spline->parent);
+ }
+ }
}
static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
{
- int a;
- LineStyleModifier *m;
-
- for (a = 0; a < MAX_MTEX; a++) {
- if (linestyle->mtex[a]) {
- expand_doit(fd, mainvar, linestyle->mtex[a]->tex);
- expand_doit(fd, mainvar, linestyle->mtex[a]->object);
- }
- }
- if (linestyle->nodetree)
- expand_nodetree(fd, mainvar, linestyle->nodetree);
-
- if (linestyle->adt)
- expand_animdata(fd, mainvar, linestyle->adt);
- for (m = linestyle->color_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
- expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
- }
- for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
- expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
- }
- for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
- expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
- }
+ int a;
+ LineStyleModifier *m;
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ expand_doit(fd, mainvar, linestyle->mtex[a]->tex);
+ expand_doit(fd, mainvar, linestyle->mtex[a]->object);
+ }
+ }
+ if (linestyle->nodetree)
+ expand_nodetree(fd, mainvar, linestyle->nodetree);
+
+ if (linestyle->adt)
+ expand_animdata(fd, mainvar, linestyle->adt);
+ for (m = linestyle->color_modifiers.first; m; m = m->next) {
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
+ }
+ for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
+ }
+ for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
+ }
}
static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
{
- if (gpd->adt) {
- expand_animdata(fd, mainvar, gpd->adt);
- }
+ if (gpd->adt) {
+ expand_animdata(fd, mainvar, gpd->adt);
+ }
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- expand_doit(fd, mainvar, gpl->parent);
- }
-
- for (int a = 0; a < gpd->totcol; a++) {
- expand_doit(fd, mainvar, gpd->mat[a]);
- }
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ expand_doit(fd, mainvar, gpl->parent);
+ }
+ for (int a = 0; a < gpd->totcol; a++) {
+ expand_doit(fd, mainvar, gpd->mat[a]);
+ }
}
static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
{
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
+ ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
- expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout));
- }
+ for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout));
+ }
}
/**
@@ -10649,7 +10791,7 @@ static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
*/
void BLO_main_expander(BLOExpandDoitCallback expand_doit_func)
{
- expand_doit = expand_doit_func;
+ expand_doit = expand_doit_func;
}
/**
@@ -10661,120 +10803,119 @@ void BLO_main_expander(BLOExpandDoitCallback expand_doit_func)
*/
void BLO_expand_main(void *fdhandle, Main *mainvar)
{
- ListBase *lbarray[MAX_LIBARRAY];
- FileData *fd = fdhandle;
- ID *id;
- int a;
- bool do_it = true;
-
- while (do_it) {
- do_it = false;
-
- a = set_listbasepointers(mainvar, lbarray);
- while (a--) {
- id = lbarray[a]->first;
- while (id) {
- if (id->tag & LIB_TAG_NEED_EXPAND) {
- expand_id(fd, mainvar, id);
- expand_idprops(fd, mainvar, id->properties);
-
- switch (GS(id->name)) {
- case ID_OB:
- expand_object(fd, mainvar, (Object *)id);
- break;
- case ID_ME:
- expand_mesh(fd, mainvar, (Mesh *)id);
- break;
- case ID_CU:
- expand_curve(fd, mainvar, (Curve *)id);
- break;
- case ID_MB:
- expand_mball(fd, mainvar, (MetaBall *)id);
- break;
- case ID_SCE:
- expand_scene(fd, mainvar, (Scene *)id);
- break;
- case ID_MA:
- expand_material(fd, mainvar, (Material *)id);
- break;
- case ID_TE:
- expand_texture(fd, mainvar, (Tex *)id);
- break;
- case ID_WO:
- expand_world(fd, mainvar, (World *)id);
- break;
- case ID_LT:
- expand_lattice(fd, mainvar, (Lattice *)id);
- break;
- case ID_LA:
- expand_light(fd, mainvar, (Light *)id);
- break;
- case ID_KE:
- expand_key(fd, mainvar, (Key *)id);
- break;
- case ID_CA:
- expand_camera(fd, mainvar, (Camera *)id);
- break;
- case ID_SPK:
- expand_speaker(fd, mainvar, (Speaker *)id);
- break;
- case ID_SO:
- expand_sound(fd, mainvar, (bSound *)id);
- break;
- case ID_LP:
- expand_lightprobe(fd, mainvar, (LightProbe *)id);
- break;
- case ID_AR:
- expand_armature(fd, mainvar, (bArmature *)id);
- break;
- case ID_AC:
- expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system
- break;
- case ID_GR:
- expand_collection(fd, mainvar, (Collection *)id);
- break;
- case ID_NT:
- expand_nodetree(fd, mainvar, (bNodeTree *)id);
- break;
- case ID_BR:
- expand_brush(fd, mainvar, (Brush *)id);
- break;
- case ID_IP:
- expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system
- break;
- case ID_PA:
- expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
- break;
- case ID_MC:
- expand_movieclip(fd, mainvar, (MovieClip *)id);
- break;
- case ID_MSK:
- expand_mask(fd, mainvar, (Mask *)id);
- break;
- case ID_LS:
- expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
- break;
- case ID_GD:
- expand_gpencil(fd, mainvar, (bGPdata *)id);
- break;
- case ID_CF:
- expand_cachefile(fd, mainvar, (CacheFile *)id);
- break;
- case ID_WS:
- expand_workspace(fd, mainvar, (WorkSpace *)id);
- break;
- default:
- break;
- }
-
- do_it = true;
- id->tag &= ~LIB_TAG_NEED_EXPAND;
-
- }
- id = id->next;
- }
- }
- }
+ ListBase *lbarray[MAX_LIBARRAY];
+ FileData *fd = fdhandle;
+ ID *id;
+ int a;
+ bool do_it = true;
+
+ while (do_it) {
+ do_it = false;
+
+ a = set_listbasepointers(mainvar, lbarray);
+ while (a--) {
+ id = lbarray[a]->first;
+ while (id) {
+ if (id->tag & LIB_TAG_NEED_EXPAND) {
+ expand_id(fd, mainvar, id);
+ expand_idprops(fd, mainvar, id->properties);
+
+ switch (GS(id->name)) {
+ case ID_OB:
+ expand_object(fd, mainvar, (Object *)id);
+ break;
+ case ID_ME:
+ expand_mesh(fd, mainvar, (Mesh *)id);
+ break;
+ case ID_CU:
+ expand_curve(fd, mainvar, (Curve *)id);
+ break;
+ case ID_MB:
+ expand_mball(fd, mainvar, (MetaBall *)id);
+ break;
+ case ID_SCE:
+ expand_scene(fd, mainvar, (Scene *)id);
+ break;
+ case ID_MA:
+ expand_material(fd, mainvar, (Material *)id);
+ break;
+ case ID_TE:
+ expand_texture(fd, mainvar, (Tex *)id);
+ break;
+ case ID_WO:
+ expand_world(fd, mainvar, (World *)id);
+ break;
+ case ID_LT:
+ expand_lattice(fd, mainvar, (Lattice *)id);
+ break;
+ case ID_LA:
+ expand_light(fd, mainvar, (Light *)id);
+ break;
+ case ID_KE:
+ expand_key(fd, mainvar, (Key *)id);
+ break;
+ case ID_CA:
+ expand_camera(fd, mainvar, (Camera *)id);
+ break;
+ case ID_SPK:
+ expand_speaker(fd, mainvar, (Speaker *)id);
+ break;
+ case ID_SO:
+ expand_sound(fd, mainvar, (bSound *)id);
+ break;
+ case ID_LP:
+ expand_lightprobe(fd, mainvar, (LightProbe *)id);
+ break;
+ case ID_AR:
+ expand_armature(fd, mainvar, (bArmature *)id);
+ break;
+ case ID_AC:
+ expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system
+ break;
+ case ID_GR:
+ expand_collection(fd, mainvar, (Collection *)id);
+ break;
+ case ID_NT:
+ expand_nodetree(fd, mainvar, (bNodeTree *)id);
+ break;
+ case ID_BR:
+ expand_brush(fd, mainvar, (Brush *)id);
+ break;
+ case ID_IP:
+ expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system
+ break;
+ case ID_PA:
+ expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
+ break;
+ case ID_MC:
+ expand_movieclip(fd, mainvar, (MovieClip *)id);
+ break;
+ case ID_MSK:
+ expand_mask(fd, mainvar, (Mask *)id);
+ break;
+ case ID_LS:
+ expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
+ break;
+ case ID_GD:
+ expand_gpencil(fd, mainvar, (bGPdata *)id);
+ break;
+ case ID_CF:
+ expand_cachefile(fd, mainvar, (CacheFile *)id);
+ break;
+ case ID_WS:
+ expand_workspace(fd, mainvar, (WorkSpace *)id);
+ break;
+ default:
+ break;
+ }
+
+ do_it = true;
+ id->tag &= ~LIB_TAG_NEED_EXPAND;
+ }
+ id = id->next;
+ }
+ }
+ }
}
/** \} */
@@ -10783,238 +10924,246 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
/** \name Library Linking (helper functions)
* \{ */
-
static bool object_in_any_scene(Main *bmain, Object *ob)
{
- Scene *sce;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (BKE_scene_object_find(sce, ob)) {
- return true;
- }
- }
-
- return false;
-}
-
-static void add_loose_objects_to_scene(
- Main *mainvar, Main *bmain,
- Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
-{
- Collection *active_collection = NULL;
- const bool is_link = (flag & FILE_LINK) != 0;
-
- BLI_assert(scene);
-
- /* Give all objects which are LIB_TAG_INDIRECT a base, or for a collection when *lib has been set. */
- for (Object *ob = mainvar->objects.first; ob; ob = ob->id.next) {
- bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0;
- if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) {
- if (!is_link) {
- if (ob->id.us == 0) {
- do_it = true;
- }
- else if ((ob->id.lib == lib) && (object_in_any_scene(bmain, ob) == 0)) {
- /* When appending, make sure any indirectly loaded objects get a base, else they cant be accessed at all
- * (see T27437). */
- do_it = true;
- }
- }
-
- if (do_it) {
- /* Find or add collection as needed. */
- if (active_collection == NULL) {
- if (flag & FILE_ACTIVE_COLLECTION) {
- LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
- active_collection = lc->collection;
- }
- else {
- active_collection = BKE_collection_add(bmain, scene->master_collection, NULL);
- }
- }
-
- CLAMP_MIN(ob->id.us, 0);
- ob->mode = OB_MODE_OBJECT;
-
- BKE_collection_object_add(bmain, active_collection, ob);
- Base *base = BKE_view_layer_base_find(view_layer, ob);
-
- if (v3d != NULL) {
- base->local_view_bits |= v3d->local_view_uuid;
- }
-
- if (flag & FILE_AUTOSELECT) {
- base->flag |= BASE_SELECTED;
- /* Do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level. */
- }
-
- BKE_scene_object_base_flag_sync_from_base(base);
-
- ob->id.tag &= ~LIB_TAG_INDIRECT;
- ob->id.tag |= LIB_TAG_EXTERN;
- }
- }
- }
-}
-
-static void add_collections_to_scene(
- Main *mainvar, Main *bmain,
- Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
-{
- const bool do_append = (flag & FILE_LINK) == 0;
-
- Collection *active_collection = scene->master_collection;
- if (flag & FILE_ACTIVE_COLLECTION) {
- LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
- active_collection = lc->collection;
- }
-
- /* Give all objects which are tagged a base. */
- for (Collection *collection = mainvar->collections.first; collection; collection = collection->id.next) {
- if ((flag & FILE_GROUP_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) {
- /* Any indirect collection should not have been tagged. */
- BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0);
-
- /* BKE_object_add(...) messes with the selection. */
- Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2);
- ob->type = OB_EMPTY;
-
- BKE_collection_object_add(bmain, active_collection, ob);
- Base *base = BKE_view_layer_base_find(view_layer, ob);
-
- if (v3d != NULL) {
- base->local_view_bits |= v3d->local_view_uuid;
- }
-
- if (base->flag & BASE_SELECTABLE) {
- base->flag |= BASE_SELECTED;
- }
-
- BKE_scene_object_base_flag_sync_from_base(base);
- DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- view_layer->basact = base;
-
- /* Assign the collection. */
- ob->instance_collection = collection;
- id_us_plus(&collection->id);
- ob->transflag |= OB_DUPLICOLLECTION;
- copy_v3_v3(ob->loc, scene->cursor.location);
- }
- /* We do not want to force instantiation of indirectly linked collections...
- * Except when we are appending (since in that case, we'll end up instantiating all objects,
- * it's better to do it via their own collections if possible).
- * Reports showing that desired difference in behaviors between link and append: T62570, T61796. */
- else if (do_append || (collection->id.tag & LIB_TAG_INDIRECT) == 0) {
- bool do_add_collection = (collection->id.tag & LIB_TAG_DOIT) != 0;
- if (!do_add_collection) {
- /* We need to check that objects in that collections are already instantiated in a scene.
- * Otherwise, it's better to add the collection to the scene's active collection, than to
- * instantiate its objects in active scene's collection directly. See T61141.
- * Note that we only check object directly into that collection, not recursively into its children.
- */
- for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL; coll_ob = coll_ob->next) {
- Object *ob = coll_ob->ob;
- if ((ob->id.tag & LIB_TAG_PRE_EXISTING) == 0 &&
- (ob->id.tag & LIB_TAG_DOIT) == 0 &&
- (do_append || (ob->id.tag & LIB_TAG_INDIRECT) == 0) &&
- (ob->id.lib == lib) &&
- (object_in_any_scene(bmain, ob) == 0))
- {
- do_add_collection = true;
- break;
- }
- }
- }
- if (do_add_collection) {
- /* Add collection as child of active collection. */
- BKE_collection_child_add(bmain, active_collection, collection);
-
- if (flag & FILE_AUTOSELECT) {
- for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL; coll_ob = coll_ob->next) {
- Object *ob = coll_ob->ob;
- Base *base = BKE_view_layer_base_find(view_layer, ob);
- if (base) {
- base->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(base);
- }
- }
- }
-
- collection->id.tag &= ~LIB_TAG_INDIRECT;
- collection->id.tag |= LIB_TAG_EXTERN;
- }
- }
- }
+ Scene *sce;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (BKE_scene_object_find(sce, ob)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void add_loose_objects_to_scene(Main *mainvar,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ const View3D *v3d,
+ Library *lib,
+ const short flag)
+{
+ Collection *active_collection = NULL;
+ const bool is_link = (flag & FILE_LINK) != 0;
+
+ BLI_assert(scene);
+
+ /* Give all objects which are LIB_TAG_INDIRECT a base, or for a collection when *lib has been set. */
+ for (Object *ob = mainvar->objects.first; ob; ob = ob->id.next) {
+ bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0;
+ if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) {
+ if (!is_link) {
+ if (ob->id.us == 0) {
+ do_it = true;
+ }
+ else if ((ob->id.lib == lib) && (object_in_any_scene(bmain, ob) == 0)) {
+ /* When appending, make sure any indirectly loaded objects get a base, else they cant be accessed at all
+ * (see T27437). */
+ do_it = true;
+ }
+ }
+
+ if (do_it) {
+ /* Find or add collection as needed. */
+ if (active_collection == NULL) {
+ if (flag & FILE_ACTIVE_COLLECTION) {
+ LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
+ active_collection = lc->collection;
+ }
+ else {
+ active_collection = BKE_collection_add(bmain, scene->master_collection, NULL);
+ }
+ }
+
+ CLAMP_MIN(ob->id.us, 0);
+ ob->mode = OB_MODE_OBJECT;
+
+ BKE_collection_object_add(bmain, active_collection, ob);
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+ if (v3d != NULL) {
+ base->local_view_bits |= v3d->local_view_uuid;
+ }
+
+ if (flag & FILE_AUTOSELECT) {
+ base->flag |= BASE_SELECTED;
+ /* Do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level. */
+ }
+
+ BKE_scene_object_base_flag_sync_from_base(base);
+
+ ob->id.tag &= ~LIB_TAG_INDIRECT;
+ ob->id.tag |= LIB_TAG_EXTERN;
+ }
+ }
+ }
+}
+
+static void add_collections_to_scene(Main *mainvar,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ const View3D *v3d,
+ Library *lib,
+ const short flag)
+{
+ const bool do_append = (flag & FILE_LINK) == 0;
+
+ Collection *active_collection = scene->master_collection;
+ if (flag & FILE_ACTIVE_COLLECTION) {
+ LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
+ active_collection = lc->collection;
+ }
+
+ /* Give all objects which are tagged a base. */
+ for (Collection *collection = mainvar->collections.first; collection;
+ collection = collection->id.next) {
+ if ((flag & FILE_GROUP_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) {
+ /* Any indirect collection should not have been tagged. */
+ BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0);
+
+ /* BKE_object_add(...) messes with the selection. */
+ Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2);
+ ob->type = OB_EMPTY;
+
+ BKE_collection_object_add(bmain, active_collection, ob);
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+ if (v3d != NULL) {
+ base->local_view_bits |= v3d->local_view_uuid;
+ }
+
+ if (base->flag & BASE_SELECTABLE) {
+ base->flag |= BASE_SELECTED;
+ }
+
+ BKE_scene_object_base_flag_sync_from_base(base);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
+ view_layer->basact = base;
+
+ /* Assign the collection. */
+ ob->instance_collection = collection;
+ id_us_plus(&collection->id);
+ ob->transflag |= OB_DUPLICOLLECTION;
+ copy_v3_v3(ob->loc, scene->cursor.location);
+ }
+ /* We do not want to force instantiation of indirectly linked collections...
+ * Except when we are appending (since in that case, we'll end up instantiating all objects,
+ * it's better to do it via their own collections if possible).
+ * Reports showing that desired difference in behaviors between link and append: T62570, T61796. */
+ else if (do_append || (collection->id.tag & LIB_TAG_INDIRECT) == 0) {
+ bool do_add_collection = (collection->id.tag & LIB_TAG_DOIT) != 0;
+ if (!do_add_collection) {
+ /* We need to check that objects in that collections are already instantiated in a scene.
+ * Otherwise, it's better to add the collection to the scene's active collection, than to
+ * instantiate its objects in active scene's collection directly. See T61141.
+ * Note that we only check object directly into that collection, not recursively into its children.
+ */
+ for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL;
+ coll_ob = coll_ob->next) {
+ Object *ob = coll_ob->ob;
+ if ((ob->id.tag & LIB_TAG_PRE_EXISTING) == 0 && (ob->id.tag & LIB_TAG_DOIT) == 0 &&
+ (do_append || (ob->id.tag & LIB_TAG_INDIRECT) == 0) && (ob->id.lib == lib) &&
+ (object_in_any_scene(bmain, ob) == 0)) {
+ do_add_collection = true;
+ break;
+ }
+ }
+ }
+ if (do_add_collection) {
+ /* Add collection as child of active collection. */
+ BKE_collection_child_add(bmain, active_collection, collection);
+
+ if (flag & FILE_AUTOSELECT) {
+ for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL;
+ coll_ob = coll_ob->next) {
+ Object *ob = coll_ob->ob;
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (base) {
+ base->flag |= BASE_SELECTED;
+ BKE_scene_object_base_flag_sync_from_base(base);
+ }
+ }
+ }
+
+ collection->id.tag &= ~LIB_TAG_INDIRECT;
+ collection->id.tag |= LIB_TAG_EXTERN;
+ }
+ }
+ }
}
static ID *create_placeholder(Main *mainvar, const short idcode, const char *idname, const int tag)
{
- ListBase *lb = which_libbase(mainvar, idcode);
- ID *ph_id = BKE_libblock_alloc_notest(idcode);
+ ListBase *lb = which_libbase(mainvar, idcode);
+ ID *ph_id = BKE_libblock_alloc_notest(idcode);
- *((short *)ph_id->name) = idcode;
- BLI_strncpy(ph_id->name + 2, idname, sizeof(ph_id->name) - 2);
- BKE_libblock_init_empty(ph_id);
- ph_id->lib = mainvar->curlib;
- ph_id->tag = tag | LIB_TAG_MISSING;
- ph_id->us = ID_FAKE_USERS(ph_id);
- ph_id->icon_id = 0;
+ *((short *)ph_id->name) = idcode;
+ BLI_strncpy(ph_id->name + 2, idname, sizeof(ph_id->name) - 2);
+ BKE_libblock_init_empty(ph_id);
+ ph_id->lib = mainvar->curlib;
+ ph_id->tag = tag | LIB_TAG_MISSING;
+ ph_id->us = ID_FAKE_USERS(ph_id);
+ ph_id->icon_id = 0;
- BLI_addtail(lb, ph_id);
- id_sort_by_name(lb, ph_id);
+ BLI_addtail(lb, ph_id);
+ id_sort_by_name(lb, ph_id);
- return ph_id;
+ return ph_id;
}
/* returns true if the item was found
* but it may already have already been appended/linked */
static ID *link_named_part(
- Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
-{
- BHead *bhead = find_bhead_from_code_name(fd, idcode, name);
- ID *id;
-
- const bool use_placeholders = (flag & BLO_LIBLINK_USE_PLACEHOLDERS) != 0;
- const bool force_indirect = (flag & BLO_LIBLINK_FORCE_INDIRECT) != 0;
-
- BLI_assert(BKE_idcode_is_linkable(idcode) && BKE_idcode_is_valid(idcode));
-
- if (bhead) {
- id = is_yet_read(fd, mainl, bhead);
- if (id == NULL) {
- /* not read yet */
- const int tag = force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN;
- read_libblock(fd, mainl, bhead, tag | LIB_TAG_NEED_EXPAND, &id);
-
- if (id) {
- /* sort by name in list */
- ListBase *lb = which_libbase(mainl, idcode);
- id_sort_by_name(lb, id);
- }
- }
- else {
- /* already linked */
- if (G.debug)
- printf("append: already linked\n");
- oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
- if (!force_indirect && (id->tag & LIB_TAG_INDIRECT)) {
- id->tag &= ~LIB_TAG_INDIRECT;
- id->tag |= LIB_TAG_EXTERN;
- }
- }
- }
- else if (use_placeholders) {
- /* XXX flag part is weak! */
- id = create_placeholder(mainl, idcode, name, force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN);
- }
- else {
- id = NULL;
- }
-
- /* if we found the id but the id is NULL, this is really bad */
- BLI_assert(!((bhead != NULL) && (id == NULL)));
-
- return id;
+ Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
+{
+ BHead *bhead = find_bhead_from_code_name(fd, idcode, name);
+ ID *id;
+
+ const bool use_placeholders = (flag & BLO_LIBLINK_USE_PLACEHOLDERS) != 0;
+ const bool force_indirect = (flag & BLO_LIBLINK_FORCE_INDIRECT) != 0;
+
+ BLI_assert(BKE_idcode_is_linkable(idcode) && BKE_idcode_is_valid(idcode));
+
+ if (bhead) {
+ id = is_yet_read(fd, mainl, bhead);
+ if (id == NULL) {
+ /* not read yet */
+ const int tag = force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN;
+ read_libblock(fd, mainl, bhead, tag | LIB_TAG_NEED_EXPAND, &id);
+
+ if (id) {
+ /* sort by name in list */
+ ListBase *lb = which_libbase(mainl, idcode);
+ id_sort_by_name(lb, id);
+ }
+ }
+ else {
+ /* already linked */
+ if (G.debug)
+ printf("append: already linked\n");
+ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
+ if (!force_indirect && (id->tag & LIB_TAG_INDIRECT)) {
+ id->tag &= ~LIB_TAG_INDIRECT;
+ id->tag |= LIB_TAG_EXTERN;
+ }
+ }
+ }
+ else if (use_placeholders) {
+ /* XXX flag part is weak! */
+ id = create_placeholder(
+ mainl, idcode, name, force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN);
+ }
+ else {
+ id = NULL;
+ }
+
+ /* if we found the id but the id is NULL, this is really bad */
+ BLI_assert(!((bhead != NULL) && (id == NULL)));
+
+ return id;
}
/**
@@ -11022,57 +11171,57 @@ static ID *link_named_part(
*/
int BLO_library_link_copypaste(Main *mainl, BlendHandle *bh, const unsigned int id_types_mask)
{
- FileData *fd = (FileData *)(bh);
- BHead *bhead;
- int num_directly_linked = 0;
+ FileData *fd = (FileData *)(bh);
+ BHead *bhead;
+ int num_directly_linked = 0;
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- ID *id = NULL;
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ ID *id = NULL;
- if (bhead->code == ENDB)
- break;
+ if (bhead->code == ENDB)
+ break;
- if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) &&
- (id_types_mask == 0 || (BKE_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0))
- {
- read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, &id);
- num_directly_linked++;
- }
+ if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) &&
+ (id_types_mask == 0 ||
+ (BKE_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0)) {
+ read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, &id);
+ num_directly_linked++;
+ }
- if (id) {
- /* sort by name in list */
- ListBase *lb = which_libbase(mainl, GS(id->name));
- id_sort_by_name(lb, id);
+ if (id) {
+ /* sort by name in list */
+ ListBase *lb = which_libbase(mainl, GS(id->name));
+ id_sort_by_name(lb, id);
- if (bhead->code == ID_OB) {
- /* Instead of instancing Base's directly, postpone until after collections are loaded
- * otherwise the base's flag is set incorrectly when collections are used */
- Object *ob = (Object *)id;
- ob->mode = OB_MODE_OBJECT;
- /* ensure add_loose_objects_to_scene runs on this object */
- BLI_assert(id->us == 0);
- }
- }
- }
+ if (bhead->code == ID_OB) {
+ /* Instead of instancing Base's directly, postpone until after collections are loaded
+ * otherwise the base's flag is set incorrectly when collections are used */
+ Object *ob = (Object *)id;
+ ob->mode = OB_MODE_OBJECT;
+ /* ensure add_loose_objects_to_scene runs on this object */
+ BLI_assert(id->us == 0);
+ }
+ }
+ }
- return num_directly_linked;
+ return num_directly_linked;
}
static ID *link_named_part_ex(
- Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
+ Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
{
- ID *id = link_named_part(mainl, fd, idcode, name, flag);
+ ID *id = link_named_part(mainl, fd, idcode, name, flag);
- if (id && (GS(id->name) == ID_OB)) {
- /* Tag as loose object needing to be instantiated somewhere... */
- id->tag |= LIB_TAG_DOIT;
- }
- else if (id && (GS(id->name) == ID_GR)) {
- /* tag as needing to be instantiated or linked */
- id->tag |= LIB_TAG_DOIT;
- }
+ if (id && (GS(id->name) == ID_OB)) {
+ /* Tag as loose object needing to be instantiated somewhere... */
+ id->tag |= LIB_TAG_DOIT;
+ }
+ else if (id && (GS(id->name) == ID_GR)) {
+ /* tag as needing to be instantiated or linked */
+ id->tag |= LIB_TAG_DOIT;
+ }
- return id;
+ return id;
}
/**
@@ -11084,10 +11233,13 @@ static ID *link_named_part_ex(
* \param name: The name of the data-block (without the 2 char ID prefix).
* \return the linked ID when found.
*/
-ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name)
+ID *BLO_library_link_named_part(Main *mainl,
+ BlendHandle **bh,
+ const short idcode,
+ const char *name)
{
- FileData *fd = (FileData *)(*bh);
- return link_named_part(mainl, fd, idcode, name, 0);
+ FileData *fd = (FileData *)(*bh);
+ return link_named_part(mainl, fd, idcode, name, 0);
}
/**
@@ -11104,39 +11256,38 @@ ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcod
* \return the linked ID when found.
*/
ID *BLO_library_link_named_part_ex(
- Main *mainl, BlendHandle **bh,
- const short idcode, const char *name, const int flag)
+ Main *mainl, BlendHandle **bh, const short idcode, const char *name, const int flag)
{
- FileData *fd = (FileData *)(*bh);
- return link_named_part_ex(mainl, fd, idcode, name, flag);
+ FileData *fd = (FileData *)(*bh);
+ return link_named_part_ex(mainl, fd, idcode, name, flag);
}
/* common routine to append/link something from a library */
static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepath)
{
- Main *mainl;
+ Main *mainl;
- (*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
+ (*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
- /* clear for objects and collections instantiating tag */
- BKE_main_id_tag_listbase(&(mainvar->objects), LIB_TAG_DOIT, false);
- BKE_main_id_tag_listbase(&(mainvar->collections), LIB_TAG_DOIT, false);
+ /* clear for objects and collections instantiating tag */
+ BKE_main_id_tag_listbase(&(mainvar->objects), LIB_TAG_DOIT, false);
+ BKE_main_id_tag_listbase(&(mainvar->collections), LIB_TAG_DOIT, false);
- /* make mains */
- blo_split_main((*fd)->mainlist, mainvar);
+ /* make mains */
+ blo_split_main((*fd)->mainlist, mainvar);
- /* which one do we need? */
- mainl = blo_find_main(*fd, filepath, BKE_main_blendfile_path(mainvar));
+ /* which one do we need? */
+ mainl = blo_find_main(*fd, filepath, BKE_main_blendfile_path(mainvar));
- /* needed for do_version */
- mainl->versionfile = (*fd)->fileversion;
- read_file_version(*fd, mainl);
+ /* needed for do_version */
+ mainl->versionfile = (*fd)->fileversion;
+ read_file_version(*fd, mainl);
#ifdef USE_GHASH_BHEAD
- read_file_bhead_idname_map_create(*fd);
+ read_file_bhead_idname_map_create(*fd);
#endif
- return mainl;
+ return mainl;
}
/**
@@ -11149,113 +11300,118 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
*/
Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
{
- FileData *fd = (FileData *)(*bh);
- return library_link_begin(mainvar, &fd, filepath);
+ FileData *fd = (FileData *)(*bh);
+ return library_link_begin(mainvar, &fd, filepath);
}
static void split_main_newid(Main *mainptr, Main *main_newid)
{
- /* We only copy the necessary subset of data in this temp main. */
- main_newid->versionfile = mainptr->versionfile;
- main_newid->subversionfile = mainptr->subversionfile;
- BLI_strncpy(main_newid->name, mainptr->name, sizeof(main_newid->name));
- main_newid->curlib = mainptr->curlib;
+ /* We only copy the necessary subset of data in this temp main. */
+ main_newid->versionfile = mainptr->versionfile;
+ main_newid->subversionfile = mainptr->subversionfile;
+ BLI_strncpy(main_newid->name, mainptr->name, sizeof(main_newid->name));
+ main_newid->curlib = mainptr->curlib;
- ListBase *lbarray[MAX_LIBARRAY];
- ListBase *lbarray_newid[MAX_LIBARRAY];
- int i = set_listbasepointers(mainptr, lbarray);
- set_listbasepointers(main_newid, lbarray_newid);
- while (i--) {
- BLI_listbase_clear(lbarray_newid[i]);
+ ListBase *lbarray[MAX_LIBARRAY];
+ ListBase *lbarray_newid[MAX_LIBARRAY];
+ int i = set_listbasepointers(mainptr, lbarray);
+ set_listbasepointers(main_newid, lbarray_newid);
+ while (i--) {
+ BLI_listbase_clear(lbarray_newid[i]);
- for (ID *id = lbarray[i]->first, *idnext; id; id = idnext) {
- idnext = id->next;
+ for (ID *id = lbarray[i]->first, *idnext; id; id = idnext) {
+ idnext = id->next;
- if (id->tag & LIB_TAG_NEW) {
- BLI_remlink(lbarray[i], id);
- BLI_addtail(lbarray_newid[i], id);
- }
- }
- }
+ if (id->tag & LIB_TAG_NEW) {
+ BLI_remlink(lbarray[i], id);
+ BLI_addtail(lbarray_newid[i], id);
+ }
+ }
+ }
}
/* scene and v3d may be NULL. */
-static void library_link_end(
- Main *mainl, FileData **fd, const short flag, Main *bmain,
- Scene *scene, ViewLayer *view_layer, const View3D *v3d)
-{
- Main *mainvar;
- Library *curlib;
-
- /* expander now is callback function */
- BLO_main_expander(expand_doit_library);
-
- /* make main consistent */
- BLO_expand_main(*fd, mainl);
-
- /* do this when expand found other libs */
- read_libraries(*fd, (*fd)->mainlist);
-
- curlib = mainl->curlib;
-
- /* make the lib path relative if required */
- if (flag & FILE_RELPATH) {
- /* use the full path, this could have been read by other library even */
- BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
-
- /* uses current .blend file as reference */
- BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global());
- }
-
- blo_join_main((*fd)->mainlist);
- mainvar = (*fd)->mainlist->first;
- mainl = NULL; /* blo_join_main free's mainl, cant use anymore */
-
- lib_link_all(*fd, mainvar);
- BKE_collections_after_lib_link(mainvar);
-
- /* Yep, second splitting... but this is a very cheap operation, so no big deal. */
- blo_split_main((*fd)->mainlist, mainvar);
- Main *main_newid = BKE_main_new();
- for (mainvar = ((Main *)(*fd)->mainlist->first)->next; mainvar; mainvar = mainvar->next) {
- BLI_assert(mainvar->versionfile != 0);
- /* We need to split out IDs already existing, or they will go again through do_versions - bad, very bad! */
- split_main_newid(mainvar, main_newid);
-
- do_versions_after_linking(main_newid);
-
- add_main_to_main(mainvar, main_newid);
- }
- BKE_main_free(main_newid);
- blo_join_main((*fd)->mainlist);
- mainvar = (*fd)->mainlist->first;
- MEM_freeN((*fd)->mainlist);
-
- BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false);
-
- lib_verify_nodetree(mainvar, false);
- fix_relpaths_library(BKE_main_blendfile_path(mainvar), mainvar); /* make all relative paths, relative to the open blend file */
-
- /* Give a base to loose objects and collections.
- * Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co,
- * here we handle indirect ones and other possible edge-cases. */
- if (scene) {
- add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
- add_loose_objects_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
- }
- else {
- /* printf("library_append_end, scene is NULL (objects wont get bases)\n"); */
- }
-
- /* Clear objects and collections instantiating tag. */
- BKE_main_id_tag_listbase(&(mainvar->objects), LIB_TAG_DOIT, false);
- BKE_main_id_tag_listbase(&(mainvar->collections), LIB_TAG_DOIT, false);
-
- /* patch to prevent switch_endian happens twice */
- if ((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
- blo_filedata_free(*fd);
- *fd = NULL;
- }
+static void library_link_end(Main *mainl,
+ FileData **fd,
+ const short flag,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ const View3D *v3d)
+{
+ Main *mainvar;
+ Library *curlib;
+
+ /* expander now is callback function */
+ BLO_main_expander(expand_doit_library);
+
+ /* make main consistent */
+ BLO_expand_main(*fd, mainl);
+
+ /* do this when expand found other libs */
+ read_libraries(*fd, (*fd)->mainlist);
+
+ curlib = mainl->curlib;
+
+ /* make the lib path relative if required */
+ if (flag & FILE_RELPATH) {
+ /* use the full path, this could have been read by other library even */
+ BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
+
+ /* uses current .blend file as reference */
+ BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global());
+ }
+
+ blo_join_main((*fd)->mainlist);
+ mainvar = (*fd)->mainlist->first;
+ mainl = NULL; /* blo_join_main free's mainl, cant use anymore */
+
+ lib_link_all(*fd, mainvar);
+ BKE_collections_after_lib_link(mainvar);
+
+ /* Yep, second splitting... but this is a very cheap operation, so no big deal. */
+ blo_split_main((*fd)->mainlist, mainvar);
+ Main *main_newid = BKE_main_new();
+ for (mainvar = ((Main *)(*fd)->mainlist->first)->next; mainvar; mainvar = mainvar->next) {
+ BLI_assert(mainvar->versionfile != 0);
+ /* We need to split out IDs already existing, or they will go again through do_versions - bad, very bad! */
+ split_main_newid(mainvar, main_newid);
+
+ do_versions_after_linking(main_newid);
+
+ add_main_to_main(mainvar, main_newid);
+ }
+ BKE_main_free(main_newid);
+ blo_join_main((*fd)->mainlist);
+ mainvar = (*fd)->mainlist->first;
+ MEM_freeN((*fd)->mainlist);
+
+ BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false);
+
+ lib_verify_nodetree(mainvar, false);
+ fix_relpaths_library(BKE_main_blendfile_path(mainvar),
+ mainvar); /* make all relative paths, relative to the open blend file */
+
+ /* Give a base to loose objects and collections.
+ * Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co,
+ * here we handle indirect ones and other possible edge-cases. */
+ if (scene) {
+ add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
+ add_loose_objects_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
+ }
+ else {
+ /* printf("library_append_end, scene is NULL (objects wont get bases)\n"); */
+ }
+
+ /* Clear objects and collections instantiating tag. */
+ BKE_main_id_tag_listbase(&(mainvar->objects), LIB_TAG_DOIT, false);
+ BKE_main_id_tag_listbase(&(mainvar->collections), LIB_TAG_DOIT, false);
+
+ /* patch to prevent switch_endian happens twice */
+ if ((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ blo_filedata_free(*fd);
+ *fd = NULL;
+ }
}
/**
@@ -11271,18 +11427,22 @@ static void library_link_end(
* \param view_layer: The scene layer in which to instantiate objects/collections (if NULL, no instantiation is done).
* \param v3d: The active View3D (only to define local-view for instantiated objects & groups, can be NULL).
*/
-void BLO_library_link_end(
- Main *mainl, BlendHandle **bh, int flag, Main *bmain,
- Scene *scene, ViewLayer *view_layer, const View3D *v3d)
+void BLO_library_link_end(Main *mainl,
+ BlendHandle **bh,
+ int flag,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ const View3D *v3d)
{
- FileData *fd = (FileData *)(*bh);
- library_link_end(mainl, &fd, flag, bmain, scene, view_layer, v3d);
- *bh = (BlendHandle *)fd;
+ FileData *fd = (FileData *)(*bh);
+ library_link_end(mainl, &fd, flag, bmain, scene, view_layer, v3d);
+ *bh = (BlendHandle *)fd;
}
void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
{
- return read_struct(fd, bh, blockname);
+ return read_struct(fd, bh, blockname);
}
/** \} */
@@ -11293,254 +11453,264 @@ void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
static int has_linked_ids_to_read(Main *mainvar)
{
- ListBase *lbarray[MAX_LIBARRAY];
- int a = set_listbasepointers(mainvar, lbarray);
-
- while (a--) {
- for (ID *id = lbarray[a]->first; id; id = id->next) {
- if (id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-static void read_library_linked_id(ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
-{
- BHead *bhead = NULL;
- const bool is_valid = BKE_idcode_is_linkable(GS(id->name)) || ((id->tag & LIB_TAG_EXTERN) == 0);
-
- if (fd) {
- bhead = find_bhead_from_idname(fd, id->name);
- }
-
- if (!is_valid) {
- blo_reportf_wrap(
- reports, RPT_ERROR,
- TIP_("LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a non-linkable data type"),
- BKE_idcode_to_name(GS(id->name)),
- id->name + 2,
- mainvar->curlib->filepath,
- library_parent_filepath(mainvar->curlib));
- }
-
- id->tag &= ~LIB_TAG_ID_LINK_PLACEHOLDER;
-
- if (bhead) {
- id->tag |= LIB_TAG_NEED_EXPAND;
- // printf("read lib block %s\n", id->name);
- read_libblock(fd, mainvar, bhead, id->tag, r_id);
- }
- else {
- blo_reportf_wrap(
- reports, RPT_WARNING,
- TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
- BKE_idcode_to_name(GS(id->name)),
- id->name + 2,
- mainvar->curlib->filepath,
- library_parent_filepath(mainvar->curlib));
-
- /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
- if (r_id) {
- *r_id = is_valid ? create_placeholder(mainvar, GS(id->name), id->name + 2, id->tag) : NULL;
- }
- }
-}
-
-static void read_library_linked_ids(FileData *basefd, FileData *fd, ListBase *mainlist, Main *mainvar)
-{
- GHash *loaded_ids = BLI_ghash_str_new(__func__);
-
- ListBase *lbarray[MAX_LIBARRAY];
- int a = set_listbasepointers(mainvar, lbarray);
-
- while (a--) {
- ID *id = lbarray[a]->first;
- ListBase pending_free_ids = {NULL};
-
- while (id) {
- ID *id_next = id->next;
- if (id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) {
- BLI_remlink(lbarray[a], id);
-
- /* When playing with lib renaming and such, you may end with cases where
- * you have more than one linked ID of the same data-block from same
- * library. This is absolutely horrible, hence we use a ghash to ensure
- * we go back to a single linked data when loading the file. */
- ID **realid = NULL;
- if (!BLI_ghash_ensure_p(loaded_ids, id->name, (void ***)&realid)) {
- read_library_linked_id(basefd->reports, fd, mainvar, id, realid);
- }
-
- /* realid shall never be NULL - unless some source file/lib is broken
- * (known case: some directly linked shapekey from a missing lib...). */
- /* BLI_assert(*realid != NULL); */
-
- /* Now that we have a real ID, replace all pointers to placeholders in
- * fd->libmap with pointers to the real datablocks. We do this for all
- * libraries since multiple might be referencing this ID. */
- change_link_placeholder_to_real_ID_pointer(mainlist, basefd, id, *realid);
-
- /* We cannot free old lib-ref placeholder ID here anymore, since we use
- * its name as key in loaded_ids hash. */
- BLI_addtail(&pending_free_ids, id);
- }
- id = id_next;
- }
-
- /* Clear GHash and free link placeholder IDs of the current type. */
- BLI_ghash_clear(loaded_ids, NULL, NULL);
- BLI_freelistN(&pending_free_ids);
- }
-
- BLI_ghash_free(loaded_ids, NULL, NULL);
-}
-
-static FileData *read_library_file_data(FileData *basefd, ListBase *mainlist, Main *mainl, Main *mainptr)
-{
- FileData *fd = mainptr->curlib->filedata;
-
- if (fd != NULL) {
- /* File already open. */
- return fd;
- }
-
- if (mainptr->curlib->packedfile) {
- /* Read packed file. */
- PackedFile *pf = mainptr->curlib->packedfile;
-
- blo_reportf_wrap(
- basefd->reports, RPT_INFO, TIP_("Read packed library: '%s', parent '%s'"),
- mainptr->curlib->name,
- library_parent_filepath(mainptr->curlib));
- fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports);
-
- /* Needed for library_append and read_libraries. */
- BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase));
- }
- else {
- /* Read file on disk. */
- blo_reportf_wrap(
- basefd->reports, RPT_INFO, TIP_("Read library: '%s', '%s', parent '%s'"),
- mainptr->curlib->filepath,
- mainptr->curlib->name,
- library_parent_filepath(mainptr->curlib));
- fd = blo_filedata_from_file(mainptr->curlib->filepath, basefd->reports);
- }
-
- if (fd) {
- /* Share the mainlist, so all libraries are added immediately in a
- * single list. It used to be that all FileData's had their own list,
- * but with indirectly linking this meant we didn't catch duplicate
- * libraries properly. */
- fd->mainlist = mainlist;
-
- fd->reports = basefd->reports;
-
- if (fd->libmap)
- oldnewmap_free(fd->libmap);
-
- fd->libmap = oldnewmap_new();
-
- mainptr->curlib->filedata = fd;
- mainptr->versionfile = fd->fileversion;
-
- /* subversion */
- read_file_version(fd, mainptr);
+ ListBase *lbarray[MAX_LIBARRAY];
+ int a = set_listbasepointers(mainvar, lbarray);
+
+ while (a--) {
+ for (ID *id = lbarray[a]->first; id; id = id->next) {
+ if (id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+static void read_library_linked_id(
+ ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
+{
+ BHead *bhead = NULL;
+ const bool is_valid = BKE_idcode_is_linkable(GS(id->name)) || ((id->tag & LIB_TAG_EXTERN) == 0);
+
+ if (fd) {
+ bhead = find_bhead_from_idname(fd, id->name);
+ }
+
+ if (!is_valid) {
+ blo_reportf_wrap(reports,
+ RPT_ERROR,
+ TIP_("LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a "
+ "non-linkable data type"),
+ BKE_idcode_to_name(GS(id->name)),
+ id->name + 2,
+ mainvar->curlib->filepath,
+ library_parent_filepath(mainvar->curlib));
+ }
+
+ id->tag &= ~LIB_TAG_ID_LINK_PLACEHOLDER;
+
+ if (bhead) {
+ id->tag |= LIB_TAG_NEED_EXPAND;
+ // printf("read lib block %s\n", id->name);
+ read_libblock(fd, mainvar, bhead, id->tag, r_id);
+ }
+ else {
+ blo_reportf_wrap(reports,
+ RPT_WARNING,
+ TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
+ BKE_idcode_to_name(GS(id->name)),
+ id->name + 2,
+ mainvar->curlib->filepath,
+ library_parent_filepath(mainvar->curlib));
+
+ /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
+ if (r_id) {
+ *r_id = is_valid ? create_placeholder(mainvar, GS(id->name), id->name + 2, id->tag) : NULL;
+ }
+ }
+}
+
+static void read_library_linked_ids(FileData *basefd,
+ FileData *fd,
+ ListBase *mainlist,
+ Main *mainvar)
+{
+ GHash *loaded_ids = BLI_ghash_str_new(__func__);
+
+ ListBase *lbarray[MAX_LIBARRAY];
+ int a = set_listbasepointers(mainvar, lbarray);
+
+ while (a--) {
+ ID *id = lbarray[a]->first;
+ ListBase pending_free_ids = {NULL};
+
+ while (id) {
+ ID *id_next = id->next;
+ if (id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) {
+ BLI_remlink(lbarray[a], id);
+
+ /* When playing with lib renaming and such, you may end with cases where
+ * you have more than one linked ID of the same data-block from same
+ * library. This is absolutely horrible, hence we use a ghash to ensure
+ * we go back to a single linked data when loading the file. */
+ ID **realid = NULL;
+ if (!BLI_ghash_ensure_p(loaded_ids, id->name, (void ***)&realid)) {
+ read_library_linked_id(basefd->reports, fd, mainvar, id, realid);
+ }
+
+ /* realid shall never be NULL - unless some source file/lib is broken
+ * (known case: some directly linked shapekey from a missing lib...). */
+ /* BLI_assert(*realid != NULL); */
+
+ /* Now that we have a real ID, replace all pointers to placeholders in
+ * fd->libmap with pointers to the real datablocks. We do this for all
+ * libraries since multiple might be referencing this ID. */
+ change_link_placeholder_to_real_ID_pointer(mainlist, basefd, id, *realid);
+
+ /* We cannot free old lib-ref placeholder ID here anymore, since we use
+ * its name as key in loaded_ids hash. */
+ BLI_addtail(&pending_free_ids, id);
+ }
+ id = id_next;
+ }
+
+ /* Clear GHash and free link placeholder IDs of the current type. */
+ BLI_ghash_clear(loaded_ids, NULL, NULL);
+ BLI_freelistN(&pending_free_ids);
+ }
+
+ BLI_ghash_free(loaded_ids, NULL, NULL);
+}
+
+static FileData *read_library_file_data(FileData *basefd,
+ ListBase *mainlist,
+ Main *mainl,
+ Main *mainptr)
+{
+ FileData *fd = mainptr->curlib->filedata;
+
+ if (fd != NULL) {
+ /* File already open. */
+ return fd;
+ }
+
+ if (mainptr->curlib->packedfile) {
+ /* Read packed file. */
+ PackedFile *pf = mainptr->curlib->packedfile;
+
+ blo_reportf_wrap(basefd->reports,
+ RPT_INFO,
+ TIP_("Read packed library: '%s', parent '%s'"),
+ mainptr->curlib->name,
+ library_parent_filepath(mainptr->curlib));
+ fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports);
+
+ /* Needed for library_append and read_libraries. */
+ BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase));
+ }
+ else {
+ /* Read file on disk. */
+ blo_reportf_wrap(basefd->reports,
+ RPT_INFO,
+ TIP_("Read library: '%s', '%s', parent '%s'"),
+ mainptr->curlib->filepath,
+ mainptr->curlib->name,
+ library_parent_filepath(mainptr->curlib));
+ fd = blo_filedata_from_file(mainptr->curlib->filepath, basefd->reports);
+ }
+
+ if (fd) {
+ /* Share the mainlist, so all libraries are added immediately in a
+ * single list. It used to be that all FileData's had their own list,
+ * but with indirectly linking this meant we didn't catch duplicate
+ * libraries properly. */
+ fd->mainlist = mainlist;
+
+ fd->reports = basefd->reports;
+
+ if (fd->libmap)
+ oldnewmap_free(fd->libmap);
+
+ fd->libmap = oldnewmap_new();
+
+ mainptr->curlib->filedata = fd;
+ mainptr->versionfile = fd->fileversion;
+
+ /* subversion */
+ read_file_version(fd, mainptr);
#ifdef USE_GHASH_BHEAD
- read_file_bhead_idname_map_create(fd);
+ read_file_bhead_idname_map_create(fd);
#endif
- }
- else {
- mainptr->curlib->filedata = NULL;
- mainptr->curlib->id.tag |= LIB_TAG_MISSING;
- /* Set lib version to current main one... Makes assert later happy. */
- mainptr->versionfile = mainptr->curlib->versionfile = mainl->versionfile;
- mainptr->subversionfile = mainptr->curlib->subversionfile = mainl->subversionfile;
- }
+ }
+ else {
+ mainptr->curlib->filedata = NULL;
+ mainptr->curlib->id.tag |= LIB_TAG_MISSING;
+ /* Set lib version to current main one... Makes assert later happy. */
+ mainptr->versionfile = mainptr->curlib->versionfile = mainl->versionfile;
+ mainptr->subversionfile = mainptr->curlib->subversionfile = mainl->subversionfile;
+ }
- if (fd == NULL) {
- blo_reportf_wrap(basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"),
- mainptr->curlib->filepath);
- }
+ if (fd == NULL) {
+ blo_reportf_wrap(
+ basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath);
+ }
- return fd;
+ return fd;
}
static void read_libraries(FileData *basefd, ListBase *mainlist)
{
- Main *mainl = mainlist->first;
- bool do_it = true;
-
- /* Expander is now callback function. */
- BLO_main_expander(expand_doit_library);
-
- /* At this point the base blend file has been read, and each library blend
- * encountered so far has a main with placeholders for linked datablocks.
- *
- * Now we will read the library blend files and replace the placeholders
- * with actual datablocks. We loop over library mains multiple times in
- * case a library needs to link additional datablocks from another library
- * that had been read previously. */
- while (do_it) {
- do_it = false;
-
- /* Loop over mains of all library blend files encountered so far. Note
- * this list gets longer as more indirectly library blends are found. */
- for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
- /* Does this library have any more linked datablocks we need to read? */
- if (has_linked_ids_to_read(mainptr)) {
- // printf("Reading linked datablocks from %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
-
- /* Open file if it has not been done yet. */
- FileData *fd = read_library_file_data(basefd, mainlist, mainl, mainptr);
-
- if (fd) {
- do_it = true;
- }
-
- /* Read linked datablocks for each link placeholder, and replace
- * the placeholder with the real datablock. */
- read_library_linked_ids(basefd, fd, mainlist, mainptr);
-
- /* Test if linked datablocks need to read further linked datablocks
- * and create link placeholders for them. */
- BLO_expand_main(fd, mainptr);
- }
- }
- }
-
- Main *main_newid = BKE_main_new();
- for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
- /* Do versioning for newly added linked datablocks. If no datablocks
- * were read from a library versionfile will still be zero and we can
- * skip it. */
- if (mainptr->versionfile) {
- /* Split out already existing IDs to avoid them going through
- * do_versions multiple times, which would have bad consequences. */
- split_main_newid(mainptr, main_newid);
-
- /* File data can be zero with link/append. */
- if (mainptr->curlib->filedata)
- do_versions(mainptr->curlib->filedata, mainptr->curlib, main_newid);
- else
- do_versions(basefd, NULL, main_newid);
-
- add_main_to_main(mainptr, main_newid);
- }
-
- /* Lib linking. */
- if (mainptr->curlib->filedata)
- lib_link_all(mainptr->curlib->filedata, mainptr);
-
- /* Free file data we no longer need. */
- if (mainptr->curlib->filedata)
- blo_filedata_free(mainptr->curlib->filedata);
- mainptr->curlib->filedata = NULL;
- }
- BKE_main_free(main_newid);
+ Main *mainl = mainlist->first;
+ bool do_it = true;
+
+ /* Expander is now callback function. */
+ BLO_main_expander(expand_doit_library);
+
+ /* At this point the base blend file has been read, and each library blend
+ * encountered so far has a main with placeholders for linked datablocks.
+ *
+ * Now we will read the library blend files and replace the placeholders
+ * with actual datablocks. We loop over library mains multiple times in
+ * case a library needs to link additional datablocks from another library
+ * that had been read previously. */
+ while (do_it) {
+ do_it = false;
+
+ /* Loop over mains of all library blend files encountered so far. Note
+ * this list gets longer as more indirectly library blends are found. */
+ for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
+ /* Does this library have any more linked datablocks we need to read? */
+ if (has_linked_ids_to_read(mainptr)) {
+ // printf("Reading linked datablocks from %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
+
+ /* Open file if it has not been done yet. */
+ FileData *fd = read_library_file_data(basefd, mainlist, mainl, mainptr);
+
+ if (fd) {
+ do_it = true;
+ }
+
+ /* Read linked datablocks for each link placeholder, and replace
+ * the placeholder with the real datablock. */
+ read_library_linked_ids(basefd, fd, mainlist, mainptr);
+
+ /* Test if linked datablocks need to read further linked datablocks
+ * and create link placeholders for them. */
+ BLO_expand_main(fd, mainptr);
+ }
+ }
+ }
+
+ Main *main_newid = BKE_main_new();
+ for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
+ /* Do versioning for newly added linked datablocks. If no datablocks
+ * were read from a library versionfile will still be zero and we can
+ * skip it. */
+ if (mainptr->versionfile) {
+ /* Split out already existing IDs to avoid them going through
+ * do_versions multiple times, which would have bad consequences. */
+ split_main_newid(mainptr, main_newid);
+
+ /* File data can be zero with link/append. */
+ if (mainptr->curlib->filedata)
+ do_versions(mainptr->curlib->filedata, mainptr->curlib, main_newid);
+ else
+ do_versions(basefd, NULL, main_newid);
+
+ add_main_to_main(mainptr, main_newid);
+ }
+
+ /* Lib linking. */
+ if (mainptr->curlib->filedata)
+ lib_link_all(mainptr->curlib->filedata, mainptr);
+
+ /* Free file data we no longer need. */
+ if (mainptr->curlib->filedata)
+ blo_filedata_free(mainptr->curlib->filedata);
+ mainptr->curlib->filedata = NULL;
+ }
+ BKE_main_free(main_newid);
}
/** \} */
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 42b79a4a3f9..55824e17c32 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -28,7 +28,7 @@
#include "zlib.h"
#include "DNA_sdna_types.h"
#include "DNA_space_types.h"
-#include "DNA_windowmanager_types.h" /* for ReportType */
+#include "DNA_windowmanager_types.h" /* for ReportType */
struct Key;
struct MemFile;
@@ -39,13 +39,13 @@ struct ReportList;
struct View3D;
enum eFileDataFlag {
- FD_FLAGS_SWITCH_ENDIAN = 1 << 0,
- FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1,
- FD_FLAGS_POINTSIZE_DIFFERS = 1 << 2,
- FD_FLAGS_FILE_OK = 1 << 3,
- FD_FLAGS_NOT_MY_BUFFER = 1 << 4,
- /* XXX Unused in practice (checked once but never set). */
- FD_FLAGS_NOT_MY_LIBMAP = 1 << 5,
+ FD_FLAGS_SWITCH_ENDIAN = 1 << 0,
+ FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1,
+ FD_FLAGS_POINTSIZE_DIFFERS = 1 << 2,
+ FD_FLAGS_FILE_OK = 1 << 3,
+ FD_FLAGS_NOT_MY_BUFFER = 1 << 4,
+ /* XXX Unused in practice (checked once but never set). */
+ FD_FLAGS_NOT_MY_LIBMAP = 1 << 5,
};
/* Disallow since it's 32bit on ms-windows. */
@@ -57,72 +57,71 @@ enum eFileDataFlag {
typedef int64_t off64_t;
#endif
-typedef int (FileDataReadFn)(struct FileData *filedata, void *buffer, unsigned int size);
-typedef off64_t (FileDataSeekFn)(struct FileData *filedata, off64_t offset, int whence);
+typedef int(FileDataReadFn)(struct FileData *filedata, void *buffer, unsigned int size);
+typedef off64_t(FileDataSeekFn)(struct FileData *filedata, off64_t offset, int whence);
typedef struct FileData {
- /** Linked list of BHeadN's. */
- ListBase bhead_list;
- enum eFileDataFlag flags;
- bool is_eof;
- int buffersize;
- int64_t file_offset;
-
- FileDataReadFn *read;
- FileDataSeekFn *seek;
-
- /** Regular file reading. */
- int filedes;
-
- /** Variables needed for reading from memory / stream. */
- const char *buffer;
- /** Variables needed for reading from memfile (undo). */
- struct MemFile *memfile;
-
- /** Variables needed for reading from file. */
- gzFile gzfiledes;
- /** Gzip stream for memory decompression. */
- z_stream strm;
-
- /** Now only in use for library appending. */
- char relabase[FILE_MAX];
-
-
- /** General reading variables. */
- struct SDNA *filesdna;
- const struct SDNA *memsdna;
- /** Array of #eSDNA_StructCompare. */
- const char *compflags;
-
- int fileversion;
- /** Used to retrieve ID names from (bhead+1). */
- int id_name_offs;
- /** For do_versions patching. */
- int globalf, fileflags;
-
- /** Optionally skip some data-blocks when they're not needed. */
- eBLOReadSkip skip_flags;
-
- struct OldNewMap *datamap;
- struct OldNewMap *globmap;
- struct OldNewMap *libmap;
- struct OldNewMap *imamap;
- struct OldNewMap *movieclipmap;
- struct OldNewMap *scenemap;
- struct OldNewMap *soundmap;
- struct OldNewMap *packedmap;
-
- struct BHeadSort *bheadmap;
- int tot_bheadmap;
-
- /** See: #USE_GHASH_BHEAD. */
- struct GHash *bhead_idname_hash;
-
- ListBase *mainlist;
- /** Used for undo. */
- ListBase *old_mainlist;
-
- struct ReportList *reports;
+ /** Linked list of BHeadN's. */
+ ListBase bhead_list;
+ enum eFileDataFlag flags;
+ bool is_eof;
+ int buffersize;
+ int64_t file_offset;
+
+ FileDataReadFn *read;
+ FileDataSeekFn *seek;
+
+ /** Regular file reading. */
+ int filedes;
+
+ /** Variables needed for reading from memory / stream. */
+ const char *buffer;
+ /** Variables needed for reading from memfile (undo). */
+ struct MemFile *memfile;
+
+ /** Variables needed for reading from file. */
+ gzFile gzfiledes;
+ /** Gzip stream for memory decompression. */
+ z_stream strm;
+
+ /** Now only in use for library appending. */
+ char relabase[FILE_MAX];
+
+ /** General reading variables. */
+ struct SDNA *filesdna;
+ const struct SDNA *memsdna;
+ /** Array of #eSDNA_StructCompare. */
+ const char *compflags;
+
+ int fileversion;
+ /** Used to retrieve ID names from (bhead+1). */
+ int id_name_offs;
+ /** For do_versions patching. */
+ int globalf, fileflags;
+
+ /** Optionally skip some data-blocks when they're not needed. */
+ eBLOReadSkip skip_flags;
+
+ struct OldNewMap *datamap;
+ struct OldNewMap *globmap;
+ struct OldNewMap *libmap;
+ struct OldNewMap *imamap;
+ struct OldNewMap *movieclipmap;
+ struct OldNewMap *scenemap;
+ struct OldNewMap *soundmap;
+ struct OldNewMap *packedmap;
+
+ struct BHeadSort *bheadmap;
+ int tot_bheadmap;
+
+ /** See: #USE_GHASH_BHEAD. */
+ struct GHash *bhead_idname_hash;
+
+ ListBase *mainlist;
+ /** Used for undo. */
+ ListBase *old_mainlist;
+
+ struct ReportList *reports;
} FileData;
#define SIZEOFBLENDERHEADER 12
@@ -161,11 +160,15 @@ const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead);
/* do versions stuff */
-void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(3, 4);
+void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
+ ATTR_PRINTF_FORMAT(3, 4);
void blo_do_versions_dna(struct SDNA *sdna, const int versionfile, const int subversionfile);
-void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, const void *oldaddr, void *newaddr, int nr);
+void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm,
+ const void *oldaddr,
+ void *newaddr,
+ int nr);
void *blo_do_versions_newlibadr(struct FileData *fd, const void *lib, const void *adr);
void *blo_do_versions_newlibadr_us(struct FileData *fd, const void *lib, const void *adr);
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index ef5d8963be7..0c09aa34a8b 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -55,88 +55,90 @@
/* not memfile itself */
void BLO_memfile_free(MemFile *memfile)
{
- MemFileChunk *chunk;
-
- while ((chunk = BLI_pophead(&memfile->chunks))) {
- if (chunk->is_identical == false) {
- MEM_freeN((void *)chunk->buf);
- }
- MEM_freeN(chunk);
- }
- memfile->size = 0;
+ MemFileChunk *chunk;
+
+ while ((chunk = BLI_pophead(&memfile->chunks))) {
+ if (chunk->is_identical == false) {
+ MEM_freeN((void *)chunk->buf);
+ }
+ MEM_freeN(chunk);
+ }
+ memfile->size = 0;
}
/* to keep list of memfiles consistent, 'first' is always first in list */
/* result is that 'first' is being freed */
void BLO_memfile_merge(MemFile *first, MemFile *second)
{
- MemFileChunk *fc, *sc;
-
- fc = first->chunks.first;
- sc = second->chunks.first;
- while (fc || sc) {
- if (fc && sc) {
- if (sc->is_identical) {
- sc->is_identical = false;
- fc->is_identical = true;
- }
- }
- if (fc) fc = fc->next;
- if (sc) sc = sc->next;
- }
-
- BLO_memfile_free(first);
+ MemFileChunk *fc, *sc;
+
+ fc = first->chunks.first;
+ sc = second->chunks.first;
+ while (fc || sc) {
+ if (fc && sc) {
+ if (sc->is_identical) {
+ sc->is_identical = false;
+ fc->is_identical = true;
+ }
+ }
+ if (fc)
+ fc = fc->next;
+ if (sc)
+ sc = sc->next;
+ }
+
+ BLO_memfile_free(first);
}
-void memfile_chunk_add(
- MemFile *memfile, const char *buf, uint size,
- MemFileChunk **compchunk_step)
+void memfile_chunk_add(MemFile *memfile, const char *buf, uint size, MemFileChunk **compchunk_step)
{
- MemFileChunk *curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
- curchunk->size = size;
- curchunk->buf = NULL;
- curchunk->is_identical = false;
- BLI_addtail(&memfile->chunks, curchunk);
-
- /* we compare compchunk with buf */
- if (*compchunk_step != NULL) {
- MemFileChunk *compchunk = *compchunk_step;
- if (compchunk->size == curchunk->size) {
- if (memcmp(compchunk->buf, buf, size) == 0) {
- curchunk->buf = compchunk->buf;
- curchunk->is_identical = true;
- }
- }
- *compchunk_step = compchunk->next;
- }
-
- /* not equal... */
- if (curchunk->buf == NULL) {
- char *buf_new = MEM_mallocN(size, "Chunk buffer");
- memcpy(buf_new, buf, size);
- curchunk->buf = buf_new;
- memfile->size += size;
- }
+ MemFileChunk *curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
+ curchunk->size = size;
+ curchunk->buf = NULL;
+ curchunk->is_identical = false;
+ BLI_addtail(&memfile->chunks, curchunk);
+
+ /* we compare compchunk with buf */
+ if (*compchunk_step != NULL) {
+ MemFileChunk *compchunk = *compchunk_step;
+ if (compchunk->size == curchunk->size) {
+ if (memcmp(compchunk->buf, buf, size) == 0) {
+ curchunk->buf = compchunk->buf;
+ curchunk->is_identical = true;
+ }
+ }
+ *compchunk_step = compchunk->next;
+ }
+
+ /* not equal... */
+ if (curchunk->buf == NULL) {
+ char *buf_new = MEM_mallocN(size, "Chunk buffer");
+ memcpy(buf_new, buf, size);
+ curchunk->buf = buf_new;
+ memfile->size += size;
+ }
}
-struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *oldmain, struct Scene **r_scene)
+struct Main *BLO_memfile_main_get(struct MemFile *memfile,
+ struct Main *oldmain,
+ struct Scene **r_scene)
{
- struct Main *bmain_undo = NULL;
- BlendFileData *bfd = BLO_read_from_memfile(oldmain, BKE_main_blendfile_path(oldmain), memfile, BLO_READ_SKIP_NONE, NULL);
+ struct Main *bmain_undo = NULL;
+ BlendFileData *bfd = BLO_read_from_memfile(
+ oldmain, BKE_main_blendfile_path(oldmain), memfile, BLO_READ_SKIP_NONE, NULL);
- if (bfd) {
- bmain_undo = bfd->main;
- if (r_scene) {
- *r_scene = bfd->curscene;
- }
+ if (bfd) {
+ bmain_undo = bfd->main;
+ if (r_scene) {
+ *r_scene = bfd->curscene;
+ }
- MEM_freeN(bfd);
- }
+ MEM_freeN(bfd);
+ }
- return bmain_undo;
+ return bmain_undo;
}
-
/**
* Saves .blend using undo buffer.
*
@@ -144,43 +146,47 @@ struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *oldmain,
*/
bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename)
{
- MemFileChunk *chunk;
- int file, oflags;
+ MemFileChunk *chunk;
+ int file, oflags;
- /* note: This is currently used for autosave and 'quit.blend', where _not_ following symlinks is OK,
- * however if this is ever executed explicitly by the user, we may want to allow writing to symlinks.
- */
+ /* note: This is currently used for autosave and 'quit.blend', where _not_ following symlinks is OK,
+ * however if this is ever executed explicitly by the user, we may want to allow writing to symlinks.
+ */
- oflags = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC;
+ oflags = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC;
#ifdef O_NOFOLLOW
- /* use O_NOFOLLOW to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
- oflags |= O_NOFOLLOW;
+ /* use O_NOFOLLOW to avoid writing to a symlink - use 'O_EXCL' (CVE-2008-1103) */
+ oflags |= O_NOFOLLOW;
#else
- /* TODO(sergey): How to deal with symlinks on windows? */
+ /* TODO(sergey): How to deal with symlinks on windows? */
# ifndef _MSC_VER
# warning "Symbolic links will be followed on undo save, possibly causing CVE-2008-1103"
# endif
#endif
- file = BLI_open(filename, oflags, 0666);
-
- if (file == -1) {
- fprintf(stderr, "Unable to save '%s': %s\n",
- filename, errno ? strerror(errno) : "Unknown error opening file");
- return false;
- }
-
- for (chunk = memfile->chunks.first; chunk; chunk = chunk->next) {
- if ((size_t)write(file, chunk->buf, chunk->size) != chunk->size) {
- break;
- }
- }
-
- close(file);
-
- if (chunk) {
- fprintf(stderr, "Unable to save '%s': %s\n",
- filename, errno ? strerror(errno) : "Unknown error writing file");
- return false;
- }
- return true;
+ file = BLI_open(filename, oflags, 0666);
+
+ if (file == -1) {
+ fprintf(stderr,
+ "Unable to save '%s': %s\n",
+ filename,
+ errno ? strerror(errno) : "Unknown error opening file");
+ return false;
+ }
+
+ for (chunk = memfile->chunks.first; chunk; chunk = chunk->next) {
+ if ((size_t)write(file, chunk->buf, chunk->size) != chunk->size) {
+ break;
+ }
+ }
+
+ close(file);
+
+ if (chunk) {
+ fprintf(stderr,
+ "Unable to save '%s': %s\n",
+ filename,
+ errno ? strerror(errno) : "Unknown error writing file");
+ return false;
+ }
+ return true;
}
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index d8bd0e8d5b9..723701da113 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -19,10 +19,10 @@
*/
#ifndef WIN32
-# include <unistd.h> /* for read close */
+# include <unistd.h> /* for read close */
#else
-# include <zlib.h> /* odd include order-issue */
-# include <io.h> // for open close read
+# include <zlib.h> /* odd include order-issue */
+# include <io.h> // for open close read
# include "winsock2.h"
# include "BLI_winstuff.h"
#endif
@@ -64,10 +64,10 @@
#include "BKE_anim.h"
#include "BKE_armature.h"
#include "BKE_colortools.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" // for G
#include "BKE_library.h"
#include "BKE_main.h"
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_particle.h"
@@ -88,466 +88,457 @@
/* 2.50 patch */
static void area_add_header_region(ScrArea *sa, ListBase *lb)
{
- ARegion *ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
-
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- if (sa->headertype == 1)
- ar->alignment = RGN_ALIGN_BOTTOM;
- else
- ar->alignment = RGN_ALIGN_TOP;
-
- /* initialize view2d data for header region, to allow panning */
- /* is copy from ui_view2d.c */
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
- ar->v2d.keepofs = V2D_LOCKOFS_Y;
- ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag = (V2D_PIXELOFS_X | V2D_PIXELOFS_Y);
+ ARegion *ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ if (sa->headertype == 1)
+ ar->alignment = RGN_ALIGN_BOTTOM;
+ else
+ ar->alignment = RGN_ALIGN_TOP;
+
+ /* initialize view2d data for header region, to allow panning */
+ /* is copy from ui_view2d.c */
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ ar->v2d.keepofs = V2D_LOCKOFS_Y;
+ ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag = (V2D_PIXELOFS_X | V2D_PIXELOFS_Y);
}
static void sequencer_init_preview_region(ARegion *ar)
{
- // XXX a bit ugly still, copied from space_sequencer
- /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
- ar->regiontype = RGN_TYPE_PREVIEW;
- ar->alignment = RGN_ALIGN_TOP;
- ar->flag |= RGN_FLAG_HIDDEN;
- ar->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM;
- ar->v2d.minzoom = 0.00001f;
- ar->v2d.maxzoom = 100000.0f;
- ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
- ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
- ar->v2d.tot.xmax = 960.0f;
- ar->v2d.tot.ymax = 540.0f;
- ar->v2d.min[0] = 0.0f;
- ar->v2d.min[1] = 0.0f;
- ar->v2d.max[0] = 12000.0f;
- ar->v2d.max[1] = 12000.0f;
- ar->v2d.cur = ar->v2d.tot;
- ar->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
- ar->v2d.keeptot = V2D_KEEPTOT_FREE;
+ // XXX a bit ugly still, copied from space_sequencer
+ /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
+ ar->regiontype = RGN_TYPE_PREVIEW;
+ ar->alignment = RGN_ALIGN_TOP;
+ ar->flag |= RGN_FLAG_HIDDEN;
+ ar->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM;
+ ar->v2d.minzoom = 0.00001f;
+ ar->v2d.maxzoom = 100000.0f;
+ ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
+ ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
+ ar->v2d.tot.xmax = 960.0f;
+ ar->v2d.tot.ymax = 540.0f;
+ ar->v2d.min[0] = 0.0f;
+ ar->v2d.min[1] = 0.0f;
+ ar->v2d.max[0] = 12000.0f;
+ ar->v2d.max[1] = 12000.0f;
+ ar->v2d.cur = ar->v2d.tot;
+ ar->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
+ ar->v2d.keeptot = V2D_KEEPTOT_FREE;
}
static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
{
- ARegion *ar;
- ARegion *ar_main;
-
- if (sl) {
- /* first channels for ipo action nla... */
- switch (sl->spacetype) {
- case SPACE_GRAPH:
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_CHANNELS;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
-
- /* for some reason, this doesn't seem to go auto like for NLA... */
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
- ar->v2d.scroll = V2D_SCROLL_RIGHT;
- ar->v2d.flag = RGN_FLAG_HIDDEN;
- break;
-
- case SPACE_ACTION:
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_CHANNELS;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = V2D_SCROLL_BOTTOM;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
- break;
-
- case SPACE_NLA:
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_CHANNELS;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = V2D_SCROLL_BOTTOM;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
- /* for some reason, some files still don't get this auto */
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
- ar->v2d.scroll = V2D_SCROLL_RIGHT;
- ar->v2d.flag = RGN_FLAG_HIDDEN;
- break;
-
- case SPACE_NODE:
- ar = MEM_callocN(sizeof(ARegion), "nodetree area for node");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
- /* temporarily hide it */
- ar->flag = RGN_FLAG_HIDDEN;
- break;
- case SPACE_FILE:
- ar = MEM_callocN(sizeof(ARegion), "nodetree area for node");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_CHANNELS;
- ar->alignment = RGN_ALIGN_LEFT;
-
- ar = MEM_callocN(sizeof(ARegion), "ui area for file");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_TOP;
- break;
- case SPACE_SEQ:
- ar_main = (ARegion *)lb->first;
- for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
- break;
- }
- ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
- BLI_insertlinkbefore(lb, ar_main, ar);
- sequencer_init_preview_region(ar);
- break;
- case SPACE_VIEW3D:
- /* toolbar */
- ar = MEM_callocN(sizeof(ARegion), "toolbar for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_TOOLS;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->flag = RGN_FLAG_HIDDEN;
-
- /* tool properties */
- ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_TOOL_PROPS;
- ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
- ar->flag = RGN_FLAG_HIDDEN;
-
- /* buttons/list view */
- ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
-
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
- ar->flag = RGN_FLAG_HIDDEN;
+ ARegion *ar;
+ ARegion *ar_main;
+
+ if (sl) {
+ /* first channels for ipo action nla... */
+ switch (sl->spacetype) {
+ case SPACE_GRAPH:
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_CHANNELS;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+
+ /* for some reason, this doesn't seem to go auto like for NLA... */
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar->v2d.scroll = V2D_SCROLL_RIGHT;
+ ar->v2d.flag = RGN_FLAG_HIDDEN;
+ break;
+
+ case SPACE_ACTION:
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_CHANNELS;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->v2d.scroll = V2D_SCROLL_BOTTOM;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+ break;
+
+ case SPACE_NLA:
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_CHANNELS;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->v2d.scroll = V2D_SCROLL_BOTTOM;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+
+ /* for some reason, some files still don't get this auto */
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar->v2d.scroll = V2D_SCROLL_RIGHT;
+ ar->v2d.flag = RGN_FLAG_HIDDEN;
+ break;
+
+ case SPACE_NODE:
+ ar = MEM_callocN(sizeof(ARegion), "nodetree area for node");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+ /* temporarily hide it */
+ ar->flag = RGN_FLAG_HIDDEN;
+ break;
+ case SPACE_FILE:
+ ar = MEM_callocN(sizeof(ARegion), "nodetree area for node");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_CHANNELS;
+ ar->alignment = RGN_ALIGN_LEFT;
+
+ ar = MEM_callocN(sizeof(ARegion), "ui area for file");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_TOP;
+ break;
+ case SPACE_SEQ:
+ ar_main = (ARegion *)lb->first;
+ for (; ar_main; ar_main = ar_main->next) {
+ if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ break;
+ }
+ ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+ BLI_insertlinkbefore(lb, ar_main, ar);
+ sequencer_init_preview_region(ar);
+ break;
+ case SPACE_VIEW3D:
+ /* toolbar */
+ ar = MEM_callocN(sizeof(ARegion), "toolbar for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_TOOLS;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->flag = RGN_FLAG_HIDDEN;
+
+ /* tool properties */
+ ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_TOOL_PROPS;
+ ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+ ar->flag = RGN_FLAG_HIDDEN;
+
+ /* buttons/list view */
+ ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
+
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar->flag = RGN_FLAG_HIDDEN;
#if 0
- case SPACE_PROPERTIES:
- /* context UI region */
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
- BLI_addtail(lb, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
-
- break;
+ case SPACE_PROPERTIES:
+ /* context UI region */
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+ BLI_addtail(lb, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_RIGHT;
+
+ break;
#endif
- }
- }
-
- /* main region */
- ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
-
- BLI_addtail(lb, ar);
- ar->winrct = sa->totrct;
-
- ar->regiontype = RGN_TYPE_WINDOW;
-
- if (sl) {
- /* if active spacetype has view2d data, copy that over to main region */
- /* and we split view3d */
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- blo_do_versions_view3d_split_250((View3D *)sl, lb);
- break;
-
- case SPACE_OUTLINER:
- {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
-
- memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
-
- ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
- ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
- case SPACE_GRAPH:
- {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
-
- /* init mainarea view2d */
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
-
- ar->v2d.min[0] = FLT_MIN;
- ar->v2d.min[1] = FLT_MIN;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = FLT_MAX;
-
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
-
- ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- ar->v2d.tot.ymax = 0.0f;
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
- break;
- }
- case SPACE_ACTION:
- {
- SpaceAction *saction = (SpaceAction *)sl;
-
- /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
- ar->v2d.tot.xmin = -20.0f;
- ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120);
- ar->v2d.tot.ymax = 0.0f;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 0.0f;
- ar->v2d.min[1] = 0.0f;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = FLT_MAX;
-
- ar->v2d.minzoom = 0.01f;
- ar->v2d.maxzoom = 50;
- ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
- ar->v2d.align = V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
- /* for old files with ShapeKey editors open + an action set, clear the action as
- * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
- * only shows ShapeKey-rooted actions only)
- */
- if (saction->mode == SACTCONT_SHAPEKEY)
- saction->action = NULL;
- break;
- }
- case SPACE_SEQ:
- {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
- ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
-
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT;
- break;
- }
- case SPACE_PROPERTIES:
- {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
-
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- break;
- }
- case SPACE_FILE:
- {
- // SpaceFile *sfile = (SpaceFile *)sl;
- ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
- ar->v2d.tot.xmax = ar->winx;
- ar->v2d.tot.ymax = ar->winy;
- ar->v2d.cur = ar->v2d.tot;
- ar->regiontype = RGN_TYPE_WINDOW;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
- break;
- }
- case SPACE_TEXT:
- {
- SpaceText *st = (SpaceText *)sl;
- st->flags |= ST_FIND_WRAP;
- }
- //case SPACE_XXX: // FIXME... add other ones
- // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
- // break;
- }
- }
+ }
+ }
+
+ /* main region */
+ ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
+
+ BLI_addtail(lb, ar);
+ ar->winrct = sa->totrct;
+
+ ar->regiontype = RGN_TYPE_WINDOW;
+
+ if (sl) {
+ /* if active spacetype has view2d data, copy that over to main region */
+ /* and we split view3d */
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D:
+ blo_do_versions_view3d_split_250((View3D *)sl, lb);
+ break;
+
+ case SPACE_OUTLINER: {
+ SpaceOutliner *soops = (SpaceOutliner *)sl;
+
+ memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
+
+ ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
+ ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
+ case SPACE_GRAPH: {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
+
+ /* init mainarea view2d */
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
+
+ ar->v2d.min[0] = FLT_MIN;
+ ar->v2d.min[1] = FLT_MIN;
+
+ ar->v2d.max[0] = MAXFRAMEF;
+ ar->v2d.max[1] = FLT_MAX;
+
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
+ case SPACE_NLA: {
+ SpaceNla *snla = (SpaceNla *)sl;
+ memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
+
+ ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ ar->v2d.tot.ymax = 0.0f;
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
+ break;
+ }
+ case SPACE_ACTION: {
+ SpaceAction *saction = (SpaceAction *)sl;
+
+ /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
+ ar->v2d.tot.xmin = -20.0f;
+ ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120);
+ ar->v2d.tot.ymax = 0.0f;
+
+ ar->v2d.cur = ar->v2d.tot;
+
+ ar->v2d.min[0] = 0.0f;
+ ar->v2d.min[1] = 0.0f;
+
+ ar->v2d.max[0] = MAXFRAMEF;
+ ar->v2d.max[1] = FLT_MAX;
+
+ ar->v2d.minzoom = 0.01f;
+ ar->v2d.maxzoom = 50;
+ ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+
+ /* for old files with ShapeKey editors open + an action set, clear the action as
+ * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
+ * only shows ShapeKey-rooted actions only)
+ */
+ if (saction->mode == SACTCONT_SHAPEKEY)
+ saction->action = NULL;
+ break;
+ }
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
+ ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)sl;
+ memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
+
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT;
+ break;
+ }
+ case SPACE_PROPERTIES: {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+ memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
+
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ break;
+ }
+ case SPACE_FILE: {
+ // SpaceFile *sfile = (SpaceFile *)sl;
+ ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
+ ar->v2d.tot.xmax = ar->winx;
+ ar->v2d.tot.ymax = ar->winy;
+ ar->v2d.cur = ar->v2d.tot;
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ break;
+ }
+ case SPACE_TEXT: {
+ SpaceText *st = (SpaceText *)sl;
+ st->flags |= ST_FIND_WRAP;
+ }
+ //case SPACE_XXX: // FIXME... add other ones
+ // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
+ // break;
+ }
+ }
}
static void do_versions_windowmanager_2_50(bScreen *screen)
{
- ScrArea *sa;
- SpaceLink *sl;
-
- /* add regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- /* we keep headertype variable to convert old files only */
- if (sa->headertype)
- area_add_header_region(sa, &sa->regionbase);
-
- area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
-
- /* space imageselect is deprecated */
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMASEL)
- sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
- }
-
- /* space sound is deprecated */
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SOUND)
- sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
- }
-
- /* pushed back spaces also need regions! */
- if (sa->spacedata.first) {
- sl = sa->spacedata.first;
- for (sl = sl->next; sl; sl = sl->next) {
- if (sa->headertype)
- area_add_header_region(sa, &sl->regionbase);
- area_add_window_regions(sa, sl, &sl->regionbase);
- }
- }
- }
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* add regions */
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ /* we keep headertype variable to convert old files only */
+ if (sa->headertype)
+ area_add_header_region(sa, &sa->regionbase);
+
+ area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
+
+ /* space imageselect is deprecated */
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMASEL)
+ sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ }
+
+ /* space sound is deprecated */
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SOUND)
+ sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ }
+
+ /* pushed back spaces also need regions! */
+ if (sa->spacedata.first) {
+ sl = sa->spacedata.first;
+ for (sl = sl->next; sl; sl = sl->next) {
+ if (sa->headertype)
+ area_add_header_region(sa, &sl->regionbase);
+ area_add_window_regions(sa, sl, &sl->regionbase);
+ }
+ }
+ }
}
static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
{
- BLI_addtail(lb, id);
- id->us = 1;
- id->flag = LIB_FAKEUSER;
- *( (short *)id->name) = ID_GD;
+ BLI_addtail(lb, id);
+ id->us = 1;
+ id->flag = LIB_FAKEUSER;
+ *((short *)id->name) = ID_GD;
- BKE_id_new_name_validate(lb, id, name);
- /* alphabetic insertion: is in BKE_id_new_name_validate */
+ BKE_id_new_name_validate(lb, id, name);
+ /* alphabetic insertion: is in BKE_id_new_name_validate */
- if (G.debug & G_DEBUG)
- printf("Converted GPencil to ID: %s\n", id->name + 2);
+ if (G.debug & G_DEBUG)
+ printf("Converted GPencil to ID: %s\n", id->name + 2);
}
static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
{
- ScrArea *sa;
- SpaceLink *sl;
-
- /* add regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->gpd) {
- versions_gpencil_add_main(&main->gpencils, (ID *)v3d->gpd, "GPencil View3D");
- v3d->gpd = NULL;
- }
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- if (snode->gpd) {
- versions_gpencil_add_main(&main->gpencils, (ID *)snode->gpd, "GPencil Node");
- snode->gpd = NULL;
- }
- }
- else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- if (sseq->gpd) {
- versions_gpencil_add_main(&main->gpencils, (ID *)sseq->gpd, "GPencil Node");
- sseq->gpd = NULL;
- }
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-#if 0 /* see comment on r28002 */
- if (sima->gpd) {
- versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
- sima->gpd = NULL;
- }
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* add regions */
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->gpd) {
+ versions_gpencil_add_main(&main->gpencils, (ID *)v3d->gpd, "GPencil View3D");
+ v3d->gpd = NULL;
+ }
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ if (snode->gpd) {
+ versions_gpencil_add_main(&main->gpencils, (ID *)snode->gpd, "GPencil Node");
+ snode->gpd = NULL;
+ }
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ if (sseq->gpd) {
+ versions_gpencil_add_main(&main->gpencils, (ID *)sseq->gpd, "GPencil Node");
+ sseq->gpd = NULL;
+ }
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+#if 0 /* see comment on r28002 */
+ if (sima->gpd) {
+ versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
+ sima->gpd = NULL;
+ }
#else
- sima->gpd = NULL;
+ sima->gpd = NULL;
#endif
- }
- }
- }
+ }
+ }
+ }
}
static void do_version_mdef_250(Main *main)
{
- Object *ob;
- ModifierData *md;
- MeshDeformModifierData *mmd;
-
- for (ob = main->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_MeshDeform) {
- mmd = (MeshDeformModifierData *)md;
-
- if (mmd->bindcos) {
- /* make bindcos NULL in order to trick older versions
- * into thinking that the mesh was not bound yet */
- mmd->bindcagecos = mmd->bindcos;
- mmd->bindcos = NULL;
-
- modifier_mdef_compact_influences(md);
- }
- }
- }
- }
+ Object *ob;
+ ModifierData *md;
+ MeshDeformModifierData *mmd;
+
+ for (ob = main->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_MeshDeform) {
+ mmd = (MeshDeformModifierData *)md;
+
+ if (mmd->bindcos) {
+ /* make bindcos NULL in order to trick older versions
+ * into thinking that the mesh was not bound yet */
+ mmd->bindcagecos = mmd->bindcos;
+ mmd->bindcos = NULL;
+
+ modifier_mdef_compact_influences(md);
+ }
+ }
+ }
+ }
}
static void do_version_constraints_radians_degrees_250(ListBase *lb)
{
- bConstraint *con;
-
- for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = con->data;
- data->poleangle *= (float)(M_PI / 180.0);
- }
- else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
- bRotLimitConstraint *data = con->data;
-
- data->xmin *= (float)(M_PI / 180.0);
- data->xmax *= (float)(M_PI / 180.0);
- data->ymin *= (float)(M_PI / 180.0);
- data->ymax *= (float)(M_PI / 180.0);
- data->zmin *= (float)(M_PI / 180.0);
- data->zmax *= (float)(M_PI / 180.0);
- }
- }
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = con->data;
+ data->poleangle *= (float)(M_PI / 180.0);
+ }
+ else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
+ bRotLimitConstraint *data = con->data;
+
+ data->xmin *= (float)(M_PI / 180.0);
+ data->xmax *= (float)(M_PI / 180.0);
+ data->ymin *= (float)(M_PI / 180.0);
+ data->ymax *= (float)(M_PI / 180.0);
+ data->zmin *= (float)(M_PI / 180.0);
+ data->zmax *= (float)(M_PI / 180.0);
+ }
+ }
}
static void do_version_bone_roll_256(Bone *bone)
{
- Bone *child;
- float submat[3][3];
+ Bone *child;
+ float submat[3][3];
- copy_m3_m4(submat, bone->arm_mat);
- mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
+ copy_m3_m4(submat, bone->arm_mat);
+ mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
- for (child = bone->childbase.first; child; child = child->next)
- do_version_bone_roll_256(child);
+ for (child = bone->childbase.first; child; child = child->next)
+ do_version_bone_roll_256(child);
}
/* deprecated, only keep this for readfile.c */
@@ -557,29 +548,32 @@ static void do_version_bone_roll_256(Bone *bone)
* for do_versions of pre-2.56.2 code (r35033), so later proxy nodes
* can be generated consistently from ntree socket lists.
*/
-static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, const char *name, int type, int in_out)
+static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
+ const char *name,
+ int type,
+ int in_out)
{
-// bNodeSocketType *stype = ntreeGetSocketType(type);
- bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket");
+ // bNodeSocketType *stype = ntreeGetSocketType(type);
+ bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket");
- BLI_strncpy(gsock->name, name, sizeof(gsock->name));
- gsock->type = type;
+ BLI_strncpy(gsock->name, name, sizeof(gsock->name));
+ gsock->type = type;
- gsock->next = gsock->prev = NULL;
- gsock->new_sock = NULL;
- gsock->link = NULL;
- /* assign new unique index */
- gsock->own_index = ngroup->cur_index++;
- gsock->limit = (in_out == SOCK_IN ? 0xFFF : 1);
+ gsock->next = gsock->prev = NULL;
+ gsock->new_sock = NULL;
+ gsock->link = NULL;
+ /* assign new unique index */
+ gsock->own_index = ngroup->cur_index++;
+ gsock->limit = (in_out == SOCK_IN ? 0xFFF : 1);
-// if (stype->value_structsize > 0)
-// gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
+ // if (stype->value_structsize > 0)
+ // gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
- BLI_addtail(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock);
+ BLI_addtail(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock);
- ngroup->update |= (in_out == SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT);
+ ngroup->update |= (in_out == SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT);
- return gsock;
+ return gsock;
}
/* Create default_value structs for node sockets from the internal bNodeStack value.
@@ -591,1592 +585,1600 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
*/
static void do_versions_socket_default_value_259(bNodeSocket *sock)
{
- bNodeSocketValueFloat *valfloat;
- bNodeSocketValueVector *valvector;
- bNodeSocketValueRGBA *valrgba;
-
- if (sock->default_value)
- return;
-
- switch (sock->type) {
- case SOCK_FLOAT:
- valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value");
- valfloat->value = sock->ns.vec[0];
- valfloat->min = sock->ns.min;
- valfloat->max = sock->ns.max;
- valfloat->subtype = PROP_NONE;
- break;
- case SOCK_VECTOR:
- valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector), "default socket value");
- copy_v3_v3(valvector->value, sock->ns.vec);
- valvector->min = sock->ns.min;
- valvector->max = sock->ns.max;
- valvector->subtype = PROP_NONE;
- break;
- case SOCK_RGBA:
- valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA), "default socket value");
- copy_v4_v4(valrgba->value, sock->ns.vec);
- break;
- }
+ bNodeSocketValueFloat *valfloat;
+ bNodeSocketValueVector *valvector;
+ bNodeSocketValueRGBA *valrgba;
+
+ if (sock->default_value)
+ return;
+
+ switch (sock->type) {
+ case SOCK_FLOAT:
+ valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat),
+ "default socket value");
+ valfloat->value = sock->ns.vec[0];
+ valfloat->min = sock->ns.min;
+ valfloat->max = sock->ns.max;
+ valfloat->subtype = PROP_NONE;
+ break;
+ case SOCK_VECTOR:
+ valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector),
+ "default socket value");
+ copy_v3_v3(valvector->value, sock->ns.vec);
+ valvector->min = sock->ns.min;
+ valvector->max = sock->ns.max;
+ valvector->subtype = PROP_NONE;
+ break;
+ case SOCK_RGBA:
+ valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA),
+ "default socket value");
+ copy_v4_v4(valrgba->value, sock->ns.vec);
+ break;
+ }
}
void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
{
- /* WATCH IT!!!: pointers from libdata have not been converted */
-
- if (bmain->versionfile < 250) {
- bScreen *screen;
- Scene *scene;
- Base *base;
- Material *ma;
- Camera *cam;
- Curve *cu;
- Scene *sce;
- Tex *tx;
- ParticleSettings *part;
- Object *ob;
- //PTCacheID *pid;
- //ListBase pidlist;
-
- bSound *sound;
- Sequence *seq;
-
- for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
- if (sound->newpackedfile) {
- sound->packedfile = sound->newpackedfile;
- sound->newpackedfile = NULL;
- }
- }
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->ed && scene->ed->seqbasep) {
- SEQ_BEGIN(scene->ed, seq)
- {
- if (seq->type == SEQ_TYPE_SOUND_HD) {
- char str[FILE_MAX];
- BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(str, BKE_main_blendfile_path(bmain));
- seq->sound = BKE_sound_new_file(bmain, str);
- }
+ /* WATCH IT!!!: pointers from libdata have not been converted */
+
+ if (bmain->versionfile < 250) {
+ bScreen *screen;
+ Scene *scene;
+ Base *base;
+ Material *ma;
+ Camera *cam;
+ Curve *cu;
+ Scene *sce;
+ Tex *tx;
+ ParticleSettings *part;
+ Object *ob;
+ //PTCacheID *pid;
+ //ListBase pidlist;
+
+ bSound *sound;
+ Sequence *seq;
+
+ for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
+ if (sound->newpackedfile) {
+ sound->packedfile = sound->newpackedfile;
+ sound->newpackedfile = NULL;
+ }
+ }
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->ed && scene->ed->seqbasep) {
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->type == SEQ_TYPE_SOUND_HD) {
+ char str[FILE_MAX];
+ BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(str, BKE_main_blendfile_path(bmain));
+ seq->sound = BKE_sound_new_file(bmain, str);
+ }
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
- /* don't know, if anybody used that this way, but just in case, upgrade to new way... */
- if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) &&
- !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
- {
- BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
- }
+ /* don't know, if anybody used that this way, but just in case, upgrade to new way... */
+ if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) {
+ BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
+ }
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
- } SEQ_END;
- }
- }
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- do_versions_windowmanager_2_50(screen);
- do_versions_gpencil_2_50(bmain, screen);
- }
-
- /* shader, composite and texture node trees have id.name empty, put something in
- * to have them show in RNA viewer and accessible otherwise.
- */
- for (ma = bmain->materials.first; ma; ma = ma->id.next) {
- if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
- strcpy(ma->nodetree->id.name, "NTShader Nodetree");
- }
-
- /* and composite trees */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- enum { R_PANORAMA = (1 << 10) };
- if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
- strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
-
- /* move to cameras */
- if (sce->r.mode & R_PANORAMA) {
- for (base = sce->base.first; base; base = base->next) {
- ob = blo_do_versions_newlibadr(fd, lib, base->object);
-
- if (ob->type == OB_CAMERA && !ob->id.lib) {
- cam = blo_do_versions_newlibadr(fd, lib, ob->data);
- cam->flag |= CAM_PANORAMA;
- }
- }
-
- sce->r.mode &= ~R_PANORAMA;
- }
- }
-
- /* and texture trees */
- for (tx = bmain->textures.first; tx; tx = tx->id.next) {
- bNode *node;
-
- if (tx->nodetree) {
- if (tx->nodetree->id.name[0] == '\0')
- strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
-
- /* which_output 0 is now "not specified" */
- for (node = tx->nodetree->nodes.first; node; node = node->next)
- if (node->type == TEX_NODE_OUTPUT)
- node->custom1++;
- }
- }
-
- /* particle draw and render types */
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->draw_as) {
- if (part->draw_as == PART_DRAW_DOT) {
- part->ren_as = PART_DRAW_HALO;
- part->draw_as = PART_DRAW_REND;
- }
- else if (part->draw_as <= PART_DRAW_AXIS) {
- part->ren_as = PART_DRAW_HALO;
- }
- else {
- part->ren_as = part->draw_as;
- part->draw_as = PART_DRAW_REND;
- }
- }
- part->path_end = 1.0f;
- part->clength = 1.0f;
- }
-
- /* set old pointcaches to have disk cache flag */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
-
- //BKE_ptcache_ids_from_object(&pidlist, ob);
-
- //for (pid = pidlist.first; pid; pid = pid->next)
- // pid->cache->flag |= PTCACHE_DISK_CACHE;
-
- //BLI_freelistN(&pidlist);
- }
-
- /* type was a mixed flag & enum. move the 2d flag elsewhere */
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- Nurb *nu;
-
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- nu->flag |= (nu->type & CU_2D);
- nu->type &= CU_TYPE;
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
- Object *ob;
- Tex *tex;
- Scene *sce;
- ToolSettings *ts;
- //PTCacheID *pid;
- //ListBase pidlist;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
-
- //for (pid = pidlist.first; pid; pid = pid->next) {
- // if (BLI_listbase_is_empty(pid->ptcaches))
- // pid->ptcaches->first = pid->ptcaches->last = pid->cache;
- //}
-
- //BLI_freelistN(&pidlist);
-
- if (ob->type == OB_MESH) {
- Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
- void *olddata = ob->data;
- ob->data = me;
-
- /* XXX - library meshes crash on loading most yoFrankie levels,
- * the multires pointer gets invalid - Campbell */
- if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) {
- multires_load_old(ob, me);
- }
-
- ob->data = olddata;
- }
-
- if (ob->totcol && ob->matbits == NULL) {
- int a;
-
- ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
- for (a = 0; a < ob->totcol; a++)
- ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
- }
- }
-
- /* texture filter */
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->afmax == 0)
- tex->afmax = 8;
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- ts = sce->toolsettings;
- if (!ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
- ts->selectmode = SCE_SELECT_VERTEX;
-
- /* autokeying - setting should be taken from the user-prefs
- * but the userprefs version may not have correct flags set
- * (i.e. will result in blank box when enabled)
- */
- ts->autokey_mode = U.autokey_mode;
- if (ts->autokey_mode == 0)
- ts->autokey_mode = 2; /* 'add/replace' but not on */
- ts->uv_selectmode = UV_SELECT_VERTEX;
- ts->vgroup_weight = 1.0f;
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->flag & 8192) // OB_POSEMODE = 8192
- ob->mode |= OB_MODE_POSE;
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) {
- Scene *sce;
- Object *ob;
- ParticleSettings *part;
- bool do_gravity = false;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->unit.scale_length == 0.0f)
- sce->unit.scale_length = 1.0f;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- /* fluid-sim stuff */
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- if (fluidmd)
- fluidmd->fss->fmd = fluidmd;
-
- /* rotation modes were added, but old objects would now default to being 'quaternion based' */
- ob->rotmode = ROT_MODE_EUL;
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->audio.main == 0.0f)
- sce->audio.main = 1.0f;
-
- sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
- sce->r.ffcodecdata.audio_volume = sce->audio.main;
- sce->audio.distance_model = 2;
- sce->audio.doppler_factor = 1.0f;
- sce->audio.speed_of_sound = 343.3f;
- }
-
- /* Add default gravity to scenes */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
- is_zero_v3(sce->physics_settings.gravity))
- {
- sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
- sce->physics_settings.gravity[2] = -9.81f;
- sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
- do_gravity = true;
- }
- }
-
- /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
- if (do_gravity) {
- for (part = bmain->particles.first; part; part = part->id.next)
- part->effector_weights->global_gravity = part->acc[2] / -9.81f;
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- if (do_gravity) {
- for (md = ob->modifiers.first; md; md = md->next) {
- ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
- if (clmd)
- clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2] / -9.81f;
- }
-
- if (ob->soft)
- ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
- }
-
- /* Normal wind shape is plane */
- if (ob->pd) {
- if (ob->pd->forcefield == PFIELD_WIND)
- ob->pd->shape = PFIELD_SHAPE_PLANE;
-
- if (ob->pd->flag & PFIELD_PLANAR)
- ob->pd->shape = PFIELD_SHAPE_PLANE;
- else if (ob->pd->flag & PFIELD_SURFACE)
- ob->pd->shape = PFIELD_SHAPE_SURFACE;
-
- ob->pd->flag |= PFIELD_DO_LOCATION;
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
- Object *ob;
-
- /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- /* new variables for all objects */
- ob->quat[0] = 1.0f;
- ob->rotAxis[1] = 1.0f;
-
- /* bones */
- if (ob->pose) {
- bPoseChannel *pchan;
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* just need to initalise rotation axis properly... */
- pchan->rotAxis[1] = 1.0f;
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) {
- Mesh *me;
- Nurb *nu;
- Lattice *lt;
- Curve *cu;
- Key *key;
- const float *data;
- int a, tot;
-
- /* shape keys are no longer applied to the mesh itself, but rather
- * to the derivedmesh/displist, so here we ensure that the basis
- * shape key is always set in the mesh coordinates. */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
- data = key->refkey->data;
- tot = MIN2(me->totvert, key->refkey->totelem);
-
- for (a = 0; a < tot; a++, data += 3)
- copy_v3_v3(me->mvert[a].co, data);
- }
- }
-
- for (lt = bmain->lattices.first; lt; lt = lt->id.next) {
- if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
- data = key->refkey->data;
- tot = MIN2(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
-
- for (a = 0; a < tot; a++, data += 3)
- copy_v3_v3(lt->def[a].vec, data);
- }
- }
-
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) {
- data = key->refkey->data;
-
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- if (nu->bezt) {
- BezTriple *bezt = nu->bezt;
-
- for (a = 0; a < nu->pntsu; a++, bezt++) {
- copy_v3_v3(bezt->vec[0], data); data += 3;
- copy_v3_v3(bezt->vec[1], data); data += 3;
- copy_v3_v3(bezt->vec[2], data); data += 3;
- bezt->tilt = *data; data++;
- }
- }
- else if (nu->bp) {
- BPoint *bp = nu->bp;
-
- for (a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- copy_v3_v3(bp->vec, data); data += 3;
- bp->tilt = *data; data++;
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
- {
- Scene *sce = bmain->scenes.first;
- while (sce) {
- if (sce->r.frame_step == 0)
- sce->r.frame_step = 1;
-
- sce = sce->id.next;
- }
- }
-
- {
- /* ensure all nodes have unique names */
- bNodeTree *ntree = bmain->nodetrees.first;
- while (ntree) {
- bNode *node = ntree->nodes.first;
-
- while (node) {
- nodeUniqueName(ntree, node);
- node = node->next;
- }
-
- ntree = ntree->id.next;
- }
- }
-
- {
- Object *ob = bmain->objects.first;
- while (ob) {
- /* shaded mode disabled for now */
- if (ob->dt == OB_MATERIAL)
- ob->dt = OB_TEXTURE;
- ob = ob->id.next;
- }
- }
-
- {
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->drawtype == OB_MATERIAL)
- v3d->drawtype = OB_SOLID;
- }
- }
- }
- }
- }
-
- /* only convert old 2.50 files with color management */
- if (bmain->versionfile == 250) {
- Scene *sce = bmain->scenes.first;
- Material *ma = bmain->materials.first;
- Tex *tex = bmain->textures.first;
- int i, convert = 0;
-
- /* convert to new color management system:
- * while previously colors were stored as srgb,
- * now they are stored as linear internally,
- * with screen gamma correction in certain places in the UI. */
-
- /* don't know what scene is active, so we'll convert if any scene has it enabled... */
- while (sce) {
- if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- convert = 1;
- sce = sce->id.next;
- }
-
- if (convert) {
- while (ma) {
- srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
- srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
- ma = ma->id.next;
- }
-
- while (tex) {
- if (tex->coba) {
- ColorBand *band = (ColorBand *)tex->coba;
- for (i = 0; i < band->tot; i++) {
- CBData *data = band->data + i;
- srgb_to_linearrgb_v3_v3(&data->r, &data->r);
- }
- }
- tex = tex->id.next;
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) {
- Scene *sce;
- Mesh *me;
- Object *ob;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (!sce->toolsettings->particle.selectmode)
- sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
-
- if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
- for (me = bmain->meshes.first; me; me = me->id.next)
- multires_load_old_250(me);
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires);
-
- if (mmd) {
- mmd->totlvl--;
- mmd->lvl--;
- mmd->sculptlvl = mmd->lvl;
- mmd->renderlvl = mmd->lvl;
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) {
- Object *ob;
-
- /* properly initialize hair clothsim data on old files */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- if (clmd->sim_parms->velocity_smooth < 0.01f)
- clmd->sim_parms->velocity_smooth = 0.f;
- }
- }
- }
- }
-
- /* fix bad area setup in subversion 10 */
- if (bmain->versionfile == 250 && bmain->subversionfile == 10) {
- /* fix for new view type in sequencer */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- /* remove all preview window in wrong spaces */
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype != SPACE_SEQ) {
- ARegion *ar;
- ListBase *regionbase;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
- for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW)
- break;
- }
-
- if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
- SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ);
- BKE_area_region_free(st, ar);
- BLI_freelinkN(regionbase, ar);
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 11)) {
- {
- /* fix for new view type in sequencer */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SEQ) {
- ARegion *ar;
- ARegion *ar_main;
- ListBase *regionbase;
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
- if (sseq->view == 0)
- sseq->view = SEQ_VIEW_SEQUENCE;
- if (sseq->mainb == 0)
- sseq->mainb = SEQ_DRAW_IMG_IMBUF;
-
- ar_main = (ARegion *)regionbase->first;
- for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
- break;
- }
- ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
- BLI_insertlinkbefore(regionbase, ar_main, ar);
- sequencer_init_preview_region(ar);
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) {
- Object *ob;
- Brush *brush;
-
- /* anim viz changes */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- /* initialize object defaults */
- animviz_settings_init(&ob->avs);
-
- /* if armature, copy settings for pose from armature data
- * performing initialization where appropriate
- */
- if (ob->pose && ob->data) {
- bArmature *arm = blo_do_versions_newlibadr(fd, lib, ob->data);
- if (arm) { /* XXX - why does this fail in some cases? */
- bAnimVizSettings *avs = &ob->pose->avs;
-
- /* path settings --------------------- */
- /* ranges */
- avs->path_bc = 10;
- avs->path_ac = 10;
-
- avs->path_sf = 1;
- avs->path_ef = 250;
-
- /* flags */
- if (arm->pathflag & ARM_PATH_FNUMS)
- avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
- if (arm->pathflag & ARM_PATH_KFRAS)
- avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
- if (arm->pathflag & ARM_PATH_KFNOS)
- avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
-
- /* bake flags */
- if (arm->pathflag & ARM_PATH_HEADS)
- avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
-
- /* type */
- if (arm->pathflag & ARM_PATH_ACFRA)
- avs->path_type = MOTIONPATH_TYPE_ACFRA;
-
- /* stepsize */
- avs->path_step = 1;
- }
- else
- animviz_settings_init(&ob->pose->avs);
- }
- }
-
- /* brush texture changes */
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- BKE_texture_mtex_default(&brush->mtex);
- BKE_texture_mtex_default(&brush->mask_mtex);
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 13)) {
- /* NOTE: if you do more conversion, be sure to do it outside of this and
- * increase subversion again, otherwise it will not be correct */
- Object *ob;
-
- /* convert degrees to radians for internal use */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- bPoseChannel *pchan;
-
- do_version_constraints_radians_degrees_250(&ob->constraints);
-
- if (ob->pose) {
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- pchan->limitmin[0] *= (float)(M_PI / 180.0);
- pchan->limitmin[1] *= (float)(M_PI / 180.0);
- pchan->limitmin[2] *= (float)(M_PI / 180.0);
- pchan->limitmax[0] *= (float)(M_PI / 180.0);
- pchan->limitmax[1] *= (float)(M_PI / 180.0);
- pchan->limitmax[2] *= (float)(M_PI / 180.0);
-
- do_version_constraints_radians_degrees_250(&pchan->constraints);
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) {
- /* fix for bad View2D extents for Animation Editors */
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *regionbase;
- ARegion *ar;
-
- if (sl == sa->spacedata.first)
- regionbase = &sa->regionbase;
- else
- regionbase = &sl->regionbase;
-
- if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
- for (ar = (ARegion *)regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f;
- ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- }
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) {
- Scene *sce;
- Sequence *seq;
-
- /* initialize to sane default so toggling on border shows something */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f &&
- sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f)
- {
- sce->r.border.xmin = 0.0f;
- sce->r.border.ymin = 0.0f;
- sce->r.border.xmax = 1.0f;
- sce->r.border.ymax = 1.0f;
- }
-
- if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
- sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
-
- SEQ_BEGIN(sce->ed, seq)
- {
- seq->volume = 1.0f;
- } SEQ_END;
- }
-
- /* particle brush strength factor was changed from int to float */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- ParticleEditSettings *pset = &sce->toolsettings->particle;
- int a;
-
- for (a = 0; a < ARRAY_SIZE(pset->brush); a++)
- pset->brush[a].strength /= 100.0f;
- }
-
- /* sequencer changes */
- {
- bScreen *screen;
- ScrArea *sa;
- SpaceLink *sl;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SEQ) {
- ARegion *ar_preview;
- ListBase *regionbase;
-
- if (sl == sa->spacedata.first) {
- regionbase = &sa->regionbase;
- }
- else {
- regionbase = &sl->regionbase;
- }
-
- ar_preview = (ARegion *)regionbase->first;
- for (; ar_preview; ar_preview = ar_preview->next) {
- if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
- break;
- }
- if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
- sequencer_init_preview_region(ar_preview);
- }
- }
- }
- }
- }
- } /* sequencer changes */
- }
-
- if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
- bScreen *sc;
-
- /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_HIDE_OVERLAYS.
- * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
- * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set,
- * which would cause cameras, lights, etc to become invisible */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->flag2 &= ~V3D_HIDE_OVERLAYS;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) {
- Brush *brush;
- Object *ob;
- Scene *scene;
- bNodeTree *ntree;
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->curve)
- brush->curve->preset = CURVE_PRESET_SMOOTH;
- }
-
- /* properly initialize active flag for fluidsim modifiers */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
- fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
- }
- }
- }
-
- /* adjustment to color balance node values */
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->nodetree) {
- bNode *node = scene->nodetree->nodes.first;
-
- while (node) {
- if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n = (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
- }
- node = node->next;
- }
- }
- }
- /* check inside node groups too */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
- bNode *node = ntree->nodes.first;
-
- while (node) {
- if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n = (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
- }
-
- node = node->next;
- }
- }
- }
-
- /* old-track -> constraints (this time we're really doing it!) */
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
- blo_do_version_old_trackto_to_constraints(ob);
- }
-
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
- bScreen *sc;
-
- /* Image editor scopes */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
- scopes_new(&sima->scopes);
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 253) {
- Object *ob;
- Scene *scene;
- bScreen *sc;
- Tex *tex;
- Brush *brush;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- ListBase *regionbase;
- ARegion *ar;
-
- if (sl == sa->spacedata.first)
- regionbase = &sa->regionbase;
- else
- regionbase = &sl->regionbase;
-
- if (snode->v2d.minzoom > 0.09f)
- snode->v2d.minzoom = 0.09f;
- if (snode->v2d.maxzoom < 2.31f)
- snode->v2d.maxzoom = 2.31f;
-
- for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.minzoom > 0.09f)
- ar->v2d.minzoom = 0.09f;
- if (ar->v2d.maxzoom < 2.31f)
- ar->v2d.maxzoom = 2.31f;
- }
- }
- }
- }
- }
- }
-
- do_version_mdef_250(bmain);
-
- /* parent type to modifier */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->parent) {
- Object *parent = (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent);
- if (parent) { /* parent may not be in group */
- enum { PARCURVE = 1 };
- if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
- ArmatureModifierData *amd;
- bArmature *arm = (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data);
-
- amd = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
- amd->object = ob->parent;
- BLI_addtail((ListBase *)&ob->modifiers, amd);
- amd->deformflag = arm->deformflag;
- ob->partype = PAROBJECT;
- }
- else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) {
- LatticeModifierData *lmd;
-
- lmd = (LatticeModifierData *)modifier_new(eModifierType_Lattice);
- lmd->object = ob->parent;
- BLI_addtail((ListBase *)&ob->modifiers, lmd);
- ob->partype = PAROBJECT;
- }
- else if (parent->type == OB_CURVE && ob->partype == PARCURVE) {
- CurveModifierData *cmd;
-
- cmd = (CurveModifierData *)modifier_new(eModifierType_Curve);
- cmd->object = ob->parent;
- BLI_addtail((ListBase *)&ob->modifiers, cmd);
- ob->partype = PAROBJECT;
- }
- }
- }
- }
-
- /* initialize scene active layer */
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- int i;
- for (i = 0; i < 20; i++) {
- if (scene->lay & (1 << i)) {
- scene->layact = 1 << i;
- break;
- }
- }
- }
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- /* if youre picky, this isn't correct until we do a version bump
- * since you could set saturation to be 0.0*/
- if (tex->saturation == 0.0f)
- tex->saturation = 1.0f;
- }
-
- {
- Curve *cu;
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- cu->smallcaps_scale = 0.75f;
- }
- }
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene) {
- Sequence *seq;
- SEQ_BEGIN(scene->ed, seq)
- {
- if (seq->sat == 0.0f) {
- seq->sat = 1.0f;
- }
- } SEQ_END;
- }
- }
-
- /* GSOC 2010 Sculpt - New settings for Brush */
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- /* Sanity Check */
-
- /* infinite number of dabs */
- if (brush->spacing == 0)
- brush->spacing = 10;
-
- /* will have no effect */
- if (brush->alpha == 0)
- brush->alpha = 0.5f;
-
- /* bad radius */
- if (brush->unprojected_radius == 0)
- brush->unprojected_radius = 0.125f;
-
- /* unusable size */
- if (brush->size == 0)
- brush->size = 35;
-
- /* can't see overlay */
- if (brush->texture_overlay_alpha == 0)
- brush->texture_overlay_alpha = 33;
-
- /* same as draw brush */
- if (brush->crease_pinch_factor == 0)
- brush->crease_pinch_factor = 0.5f;
-
- /* will sculpt no vertexes */
- if (brush->plane_trim == 0)
- brush->plane_trim = 0.5f;
-
- /* same as smooth stroke off */
- if (brush->smooth_stroke_radius == 0)
- brush->smooth_stroke_radius = 75;
-
- /* will keep cursor in one spot */
- if (brush->smooth_stroke_radius == 1)
- brush->smooth_stroke_factor = 0.9f;
-
- /* same as dots */
- if (brush->rate == 0)
- brush->rate = 0.1f;
-
- /* New Settings */
- if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
- brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
-
- /* spacing was originally in pixels, convert it to percentage for new version
- * size should not be zero due to sanity check above
- */
- brush->spacing = (int)(100 * ((float)brush->spacing) / ((float)brush->size));
-
- if (brush->add_col[0] == 0 &&
- brush->add_col[1] == 0 &&
- brush->add_col[2] == 0)
- {
- brush->add_col[0] = 1.00f;
- brush->add_col[1] = 0.39f;
- brush->add_col[2] = 0.39f;
- }
-
- if (brush->sub_col[0] == 0 &&
- brush->sub_col[1] == 0 &&
- brush->sub_col[2] == 0)
- {
- brush->sub_col[0] = 0.39f;
- brush->sub_col[1] = 0.39f;
- brush->sub_col[2] = 1.00f;
- }
- }
- }
- }
-
- /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
- if (bmain->versionfile < 253) {
- Scene *sce;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
- sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
-
- if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0)
- sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
-
- if (sce->toolsettings->sculpt_paint_unified_size == 0)
- sce->toolsettings->sculpt_paint_unified_size = 35;
- }
- }
-
- if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
-
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- smd->domain->vorticity = 2.0f;
- smd->domain->time_scale = 1.0f;
-
- if (!(smd->domain->flags & (1 << 4)))
- continue;
-
- /* delete old MOD_SMOKE_INITVELOCITY flag */
- smd->domain->flags &= ~(1 << 4);
-
- /* for now just add it to all flow objects in the scene */
- {
- Object *ob2;
- for (ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
- ModifierData *md2;
- for (md2 = ob2->modifiers.first; md2; md2 = md2->next) {
- if (md2->type == eModifierType_Smoke) {
- SmokeModifierData *smd2 = (SmokeModifierData *)md2;
-
- if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) {
- smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY;
- }
- }
- }
- }
- }
-
- }
- else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
- smd->flow->vel_multi = 1.0f;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) {
- Brush *br;
- ParticleSettings *part;
- bScreen *sc;
-
- for (br = bmain->brushes.first; br; br = br->id.next) {
- if (br->ob_mode == 0)
- br->ob_mode = OB_MODE_ALL_PAINT;
- }
-
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->boids)
- part->boids->pitch = 1.0f;
-
- part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
- part->kink_amp_clump = 1.f; /* keep old files looking similar */
- }
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_INFO) {
- SpaceInfo *sinfo = (SpaceInfo *)sl;
- ARegion *ar;
-
- sinfo->rpt_mask = INFO_RPT_OP;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.scroll = (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
- ar->v2d.keepofs = V2D_LOCKOFS_X;
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
- ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
- ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
- }
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 3)) {
- Object *ob;
-
- /* ocean res is now squared, reset old ones - will be massive */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Ocean) {
- OceanModifierData *omd = (OceanModifierData *)md;
- omd->resolution = 7;
- omd->oceancache = NULL;
- }
- }
- }
- }
-
- if (bmain->versionfile < 256) {
- bScreen *sc;
- ScrArea *sa;
- Key *key;
-
- /* Fix for sample line scope initializing with no height */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
- if (sima->sample_line_hist.height == 0)
- sima->sample_line_hist.height = 100;
- }
- }
- sa = sa->next;
- }
- }
-
- /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
- * 2.4x would never reveal this to users as a dummy value always ended up getting used
- * instead
- */
- for (key = bmain->shapekeys.first; key; key = key->id.next) {
- KeyBlock *kb;
-
- for (kb = key->block.first; kb; kb = kb->next) {
- if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f))
- kb->slidermax = kb->slidermin + 1.0f;
- }
- }
- }
-
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 1)) {
- /* fix for bones that didn't have arm_roll before */
- bArmature *arm;
- Bone *bone;
- Object *ob;
-
- for (arm = bmain->armatures.first; arm; arm = arm->id.next)
- for (bone = arm->bonebase.first; bone; bone = bone->next)
- do_version_bone_roll_256(bone);
-
- /* fix for objects which have zero dquat's
- * since this is multiplied with the quat rather than added */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (is_zero_v4(ob->dquat)) {
- unit_qt(ob->dquat);
- }
- if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
- unit_axis_angle(ob->drotAxis, &ob->drotAngle);
- }
- }
- }
-
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
- bNodeTree *ntree;
- bNode *node;
- bNodeSocket *sock, *gsock;
- bNodeLink *link;
-
- /* node sockets are not exposed automatically any more,
- * this mimics the old behavior by adding all unlinked sockets to groups.
- */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
- /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
-
- /* first make sure the own_index for new sockets is valid */
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (sock->own_index >= ntree->cur_index)
- ntree->cur_index = sock->own_index + 1;
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (sock->own_index >= ntree->cur_index)
- ntree->cur_index = sock->own_index + 1;
- }
-
- /* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next) {
- if (!sock->link && !nodeSocketIsHidden(sock)) {
-
- gsock = do_versions_node_group_add_socket_2_56_2(ntree, sock->name, sock->type, SOCK_IN);
-
- /* initialize the default socket value */
- copy_v4_v4(gsock->ns.vec, sock->ns.vec);
-
- /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
- * have to create these directly here. These links are updated again in subsequent do_version!
- */
- link = MEM_callocN(sizeof(bNodeLink), "link");
- BLI_addtail(&ntree->links, link);
- link->fromnode = NULL;
- link->fromsock = gsock;
- link->tonode = node;
- link->tosock = sock;
- ntree->update |= NTREE_UPDATE_LINKS;
-
- sock->link = link;
- }
- }
- for (sock = node->outputs.first; sock; sock = sock->next) {
- if (nodeCountSocketLinks(ntree, sock) == 0 && !nodeSocketIsHidden(sock)) {
- gsock = do_versions_node_group_add_socket_2_56_2(ntree, sock->name, sock->type, SOCK_OUT);
-
- /* initialize the default socket value */
- copy_v4_v4(gsock->ns.vec, sock->ns.vec);
-
- /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
- * have to create these directly here. These links are updated again in subsequent do_version!
- */
- link = MEM_callocN(sizeof(bNodeLink), "link");
- BLI_addtail(&ntree->links, link);
- link->fromnode = node;
- link->fromsock = sock;
- link->tonode = NULL;
- link->tosock = gsock;
- ntree->update |= NTREE_UPDATE_LINKS;
-
- gsock->link = link;
- }
- }
- }
-
- /* XXX The external group node sockets needs to adjust their own_index to point at
- * associated ntree inputs/outputs internal sockets. However, this can only happen
- * after lib-linking (needs access to internal node group tree)!
- * Setting a temporary flag here, actual do_versions happens in lib_verify_nodetree.
- */
- ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
- }
- }
-
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) {
- bScreen *sc;
- Brush *brush;
- Object *ob;
- ParticleSettings *part;
-
- /* redraws flag in SpaceTime has been moved to Screen level */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- if (sc->redraws_flag == 0) {
- /* just initialize to default? */
- /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
- sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
- }
- }
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->height == 0)
- brush->height = 0.4f;
- }
-
- /* replace 'rim material' option for in offset*/
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Solidify) {
- SolidifyModifierData *smd = (SolidifyModifierData *)md;
- if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
- smd->mat_ofs_rim = 1;
- smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
- }
- }
- }
- }
-
- /* particle draw color from material */
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->draw & PART_DRAW_MAT_COL)
- part->draw_col = PART_DRAW_COL_MAT;
- }
- }
-
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
- Mesh *me;
-
- for (me = bmain->meshes.first; me; me = me->id.next)
- BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
- }
-
- if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
- /* update blur area sizes from 0..1 range to 0..100 percentage */
- Scene *scene;
- bNode *node;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
- if (scene->nodetree)
- for (node = scene->nodetree->nodes.first; node; node = node->next)
- if (node->type == CMP_NODE_BLUR) {
- NodeBlurData *nbd = node->storage;
- nbd->percentx *= 100.0f;
- nbd->percenty *= 100.0f;
- }
- }
-
- if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
- /* screen view2d settings were not properly initialized [#27164]
- * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
- * need to make less ugly - possibly an iterator? */
- bScreen *screen;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
- /* add regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl = sa->spacedata.first;
- if (sl->spacetype == SPACE_IMAGE) {
- ARegion *ar;
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- View2D *v2d = &ar->v2d;
- v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = v2d->keepofs = v2d->align = 0;
- }
- }
- }
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- ARegion *ar;
- for (ar = sl->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- View2D *v2d = &ar->v2d;
- v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = v2d->keepofs = v2d->align = 0;
- }
- }
- }
- }
- }
- }
-
- {
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- /* Initialize particle billboard scale */
- part->bb_size[0] = part->bb_size[1] = 1.0f;
- }
- }
- }
-
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
- {
- Scene *scene;
- Sequence *seq;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->r.ffcodecdata.audio_channels = 2;
- scene->audio.volume = 1.0f;
- SEQ_BEGIN(scene->ed, seq)
- {
- seq->pitch = 1.0f;
- } SEQ_END;
- }
- }
-
- {
- bScreen *screen;
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
-
- /* add regions */
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl = sa->spacedata.first;
- if (sl->spacetype == SPACE_SEQ) {
- ARegion *ar;
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
- ar->v2d.min[1] = 0.5f;
- }
- }
- }
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SEQ) {
- ARegion *ar;
- for (ar = sl->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
- ar->v2d.min[1] = 0.5f;
- }
- }
- }
- }
- }
- }
- }
-
- {
- /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
- *
- * We're only patching F-Curves in Actions here, since it is assumed that most
- * drivers out there won't be using this (and if they are, they're in the minority).
- * While we should aim to fix everything ideally, in practice it's far too hard
- * to get to every animdata block, not to mention the performance hit that'd have
- */
- bAction *act;
- FCurve *fcu;
-
- for (act = bmain->actions.first; act; act = act->id.next) {
- for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- BezTriple *bezt;
- uint i = 0;
-
- /* only need to touch curves that had this flag set */
- if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
- continue;
- if ((fcu->totvert == 0) || (fcu->bezt == NULL))
- continue;
-
- /* only change auto-handles to auto-clamped */
- for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
- if (bezt->h1 == HD_AUTO)
- bezt->h1 = HD_AUTO_ANIM;
- if (bezt->h2 == HD_AUTO)
- bezt->h2 = HD_AUTO_ANIM;
- }
-
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
- }
- }
- }
- }
-
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
- {
- /* Convert default socket values from bNodeStack */
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- bNode *node;
- bNodeSocket *sock;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
- do_versions_socket_default_value_259(sock);
- for (sock = node->outputs.first; sock; sock = sock->next)
- do_versions_socket_default_value_259(sock);
- }
-
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- do_versions_socket_default_value_259(sock);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- do_versions_socket_default_value_259(sock);
-
- ntree->update |= NTREE_UPDATE;
- } FOREACH_NODETREE_END;
- }
-
- {
- /* Initialize group tree nodetypes.
- * These are used to distinguish tree types and
- * associate them with specific node types for polling.
- */
- bNodeTree *ntree;
- /* all node trees in bmain->nodetree are considered groups */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- ntree->nodetype = NODE_GROUP;
- }
- }
-
- if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) {
- {
- /* Adaptive time step for particle systems */
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- part->courant_target = 0.2f;
- part->time_flag &= ~PART_TIME_AUTOSF;
- }
- }
- }
+ }
+ SEQ_END;
+ }
+ }
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ do_versions_windowmanager_2_50(screen);
+ do_versions_gpencil_2_50(bmain, screen);
+ }
+
+ /* shader, composite and texture node trees have id.name empty, put something in
+ * to have them show in RNA viewer and accessible otherwise.
+ */
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+ if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
+ strcpy(ma->nodetree->id.name, "NTShader Nodetree");
+ }
+
+ /* and composite trees */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ enum { R_PANORAMA = (1 << 10) };
+ if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
+ strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
+
+ /* move to cameras */
+ if (sce->r.mode & R_PANORAMA) {
+ for (base = sce->base.first; base; base = base->next) {
+ ob = blo_do_versions_newlibadr(fd, lib, base->object);
+
+ if (ob->type == OB_CAMERA && !ob->id.lib) {
+ cam = blo_do_versions_newlibadr(fd, lib, ob->data);
+ cam->flag |= CAM_PANORAMA;
+ }
+ }
+
+ sce->r.mode &= ~R_PANORAMA;
+ }
+ }
+
+ /* and texture trees */
+ for (tx = bmain->textures.first; tx; tx = tx->id.next) {
+ bNode *node;
+
+ if (tx->nodetree) {
+ if (tx->nodetree->id.name[0] == '\0')
+ strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
+
+ /* which_output 0 is now "not specified" */
+ for (node = tx->nodetree->nodes.first; node; node = node->next)
+ if (node->type == TEX_NODE_OUTPUT)
+ node->custom1++;
+ }
+ }
+
+ /* particle draw and render types */
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (part->draw_as) {
+ if (part->draw_as == PART_DRAW_DOT) {
+ part->ren_as = PART_DRAW_HALO;
+ part->draw_as = PART_DRAW_REND;
+ }
+ else if (part->draw_as <= PART_DRAW_AXIS) {
+ part->ren_as = PART_DRAW_HALO;
+ }
+ else {
+ part->ren_as = part->draw_as;
+ part->draw_as = PART_DRAW_REND;
+ }
+ }
+ part->path_end = 1.0f;
+ part->clength = 1.0f;
+ }
+
+ /* set old pointcaches to have disk cache flag */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+
+ //BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ //for (pid = pidlist.first; pid; pid = pid->next)
+ // pid->cache->flag |= PTCACHE_DISK_CACHE;
+
+ //BLI_freelistN(&pidlist);
+ }
+
+ /* type was a mixed flag & enum. move the 2d flag elsewhere */
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ Nurb *nu;
+
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ nu->flag |= (nu->type & CU_2D);
+ nu->type &= CU_TYPE;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
+ Object *ob;
+ Tex *tex;
+ Scene *sce;
+ ToolSettings *ts;
+ //PTCacheID *pid;
+ //ListBase pidlist;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ //BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ //for (pid = pidlist.first; pid; pid = pid->next) {
+ // if (BLI_listbase_is_empty(pid->ptcaches))
+ // pid->ptcaches->first = pid->ptcaches->last = pid->cache;
+ //}
+
+ //BLI_freelistN(&pidlist);
+
+ if (ob->type == OB_MESH) {
+ Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
+ void *olddata = ob->data;
+ ob->data = me;
+
+ /* XXX - library meshes crash on loading most yoFrankie levels,
+ * the multires pointer gets invalid - Campbell */
+ if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) {
+ multires_load_old(ob, me);
+ }
+
+ ob->data = olddata;
+ }
+
+ if (ob->totcol && ob->matbits == NULL) {
+ int a;
+
+ ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
+ for (a = 0; a < ob->totcol; a++)
+ ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
+ }
+ }
+
+ /* texture filter */
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->afmax == 0)
+ tex->afmax = 8;
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ ts = sce->toolsettings;
+ if (!ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
+ ts->selectmode = SCE_SELECT_VERTEX;
+
+ /* autokeying - setting should be taken from the user-prefs
+ * but the userprefs version may not have correct flags set
+ * (i.e. will result in blank box when enabled)
+ */
+ ts->autokey_mode = U.autokey_mode;
+ if (ts->autokey_mode == 0)
+ ts->autokey_mode = 2; /* 'add/replace' but not on */
+ ts->uv_selectmode = UV_SELECT_VERTEX;
+ ts->vgroup_weight = 1.0f;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->flag & 8192) // OB_POSEMODE = 8192
+ ob->mode |= OB_MODE_POSE;
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) {
+ Scene *sce;
+ Object *ob;
+ ParticleSettings *part;
+ bool do_gravity = false;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next)
+ if (sce->unit.scale_length == 0.0f)
+ sce->unit.scale_length = 1.0f;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ /* fluid-sim stuff */
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
+ ob, eModifierType_Fluidsim);
+ if (fluidmd)
+ fluidmd->fss->fmd = fluidmd;
+
+ /* rotation modes were added, but old objects would now default to being 'quaternion based' */
+ ob->rotmode = ROT_MODE_EUL;
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->audio.main == 0.0f)
+ sce->audio.main = 1.0f;
+
+ sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
+ sce->r.ffcodecdata.audio_volume = sce->audio.main;
+ sce->audio.distance_model = 2;
+ sce->audio.doppler_factor = 1.0f;
+ sce->audio.speed_of_sound = 343.3f;
+ }
+
+ /* Add default gravity to scenes */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
+ is_zero_v3(sce->physics_settings.gravity)) {
+ sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
+ sce->physics_settings.gravity[2] = -9.81f;
+ sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
+ do_gravity = true;
+ }
+ }
+
+ /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
+ if (do_gravity) {
+ for (part = bmain->particles.first; part; part = part->id.next)
+ part->effector_weights->global_gravity = part->acc[2] / -9.81f;
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ if (do_gravity) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob,
+ eModifierType_Cloth);
+ if (clmd)
+ clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2] /
+ -9.81f;
+ }
+
+ if (ob->soft)
+ ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
+ }
+
+ /* Normal wind shape is plane */
+ if (ob->pd) {
+ if (ob->pd->forcefield == PFIELD_WIND)
+ ob->pd->shape = PFIELD_SHAPE_PLANE;
+
+ if (ob->pd->flag & PFIELD_PLANAR)
+ ob->pd->shape = PFIELD_SHAPE_PLANE;
+ else if (ob->pd->flag & PFIELD_SURFACE)
+ ob->pd->shape = PFIELD_SHAPE_SURFACE;
+
+ ob->pd->flag |= PFIELD_DO_LOCATION;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
+ Object *ob;
+
+ /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ /* new variables for all objects */
+ ob->quat[0] = 1.0f;
+ ob->rotAxis[1] = 1.0f;
+
+ /* bones */
+ if (ob->pose) {
+ bPoseChannel *pchan;
+
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* just need to initalise rotation axis properly... */
+ pchan->rotAxis[1] = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) {
+ Mesh *me;
+ Nurb *nu;
+ Lattice *lt;
+ Curve *cu;
+ Key *key;
+ const float *data;
+ int a, tot;
+
+ /* shape keys are no longer applied to the mesh itself, but rather
+ * to the derivedmesh/displist, so here we ensure that the basis
+ * shape key is always set in the mesh coordinates. */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
+ data = key->refkey->data;
+ tot = MIN2(me->totvert, key->refkey->totelem);
+
+ for (a = 0; a < tot; a++, data += 3)
+ copy_v3_v3(me->mvert[a].co, data);
+ }
+ }
+
+ for (lt = bmain->lattices.first; lt; lt = lt->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
+ data = key->refkey->data;
+ tot = MIN2(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
+
+ for (a = 0; a < tot; a++, data += 3)
+ copy_v3_v3(lt->def[a].vec, data);
+ }
+ }
+
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) {
+ data = key->refkey->data;
+
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu->bezt) {
+ BezTriple *bezt = nu->bezt;
+
+ for (a = 0; a < nu->pntsu; a++, bezt++) {
+ copy_v3_v3(bezt->vec[0], data);
+ data += 3;
+ copy_v3_v3(bezt->vec[1], data);
+ data += 3;
+ copy_v3_v3(bezt->vec[2], data);
+ data += 3;
+ bezt->tilt = *data;
+ data++;
+ }
+ }
+ else if (nu->bp) {
+ BPoint *bp = nu->bp;
+
+ for (a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
+ copy_v3_v3(bp->vec, data);
+ data += 3;
+ bp->tilt = *data;
+ data++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
+ {
+ Scene *sce = bmain->scenes.first;
+ while (sce) {
+ if (sce->r.frame_step == 0)
+ sce->r.frame_step = 1;
+
+ sce = sce->id.next;
+ }
+ }
+
+ {
+ /* ensure all nodes have unique names */
+ bNodeTree *ntree = bmain->nodetrees.first;
+ while (ntree) {
+ bNode *node = ntree->nodes.first;
+
+ while (node) {
+ nodeUniqueName(ntree, node);
+ node = node->next;
+ }
+
+ ntree = ntree->id.next;
+ }
+ }
+
+ {
+ Object *ob = bmain->objects.first;
+ while (ob) {
+ /* shaded mode disabled for now */
+ if (ob->dt == OB_MATERIAL)
+ ob->dt = OB_TEXTURE;
+ ob = ob->id.next;
+ }
+ }
+
+ {
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_MATERIAL)
+ v3d->drawtype = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ /* only convert old 2.50 files with color management */
+ if (bmain->versionfile == 250) {
+ Scene *sce = bmain->scenes.first;
+ Material *ma = bmain->materials.first;
+ Tex *tex = bmain->textures.first;
+ int i, convert = 0;
+
+ /* convert to new color management system:
+ * while previously colors were stored as srgb,
+ * now they are stored as linear internally,
+ * with screen gamma correction in certain places in the UI. */
+
+ /* don't know what scene is active, so we'll convert if any scene has it enabled... */
+ while (sce) {
+ if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ convert = 1;
+ sce = sce->id.next;
+ }
+
+ if (convert) {
+ while (ma) {
+ srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
+ srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr);
+ ma = ma->id.next;
+ }
+
+ while (tex) {
+ if (tex->coba) {
+ ColorBand *band = (ColorBand *)tex->coba;
+ for (i = 0; i < band->tot; i++) {
+ CBData *data = band->data + i;
+ srgb_to_linearrgb_v3_v3(&data->r, &data->r);
+ }
+ }
+ tex = tex->id.next;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) {
+ Scene *sce;
+ Mesh *me;
+ Object *ob;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next)
+ if (!sce->toolsettings->particle.selectmode)
+ sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
+
+ if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
+ for (me = bmain->meshes.first; me; me = me->id.next)
+ multires_load_old_250(me);
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(
+ ob, eModifierType_Multires);
+
+ if (mmd) {
+ mmd->totlvl--;
+ mmd->lvl--;
+ mmd->sculptlvl = mmd->lvl;
+ mmd->renderlvl = mmd->lvl;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) {
+ Object *ob;
+
+ /* properly initialize hair clothsim data on old files */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ if (clmd->sim_parms->velocity_smooth < 0.01f)
+ clmd->sim_parms->velocity_smooth = 0.f;
+ }
+ }
+ }
+ }
+
+ /* fix bad area setup in subversion 10 */
+ if (bmain->versionfile == 250 && bmain->subversionfile == 10) {
+ /* fix for new view type in sequencer */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* remove all preview window in wrong spaces */
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype != SPACE_SEQ) {
+ ARegion *ar;
+ ListBase *regionbase;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_PREVIEW)
+ break;
+ }
+
+ if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
+ SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ);
+ BKE_area_region_free(st, ar);
+ BLI_freelinkN(regionbase, ar);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 11)) {
+ {
+ /* fix for new view type in sequencer */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SEQ) {
+ ARegion *ar;
+ ARegion *ar_main;
+ ListBase *regionbase;
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+ if (sseq->view == 0)
+ sseq->view = SEQ_VIEW_SEQUENCE;
+ if (sseq->mainb == 0)
+ sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+
+ ar_main = (ARegion *)regionbase->first;
+ for (; ar_main; ar_main = ar_main->next) {
+ if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ break;
+ }
+ ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+ BLI_insertlinkbefore(regionbase, ar_main, ar);
+ sequencer_init_preview_region(ar);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) {
+ Object *ob;
+ Brush *brush;
+
+ /* anim viz changes */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ /* initialize object defaults */
+ animviz_settings_init(&ob->avs);
+
+ /* if armature, copy settings for pose from armature data
+ * performing initialization where appropriate
+ */
+ if (ob->pose && ob->data) {
+ bArmature *arm = blo_do_versions_newlibadr(fd, lib, ob->data);
+ if (arm) { /* XXX - why does this fail in some cases? */
+ bAnimVizSettings *avs = &ob->pose->avs;
+
+ /* path settings --------------------- */
+ /* ranges */
+ avs->path_bc = 10;
+ avs->path_ac = 10;
+
+ avs->path_sf = 1;
+ avs->path_ef = 250;
+
+ /* flags */
+ if (arm->pathflag & ARM_PATH_FNUMS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
+ if (arm->pathflag & ARM_PATH_KFRAS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
+ if (arm->pathflag & ARM_PATH_KFNOS)
+ avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
+
+ /* bake flags */
+ if (arm->pathflag & ARM_PATH_HEADS)
+ avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
+
+ /* type */
+ if (arm->pathflag & ARM_PATH_ACFRA)
+ avs->path_type = MOTIONPATH_TYPE_ACFRA;
+
+ /* stepsize */
+ avs->path_step = 1;
+ }
+ else
+ animviz_settings_init(&ob->pose->avs);
+ }
+ }
+
+ /* brush texture changes */
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ BKE_texture_mtex_default(&brush->mtex);
+ BKE_texture_mtex_default(&brush->mask_mtex);
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 13)) {
+ /* NOTE: if you do more conversion, be sure to do it outside of this and
+ * increase subversion again, otherwise it will not be correct */
+ Object *ob;
+
+ /* convert degrees to radians for internal use */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bPoseChannel *pchan;
+
+ do_version_constraints_radians_degrees_250(&ob->constraints);
+
+ if (ob->pose) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ pchan->limitmin[0] *= (float)(M_PI / 180.0);
+ pchan->limitmin[1] *= (float)(M_PI / 180.0);
+ pchan->limitmin[2] *= (float)(M_PI / 180.0);
+ pchan->limitmax[0] *= (float)(M_PI / 180.0);
+ pchan->limitmax[1] *= (float)(M_PI / 180.0);
+ pchan->limitmax[2] *= (float)(M_PI / 180.0);
+
+ do_version_constraints_radians_degrees_250(&pchan->constraints);
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 14)) {
+ /* fix for bad View2D extents for Animation Editors */
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase;
+ ARegion *ar;
+
+ if (sl == sa->spacedata.first)
+ regionbase = &sa->regionbase;
+ else
+ regionbase = &sl->regionbase;
+
+ if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
+ for (ar = (ARegion *)regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f;
+ ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) {
+ Scene *sce;
+ Sequence *seq;
+
+ /* initialize to sane default so toggling on border shows something */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && sce->r.border.xmax == 0.0f &&
+ sce->r.border.ymax == 0.0f) {
+ sce->r.border.xmin = 0.0f;
+ sce->r.border.ymin = 0.0f;
+ sce->r.border.xmax = 1.0f;
+ sce->r.border.ymax = 1.0f;
+ }
+
+ if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
+ sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
+
+ SEQ_BEGIN (sce->ed, seq) {
+ seq->volume = 1.0f;
+ }
+ SEQ_END;
+ }
+
+ /* particle brush strength factor was changed from int to float */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ ParticleEditSettings *pset = &sce->toolsettings->particle;
+ int a;
+
+ for (a = 0; a < ARRAY_SIZE(pset->brush); a++)
+ pset->brush[a].strength /= 100.0f;
+ }
+
+ /* sequencer changes */
+ {
+ bScreen *screen;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SEQ) {
+ ARegion *ar_preview;
+ ListBase *regionbase;
+
+ if (sl == sa->spacedata.first) {
+ regionbase = &sa->regionbase;
+ }
+ else {
+ regionbase = &sl->regionbase;
+ }
+
+ ar_preview = (ARegion *)regionbase->first;
+ for (; ar_preview; ar_preview = ar_preview->next) {
+ if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
+ break;
+ }
+ if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
+ sequencer_init_preview_region(ar_preview);
+ }
+ }
+ }
+ }
+ }
+ } /* sequencer changes */
+ }
+
+ if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
+ bScreen *sc;
+
+ /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_HIDE_OVERLAYS.
+ * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
+ * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set,
+ * which would cause cameras, lights, etc to become invisible */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->flag2 &= ~V3D_HIDE_OVERLAYS;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) {
+ Brush *brush;
+ Object *ob;
+ Scene *scene;
+ bNodeTree *ntree;
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->curve)
+ brush->curve->preset = CURVE_PRESET_SMOOTH;
+ }
+
+ /* properly initialize active flag for fluidsim modifiers */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fmd = (FluidsimModifierData *)md;
+ fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
+ fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
+ }
+ }
+ }
+
+ /* adjustment to color balance node values */
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->nodetree) {
+ bNode *node = scene->nodetree->nodes.first;
+
+ while (node) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n = (NodeColorBalance *)node->storage;
+ n->lift[0] += 1.f;
+ n->lift[1] += 1.f;
+ n->lift[2] += 1.f;
+ }
+ node = node->next;
+ }
+ }
+ }
+ /* check inside node groups too */
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
+ bNode *node = ntree->nodes.first;
+
+ while (node) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n = (NodeColorBalance *)node->storage;
+ n->lift[0] += 1.f;
+ n->lift[1] += 1.f;
+ n->lift[2] += 1.f;
+ }
+
+ node = node->next;
+ }
+ }
+ }
+
+ /* old-track -> constraints (this time we're really doing it!) */
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next)
+ blo_do_version_old_trackto_to_constraints(ob);
+ }
+
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
+ bScreen *sc;
+
+ /* Image editor scopes */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ scopes_new(&sima->scopes);
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 253) {
+ Object *ob;
+ Scene *scene;
+ bScreen *sc;
+ Tex *tex;
+ Brush *brush;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ ListBase *regionbase;
+ ARegion *ar;
+
+ if (sl == sa->spacedata.first)
+ regionbase = &sa->regionbase;
+ else
+ regionbase = &sl->regionbase;
+
+ if (snode->v2d.minzoom > 0.09f)
+ snode->v2d.minzoom = 0.09f;
+ if (snode->v2d.maxzoom < 2.31f)
+ snode->v2d.maxzoom = 2.31f;
+
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.minzoom > 0.09f)
+ ar->v2d.minzoom = 0.09f;
+ if (ar->v2d.maxzoom < 2.31f)
+ ar->v2d.maxzoom = 2.31f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ do_version_mdef_250(bmain);
+
+ /* parent type to modifier */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->parent) {
+ Object *parent = (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent);
+ if (parent) { /* parent may not be in group */
+ enum { PARCURVE = 1 };
+ if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
+ ArmatureModifierData *amd;
+ bArmature *arm = (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data);
+
+ amd = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
+ amd->object = ob->parent;
+ BLI_addtail((ListBase *)&ob->modifiers, amd);
+ amd->deformflag = arm->deformflag;
+ ob->partype = PAROBJECT;
+ }
+ else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) {
+ LatticeModifierData *lmd;
+
+ lmd = (LatticeModifierData *)modifier_new(eModifierType_Lattice);
+ lmd->object = ob->parent;
+ BLI_addtail((ListBase *)&ob->modifiers, lmd);
+ ob->partype = PAROBJECT;
+ }
+ else if (parent->type == OB_CURVE && ob->partype == PARCURVE) {
+ CurveModifierData *cmd;
+
+ cmd = (CurveModifierData *)modifier_new(eModifierType_Curve);
+ cmd->object = ob->parent;
+ BLI_addtail((ListBase *)&ob->modifiers, cmd);
+ ob->partype = PAROBJECT;
+ }
+ }
+ }
+ }
+
+ /* initialize scene active layer */
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ int i;
+ for (i = 0; i < 20; i++) {
+ if (scene->lay & (1 << i)) {
+ scene->layact = 1 << i;
+ break;
+ }
+ }
+ }
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ /* if youre picky, this isn't correct until we do a version bump
+ * since you could set saturation to be 0.0*/
+ if (tex->saturation == 0.0f)
+ tex->saturation = 1.0f;
+ }
+
+ {
+ Curve *cu;
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ cu->smallcaps_scale = 0.75f;
+ }
+ }
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene) {
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->sat == 0.0f) {
+ seq->sat = 1.0f;
+ }
+ }
+ SEQ_END;
+ }
+ }
+
+ /* GSOC 2010 Sculpt - New settings for Brush */
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ /* Sanity Check */
+
+ /* infinite number of dabs */
+ if (brush->spacing == 0)
+ brush->spacing = 10;
+
+ /* will have no effect */
+ if (brush->alpha == 0)
+ brush->alpha = 0.5f;
+
+ /* bad radius */
+ if (brush->unprojected_radius == 0)
+ brush->unprojected_radius = 0.125f;
+
+ /* unusable size */
+ if (brush->size == 0)
+ brush->size = 35;
+
+ /* can't see overlay */
+ if (brush->texture_overlay_alpha == 0)
+ brush->texture_overlay_alpha = 33;
+
+ /* same as draw brush */
+ if (brush->crease_pinch_factor == 0)
+ brush->crease_pinch_factor = 0.5f;
+
+ /* will sculpt no vertexes */
+ if (brush->plane_trim == 0)
+ brush->plane_trim = 0.5f;
+
+ /* same as smooth stroke off */
+ if (brush->smooth_stroke_radius == 0)
+ brush->smooth_stroke_radius = 75;
+
+ /* will keep cursor in one spot */
+ if (brush->smooth_stroke_radius == 1)
+ brush->smooth_stroke_factor = 0.9f;
+
+ /* same as dots */
+ if (brush->rate == 0)
+ brush->rate = 0.1f;
+
+ /* New Settings */
+ if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
+ brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space
+
+ /* spacing was originally in pixels, convert it to percentage for new version
+ * size should not be zero due to sanity check above
+ */
+ brush->spacing = (int)(100 * ((float)brush->spacing) / ((float)brush->size));
+
+ if (brush->add_col[0] == 0 && brush->add_col[1] == 0 && brush->add_col[2] == 0) {
+ brush->add_col[0] = 1.00f;
+ brush->add_col[1] = 0.39f;
+ brush->add_col[2] = 0.39f;
+ }
+
+ if (brush->sub_col[0] == 0 && brush->sub_col[1] == 0 && brush->sub_col[2] == 0) {
+ brush->sub_col[0] = 0.39f;
+ brush->sub_col[1] = 0.39f;
+ brush->sub_col[2] = 1.00f;
+ }
+ }
+ }
+ }
+
+ /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
+ if (bmain->versionfile < 253) {
+ Scene *sce;
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
+ sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
+
+ if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0)
+ sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
+
+ if (sce->toolsettings->sculpt_paint_unified_size == 0)
+ sce->toolsettings->sculpt_paint_unified_size = 35;
+ }
+ }
+
+ if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ smd->domain->vorticity = 2.0f;
+ smd->domain->time_scale = 1.0f;
+
+ if (!(smd->domain->flags & (1 << 4)))
+ continue;
+
+ /* delete old MOD_SMOKE_INITVELOCITY flag */
+ smd->domain->flags &= ~(1 << 4);
+
+ /* for now just add it to all flow objects in the scene */
+ {
+ Object *ob2;
+ for (ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
+ ModifierData *md2;
+ for (md2 = ob2->modifiers.first; md2; md2 = md2->next) {
+ if (md2->type == eModifierType_Smoke) {
+ SmokeModifierData *smd2 = (SmokeModifierData *)md2;
+
+ if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) {
+ smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ smd->flow->vel_multi = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) {
+ Brush *br;
+ ParticleSettings *part;
+ bScreen *sc;
+
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ if (br->ob_mode == 0)
+ br->ob_mode = OB_MODE_ALL_PAINT;
+ }
+
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (part->boids)
+ part->boids->pitch = 1.0f;
+
+ part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
+ part->kink_amp_clump = 1.f; /* keep old files looking similar */
+ }
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_INFO) {
+ SpaceInfo *sinfo = (SpaceInfo *)sl;
+ ARegion *ar;
+
+ sinfo->rpt_mask = INFO_RPT_OP;
+
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT);
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
+ ar->v2d.keepofs = V2D_LOCKOFS_X;
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM |
+ V2D_KEEPASPECT);
+ ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
+ ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 3)) {
+ Object *ob;
+
+ /* ocean res is now squared, reset old ones - will be massive */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Ocean) {
+ OceanModifierData *omd = (OceanModifierData *)md;
+ omd->resolution = 7;
+ omd->oceancache = NULL;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 256) {
+ bScreen *sc;
+ ScrArea *sa;
+ Key *key;
+
+ /* Fix for sample line scope initializing with no height */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ if (sima->sample_line_hist.height == 0)
+ sima->sample_line_hist.height = 100;
+ }
+ }
+ sa = sa->next;
+ }
+ }
+
+ /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
+ * 2.4x would never reveal this to users as a dummy value always ended up getting used
+ * instead
+ */
+ for (key = bmain->shapekeys.first; key; key = key->id.next) {
+ KeyBlock *kb;
+
+ for (kb = key->block.first; kb; kb = kb->next) {
+ if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f))
+ kb->slidermax = kb->slidermin + 1.0f;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 1)) {
+ /* fix for bones that didn't have arm_roll before */
+ bArmature *arm;
+ Bone *bone;
+ Object *ob;
+
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next)
+ for (bone = arm->bonebase.first; bone; bone = bone->next)
+ do_version_bone_roll_256(bone);
+
+ /* fix for objects which have zero dquat's
+ * since this is multiplied with the quat rather than added */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (is_zero_v4(ob->dquat)) {
+ unit_qt(ob->dquat);
+ }
+ if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
+ unit_axis_angle(ob->drotAxis, &ob->drotAngle);
+ }
+ }
+ }
+
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ bNodeTree *ntree;
+ bNode *node;
+ bNodeSocket *sock, *gsock;
+ bNodeLink *link;
+
+ /* node sockets are not exposed automatically any more,
+ * this mimics the old behavior by adding all unlinked sockets to groups.
+ */
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
+ /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
+
+ /* first make sure the own_index for new sockets is valid */
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ if (sock->own_index >= ntree->cur_index)
+ ntree->cur_index = sock->own_index + 1;
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ if (sock->own_index >= ntree->cur_index)
+ ntree->cur_index = sock->own_index + 1;
+ }
+
+ /* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (!sock->link && !nodeSocketIsHidden(sock)) {
+
+ gsock = do_versions_node_group_add_socket_2_56_2(
+ ntree, sock->name, sock->type, SOCK_IN);
+
+ /* initialize the default socket value */
+ copy_v4_v4(gsock->ns.vec, sock->ns.vec);
+
+ /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
+ * have to create these directly here. These links are updated again in subsequent do_version!
+ */
+ link = MEM_callocN(sizeof(bNodeLink), "link");
+ BLI_addtail(&ntree->links, link);
+ link->fromnode = NULL;
+ link->fromsock = gsock;
+ link->tonode = node;
+ link->tosock = sock;
+ ntree->update |= NTREE_UPDATE_LINKS;
+
+ sock->link = link;
+ }
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (nodeCountSocketLinks(ntree, sock) == 0 && !nodeSocketIsHidden(sock)) {
+ gsock = do_versions_node_group_add_socket_2_56_2(
+ ntree, sock->name, sock->type, SOCK_OUT);
+
+ /* initialize the default socket value */
+ copy_v4_v4(gsock->ns.vec, sock->ns.vec);
+
+ /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
+ * have to create these directly here. These links are updated again in subsequent do_version!
+ */
+ link = MEM_callocN(sizeof(bNodeLink), "link");
+ BLI_addtail(&ntree->links, link);
+ link->fromnode = node;
+ link->fromsock = sock;
+ link->tonode = NULL;
+ link->tosock = gsock;
+ ntree->update |= NTREE_UPDATE_LINKS;
+
+ gsock->link = link;
+ }
+ }
+ }
+
+ /* XXX The external group node sockets needs to adjust their own_index to point at
+ * associated ntree inputs/outputs internal sockets. However, this can only happen
+ * after lib-linking (needs access to internal node group tree)!
+ * Setting a temporary flag here, actual do_versions happens in lib_verify_nodetree.
+ */
+ ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
+ }
+ }
+
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) {
+ bScreen *sc;
+ Brush *brush;
+ Object *ob;
+ ParticleSettings *part;
+
+ /* redraws flag in SpaceTime has been moved to Screen level */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ if (sc->redraws_flag == 0) {
+ /* just initialize to default? */
+ /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
+ sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
+ }
+ }
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->height == 0)
+ brush->height = 0.4f;
+ }
+
+ /* replace 'rim material' option for in offset*/
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Solidify) {
+ SolidifyModifierData *smd = (SolidifyModifierData *)md;
+ if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
+ smd->mat_ofs_rim = 1;
+ smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
+ }
+ }
+ }
+ }
+
+ /* particle draw color from material */
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (part->draw & PART_DRAW_MAT_COL)
+ part->draw_col = PART_DRAW_COL_MAT;
+ }
+ }
+
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
+ Mesh *me;
+
+ for (me = bmain->meshes.first; me; me = me->id.next)
+ BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
+ }
+
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ /* update blur area sizes from 0..1 range to 0..100 percentage */
+ Scene *scene;
+ bNode *node;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+ if (scene->nodetree)
+ for (node = scene->nodetree->nodes.first; node; node = node->next)
+ if (node->type == CMP_NODE_BLUR) {
+ NodeBlurData *nbd = node->storage;
+ nbd->percentx *= 100.0f;
+ nbd->percenty *= 100.0f;
+ }
+ }
+
+ if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+ /* screen view2d settings were not properly initialized [#27164]
+ * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
+ * need to make less ugly - possibly an iterator? */
+ bScreen *screen;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+ /* add regions */
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl = sa->spacedata.first;
+ if (sl->spacetype == SPACE_IMAGE) {
+ ARegion *ar;
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ View2D *v2d = &ar->v2d;
+ v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
+ v2d->keepofs = v2d->align = 0;
+ }
+ }
+ }
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ ARegion *ar;
+ for (ar = sl->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ View2D *v2d = &ar->v2d;
+ v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
+ v2d->keepofs = v2d->align = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ /* Initialize particle billboard scale */
+ part->bb_size[0] = part->bb_size[1] = 1.0f;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
+ {
+ Scene *scene;
+ Sequence *seq;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->r.ffcodecdata.audio_channels = 2;
+ scene->audio.volume = 1.0f;
+ SEQ_BEGIN (scene->ed, seq) {
+ seq->pitch = 1.0f;
+ }
+ SEQ_END;
+ }
+ }
+
+ {
+ bScreen *screen;
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+
+ /* add regions */
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl = sa->spacedata.first;
+ if (sl->spacetype == SPACE_SEQ) {
+ ARegion *ar;
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1] = 0.5f;
+ }
+ }
+ }
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SEQ) {
+ ARegion *ar;
+ for (ar = sl->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->v2d.min[1] == 4.0f)
+ ar->v2d.min[1] = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
+ *
+ * We're only patching F-Curves in Actions here, since it is assumed that most
+ * drivers out there won't be using this (and if they are, they're in the minority).
+ * While we should aim to fix everything ideally, in practice it's far too hard
+ * to get to every animdata block, not to mention the performance hit that'd have
+ */
+ bAction *act;
+ FCurve *fcu;
+
+ for (act = bmain->actions.first; act; act = act->id.next) {
+ for (fcu = act->curves.first; fcu; fcu = fcu->next) {
+ BezTriple *bezt;
+ uint i = 0;
+
+ /* only need to touch curves that had this flag set */
+ if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
+ continue;
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ continue;
+
+ /* only change auto-handles to auto-clamped */
+ for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ if (bezt->h1 == HD_AUTO)
+ bezt->h1 = HD_AUTO_ANIM;
+ if (bezt->h2 == HD_AUTO)
+ bezt->h2 = HD_AUTO_ANIM;
+ }
+
+ fcu->flag &= ~FCURVE_AUTO_HANDLES;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
+ {
+ /* Convert default socket values from bNodeStack */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNode *node;
+ bNodeSocket *sock;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ do_versions_socket_default_value_259(sock);
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ do_versions_socket_default_value_259(sock);
+ }
+
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ do_versions_socket_default_value_259(sock);
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ do_versions_socket_default_value_259(sock);
+
+ ntree->update |= NTREE_UPDATE;
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ {
+ /* Initialize group tree nodetypes.
+ * These are used to distinguish tree types and
+ * associate them with specific node types for polling.
+ */
+ bNodeTree *ntree;
+ /* all node trees in bmain->nodetree are considered groups */
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ ntree->nodetype = NODE_GROUP;
+ }
+ }
+
+ if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) {
+ {
+ /* Adaptive time step for particle systems */
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ part->courant_target = 0.2f;
+ part->time_flag &= ~PART_TIME_AUTOSF;
+ }
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 31be2244d17..42d0edbcc0c 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -52,15 +52,15 @@
#include "BKE_anim.h"
#include "BKE_image.h"
-#include "BKE_main.h" // for Main
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_main.h" // for Main
+#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
-#include "BKE_text.h" // for txt_extended_ascii_as_utf8
+#include "BKE_text.h" // for txt_extended_ascii_as_utf8
#include "BKE_texture.h"
#include "BKE_tracking.h"
#include "BKE_writeffmpeg.h"
@@ -75,2398 +75,2401 @@
static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
- /* default Image output value should have 0 alpha */
- sock = node->outputs.first;
- ((bNodeSocketValueRGBA *)(sock->default_value))->value[3] = 0.0f;
- }
- }
+ bNode *node;
+ bNodeSocket *sock;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
+ /* default Image output value should have 0 alpha */
+ sock = node->outputs.first;
+ ((bNodeSocketValueRGBA *)(sock->default_value))->value[3] = 0.0f;
+ }
+ }
}
static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
{
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_ROTATE) {
- /* Convert degrees to radians. */
- bNodeSocket *sock = ((bNodeSocket *)node->inputs.first)->next;
- ((bNodeSocketValueFloat *)sock->default_value)->value =
- DEG2RADF(((bNodeSocketValueFloat *)sock->default_value)->value);
- }
- else if (node->type == CMP_NODE_DBLUR) {
- /* Convert degrees to radians. */
- NodeDBlurData *ndbd = node->storage;
- ndbd->angle = DEG2RADF(ndbd->angle);
- ndbd->spin = DEG2RADF(ndbd->spin);
- }
- else if (node->type == CMP_NODE_DEFOCUS) {
- /* Convert degrees to radians. */
- NodeDefocus *nqd = node->storage;
- /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
- nqd->rotation = DEG2RADF(nqd->rotation * 255.0f);
- }
- else if (node->type == CMP_NODE_CHROMA_MATTE) {
- /* Convert degrees to radians. */
- NodeChroma *ndc = node->storage;
- ndc->t1 = DEG2RADF(ndc->t1);
- ndc->t2 = DEG2RADF(ndc->t2);
- }
- else if (node->type == CMP_NODE_GLARE) {
- /* Convert degrees to radians. */
- NodeGlare *ndg = node->storage;
- /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
- ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f);
- }
- /* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue),
- * but not the rot part...
- */
- else if (node->type == SH_NODE_MAPPING) {
- /* Convert degrees to radians. */
- TexMapping *tmap = node->storage;
- tmap->rot[0] = DEG2RADF(tmap->rot[0]);
- tmap->rot[1] = DEG2RADF(tmap->rot[1]);
- tmap->rot[2] = DEG2RADF(tmap->rot[2]);
- }
- }
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_ROTATE) {
+ /* Convert degrees to radians. */
+ bNodeSocket *sock = ((bNodeSocket *)node->inputs.first)->next;
+ ((bNodeSocketValueFloat *)sock->default_value)->value = DEG2RADF(
+ ((bNodeSocketValueFloat *)sock->default_value)->value);
+ }
+ else if (node->type == CMP_NODE_DBLUR) {
+ /* Convert degrees to radians. */
+ NodeDBlurData *ndbd = node->storage;
+ ndbd->angle = DEG2RADF(ndbd->angle);
+ ndbd->spin = DEG2RADF(ndbd->spin);
+ }
+ else if (node->type == CMP_NODE_DEFOCUS) {
+ /* Convert degrees to radians. */
+ NodeDefocus *nqd = node->storage;
+ /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
+ nqd->rotation = DEG2RADF(nqd->rotation * 255.0f);
+ }
+ else if (node->type == CMP_NODE_CHROMA_MATTE) {
+ /* Convert degrees to radians. */
+ NodeChroma *ndc = node->storage;
+ ndc->t1 = DEG2RADF(ndc->t1);
+ ndc->t2 = DEG2RADF(ndc->t2);
+ }
+ else if (node->type == CMP_NODE_GLARE) {
+ /* Convert degrees to radians. */
+ NodeGlare *ndg = node->storage;
+ /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
+ ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f);
+ }
+ /* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue),
+ * but not the rot part...
+ */
+ else if (node->type == SH_NODE_MAPPING) {
+ /* Convert degrees to radians. */
+ TexMapping *tmap = node->storage;
+ tmap->rot[0] = DEG2RADF(tmap->rot[0]);
+ tmap->rot[1] = DEG2RADF(tmap->rot[1]);
+ tmap->rot[2] = DEG2RADF(tmap->rot[2]);
+ }
+ }
}
static void do_versions_image_settings_2_60(Scene *sce)
{
- /* note: rd->subimtype is moved into individual settings now and no longer
- * exists */
- RenderData *rd = &sce->r;
- ImageFormatData *imf = &sce->r.im_format;
-
- /* we know no data loss happens here, the old values were in char range */
- imf->imtype = (char)rd->imtype;
- imf->planes = (char)rd->planes;
- imf->compress = (char)rd->quality;
- imf->quality = (char)rd->quality;
-
- /* default, was stored in multiple places, may override later */
- imf->depth = R_IMF_CHAN_DEPTH_8;
-
- /* openexr */
- imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid values, OPENEXR_COMPRESS */
-
- switch (imf->imtype) {
- case R_IMF_IMTYPE_OPENEXR:
- imf->depth = (rd->subimtype & R_OPENEXR_HALF) ? R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32;
- if (rd->subimtype & R_PREVIEW_JPG) {
- imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
- }
- if (rd->subimtype & R_OPENEXR_ZBUF) {
- imf->flag |= R_IMF_FLAG_ZBUF;
- }
- break;
- case R_IMF_IMTYPE_TIFF:
- if (rd->subimtype & R_TIFF_16BIT) {
- imf->depth = R_IMF_CHAN_DEPTH_16;
- }
- break;
- case R_IMF_IMTYPE_JP2:
- if (rd->subimtype & R_JPEG2K_16BIT) {
- imf->depth = R_IMF_CHAN_DEPTH_16;
- }
- else if (rd->subimtype & R_JPEG2K_12BIT) {
- imf->depth = R_IMF_CHAN_DEPTH_12;
- }
-
- if (rd->subimtype & R_JPEG2K_YCC) {
- imf->jp2_flag |= R_IMF_JP2_FLAG_YCC;
- }
- if (rd->subimtype & R_JPEG2K_CINE_PRESET) {
- imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
- }
- if (rd->subimtype & R_JPEG2K_CINE_48FPS) {
- imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
- }
- break;
- case R_IMF_IMTYPE_CINEON:
- case R_IMF_IMTYPE_DPX:
- if (rd->subimtype & R_CINEON_LOG) {
- imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG;
- }
- break;
- }
+ /* note: rd->subimtype is moved into individual settings now and no longer
+ * exists */
+ RenderData *rd = &sce->r;
+ ImageFormatData *imf = &sce->r.im_format;
+
+ /* we know no data loss happens here, the old values were in char range */
+ imf->imtype = (char)rd->imtype;
+ imf->planes = (char)rd->planes;
+ imf->compress = (char)rd->quality;
+ imf->quality = (char)rd->quality;
+
+ /* default, was stored in multiple places, may override later */
+ imf->depth = R_IMF_CHAN_DEPTH_8;
+
+ /* openexr */
+ imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid values, OPENEXR_COMPRESS */
+
+ switch (imf->imtype) {
+ case R_IMF_IMTYPE_OPENEXR:
+ imf->depth = (rd->subimtype & R_OPENEXR_HALF) ? R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32;
+ if (rd->subimtype & R_PREVIEW_JPG) {
+ imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
+ }
+ if (rd->subimtype & R_OPENEXR_ZBUF) {
+ imf->flag |= R_IMF_FLAG_ZBUF;
+ }
+ break;
+ case R_IMF_IMTYPE_TIFF:
+ if (rd->subimtype & R_TIFF_16BIT) {
+ imf->depth = R_IMF_CHAN_DEPTH_16;
+ }
+ break;
+ case R_IMF_IMTYPE_JP2:
+ if (rd->subimtype & R_JPEG2K_16BIT) {
+ imf->depth = R_IMF_CHAN_DEPTH_16;
+ }
+ else if (rd->subimtype & R_JPEG2K_12BIT) {
+ imf->depth = R_IMF_CHAN_DEPTH_12;
+ }
+
+ if (rd->subimtype & R_JPEG2K_YCC) {
+ imf->jp2_flag |= R_IMF_JP2_FLAG_YCC;
+ }
+ if (rd->subimtype & R_JPEG2K_CINE_PRESET) {
+ imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
+ }
+ if (rd->subimtype & R_JPEG2K_CINE_48FPS) {
+ imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
+ }
+ break;
+ case R_IMF_IMTYPE_CINEON:
+ case R_IMF_IMTYPE_DPX:
+ if (rd->subimtype & R_CINEON_LOG) {
+ imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG;
+ }
+ break;
+ }
}
/* socket use flags were only temporary before */
static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
- sock->flag &= ~SOCK_IN_USE;
- for (sock = node->outputs.first; sock; sock = sock->next)
- sock->flag &= ~SOCK_IN_USE;
- }
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- sock->flag &= ~SOCK_IN_USE;
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- sock->flag &= ~SOCK_IN_USE;
-
- for (link = ntree->links.first; link; link = link->next) {
- link->fromsock->flag |= SOCK_IN_USE;
- link->tosock->flag |= SOCK_IN_USE;
- }
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_IN_USE;
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_IN_USE;
+ }
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_IN_USE;
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ sock->flag &= ~SOCK_IN_USE;
+
+ for (link = ntree->links.first; link; link = link->next) {
+ link->fromsock->flag |= SOCK_IN_USE;
+ link->tosock->flag |= SOCK_IN_USE;
+ }
}
static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree)
{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_OUTPUT_FILE) {
- /* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */
- NodeImageFile *old_data = node->storage;
- NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
- bNodeSocket *old_image = BLI_findlink(&node->inputs, 0);
- bNodeSocket *old_z = BLI_findlink(&node->inputs, 1);
- bNodeSocket *sock;
- char filename[FILE_MAXFILE];
-
- /* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets.
- * sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
- */
- BLI_listbase_clear(&node->inputs);
-
- node->storage = nimf;
-
- /* looks like storage data can be messed up somehow, stupid check here */
- if (old_data) {
- char basepath[FILE_MAXDIR];
-
- /* split off filename from the old path, to be used as socket sub-path */
- BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
-
- BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
- nimf->format = old_data->im_format;
- }
- else {
- BLI_strncpy(filename, old_image->name, sizeof(filename));
- }
-
- /* if z buffer is saved, change the image type to multilayer exr.
- * XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ...
- * i'm just assuming here that IRIZ means IRIS with z buffer ...
- */
- if (old_data && ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
- char sockpath[FILE_MAX];
-
- nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
-
- BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename);
- sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
- /* XXX later do_versions copies path from socket name, need to set this explicitly */
- BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
- if (old_image->link) {
- old_image->link->tosock = sock;
- sock->link = old_image->link;
- }
-
- BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename);
- sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
- /* XXX later do_versions copies path from socket name, need to set this explicitly */
- BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
- if (old_z->link) {
- old_z->link->tosock = sock;
- sock->link = old_z->link;
- }
- }
- else {
- sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format);
- /* XXX later do_versions copies path from socket name, need to set this explicitly */
- BLI_strncpy(sock->name, filename, sizeof(sock->name));
- if (old_image->link) {
- old_image->link->tosock = sock;
- sock->link = old_image->link;
- }
- }
-
- nodeRemoveSocket(ntree, node, old_image);
- nodeRemoveSocket(ntree, node, old_z);
- if (old_data)
- MEM_freeN(old_data);
- }
- else if (node->type == CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
- NodeImageMultiFile *nimf = node->storage;
- bNodeSocket *sock;
-
- /* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */
- node->type = CMP_NODE_OUTPUT_FILE;
-
- /* initialize the node-wide image format from render data, if available */
- if (sce)
- nimf->format = sce->r.im_format;
-
- /* transfer render format toggle to node format toggle */
- for (sock = node->inputs.first; sock; sock = sock->next) {
- NodeImageMultiFileSocket *simf = sock->storage;
- simf->use_node_format = simf->use_render_format;
- }
-
- /* we do have preview now */
- node->flag |= NODE_PREVIEW;
- }
- }
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
+ /* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */
+ NodeImageFile *old_data = node->storage;
+ NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
+ bNodeSocket *old_image = BLI_findlink(&node->inputs, 0);
+ bNodeSocket *old_z = BLI_findlink(&node->inputs, 1);
+ bNodeSocket *sock;
+ char filename[FILE_MAXFILE];
+
+ /* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets.
+ * sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
+ */
+ BLI_listbase_clear(&node->inputs);
+
+ node->storage = nimf;
+
+ /* looks like storage data can be messed up somehow, stupid check here */
+ if (old_data) {
+ char basepath[FILE_MAXDIR];
+
+ /* split off filename from the old path, to be used as socket sub-path */
+ BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
+
+ BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
+ nimf->format = old_data->im_format;
+ }
+ else {
+ BLI_strncpy(filename, old_image->name, sizeof(filename));
+ }
+
+ /* if z buffer is saved, change the image type to multilayer exr.
+ * XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ...
+ * i'm just assuming here that IRIZ means IRIS with z buffer ...
+ */
+ if (old_data && ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
+ char sockpath[FILE_MAX];
+
+ nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
+
+ BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename);
+ sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
+ /* XXX later do_versions copies path from socket name, need to set this explicitly */
+ BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
+ if (old_image->link) {
+ old_image->link->tosock = sock;
+ sock->link = old_image->link;
+ }
+
+ BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename);
+ sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
+ /* XXX later do_versions copies path from socket name, need to set this explicitly */
+ BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
+ if (old_z->link) {
+ old_z->link->tosock = sock;
+ sock->link = old_z->link;
+ }
+ }
+ else {
+ sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format);
+ /* XXX later do_versions copies path from socket name, need to set this explicitly */
+ BLI_strncpy(sock->name, filename, sizeof(sock->name));
+ if (old_image->link) {
+ old_image->link->tosock = sock;
+ sock->link = old_image->link;
+ }
+ }
+
+ nodeRemoveSocket(ntree, node, old_image);
+ nodeRemoveSocket(ntree, node, old_z);
+ if (old_data)
+ MEM_freeN(old_data);
+ }
+ else if (node->type == CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
+ NodeImageMultiFile *nimf = node->storage;
+ bNodeSocket *sock;
+
+ /* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */
+ node->type = CMP_NODE_OUTPUT_FILE;
+
+ /* initialize the node-wide image format from render data, if available */
+ if (sce)
+ nimf->format = sce->r.im_format;
+
+ /* transfer render format toggle to node format toggle */
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ NodeImageMultiFileSocket *simf = sock->storage;
+ simf->use_node_format = simf->use_render_format;
+ }
+
+ /* we do have preview now */
+ node->flag |= NODE_PREVIEW;
+ }
+ }
}
/* blue and red are swapped pre 2.62.1, be sane (red == red) now! */
static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *me)
{
- CustomDataLayer *layer;
- MLoopCol *mloopcol;
- int a;
- int i;
-
- for (a = 0; a < me->ldata.totlayer; a++) {
- layer = &me->ldata.layers[a];
-
- if (layer->type == CD_MLOOPCOL) {
- mloopcol = (MLoopCol *)layer->data;
- for (i = 0; i < me->totloop; i++, mloopcol++) {
- SWAP(uchar, mloopcol->r, mloopcol->b);
- }
- }
- }
+ CustomDataLayer *layer;
+ MLoopCol *mloopcol;
+ int a;
+ int i;
+
+ for (a = 0; a < me->ldata.totlayer; a++) {
+ layer = &me->ldata.layers[a];
+
+ if (layer->type == CD_MLOOPCOL) {
+ mloopcol = (MLoopCol *)layer->data;
+ for (i = 0; i < me->totloop; i++, mloopcol++) {
+ SWAP(uchar, mloopcol->r, mloopcol->b);
+ }
+ }
+ }
}
static void do_versions_nodetree_multi_file_output_path_2_63_1(bNodeTree *ntree)
{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_OUTPUT_FILE) {
- bNodeSocket *sock;
- for (sock = node->inputs.first; sock; sock = sock->next) {
- NodeImageMultiFileSocket *input = sock->storage;
- /* input file path is stored in dedicated struct now instead socket name */
- BLI_strncpy(input->path, sock->name, sizeof(input->path));
- }
- }
- }
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
+ bNodeSocket *sock;
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ NodeImageMultiFileSocket *input = sock->storage;
+ /* input file path is stored in dedicated struct now instead socket name */
+ BLI_strncpy(input->path, sock->name, sizeof(input->path));
+ }
+ }
+ }
}
static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree)
{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_OUTPUT_FILE) {
- bNodeSocket *sock;
- for (sock = node->inputs.first; sock; sock = sock->next) {
- NodeImageMultiFileSocket *input = sock->storage;
-
- /* multilayer names are stored as separate strings now,
- * used the path string before, so copy it over.
- */
- BLI_strncpy(input->layer, input->path, sizeof(input->layer));
-
- /* paths/layer names also have to be unique now, initial check */
- ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_');
- ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_');
- }
- }
- }
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
+ bNodeSocket *sock;
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ NodeImageMultiFileSocket *input = sock->storage;
+
+ /* multilayer names are stored as separate strings now,
+ * used the path string before, so copy it over.
+ */
+ BLI_strncpy(input->layer, input->path, sizeof(input->layer));
+
+ /* paths/layer names also have to be unique now, initial check */
+ ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_');
+ ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_');
+ }
+ }
+ }
}
static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree)
{
- bNode *node;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_IMAGE) {
- bNodeSocket *sock;
- for (sock = node->outputs.first; sock; sock = sock->next) {
- NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
-
- /* take pass index both from current storage ptr (actually an int) */
- output->pass_index = POINTER_AS_INT(sock->storage);
-
- /* replace socket data pointer */
- sock->storage = output;
- }
- }
- }
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_IMAGE) {
+ bNodeSocket *sock;
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
+
+ /* take pass index both from current storage ptr (actually an int) */
+ output->pass_index = POINTER_AS_INT(sock->storage);
+
+ /* replace socket data pointer */
+ sock->storage = output;
+ }
+ }
+ }
}
static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
{
- bNode *node;
+ bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_FRAME) {
- /* initialize frame node storage data */
- if (node->storage == NULL) {
- NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
- node->storage = data;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_FRAME) {
+ /* initialize frame node storage data */
+ if (node->storage == NULL) {
+ NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
+ node->storage = data;
- /* copy current flags */
- data->flag = node->custom1;
+ /* copy current flags */
+ data->flag = node->custom1;
- data->label_size = 20;
- }
- }
+ data->label_size = 20;
+ }
+ }
- /* initialize custom node color */
- node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
- }
+ /* initialize custom node color */
+ node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
+ }
}
static void do_versions_affine_tracker_track(MovieTrackingTrack *track)
{
- int i;
+ int i;
- for (i = 0; i < track->markersnr; i++) {
- MovieTrackingMarker *marker = &track->markers[i];
+ for (i = 0; i < track->markersnr; i++) {
+ MovieTrackingMarker *marker = &track->markers[i];
- if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
- is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3]))
- {
- marker->pattern_corners[0][0] = track->pat_min[0];
- marker->pattern_corners[0][1] = track->pat_min[1];
+ if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
+ is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3])) {
+ marker->pattern_corners[0][0] = track->pat_min[0];
+ marker->pattern_corners[0][1] = track->pat_min[1];
- marker->pattern_corners[1][0] = track->pat_max[0];
- marker->pattern_corners[1][1] = track->pat_min[1];
+ marker->pattern_corners[1][0] = track->pat_max[0];
+ marker->pattern_corners[1][1] = track->pat_min[1];
- marker->pattern_corners[2][0] = track->pat_max[0];
- marker->pattern_corners[2][1] = track->pat_max[1];
+ marker->pattern_corners[2][0] = track->pat_max[0];
+ marker->pattern_corners[2][1] = track->pat_max[1];
- marker->pattern_corners[3][0] = track->pat_min[0];
- marker->pattern_corners[3][1] = track->pat_max[1];
- }
+ marker->pattern_corners[3][0] = track->pat_min[0];
+ marker->pattern_corners[3][1] = track->pat_max[1];
+ }
- if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
- copy_v2_v2(marker->search_min, track->search_min);
- copy_v2_v2(marker->search_max, track->search_max);
- }
- }
+ if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
+ copy_v2_v2(marker->search_min, track->search_min);
+ copy_v2_v2(marker->search_max, track->search_max);
+ }
+ }
}
static const char *node_get_static_idname(int type, int treetype)
{
- /* use static type info header to map static int type to identifier string */
+ /* use static type info header to map static int type to identifier string */
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
- case ID: return #Category #StructName;
-
- /* XXX hack, group types share a single static integer identifier, but are registered as separate types */
- if (type == NODE_GROUP) {
- switch (treetype) {
- case NTREE_COMPOSIT: return "CompositorNodeGroup";
- case NTREE_SHADER: return "ShaderNodeGroup";
- case NTREE_TEXTURE: return "TextureNodeGroup";
- }
- }
- else {
- switch (type) {
+ case ID: \
+ return #Category #StructName;
+
+ /* XXX hack, group types share a single static integer identifier, but are registered as separate types */
+ if (type == NODE_GROUP) {
+ switch (treetype) {
+ case NTREE_COMPOSIT:
+ return "CompositorNodeGroup";
+ case NTREE_SHADER:
+ return "ShaderNodeGroup";
+ case NTREE_TEXTURE:
+ return "TextureNodeGroup";
+ }
+ }
+ else {
+ switch (type) {
#include "NOD_static_types.h"
- }
- }
- return "";
+ }
+ }
+ return "";
}
static const char *node_socket_get_static_idname(bNodeSocket *sock)
{
- switch (sock->type) {
- case SOCK_FLOAT:
- {
- bNodeSocketValueFloat *dval = sock->default_value;
- return nodeStaticSocketType(SOCK_FLOAT, dval->subtype);
- }
- case SOCK_INT:
- {
- bNodeSocketValueInt *dval = sock->default_value;
- return nodeStaticSocketType(SOCK_INT, dval->subtype);
- }
- case SOCK_BOOLEAN:
- {
- return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE);
- }
- case SOCK_VECTOR:
- {
- bNodeSocketValueVector *dval = sock->default_value;
- return nodeStaticSocketType(SOCK_VECTOR, dval->subtype);
- }
- case SOCK_RGBA:
- {
- return nodeStaticSocketType(SOCK_RGBA, PROP_NONE);
- }
- case SOCK_STRING:
- {
- bNodeSocketValueString *dval = sock->default_value;
- return nodeStaticSocketType(SOCK_STRING, dval->subtype);
- }
- case SOCK_SHADER:
- {
- return nodeStaticSocketType(SOCK_SHADER, PROP_NONE);
- }
- }
- return "";
+ switch (sock->type) {
+ case SOCK_FLOAT: {
+ bNodeSocketValueFloat *dval = sock->default_value;
+ return nodeStaticSocketType(SOCK_FLOAT, dval->subtype);
+ }
+ case SOCK_INT: {
+ bNodeSocketValueInt *dval = sock->default_value;
+ return nodeStaticSocketType(SOCK_INT, dval->subtype);
+ }
+ case SOCK_BOOLEAN: {
+ return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE);
+ }
+ case SOCK_VECTOR: {
+ bNodeSocketValueVector *dval = sock->default_value;
+ return nodeStaticSocketType(SOCK_VECTOR, dval->subtype);
+ }
+ case SOCK_RGBA: {
+ return nodeStaticSocketType(SOCK_RGBA, PROP_NONE);
+ }
+ case SOCK_STRING: {
+ bNodeSocketValueString *dval = sock->default_value;
+ return nodeStaticSocketType(SOCK_STRING, dval->subtype);
+ }
+ case SOCK_SHADER: {
+ return nodeStaticSocketType(SOCK_SHADER, PROP_NONE);
+ }
+ }
+ return "";
}
static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_group))
{
- /* initialize node tree type idname */
- {
- bNode *node;
- bNodeSocket *sock;
-
- ntree->typeinfo = NULL;
-
- /* tree type idname */
- switch (ntree->type) {
- case NTREE_COMPOSIT:
- strcpy(ntree->idname, "CompositorNodeTree");
- break;
- case NTREE_SHADER:
- strcpy(ntree->idname, "ShaderNodeTree");
- break;
- case NTREE_TEXTURE:
- strcpy(ntree->idname, "TextureNodeTree");
- break;
- }
-
- /* node type idname */
- for (node = ntree->nodes.first; node; node = node->next) {
- BLI_strncpy(node->idname, node_get_static_idname(node->type, ntree->type), sizeof(node->idname));
-
- /* existing old nodes have been initialized already */
- node->flag |= NODE_INIT;
-
- /* sockets idname */
- for (sock = node->inputs.first; sock; sock = sock->next)
- BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- for (sock = node->outputs.first; sock; sock = sock->next)
- BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- }
- /* tree sockets idname */
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- }
-
- /* initialize socket in_out values */
- {
- bNode *node;
- bNodeSocket *sock;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
- sock->in_out = SOCK_IN;
- for (sock = node->outputs.first; sock; sock = sock->next)
- sock->in_out = SOCK_OUT;
- }
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- sock->in_out = SOCK_IN;
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- sock->in_out = SOCK_OUT;
- }
-
- /* initialize socket identifier strings */
- {
- bNode *node;
- bNodeSocket *sock;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next) {
- BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
- BLI_uniquename(&node->inputs, sock, "socket", '.',
- offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
- }
- for (sock = node->outputs.first; sock; sock = sock->next) {
- BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
- BLI_uniquename(&node->outputs, sock, "socket", '.',
- offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
- }
- }
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
- BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
- BLI_uniquename(&ntree->inputs, sock, "socket", '.',
- offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
- }
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
- BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
- BLI_uniquename(&ntree->outputs, sock, "socket", '.',
- offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
- }
- }
+ /* initialize node tree type idname */
+ {
+ bNode *node;
+ bNodeSocket *sock;
+
+ ntree->typeinfo = NULL;
+
+ /* tree type idname */
+ switch (ntree->type) {
+ case NTREE_COMPOSIT:
+ strcpy(ntree->idname, "CompositorNodeTree");
+ break;
+ case NTREE_SHADER:
+ strcpy(ntree->idname, "ShaderNodeTree");
+ break;
+ case NTREE_TEXTURE:
+ strcpy(ntree->idname, "TextureNodeTree");
+ break;
+ }
+
+ /* node type idname */
+ for (node = ntree->nodes.first; node; node = node->next) {
+ BLI_strncpy(
+ node->idname, node_get_static_idname(node->type, ntree->type), sizeof(node->idname));
+
+ /* existing old nodes have been initialized already */
+ node->flag |= NODE_INIT;
+
+ /* sockets idname */
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ }
+ /* tree sockets idname */
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ }
+
+ /* initialize socket in_out values */
+ {
+ bNode *node;
+ bNodeSocket *sock;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next)
+ sock->in_out = SOCK_IN;
+ for (sock = node->outputs.first; sock; sock = sock->next)
+ sock->in_out = SOCK_OUT;
+ }
+ for (sock = ntree->inputs.first; sock; sock = sock->next)
+ sock->in_out = SOCK_IN;
+ for (sock = ntree->outputs.first; sock; sock = sock->next)
+ sock->in_out = SOCK_OUT;
+ }
+
+ /* initialize socket identifier strings */
+ {
+ bNode *node;
+ bNodeSocket *sock;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
+ BLI_uniquename(&node->inputs,
+ sock,
+ "socket",
+ '.',
+ offsetof(bNodeSocket, identifier),
+ sizeof(sock->identifier));
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
+ BLI_uniquename(&node->outputs,
+ sock,
+ "socket",
+ '.',
+ offsetof(bNodeSocket, identifier),
+ sizeof(sock->identifier));
+ }
+ }
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
+ BLI_uniquename(&ntree->inputs,
+ sock,
+ "socket",
+ '.',
+ offsetof(bNodeSocket, identifier),
+ sizeof(sock->identifier));
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
+ BLI_uniquename(&ntree->outputs,
+ sock,
+ "socket",
+ '.',
+ offsetof(bNodeSocket, identifier),
+ sizeof(sock->identifier));
+ }
+ }
}
void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
- if (bmain->versionfile < 260) {
- {
- /* set default alpha value of Image outputs in image and render layer nodes to 0 */
- Scene *sce;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- /* there are files with invalid audio_channels value, the real cause
- * is unknown, but we fix it here anyway to avoid crashes */
- if (sce->r.ffcodecdata.audio_channels == 0)
- sce->r.ffcodecdata.audio_channels = 2;
-
- if (sce->nodetree)
- do_versions_nodetree_image_default_alpha_output(sce->nodetree);
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_versions_nodetree_image_default_alpha_output(ntree);
- }
-
- {
- /* support old particle dupliobject rotation settings */
- ParticleSettings *part;
-
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
- part->draw |= PART_DRAW_ROTATE_OB;
-
- if (part->rotmode == 0)
- part->rotmode = PART_ROT_VEL;
- }
- }
- }
- }
-
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ob->collision_boundtype = ob->boundtype;
- }
-
- {
- Camera *cam;
- for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
- if (cam->sensor_x < 0.01f)
- cam->sensor_x = DEFAULT_SENSOR_WIDTH;
-
- if (cam->sensor_y < 0.01f)
- cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
- }
- }
- }
-
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == SH_NODE_MAPPING) {
- TexMapping *tex_mapping;
-
- tex_mapping = node->storage;
- tex_mapping->projx = PROJ_X;
- tex_mapping->projy = PROJ_Y;
- tex_mapping->projz = PROJ_Z;
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
- {
- /* Convert node angles to radians! */
- Scene *sce;
- Material *mat;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
- do_versions_nodetree_convert_angle(sce->nodetree);
- }
-
- for (mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->nodetree)
- do_versions_nodetree_convert_angle(mat->nodetree);
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_versions_nodetree_convert_angle(ntree);
- }
-
- {
- /* Tomato compatibility code. */
- bScreen *sc;
- MovieClip *clip;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->bundle_size == 0.0f) {
- v3d->bundle_size = 0.2f;
- v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
- }
-
- if (v3d->bundle_drawtype == 0)
- v3d->bundle_drawtype = OB_PLAINAXES;
- }
- else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
- if (sclip->scopes.track_preview_height == 0)
- sclip->scopes.track_preview_height = 120;
- }
- }
- }
- }
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTrackingTrack *track;
-
- if (clip->aspx < 1.0f) {
- clip->aspx = 1.0f;
- clip->aspy = 1.0f;
- }
-
- clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
- IMB_TC_FREE_RUN |
- IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN;
-
- if (clip->proxy.build_size_flag == 0)
- clip->proxy.build_size_flag = IMB_PROXY_25;
-
- if (clip->proxy.quality == 0)
- clip->proxy.quality = 90;
-
- if (clip->tracking.camera.pixel_aspect < 0.01f)
- clip->tracking.camera.pixel_aspect = 1.0f;
-
- track = clip->tracking.tracks.first;
- while (track) {
- if (track->minimum_correlation == 0.0f)
- track->minimum_correlation = 0.75f;
-
- track = track->next;
- }
- }
- }
- }
-
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) {
- Scene *sce;
- MovieClip *clip;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- do_versions_image_settings_2_60(sce);
- }
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTrackingSettings *settings = &clip->tracking.settings;
-
- if (settings->default_pattern_size == 0.0f) {
- settings->default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
- settings->default_minimum_correlation = 0.75;
- settings->default_pattern_size = 11;
- settings->default_search_size = 51;
- }
- }
-
- {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- /* convert delta addition into delta scale */
- int i;
- for (i = 0; i < 3; i++) {
- if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
- (ob->scale[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
- * so fallback to 1.0f */
- {
- ob->dscale[i] = 1.0f;
- }
- else {
- ob->dscale[i] = (ob->scale[i] + ob->dsize[i]) / ob->scale[i];
- }
- }
- }
- }
- }
- /* sigh, this dscale vs dsize version patching was not done right, fix for fix,
- * this intentionally checks an exact subversion, also note this was never in a release,
- * at some point this could be removed. */
- else if (bmain->versionfile == 260 && bmain->subversionfile == 6) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (is_zero_v3(ob->dscale)) {
- copy_vn_fl(ob->dscale, 3, 1.0f);
- }
- }
- }
-
- if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) {
- Brush *brush;
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
- brush->alpha = 1.0f;
- }
- }
-
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) {
- {
- /* update use flags for node sockets (was only temporary before) */
- Scene *sce;
- Material *mat;
- Tex *tex;
- World *world;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
- do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
- }
-
- for (mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->nodetree)
- do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
- }
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->nodetree)
- do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
- }
-
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- if (la->nodetree)
- do_versions_nodetree_socket_use_flags_2_62(la->nodetree);
- }
-
- for (world = bmain->worlds.first; world; world = world->id.next) {
- if (world->nodetree)
- do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
- do_versions_nodetree_socket_use_flags_2_62(ntree);
- }
- }
- {
- MovieClip *clip;
- Object *ob;
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object = tracking->objects.first;
-
- clip->proxy.build_tc_flag |= IMB_TC_RECORD_RUN_NO_GAPS;
-
- if (!tracking->settings.object_distance)
- tracking->settings.object_distance = 1.0f;
-
- if (BLI_listbase_is_empty(&tracking->objects))
- BKE_tracking_object_add(tracking, "Camera");
-
- while (tracking_object) {
- if (!tracking_object->scale)
- tracking_object->scale = 1.0f;
-
- tracking_object = tracking_object->next;
- }
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- bConstraint *con;
- for (con = ob->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
- bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
-
- if (data->invmat[3][3] == 0.0f)
- unit_m4(data->invmat);
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) {
- {
- /* convert deprecated sculpt_paint_unified_* fields to
- * UnifiedPaintSettings */
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->size = ts->sculpt_paint_unified_size;
- ups->unprojected_radius = ts->sculpt_paint_unified_unprojected_radius;
- ups->alpha = ts->sculpt_paint_unified_alpha;
- ups->flag = ts->sculpt_paint_settings;
- }
- }
- }
-
- if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) {
- {
- /* convert extended ascii to utf-8 for text editor */
- Text *text;
- for (text = bmain->texts.first; text; text = text->id.next) {
- if (!(text->flags & TXT_ISEXT)) {
- TextLine *tl;
-
- for (tl = text->lines.first; tl; tl = tl->next) {
- int added = txt_extended_ascii_as_utf8(&tl->line);
- tl->len += added;
-
- /* reset cursor position if line was changed */
- if (added && tl == text->curl)
- text->curc = 0;
- }
- }
- }
- }
- {
- /* set new dynamic paint values */
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->canvas) {
- DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
- for (; surface; surface = surface->next) {
- surface->color_dry_threshold = 1.0f;
- surface->influence_scale = 1.0f;
- surface->radius_scale = 1.0f;
- surface->flags |= MOD_DPAINT_USE_DRYING;
- }
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 262) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- if (clmd->sim_parms)
- clmd->sim_parms->vel_damping = 1.0f;
- }
- }
- }
- }
-
- if (bmain->versionfile < 263) {
- /* set fluidsim rate. the version patch for this in 2.62 was wrong, so
- * try to correct it, if rate is 0.0 that's likely not intentional */
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- if (fmd->fss->animRate == 0.0f)
- fmd->fss->animRate = 1.0f;
- }
- }
- }
- }
-
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 1)) {
- /* update use flags for node sockets (was only temporary before) */
- Scene *sce;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
- do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
- }
-
- /* XXX can't associate with scene for group nodes, image format will stay uninitialized */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
- }
-
- /* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
- if (bmain->versionfile == 262 && bmain->subversionfile == 1) {
- {
- Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next) {
- do_versions_mesh_mloopcol_swap_2_62_1(me);
- }
- }
- }
-
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
- /* Set new idname of keyingsets from their now "label-only" name. */
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- KeyingSet *ks;
- for (ks = scene->keyingsets.first; ks; ks = ks->next) {
- if (!ks->idname[0])
- BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
- }
- }
- }
-
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
- Object *ob;
- ModifierData *md;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Lattice) {
- LatticeModifierData *lmd = (LatticeModifierData *)md;
- lmd->strength = 1.0f;
- }
- }
- }
- }
-
- if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
- /* Read Viscosity presets from older files */
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- if (fmd->fss->viscosityMode == 3) {
- fmd->fss->viscosityValue = 5.0;
- fmd->fss->viscosityExponent = 5;
- }
- else if (fmd->fss->viscosityMode == 4) {
- fmd->fss->viscosityValue = 2.0;
- fmd->fss->viscosityExponent = 3;
- }
- }
- }
- }
- }
-
-
-
- if (bmain->versionfile < 263) {
- /* Default for old files is to save particle rotations to pointcache */
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- part->flag |= PART_ROTATIONS;
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 1)) {
- /* file output node paths are now stored in the file info struct instead socket name */
- Scene *sce;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->nodetree)
- do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
- Scene *scene;
- Brush *brush;
-
- /* For weight paint, each brush now gets its own weight;
- * unified paint settings also have weight. Update unified
- * paint settings and brushes with a default weight value. */
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- if (ts) {
- ts->unified_paint_settings.weight = ts->vgroup_weight;
- ts->unified_paint_settings.flag |= UNIFIED_PAINT_WEIGHT;
- }
- }
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- brush->weight = 0.5;
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
- ARegion *ar;
- bool hide = false;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW) {
- if (ar->alignment != RGN_ALIGN_NONE) {
- ar->flag |= RGN_FLAG_HIDDEN;
- ar->v2d.flag &= ~V2D_IS_INITIALISED;
- ar->alignment = RGN_ALIGN_NONE;
-
- hide = true;
- }
- }
- }
-
- if (hide) {
- sclip->view = SC_VIEW_CLIP;
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) {
- Camera *cam;
- Curve *cu;
-
- for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
- if (cam->flag & CAM_PANORAMA) {
- cam->type = CAM_PANO;
- cam->flag &= ~CAM_PANORAMA;
- }
- }
-
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- if (cu->bevfac2 == 0.0f) {
- cu->bevfac1 = 0.0f;
- cu->bevfac2 = 1.0f;
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 5)) {
- {
- /* file output node paths are now stored in the file info struct instead socket name */
- Scene *sce;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree) {
- do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree);
- do_versions_nodetree_image_layer_2_64_5(sce->nodetree);
- }
- }
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
- do_versions_nodetree_file_output_layers_2_64_5(ntree);
- do_versions_nodetree_image_layer_2_64_5(ntree);
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
- /* update use flags for node sockets (was only temporary before) */
- Scene *sce;
- Material *mat;
- Tex *tex;
- World *world;
- bNodeTree *ntree;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->nodetree)
- do_versions_nodetree_frame_2_64_6(sce->nodetree);
-
- for (mat = bmain->materials.first; mat; mat = mat->id.next)
- if (mat->nodetree)
- do_versions_nodetree_frame_2_64_6(mat->nodetree);
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->nodetree)
- do_versions_nodetree_frame_2_64_6(tex->nodetree);
-
- for (Light *la = bmain->lights.first; la; la = la->id.next)
- if (la->nodetree)
- do_versions_nodetree_frame_2_64_6(la->nodetree);
-
- for (world = bmain->worlds.first; world; world = world->id.next)
- if (world->nodetree)
- do_versions_nodetree_frame_2_64_6(world->nodetree);
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_versions_nodetree_frame_2_64_6(ntree);
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- int maxres = max_iii(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
- smd->domain->scale = smd->domain->dx * maxres;
- smd->domain->dx = 1.0f / smd->domain->scale;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
- NodeTexImage *tex = node->storage;
-
- tex->iuser.frames = 1;
- tex->iuser.sfra = 1;
- tex->iuser.ok = 1;
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
- {
- Scene *scene;
- // composite redesign
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->nodetree) {
- if (scene->nodetree->chunksize == 0) {
- scene->nodetree->chunksize = 256;
- }
- }
- }
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_DEFOCUS) {
- NodeDefocus *data = node->storage;
- if (data->maxblur == 0.0f) {
- data->maxblur = 16.0f;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- if (sclip->around == 0) {
- sclip->around = V3D_AROUND_CENTER_MEDIAN;
- }
- }
- }
- }
- }
- }
-
- {
- MovieClip *clip;
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- clip->start_frame = 1;
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
- MovieClip *clip;
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTrackingTrack *track;
-
- track = clip->tracking.tracks.first;
- while (track) {
- do_versions_affine_tracker_track(track);
-
- track = track->next;
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_DILATEERODE) {
- if (node->storage == NULL) {
- NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__);
- data->falloff = PROP_SMOOTH;
- node->storage = data;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
- ParticleSettings *part;
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_KEYING) {
- NodeKeyingData *data = node->storage;
-
- if (data->despill_balance == 0.0f) {
- data->despill_balance = 0.5f;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
-
- /* keep compatibility for dupliobject particle size */
- for (part = bmain->particles.first; part; part = part->id.next)
- if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))
- if ((part->draw & PART_DRAW_ROTATE_OB) == 0)
- part->draw |= PART_DRAW_NO_SCALE_OB;
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_MASK) {
- if (node->storage == NULL) {
- NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__);
- /* move settings into own struct */
- data->size_x = (int)node->custom3;
- data->size_y = (int)node->custom4;
- node->custom3 = 0.5f; /* default shutter */
- node->storage = data;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
- Scene *scene;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->ed) {
- Sequence *seq;
-
- SEQ_BEGIN (scene->ed, seq)
- {
- Strip *strip = seq->strip;
-
- if (strip && strip->color_balance) {
- SequenceModifierData *smd;
- ColorBalanceModifierData *cbmd;
-
- smd = BKE_sequence_modifier_new(seq, NULL, seqModifierType_ColorBalance);
- cbmd = (ColorBalanceModifierData *)smd;
-
- cbmd->color_balance = *strip->color_balance;
-
- /* multiplication with color balance used is handled differently,
- * so we need to move multiplication to modifier so files would be
- * compatible
- */
- cbmd->color_multiply = seq->mul;
- seq->mul = 1.0f;
-
- MEM_freeN(strip->color_balance);
- strip->color_balance = NULL;
- }
- } SEQ_END;
- }
- }
- }
-
- /* color management pipeline changes compatibility code */
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) {
- Scene *scene;
- Image *ima;
- bool colormanagement_disabled = false;
-
- /* make scenes which are not using color management have got None as display device,
- * so they wouldn't perform linear-to-sRGB conversion on display
- */
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
- ColorManagedDisplaySettings *display_settings = &scene->display_settings;
-
- if (display_settings->display_device[0] == 0) {
- BKE_scene_disable_color_management(scene);
-
- }
-
- colormanagement_disabled = true;
- }
- }
-
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- if (ima->source == IMA_SRC_VIEWER) {
- ima->flag |= IMA_VIEW_AS_RENDER;
- }
- else if (colormanagement_disabled) {
- /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion
- * would happen on display and render
- * there's no clear way to check whether color management is enabled or not in render engine
- * so set all images to raw if there's at least one scene with color management disabled
- * this would still behave incorrect in cases when color management was used for only some
- * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility
- * in that cases
- */
-
- BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
- }
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) {
- Key *key;
- for (key = bmain->shapekeys.first; key; key = key->id.next) {
- blo_do_versions_key_uidgen(key);
- }
- }
-
- if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) {
- {
- Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next) {
- CustomData_update_typemap(&me->vdata);
- CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
- }
- }
- }
-
- /* correction for files saved in blender version when BKE_pose_copy_data
- * didn't copy animation visualization, which lead to deadlocks on motion
- * path calculation for proxied armatures, see [#32742]
- */
- if (bmain->versionfile < 264) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pose) {
- if (ob->pose->avs.path_step == 0) {
- animviz_settings_init(&ob->pose->avs);
- }
- }
- }
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == SH_NODE_TEX_COORD)
- node->flag |= NODE_OPTIONS;
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
- MovieClip *clip;
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object;
-
- for (tracking_object = tracking->objects.first;
- tracking_object;
- tracking_object = tracking_object->next)
- {
- if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) {
- tracking_object->keyframe1 = tracking->settings.keyframe1;
- tracking_object->keyframe2 = tracking->settings.keyframe2;
- }
- }
- }
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) {
- /* smoke branch */
- {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- /* keep branch saves if possible */
- if (!smd->domain->flame_max_temp) {
- smd->domain->burning_rate = 0.75f;
- smd->domain->flame_smoke = 1.0f;
- smd->domain->flame_vorticity = 0.5f;
- smd->domain->flame_ignition = 1.25f;
- smd->domain->flame_max_temp = 1.75f;
- smd->domain->adapt_threshold = 0.02f;
- smd->domain->adapt_margin = 4;
- smd->domain->flame_smoke_color[0] = 0.7f;
- smd->domain->flame_smoke_color[1] = 0.7f;
- smd->domain->flame_smoke_color[2] = 0.7f;
- }
- }
- else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
- if (!smd->flow->texture_size) {
- smd->flow->fuel_amount = 1.0;
- smd->flow->surface_distance = 1.5;
- smd->flow->color[0] = 0.7f;
- smd->flow->color[1] = 0.7f;
- smd->flow->color[2] = 0.7f;
- smd->flow->texture_size = 1.0f;
- }
- }
- }
- }
- }
- }
-
- /* render border for viewport */
- {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f &&
- v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f)
- {
- v3d->render_border.xmax = 1.0f;
- v3d->render_border.ymax = 1.0f;
- }
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) {
- /* set a unwrapping margin and ABF by default */
- Scene *scene;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->toolsettings->uvcalc_margin == 0.0f) {
- scene->toolsettings->uvcalc_margin = 0.001f;
- scene->toolsettings->unwrapper = 0;
- }
- }
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) {
- /* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
- * Simply remove bad internal_links lists to avoid NULL pointers.
- */
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- bNode *node;
- bNodeLink *link, *nextlink;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- for (link = node->internal_links.first; link; link = nextlink) {
- nextlink = link->next;
- if (!link->fromnode || !link->fromsock || !link->tonode || !link->tosock) {
- BLI_remlink(&node->internal_links, link);
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
- /* convert tiles size from resolution and number of tiles */
- {
- Scene *scene;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->r.tilex == 0 || scene->r.tiley == 1) {
- scene->r.tilex = scene->r.tiley = 64;
- }
- }
- }
-
- /* collision masks */
- {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->col_group == 0) {
- ob->col_group = 0x01;
- ob->col_mask = 0xff;
- }
- }
- }
- }
-
- if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
- MovieClip *clip;
-
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTrackingTrack *track;
- MovieTrackingObject *object;
-
- for (track = clip->tracking.tracks.first; track; track = track->next) {
- do_versions_affine_tracker_track(track);
- }
-
- for (object = clip->tracking.objects.first; object; object = object->next) {
- for (track = object->tracks.first; track; track = track->next) {
- do_versions_affine_tracker_track(track);
- }
- }
- }
- }
-
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) {
- bScreen *sc;
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D *)sl;
- v3d->flag2 |= V3D_SHOW_ANNOTATION;
- break;
- }
- case SPACE_SEQ:
- {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- sseq->flag |= SEQ_SHOW_GPENCIL;
- break;
- }
- case SPACE_IMAGE:
- {
- SpaceImage *sima = (SpaceImage *)sl;
- sima->flag |= SI_SHOW_GPENCIL;
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- snode->flag |= SNODE_SHOW_GPENCIL;
- break;
- }
- case SPACE_CLIP:
- {
- SpaceClip *sclip = (SpaceClip *)sl;
- sclip->flag |= SC_SHOW_ANNOTATION;
- break;
- }
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) {
- Scene *scene;
- Tex *tex;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
-
- SEQ_BEGIN (scene->ed, seq)
- {
- enum { SEQ_MAKE_PREMUL = (1 << 6) };
- if (seq->flag & SEQ_MAKE_PREMUL) {
- seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
- }
- else {
- BKE_sequence_alpha_mode_from_extension(seq);
- }
- } SEQ_END;
-
- if (scene->r.bake_samples == 0)
- scene->r.bake_samples = 256;
- }
-
- for (Image *image = bmain->images.first; image; image = image->id.next) {
- if (image->flag & IMA_DO_PREMUL) {
- image->alpha_mode = IMA_ALPHA_STRAIGHT;
- }
- else {
- BKE_image_alpha_mode_from_extension(image);
- }
- }
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
- Image *image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
-
- if (image && (image->flag & IMA_DO_PREMUL) == 0)
- image->flag |= IMA_IGNORE_ALPHA;
- }
- }
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_IMAGE) {
- Image *image = blo_do_versions_newlibadr(fd, ntree->id.lib, node->id);
-
- if (image) {
- if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT)
- node->custom1 |= CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
- else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
- /* texture use alpha was removed for 2.66 but added back again for 2.66a,
- * for compatibility all textures assumed it to be enabled */
- Tex *tex;
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->type == TEX_IMAGE)
- tex->imaflag |= TEX_USEALPHA;
- }
-
- if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
- Curve *cu;
-
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- if (cu->flag & (CU_FRONT | CU_BACK)) {
- if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
- Nurb *nu;
-
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- int a;
-
- if (nu->bezt) {
- BezTriple *bezt = nu->bezt;
- a = nu->pntsu;
-
- while (a--) {
- bezt->radius = 1.0f;
- bezt++;
- }
- }
- else if (nu->bp) {
- BPoint *bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
-
- while (a--) {
- bp->radius = 1.0f;
- bp++;
- }
- }
- }
- }
- }
- }
- }
-
- if (MAIN_VERSION_OLDER(bmain, 265, 9)) {
- Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next) {
- BKE_mesh_do_versions_cd_flag_init(me);
- }
- }
-
- if (MAIN_VERSION_OLDER(bmain, 265, 10)) {
- Brush *br;
- for (br = bmain->brushes.first; br; br = br->id.next) {
- if (br->ob_mode & OB_MODE_TEXTURE_PAINT) {
- br->mtex.brush_map_mode = MTEX_MAP_MODE_TILED;
- }
- }
- }
-
- // add storage for compositor translate nodes when not existing
- if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_TRANSLATE && node->storage == NULL) {
- node->storage = MEM_callocN(sizeof(NodeTranslateData), "node translate data");
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
- } FOREACH_NODETREE_END;
- }
-
- if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
- bScreen *sc;
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
-
- /* reset pointers to force tree path update from context */
- snode->nodetree = NULL;
- snode->edittree = NULL;
- snode->id = NULL;
- snode->from = NULL;
-
- /* convert deprecated treetype setting to tree_idname */
- switch (snode->treetype) {
- case NTREE_COMPOSIT:
- strcpy(snode->tree_idname, "CompositorNodeTree");
- break;
- case NTREE_SHADER:
- strcpy(snode->tree_idname, "ShaderNodeTree");
- break;
- case NTREE_TEXTURE:
- strcpy(snode->tree_idname, "TextureNodeTree");
- break;
- }
- }
- }
- }
- }
- }
-
- /* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */
- {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- /* XXX This should be kept without version check for now!
- * As long as USE_NODE_COMPAT_CUSTOMNODES is active, files will write links
- * to tree interface sockets for forward compatibility. These links need to be removed again
- * on file load in new versions.
- * Once forward compatibility is not required any longer, make a subversion bump
- * and only execute this for older versions.
- */
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP;
-
- /* Only add interface nodes once.
- * In old Blender versions they will be removed automatically due to undefined type */
- if (MAIN_VERSION_OLDER(bmain, 266, 2))
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
- }
- FOREACH_NODETREE_END;
- }
-
- if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
- {
- /* Fix for a very old issue:
- * Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
- * to update existing node names only applied to bmain->nodetree (i.e. group nodes).
- * Uniqueness is now required for proper preview mapping,
- * so do this now to ensure old files don't break.
- */
- bNode *node;
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (id == &ntree->id)
- continue; /* already fixed for node groups */
-
- for (node = ntree->nodes.first; node; node = node->next)
- nodeUniqueName(ntree, node);
- }
- FOREACH_NODETREE_END;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 266, 4)) {
- Brush *brush;
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- BKE_texture_mtex_default(&brush->mask_mtex);
-
- if (brush->ob_mode & OB_MODE_TEXTURE_PAINT) {
- brush->spacing /= 2;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 266, 6)) {
- Brush *brush;
+ if (bmain->versionfile < 260) {
+ {
+ /* set default alpha value of Image outputs in image and render layer nodes to 0 */
+ Scene *sce;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ /* there are files with invalid audio_channels value, the real cause
+ * is unknown, but we fix it here anyway to avoid crashes */
+ if (sce->r.ffcodecdata.audio_channels == 0)
+ sce->r.ffcodecdata.audio_channels = 2;
+
+ if (sce->nodetree)
+ do_versions_nodetree_image_default_alpha_output(sce->nodetree);
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_versions_nodetree_image_default_alpha_output(ntree);
+ }
+
+ {
+ /* support old particle dupliobject rotation settings */
+ ParticleSettings *part;
+
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
+ part->draw |= PART_DRAW_ROTATE_OB;
+
+ if (part->rotmode == 0)
+ part->rotmode = PART_ROT_VEL;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ob->collision_boundtype = ob->boundtype;
+ }
+
+ {
+ Camera *cam;
+ for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
+ if (cam->sensor_x < 0.01f)
+ cam->sensor_x = DEFAULT_SENSOR_WIDTH;
+
+ if (cam->sensor_y < 0.01f)
+ cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_MAPPING) {
+ TexMapping *tex_mapping;
+
+ tex_mapping = node->storage;
+ tex_mapping->projx = PROJ_X;
+ tex_mapping->projy = PROJ_Y;
+ tex_mapping->projz = PROJ_Z;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
+ {
+ /* Convert node angles to radians! */
+ Scene *sce;
+ Material *mat;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree)
+ do_versions_nodetree_convert_angle(sce->nodetree);
+ }
+
+ for (mat = bmain->materials.first; mat; mat = mat->id.next) {
+ if (mat->nodetree)
+ do_versions_nodetree_convert_angle(mat->nodetree);
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_versions_nodetree_convert_angle(ntree);
+ }
+
+ {
+ /* Tomato compatibility code. */
+ bScreen *sc;
+ MovieClip *clip;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->bundle_size == 0.0f) {
+ v3d->bundle_size = 0.2f;
+ v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
+ }
+
+ if (v3d->bundle_drawtype == 0)
+ v3d->bundle_drawtype = OB_PLAINAXES;
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ if (sclip->scopes.track_preview_height == 0)
+ sclip->scopes.track_preview_height = 120;
+ }
+ }
+ }
+ }
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTrackingTrack *track;
+
+ if (clip->aspx < 1.0f) {
+ clip->aspx = 1.0f;
+ clip->aspy = 1.0f;
+ }
+
+ clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN |
+ IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN;
+
+ if (clip->proxy.build_size_flag == 0)
+ clip->proxy.build_size_flag = IMB_PROXY_25;
+
+ if (clip->proxy.quality == 0)
+ clip->proxy.quality = 90;
+
+ if (clip->tracking.camera.pixel_aspect < 0.01f)
+ clip->tracking.camera.pixel_aspect = 1.0f;
+
+ track = clip->tracking.tracks.first;
+ while (track) {
+ if (track->minimum_correlation == 0.0f)
+ track->minimum_correlation = 0.75f;
+
+ track = track->next;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) {
+ Scene *sce;
+ MovieClip *clip;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ do_versions_image_settings_2_60(sce);
+ }
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTrackingSettings *settings = &clip->tracking.settings;
+
+ if (settings->default_pattern_size == 0.0f) {
+ settings->default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
+ settings->default_minimum_correlation = 0.75;
+ settings->default_pattern_size = 11;
+ settings->default_search_size = 51;
+ }
+ }
+
+ {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ /* convert delta addition into delta scale */
+ int i;
+ for (i = 0; i < 3; i++) {
+ if ((ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
+ (ob->scale[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
+ * so fallback to 1.0f */
+ {
+ ob->dscale[i] = 1.0f;
+ }
+ else {
+ ob->dscale[i] = (ob->scale[i] + ob->dsize[i]) / ob->scale[i];
+ }
+ }
+ }
+ }
+ }
+ /* sigh, this dscale vs dsize version patching was not done right, fix for fix,
+ * this intentionally checks an exact subversion, also note this was never in a release,
+ * at some point this could be removed. */
+ else if (bmain->versionfile == 260 && bmain->subversionfile == 6) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (is_zero_v3(ob->dscale)) {
+ copy_vn_fl(ob->dscale, 3, 1.0f);
+ }
+ }
+ }
+
+ if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) {
+ Brush *brush;
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
+ brush->alpha = 1.0f;
+ }
+ }
+
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) {
+ {
+ /* update use flags for node sockets (was only temporary before) */
+ Scene *sce;
+ Material *mat;
+ Tex *tex;
+ World *world;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree)
+ do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
+ }
+
+ for (mat = bmain->materials.first; mat; mat = mat->id.next) {
+ if (mat->nodetree)
+ do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
+ }
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->nodetree)
+ do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
+ }
+
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ if (la->nodetree)
+ do_versions_nodetree_socket_use_flags_2_62(la->nodetree);
+ }
+
+ for (world = bmain->worlds.first; world; world = world->id.next) {
+ if (world->nodetree)
+ do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
+ do_versions_nodetree_socket_use_flags_2_62(ntree);
+ }
+ }
+ {
+ MovieClip *clip;
+ Object *ob;
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object = tracking->objects.first;
+
+ clip->proxy.build_tc_flag |= IMB_TC_RECORD_RUN_NO_GAPS;
+
+ if (!tracking->settings.object_distance)
+ tracking->settings.object_distance = 1.0f;
+
+ if (BLI_listbase_is_empty(&tracking->objects))
+ BKE_tracking_object_add(tracking, "Camera");
+
+ while (tracking_object) {
+ if (!tracking_object->scale)
+ tracking_object->scale = 1.0f;
+
+ tracking_object = tracking_object->next;
+ }
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bConstraint *con;
+ for (con = ob->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+ bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
+
+ if (data->invmat[3][3] == 0.0f)
+ unit_m4(data->invmat);
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) {
+ {
+ /* convert deprecated sculpt_paint_unified_* fields to
+ * UnifiedPaintSettings */
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ UnifiedPaintSettings *ups = &ts->unified_paint_settings;
+ ups->size = ts->sculpt_paint_unified_size;
+ ups->unprojected_radius = ts->sculpt_paint_unified_unprojected_radius;
+ ups->alpha = ts->sculpt_paint_unified_alpha;
+ ups->flag = ts->sculpt_paint_settings;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) {
+ {
+ /* convert extended ascii to utf-8 for text editor */
+ Text *text;
+ for (text = bmain->texts.first; text; text = text->id.next) {
+ if (!(text->flags & TXT_ISEXT)) {
+ TextLine *tl;
+
+ for (tl = text->lines.first; tl; tl = tl->next) {
+ int added = txt_extended_ascii_as_utf8(&tl->line);
+ tl->len += added;
+
+ /* reset cursor position if line was changed */
+ if (added && tl == text->curl)
+ text->curc = 0;
+ }
+ }
+ }
+ }
+ {
+ /* set new dynamic paint values */
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+ if (pmd->canvas) {
+ DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
+ for (; surface; surface = surface->next) {
+ surface->color_dry_threshold = 1.0f;
+ surface->influence_scale = 1.0f;
+ surface->radius_scale = 1.0f;
+ surface->flags |= MOD_DPAINT_USE_DRYING;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 262) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ if (clmd->sim_parms)
+ clmd->sim_parms->vel_damping = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263) {
+ /* set fluidsim rate. the version patch for this in 2.62 was wrong, so
+ * try to correct it, if rate is 0.0 that's likely not intentional */
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fmd = (FluidsimModifierData *)md;
+ if (fmd->fss->animRate == 0.0f)
+ fmd->fss->animRate = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 1)) {
+ /* update use flags for node sockets (was only temporary before) */
+ Scene *sce;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree)
+ do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
+ }
+
+ /* XXX can't associate with scene for group nodes, image format will stay uninitialized */
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
+ }
+
+ /* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
+ if (bmain->versionfile == 262 && bmain->subversionfile == 1) {
+ {
+ Mesh *me;
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ do_versions_mesh_mloopcol_swap_2_62_1(me);
+ }
+ }
+ }
+
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
+ /* Set new idname of keyingsets from their now "label-only" name. */
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ KeyingSet *ks;
+ for (ks = scene->keyingsets.first; ks; ks = ks->next) {
+ if (!ks->idname[0])
+ BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
+ }
+ }
+ }
+
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
+ Object *ob;
+ ModifierData *md;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Lattice) {
+ LatticeModifierData *lmd = (LatticeModifierData *)md;
+ lmd->strength = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
+ /* Read Viscosity presets from older files */
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fmd = (FluidsimModifierData *)md;
+ if (fmd->fss->viscosityMode == 3) {
+ fmd->fss->viscosityValue = 5.0;
+ fmd->fss->viscosityExponent = 5;
+ }
+ else if (fmd->fss->viscosityMode == 4) {
+ fmd->fss->viscosityValue = 2.0;
+ fmd->fss->viscosityExponent = 3;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263) {
+ /* Default for old files is to save particle rotations to pointcache */
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ part->flag |= PART_ROTATIONS;
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 1)) {
+ /* file output node paths are now stored in the file info struct instead socket name */
+ Scene *sce;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next)
+ if (sce->nodetree)
+ do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
+ Scene *scene;
+ Brush *brush;
+
+ /* For weight paint, each brush now gets its own weight;
+ * unified paint settings also have weight. Update unified
+ * paint settings and brushes with a default weight value. */
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ if (ts) {
+ ts->unified_paint_settings.weight = ts->vgroup_weight;
+ ts->unified_paint_settings.flag |= UNIFIED_PAINT_WEIGHT;
+ }
+ }
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ brush->weight = 0.5;
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ ARegion *ar;
+ bool hide = false;
+
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
+ if (ar->alignment != RGN_ALIGN_NONE) {
+ ar->flag |= RGN_FLAG_HIDDEN;
+ ar->v2d.flag &= ~V2D_IS_INITIALISED;
+ ar->alignment = RGN_ALIGN_NONE;
+
+ hide = true;
+ }
+ }
+ }
+
+ if (hide) {
+ sclip->view = SC_VIEW_CLIP;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) {
+ Camera *cam;
+ Curve *cu;
+
+ for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
+ if (cam->flag & CAM_PANORAMA) {
+ cam->type = CAM_PANO;
+ cam->flag &= ~CAM_PANORAMA;
+ }
+ }
+
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (cu->bevfac2 == 0.0f) {
+ cu->bevfac1 = 0.0f;
+ cu->bevfac2 = 1.0f;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 5)) {
+ {
+ /* file output node paths are now stored in the file info struct instead socket name */
+ Scene *sce;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
+ do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree);
+ do_versions_nodetree_image_layer_2_64_5(sce->nodetree);
+ }
+ }
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
+ do_versions_nodetree_file_output_layers_2_64_5(ntree);
+ do_versions_nodetree_image_layer_2_64_5(ntree);
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
+ /* update use flags for node sockets (was only temporary before) */
+ Scene *sce;
+ Material *mat;
+ Tex *tex;
+ World *world;
+ bNodeTree *ntree;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next)
+ if (sce->nodetree)
+ do_versions_nodetree_frame_2_64_6(sce->nodetree);
+
+ for (mat = bmain->materials.first; mat; mat = mat->id.next)
+ if (mat->nodetree)
+ do_versions_nodetree_frame_2_64_6(mat->nodetree);
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next)
+ if (tex->nodetree)
+ do_versions_nodetree_frame_2_64_6(tex->nodetree);
+
+ for (Light *la = bmain->lights.first; la; la = la->id.next)
+ if (la->nodetree)
+ do_versions_nodetree_frame_2_64_6(la->nodetree);
+
+ for (world = bmain->worlds.first; world; world = world->id.next)
+ if (world->nodetree)
+ do_versions_nodetree_frame_2_64_6(world->nodetree);
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_versions_nodetree_frame_2_64_6(ntree);
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ int maxres = max_iii(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
+ smd->domain->scale = smd->domain->dx * maxres;
+ smd->domain->dx = 1.0f / smd->domain->scale;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
+ NodeTexImage *tex = node->storage;
+
+ tex->iuser.frames = 1;
+ tex->iuser.sfra = 1;
+ tex->iuser.ok = 1;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
+ {
+ Scene *scene;
+ // composite redesign
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->nodetree) {
+ if (scene->nodetree->chunksize == 0) {
+ scene->nodetree->chunksize = 256;
+ }
+ }
+ }
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_DEFOCUS) {
+ NodeDefocus *data = node->storage;
+ if (data->maxblur == 0.0f) {
+ data->maxblur = 16.0f;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ if (sclip->around == 0) {
+ sclip->around = V3D_AROUND_CENTER_MEDIAN;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ MovieClip *clip;
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ clip->start_frame = 1;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
+ MovieClip *clip;
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTrackingTrack *track;
+
+ track = clip->tracking.tracks.first;
+ while (track) {
+ do_versions_affine_tracker_track(track);
+
+ track = track->next;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_DILATEERODE) {
+ if (node->storage == NULL) {
+ NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__);
+ data->falloff = PROP_SMOOTH;
+ node->storage = data;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
+ ParticleSettings *part;
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_KEYING) {
+ NodeKeyingData *data = node->storage;
+
+ if (data->despill_balance == 0.0f) {
+ data->despill_balance = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+
+ /* keep compatibility for dupliobject particle size */
+ for (part = bmain->particles.first; part; part = part->id.next)
+ if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))
+ if ((part->draw & PART_DRAW_ROTATE_OB) == 0)
+ part->draw |= PART_DRAW_NO_SCALE_OB;
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_MASK) {
+ if (node->storage == NULL) {
+ NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__);
+ /* move settings into own struct */
+ data->size_x = (int)node->custom3;
+ data->size_y = (int)node->custom4;
+ node->custom3 = 0.5f; /* default shutter */
+ node->storage = data;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
+ Scene *scene;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->ed) {
+ Sequence *seq;
+
+ SEQ_BEGIN (scene->ed, seq) {
+ Strip *strip = seq->strip;
+
+ if (strip && strip->color_balance) {
+ SequenceModifierData *smd;
+ ColorBalanceModifierData *cbmd;
+
+ smd = BKE_sequence_modifier_new(seq, NULL, seqModifierType_ColorBalance);
+ cbmd = (ColorBalanceModifierData *)smd;
+
+ cbmd->color_balance = *strip->color_balance;
+
+ /* multiplication with color balance used is handled differently,
+ * so we need to move multiplication to modifier so files would be
+ * compatible
+ */
+ cbmd->color_multiply = seq->mul;
+ seq->mul = 1.0f;
+
+ MEM_freeN(strip->color_balance);
+ strip->color_balance = NULL;
+ }
+ }
+ SEQ_END;
+ }
+ }
+ }
+
+ /* color management pipeline changes compatibility code */
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) {
+ Scene *scene;
+ Image *ima;
+ bool colormanagement_disabled = false;
+
+ /* make scenes which are not using color management have got None as display device,
+ * so they wouldn't perform linear-to-sRGB conversion on display
+ */
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
+ ColorManagedDisplaySettings *display_settings = &scene->display_settings;
+
+ if (display_settings->display_device[0] == 0) {
+ BKE_scene_disable_color_management(scene);
+ }
+
+ colormanagement_disabled = true;
+ }
+ }
+
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (ima->source == IMA_SRC_VIEWER) {
+ ima->flag |= IMA_VIEW_AS_RENDER;
+ }
+ else if (colormanagement_disabled) {
+ /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion
+ * would happen on display and render
+ * there's no clear way to check whether color management is enabled or not in render engine
+ * so set all images to raw if there's at least one scene with color management disabled
+ * this would still behave incorrect in cases when color management was used for only some
+ * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility
+ * in that cases
+ */
+
+ BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
+ }
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) {
+ Key *key;
+ for (key = bmain->shapekeys.first; key; key = key->id.next) {
+ blo_do_versions_key_uidgen(key);
+ }
+ }
+
+ if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) {
+ {
+ Mesh *me;
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ CustomData_update_typemap(&me->vdata);
+ CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
+ }
+ }
+ }
+
+ /* correction for files saved in blender version when BKE_pose_copy_data
+ * didn't copy animation visualization, which lead to deadlocks on motion
+ * path calculation for proxied armatures, see [#32742]
+ */
+ if (bmain->versionfile < 264) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pose) {
+ if (ob->pose->avs.path_step == 0) {
+ animviz_settings_init(&ob->pose->avs);
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next)
+ if (node->type == SH_NODE_TEX_COORD)
+ node->flag |= NODE_OPTIONS;
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
+ MovieClip *clip;
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+
+ for (tracking_object = tracking->objects.first; tracking_object;
+ tracking_object = tracking_object->next) {
+ if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) {
+ tracking_object->keyframe1 = tracking->settings.keyframe1;
+ tracking_object->keyframe2 = tracking->settings.keyframe2;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) {
+ /* smoke branch */
+ {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ /* keep branch saves if possible */
+ if (!smd->domain->flame_max_temp) {
+ smd->domain->burning_rate = 0.75f;
+ smd->domain->flame_smoke = 1.0f;
+ smd->domain->flame_vorticity = 0.5f;
+ smd->domain->flame_ignition = 1.25f;
+ smd->domain->flame_max_temp = 1.75f;
+ smd->domain->adapt_threshold = 0.02f;
+ smd->domain->adapt_margin = 4;
+ smd->domain->flame_smoke_color[0] = 0.7f;
+ smd->domain->flame_smoke_color[1] = 0.7f;
+ smd->domain->flame_smoke_color[2] = 0.7f;
+ }
+ }
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ if (!smd->flow->texture_size) {
+ smd->flow->fuel_amount = 1.0;
+ smd->flow->surface_distance = 1.5;
+ smd->flow->color[0] = 0.7f;
+ smd->flow->color[1] = 0.7f;
+ smd->flow->color[2] = 0.7f;
+ smd->flow->texture_size = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* render border for viewport */
+ {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f &&
+ v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f) {
+ v3d->render_border.xmax = 1.0f;
+ v3d->render_border.ymax = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) {
+ /* set a unwrapping margin and ABF by default */
+ Scene *scene;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->toolsettings->uvcalc_margin == 0.0f) {
+ scene->toolsettings->uvcalc_margin = 0.001f;
+ scene->toolsettings->unwrapper = 0;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) {
+ /* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
+ * Simply remove bad internal_links lists to avoid NULL pointers.
+ */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNode *node;
+ bNodeLink *link, *nextlink;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ for (link = node->internal_links.first; link; link = nextlink) {
+ nextlink = link->next;
+ if (!link->fromnode || !link->fromsock || !link->tonode || !link->tosock) {
+ BLI_remlink(&node->internal_links, link);
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
+ /* convert tiles size from resolution and number of tiles */
+ {
+ Scene *scene;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->r.tilex == 0 || scene->r.tiley == 1) {
+ scene->r.tilex = scene->r.tiley = 64;
+ }
+ }
+ }
+
+ /* collision masks */
+ {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->col_group == 0) {
+ ob->col_group = 0x01;
+ ob->col_mask = 0xff;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
+ MovieClip *clip;
+
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTrackingTrack *track;
+ MovieTrackingObject *object;
+
+ for (track = clip->tracking.tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
+
+ for (object = clip->tracking.objects.first; object; object = object->next) {
+ for (track = object->tracks.first; track; track = track->next) {
+ do_versions_affine_tracker_track(track);
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) {
+ bScreen *sc;
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+ v3d->flag2 |= V3D_SHOW_ANNOTATION;
+ break;
+ }
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ sseq->flag |= SEQ_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->flag |= SI_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)sl;
+ snode->flag |= SNODE_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_CLIP: {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ sclip->flag |= SC_SHOW_ANNOTATION;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) {
+ Scene *scene;
+ Tex *tex;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ Sequence *seq;
+
+ SEQ_BEGIN (scene->ed, seq) {
+ enum { SEQ_MAKE_PREMUL = (1 << 6) };
+ if (seq->flag & SEQ_MAKE_PREMUL) {
+ seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
+ }
+ else {
+ BKE_sequence_alpha_mode_from_extension(seq);
+ }
+ }
+ SEQ_END;
+
+ if (scene->r.bake_samples == 0)
+ scene->r.bake_samples = 256;
+ }
+
+ for (Image *image = bmain->images.first; image; image = image->id.next) {
+ if (image->flag & IMA_DO_PREMUL) {
+ image->alpha_mode = IMA_ALPHA_STRAIGHT;
+ }
+ else {
+ BKE_image_alpha_mode_from_extension(image);
+ }
+ }
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
+ Image *image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
+
+ if (image && (image->flag & IMA_DO_PREMUL) == 0)
+ image->flag |= IMA_IGNORE_ALPHA;
+ }
+ }
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_IMAGE) {
+ Image *image = blo_do_versions_newlibadr(fd, ntree->id.lib, node->id);
+
+ if (image) {
+ if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT)
+ node->custom1 |= CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+ else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
+ /* texture use alpha was removed for 2.66 but added back again for 2.66a,
+ * for compatibility all textures assumed it to be enabled */
+ Tex *tex;
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next)
+ if (tex->type == TEX_IMAGE)
+ tex->imaflag |= TEX_USEALPHA;
+ }
+
+ if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
+ Curve *cu;
+
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (cu->flag & (CU_FRONT | CU_BACK)) {
+ if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
+ Nurb *nu;
+
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ int a;
+
+ if (nu->bezt) {
+ BezTriple *bezt = nu->bezt;
+ a = nu->pntsu;
+
+ while (a--) {
+ bezt->radius = 1.0f;
+ bezt++;
+ }
+ }
+ else if (nu->bp) {
+ BPoint *bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
+
+ while (a--) {
+ bp->radius = 1.0f;
+ bp++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 265, 9)) {
+ Mesh *me;
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ BKE_mesh_do_versions_cd_flag_init(me);
+ }
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 265, 10)) {
+ Brush *br;
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ if (br->ob_mode & OB_MODE_TEXTURE_PAINT) {
+ br->mtex.brush_map_mode = MTEX_MAP_MODE_TILED;
+ }
+ }
+ }
+
+ // add storage for compositor translate nodes when not existing
+ if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_TRANSLATE && node->storage == NULL) {
+ node->storage = MEM_callocN(sizeof(NodeTranslateData), "node translate data");
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
+ bScreen *sc;
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ /* reset pointers to force tree path update from context */
+ snode->nodetree = NULL;
+ snode->edittree = NULL;
+ snode->id = NULL;
+ snode->from = NULL;
+
+ /* convert deprecated treetype setting to tree_idname */
+ switch (snode->treetype) {
+ case NTREE_COMPOSIT:
+ strcpy(snode->tree_idname, "CompositorNodeTree");
+ break;
+ case NTREE_SHADER:
+ strcpy(snode->tree_idname, "ShaderNodeTree");
+ break;
+ case NTREE_TEXTURE:
+ strcpy(snode->tree_idname, "TextureNodeTree");
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */
+ {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ /* XXX This should be kept without version check for now!
+ * As long as USE_NODE_COMPAT_CUSTOMNODES is active, files will write links
+ * to tree interface sockets for forward compatibility. These links need to be removed again
+ * on file load in new versions.
+ * Once forward compatibility is not required any longer, make a subversion bump
+ * and only execute this for older versions.
+ */
+ ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP;
+
+ /* Only add interface nodes once.
+ * In old Blender versions they will be removed automatically due to undefined type */
+ if (MAIN_VERSION_OLDER(bmain, 266, 2))
+ ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
+ {
+ /* Fix for a very old issue:
+ * Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
+ * to update existing node names only applied to bmain->nodetree (i.e. group nodes).
+ * Uniqueness is now required for proper preview mapping,
+ * so do this now to ensure old files don't break.
+ */
+ bNode *node;
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (id == &ntree->id)
+ continue; /* already fixed for node groups */
+
+ for (node = ntree->nodes.first; node; node = node->next)
+ nodeUniqueName(ntree, node);
+ }
+ FOREACH_NODETREE_END;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 4)) {
+ Brush *brush;
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ BKE_texture_mtex_default(&brush->mask_mtex);
+
+ if (brush->ob_mode & OB_MODE_TEXTURE_PAINT) {
+ brush->spacing /= 2;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 6)) {
+ Brush *brush;
#define BRUSH_TEXTURE_OVERLAY (1 << 21)
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- brush->overlay_flags = 0;
- if (brush->flag & BRUSH_TEXTURE_OVERLAY)
- brush->overlay_flags |= (BRUSH_OVERLAY_PRIMARY | BRUSH_OVERLAY_CURSOR);
- }
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ brush->overlay_flags = 0;
+ if (brush->flag & BRUSH_TEXTURE_OVERLAY)
+ brush->overlay_flags |= (BRUSH_OVERLAY_PRIMARY | BRUSH_OVERLAY_CURSOR);
+ }
#undef BRUSH_TEXTURE_OVERLAY
- }
-
- if (bmain->versionfile < 267) {
- //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
- Brush *brush;
-
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->stencil_dimension[0] == 0) {
- brush->stencil_dimension[0] = 256;
- brush->stencil_dimension[1] = 256;
- brush->stencil_pos[0] = 256;
- brush->stencil_pos[1] = 256;
- }
- if (brush->mask_stencil_dimension[0] == 0) {
- brush->mask_stencil_dimension[0] = 256;
- brush->mask_stencil_dimension[1] = 256;
- brush->mask_stencil_pos[0] = 256;
- brush->mask_stencil_pos[1] = 256;
- }
- }
-
- /* TIP: to initialize new variables added, use the new function
- * DNA_struct_elem_find(fd->filesdna, "structname", "typename", "varname")
- * example:
- * if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "image_gpubuffer_limit"))
- * user->image_gpubuffer_limit = 10;
- */
-
- }
-
- /* default values in Freestyle settings */
- if (bmain->versionfile < 267) {
- Scene *sce;
- SceneRenderLayer *srl;
- FreestyleLineStyle *linestyle;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->r.line_thickness_mode == 0) {
- sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
- sce->r.unit_line_thickness = 1.0f;
- }
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
- if (srl->freestyleConfig.mode == 0)
- srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
- if (srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
- srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL)
- {
- srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
- srl->freestyleConfig.flags |= FREESTYLE_CULLING;
- }
- }
-
- /* not freestyle */
- {
- MeshStatVis *statvis = &sce->toolsettings->statvis;
- if (statvis->thickness_samples == 0) {
- statvis->overhang_axis = OB_NEGZ;
- statvis->overhang_min = 0;
- statvis->overhang_max = DEG2RADF(45.0f);
-
- statvis->thickness_max = 0.1f;
- statvis->thickness_samples = 1;
-
- statvis->distort_min = DEG2RADF(5.0f);
- statvis->distort_max = DEG2RADF(45.0f);
-
- statvis->sharp_min = DEG2RADF(90.0f);
- statvis->sharp_max = DEG2RADF(180.0f);
- }
- }
-
- }
- for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
+ }
+
+ if (bmain->versionfile < 267) {
+ //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
+ Brush *brush;
+
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->stencil_dimension[0] == 0) {
+ brush->stencil_dimension[0] = 256;
+ brush->stencil_dimension[1] = 256;
+ brush->stencil_pos[0] = 256;
+ brush->stencil_pos[1] = 256;
+ }
+ if (brush->mask_stencil_dimension[0] == 0) {
+ brush->mask_stencil_dimension[0] = 256;
+ brush->mask_stencil_dimension[1] = 256;
+ brush->mask_stencil_pos[0] = 256;
+ brush->mask_stencil_pos[1] = 256;
+ }
+ }
+
+ /* TIP: to initialize new variables added, use the new function
+ * DNA_struct_elem_find(fd->filesdna, "structname", "typename", "varname")
+ * example:
+ * if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "image_gpubuffer_limit"))
+ * user->image_gpubuffer_limit = 10;
+ */
+ }
+
+ /* default values in Freestyle settings */
+ if (bmain->versionfile < 267) {
+ Scene *sce;
+ SceneRenderLayer *srl;
+ FreestyleLineStyle *linestyle;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->r.line_thickness_mode == 0) {
+ sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
+ sce->r.unit_line_thickness = 1.0f;
+ }
+ for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ if (srl->freestyleConfig.mode == 0)
+ srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
+ if (srl->freestyleConfig.raycasting_algorithm ==
+ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
+ srl->freestyleConfig.raycasting_algorithm ==
+ FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
+ srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
+ srl->freestyleConfig.flags |= FREESTYLE_CULLING;
+ }
+ }
+
+ /* not freestyle */
+ {
+ MeshStatVis *statvis = &sce->toolsettings->statvis;
+ if (statvis->thickness_samples == 0) {
+ statvis->overhang_axis = OB_NEGZ;
+ statvis->overhang_min = 0;
+ statvis->overhang_max = DEG2RADF(45.0f);
+
+ statvis->thickness_max = 0.1f;
+ statvis->thickness_samples = 1;
+
+ statvis->distort_min = DEG2RADF(5.0f);
+ statvis->distort_max = DEG2RADF(45.0f);
+
+ statvis->sharp_min = DEG2RADF(90.0f);
+ statvis->sharp_max = DEG2RADF(180.0f);
+ }
+ }
+ }
+ for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
#if 1
- /* disable the Misc panel for now */
- if (linestyle->panel == LS_PANEL_MISC) {
- linestyle->panel = LS_PANEL_STROKES;
- }
+ /* disable the Misc panel for now */
+ if (linestyle->panel == LS_PANEL_MISC) {
+ linestyle->panel = LS_PANEL_STROKES;
+ }
#endif
- if (linestyle->thickness_position == 0) {
- linestyle->thickness_position = LS_THICKNESS_CENTER;
- linestyle->thickness_ratio = 0.5f;
- }
- if (linestyle->chaining == 0)
- linestyle->chaining = LS_CHAINING_PLAIN;
- if (linestyle->rounds == 0)
- linestyle->rounds = 3;
- }
- }
-
- if (bmain->versionfile < 267) {
- /* Initialize the active_viewer_key for compositing */
- bScreen *screen;
- Scene *scene;
- bNodeInstanceKey active_viewer_key = {0};
- /* simply pick the first node space and use that for the active viewer key */
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path = snode->treepath.last;
- if (!path)
- continue;
-
- active_viewer_key = path->parent_key;
- break;
- }
- }
- if (active_viewer_key.value != 0)
- break;
- }
- if (active_viewer_key.value != 0)
- break;
- }
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* NB: scene->nodetree is a local ID block, has been direct_link'ed */
- if (scene->nodetree)
- scene->nodetree->active_viewer_key = active_viewer_key;
- }
- }
-
- if (MAIN_VERSION_OLDER(bmain, 267, 1)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
- if (smd->domain->flags & MOD_SMOKE_HIGH_SMOOTH) {
- smd->domain->highres_sampling = SM_HRES_LINEAR;
- }
- else {
- smd->domain->highres_sampling = SM_HRES_NEAREST;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 268, 1)) {
- Brush *brush;
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- brush->spacing = MAX2(1, brush->spacing);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 268, 2)) {
- Brush *brush;
+ if (linestyle->thickness_position == 0) {
+ linestyle->thickness_position = LS_THICKNESS_CENTER;
+ linestyle->thickness_ratio = 0.5f;
+ }
+ if (linestyle->chaining == 0)
+ linestyle->chaining = LS_CHAINING_PLAIN;
+ if (linestyle->rounds == 0)
+ linestyle->rounds = 3;
+ }
+ }
+
+ if (bmain->versionfile < 267) {
+ /* Initialize the active_viewer_key for compositing */
+ bScreen *screen;
+ Scene *scene;
+ bNodeInstanceKey active_viewer_key = {0};
+ /* simply pick the first node space and use that for the active viewer key */
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path = snode->treepath.last;
+ if (!path)
+ continue;
+
+ active_viewer_key = path->parent_key;
+ break;
+ }
+ }
+ if (active_viewer_key.value != 0)
+ break;
+ }
+ if (active_viewer_key.value != 0)
+ break;
+ }
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* NB: scene->nodetree is a local ID block, has been direct_link'ed */
+ if (scene->nodetree)
+ scene->nodetree->active_viewer_key = active_viewer_key;
+ }
+ }
+
+ if (MAIN_VERSION_OLDER(bmain, 267, 1)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
+ if (smd->domain->flags & MOD_SMOKE_HIGH_SMOOTH) {
+ smd->domain->highres_sampling = SM_HRES_LINEAR;
+ }
+ else {
+ smd->domain->highres_sampling = SM_HRES_NEAREST;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 1)) {
+ Brush *brush;
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ brush->spacing = MAX2(1, brush->spacing);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 2)) {
+ Brush *brush;
#define BRUSH_FIXED (1 << 6)
- for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- brush->flag &= ~BRUSH_FIXED;
-
- if (brush->cursor_overlay_alpha < 2)
- brush->cursor_overlay_alpha = 33;
- if (brush->texture_overlay_alpha < 2)
- brush->texture_overlay_alpha = 33;
- if (brush->mask_overlay_alpha < 2)
- brush->mask_overlay_alpha = 33;
- }
+ for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ brush->flag &= ~BRUSH_FIXED;
+
+ if (brush->cursor_overlay_alpha < 2)
+ brush->cursor_overlay_alpha = 33;
+ if (brush->texture_overlay_alpha < 2)
+ brush->texture_overlay_alpha = 33;
+ if (brush->mask_overlay_alpha < 2)
+ brush->mask_overlay_alpha = 33;
+ }
#undef BRUSH_FIXED
- }
-
-
- if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) {
- bScreen *sc;
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- bConstraint *con;
- for (con = ob->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
- bShrinkwrapConstraint *data = (bShrinkwrapConstraint *)con->data;
- if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) data->projAxis = OB_POSX;
- else if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) data->projAxis = OB_POSY;
- else data->projAxis = OB_POSZ;
- data->projAxisSpace = CONSTRAINT_SPACE_LOCAL;
- }
- }
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
- if (!smd->flow->particle_size) {
- smd->flow->particle_size = 1.0f;
- }
- }
- }
- }
- }
-
- /*
- * FIX some files have a zoom level of 0, and was checked during the drawing of the node space
- *
- * We moved this check to the do versions to be sure the value makes any sense.
- */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- if (snode->zoom < 0.02f) {
- snode->zoom = 1.0;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) {
- bScreen *sc;
- ScrArea *sa;
-
- /* add missing (+) expander in node editor */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- ARegion *ar, *arnew;
-
- if (sa->spacetype == SPACE_NODE) {
- ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
-
- if (ar)
- continue;
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL)
- continue;
-
- arnew = MEM_callocN(sizeof(ARegion), "node tools");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_TOOLS;
- arnew->alignment = RGN_ALIGN_LEFT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) {
- /* Removal of Cycles SSS Compatible falloff */
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == SH_NODE_SUBSURFACE_SCATTERING) {
- if (node->custom1 == SHD_SUBSURFACE_COMPATIBLE) {
- node->custom1 = SHD_SUBSURFACE_CUBIC;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) {
- /* Initialize CDL settings for Color Balance nodes */
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n = node->storage;
- if (node->custom1 == 0) {
- /* LGG mode stays the same, just init CDL settings */
- ntreeCompositColorBalanceSyncFromLGG(ntree, node);
- }
- else if (node->custom1 == 1) {
- /* CDL previously used same variables as LGG, copy them over
- * and then sync LGG for comparable results in both modes.
- */
- copy_v3_v3(n->offset, n->lift);
- copy_v3_v3(n->power, n->gamma);
- copy_v3_v3(n->slope, n->gain);
- ntreeCompositColorBalanceSyncFromCDL(ntree, node);
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) {
- bScreen *sc;
- ScrArea *sa;
- SpaceLink *sl;
- Scene *scene;
-
- /* Update files using invalid (outdated) outlinevis Outliner values. */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
-
- if (!ELEM(so->outlinevis,
- SO_SCENES,
- SO_LIBRARIES,
- SO_SEQUENCE,
- SO_DATA_API))
- {
- so->outlinevis = SO_SCENES;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
- MovieClip *clip;
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object;
- for (tracking_object = tracking->objects.first;
- tracking_object;
- tracking_object = tracking_object->next)
- {
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
- MovieTrackingTrack *track;
- for (track = tracksbase->first;
- track;
- track = track->next)
- {
- track->weight = 1.0f;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Triangulate) {
- TriangulateModifierData *tmd = (TriangulateModifierData *)md;
- if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) {
- tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY;
- tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
- }
- else {
- tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
- tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
- }
- }
- }
- }
- }
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* this can now be turned off */
- ToolSettings *ts = scene->toolsettings;
- if (ts->sculpt)
- ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;
-
- /* 'Increment' mode disabled for nodes, use true grid snapping instead */
- if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT)
- scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) {
+ bScreen *sc;
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bConstraint *con;
+ for (con = ob->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
+ bShrinkwrapConstraint *data = (bShrinkwrapConstraint *)con->data;
+ if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS)
+ data->projAxis = OB_POSX;
+ else if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS)
+ data->projAxis = OB_POSY;
+ else
+ data->projAxis = OB_POSZ;
+ data->projAxisSpace = CONSTRAINT_SPACE_LOCAL;
+ }
+ }
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
+ if (!smd->flow->particle_size) {
+ smd->flow->particle_size = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * FIX some files have a zoom level of 0, and was checked during the drawing of the node space
+ *
+ * We moved this check to the do versions to be sure the value makes any sense.
+ */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ if (snode->zoom < 0.02f) {
+ snode->zoom = 1.0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) {
+ bScreen *sc;
+ ScrArea *sa;
+
+ /* add missing (+) expander in node editor */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ ARegion *ar, *arnew;
+
+ if (sa->spacetype == SPACE_NODE) {
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
+
+ if (ar)
+ continue;
+
+ /* add subdiv level; after header */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
+ /* is error! */
+ if (ar == NULL)
+ continue;
+
+ arnew = MEM_callocN(sizeof(ARegion), "node tools");
+
+ BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+ arnew->regiontype = RGN_TYPE_TOOLS;
+ arnew->alignment = RGN_ALIGN_LEFT;
+
+ arnew->flag = RGN_FLAG_HIDDEN;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) {
+ /* Removal of Cycles SSS Compatible falloff */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_SUBSURFACE_SCATTERING) {
+ if (node->custom1 == SHD_SUBSURFACE_COMPATIBLE) {
+ node->custom1 = SHD_SUBSURFACE_CUBIC;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) {
+ /* Initialize CDL settings for Color Balance nodes */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n = node->storage;
+ if (node->custom1 == 0) {
+ /* LGG mode stays the same, just init CDL settings */
+ ntreeCompositColorBalanceSyncFromLGG(ntree, node);
+ }
+ else if (node->custom1 == 1) {
+ /* CDL previously used same variables as LGG, copy them over
+ * and then sync LGG for comparable results in both modes.
+ */
+ copy_v3_v3(n->offset, n->lift);
+ copy_v3_v3(n->power, n->gamma);
+ copy_v3_v3(n->slope, n->gain);
+ ntreeCompositColorBalanceSyncFromCDL(ntree, node);
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) {
+ bScreen *sc;
+ ScrArea *sa;
+ SpaceLink *sl;
+ Scene *scene;
+
+ /* Update files using invalid (outdated) outlinevis Outliner values. */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+
+ if (!ELEM(so->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) {
+ so->outlinevis = SO_SCENES;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
+ MovieClip *clip;
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+ for (tracking_object = tracking->objects.first; tracking_object;
+ tracking_object = tracking_object->next) {
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ MovieTrackingTrack *track;
+ for (track = tracksbase->first; track; track = track->next) {
+ track->weight = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Triangulate) {
+ TriangulateModifierData *tmd = (TriangulateModifierData *)md;
+ if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) {
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
+ }
+ else {
+ tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
+ tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
+ }
+ }
+ }
+ }
+ }
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* this can now be turned off */
+ ToolSettings *ts = scene->toolsettings;
+ if (ts->sculpt)
+ ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;
+
+ /* 'Increment' mode disabled for nodes, use true grid snapping instead */
+ if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT)
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
#ifdef WITH_FFMPEG
- /* Update for removed "sound-only" option in FFMPEG export settings. */
- if (scene->r.ffcodecdata.type >= FFMPEG_INVALID) {
- scene->r.ffcodecdata.type = FFMPEG_AVI;
- }
+ /* Update for removed "sound-only" option in FFMPEG export settings. */
+ if (scene->r.ffcodecdata.type >= FFMPEG_INVALID) {
+ scene->r.ffcodecdata.type = FFMPEG_AVI;
+ }
#endif
-
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 4)) {
- /* Internal degrees to radians conversions... */
- {
- Scene *scene;
- Object *ob;
-
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->spotsize = DEG2RADF(la->spotsize);
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_EdgeSplit) {
- EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
- emd->split_angle = DEG2RADF(emd->split_angle);
- }
- else if (md->type == eModifierType_Bevel) {
- BevelModifierData *bmd = (BevelModifierData *)md;
- bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
- }
- }
- }
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
- SEQ_BEGIN (scene->ed, seq)
- {
- if (seq->type == SEQ_TYPE_WIPE) {
- WipeVars *wv = seq->effectdata;
- wv->angle = DEG2RADF(wv->angle);
- }
- } SEQ_END;
- }
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_BOKEHIMAGE) {
- NodeBokehImage *n = node->storage;
- n->angle = DEG2RADF(n->angle);
- }
- if (node->type == CMP_NODE_MASK_BOX) {
- NodeBoxMask *n = node->storage;
- n->rotation = DEG2RADF(n->rotation);
- }
- if (node->type == CMP_NODE_MASK_ELLIPSE) {
- NodeEllipseMask *n = node->storage;
- n->rotation = DEG2RADF(n->rotation);
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
- MovieClip *clip;
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTrackingPlaneTrack *plane_track;
- for (plane_track = clip->tracking.plane_tracks.first;
- plane_track;
- plane_track = plane_track->next)
- {
- plane_track->image_opacity = 1.0f;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 7)) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sculpt *sd = scene->toolsettings->sculpt;
-
- if (sd) {
- enum {
- SCULPT_SYMM_X = (1 << 0),
- SCULPT_SYMM_Y = (1 << 1),
- SCULPT_SYMM_Z = (1 << 2),
- SCULPT_SYMMETRY_FEATHER = (1 << 6),
- };
- int symmetry_flags = sd->flags & 7;
-
- if (symmetry_flags & SCULPT_SYMM_X)
- sd->paint.symmetry_flags |= PAINT_SYMM_X;
- if (symmetry_flags & SCULPT_SYMM_Y)
- sd->paint.symmetry_flags |= PAINT_SYMM_Y;
- if (symmetry_flags & SCULPT_SYMM_Z)
- sd->paint.symmetry_flags |= PAINT_SYMM_Z;
- if (symmetry_flags & SCULPT_SYMMETRY_FEATHER)
- sd->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 8)) {
- Curve *cu;
-
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- if (cu->str) {
- cu->len_wchar = BLI_strlen_utf8(cu->str);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Build) {
- BuildModifierData *bmd = (BuildModifierData *)md;
- if (bmd->randomize) {
- bmd->flag |= MOD_BUILD_FLAG_RANDOMIZE;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *space_link;
-
- for (space_link = sa->spacedata.first; space_link; space_link = space_link->next) {
- if (space_link->spacetype == SPACE_IMAGE) {
- ARegion *ar;
- ListBase *lb;
-
- if (space_link == sa->spacedata.first) {
- lb = &sa->regionbase;
- }
- else {
- lb = &space_link->regionbase;
- }
-
- for (ar = lb->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW) {
- ar->regiontype = RGN_TYPE_TOOLS;
- ar->alignment = RGN_ALIGN_LEFT;
- }
- else if (ar->regiontype == RGN_TYPE_UI) {
- ar->alignment = RGN_ALIGN_RIGHT;
- }
- }
- }
- }
- }
- }
- }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 4)) {
+ /* Internal degrees to radians conversions... */
+ {
+ Scene *scene;
+ Object *ob;
+
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->spotsize = DEG2RADF(la->spotsize);
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_EdgeSplit) {
+ EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
+ emd->split_angle = DEG2RADF(emd->split_angle);
+ }
+ else if (md->type == eModifierType_Bevel) {
+ BevelModifierData *bmd = (BevelModifierData *)md;
+ bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
+ }
+ }
+ }
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->type == SEQ_TYPE_WIPE) {
+ WipeVars *wv = seq->effectdata;
+ wv->angle = DEG2RADF(wv->angle);
+ }
+ }
+ SEQ_END;
+ }
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_BOKEHIMAGE) {
+ NodeBokehImage *n = node->storage;
+ n->angle = DEG2RADF(n->angle);
+ }
+ if (node->type == CMP_NODE_MASK_BOX) {
+ NodeBoxMask *n = node->storage;
+ n->rotation = DEG2RADF(n->rotation);
+ }
+ if (node->type == CMP_NODE_MASK_ELLIPSE) {
+ NodeEllipseMask *n = node->storage;
+ n->rotation = DEG2RADF(n->rotation);
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
+ MovieClip *clip;
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTrackingPlaneTrack *plane_track;
+ for (plane_track = clip->tracking.plane_tracks.first; plane_track;
+ plane_track = plane_track->next) {
+ plane_track->image_opacity = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 7)) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ Sculpt *sd = scene->toolsettings->sculpt;
+
+ if (sd) {
+ enum {
+ SCULPT_SYMM_X = (1 << 0),
+ SCULPT_SYMM_Y = (1 << 1),
+ SCULPT_SYMM_Z = (1 << 2),
+ SCULPT_SYMMETRY_FEATHER = (1 << 6),
+ };
+ int symmetry_flags = sd->flags & 7;
+
+ if (symmetry_flags & SCULPT_SYMM_X)
+ sd->paint.symmetry_flags |= PAINT_SYMM_X;
+ if (symmetry_flags & SCULPT_SYMM_Y)
+ sd->paint.symmetry_flags |= PAINT_SYMM_Y;
+ if (symmetry_flags & SCULPT_SYMM_Z)
+ sd->paint.symmetry_flags |= PAINT_SYMM_Z;
+ if (symmetry_flags & SCULPT_SYMMETRY_FEATHER)
+ sd->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 8)) {
+ Curve *cu;
+
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (cu->str) {
+ cu->len_wchar = BLI_strlen_utf8(cu->str);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Build) {
+ BuildModifierData *bmd = (BuildModifierData *)md;
+ if (bmd->randomize) {
+ bmd->flag |= MOD_BUILD_FLAG_RANDOMIZE;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *space_link;
+
+ for (space_link = sa->spacedata.first; space_link; space_link = space_link->next) {
+ if (space_link->spacetype == SPACE_IMAGE) {
+ ARegion *ar;
+ ListBase *lb;
+
+ if (space_link == sa->spacedata.first) {
+ lb = &sa->regionbase;
+ }
+ else {
+ lb = &space_link->regionbase;
+ }
+
+ for (ar = lb->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
+ ar->regiontype = RGN_TYPE_TOOLS;
+ ar->alignment = RGN_ALIGN_LEFT;
+ }
+ else if (ar->regiontype == RGN_TYPE_UI) {
+ ar->alignment = RGN_ALIGN_RIGHT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 5caac97c0d1..df56809869f 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -88,56 +88,64 @@
/* add a new gp-palette */
static bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name)
{
- bGPDpalette *palette;
-
- /* check that list is ok */
- if (gpd == NULL) {
- return NULL;
- }
-
- /* allocate memory and add to end of list */
- palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
-
- /* add to datablock */
- BLI_addtail(&gpd->palettes, palette);
-
- /* set basic settings */
- /* auto-name */
- BLI_strncpy(palette->info, name, sizeof(palette->info));
- BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
- sizeof(palette->info));
-
- /* return palette */
- return palette;
+ bGPDpalette *palette;
+
+ /* check that list is ok */
+ if (gpd == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
+
+ /* add to datablock */
+ BLI_addtail(&gpd->palettes, palette);
+
+ /* set basic settings */
+ /* auto-name */
+ BLI_strncpy(palette->info, name, sizeof(palette->info));
+ BLI_uniquename(&gpd->palettes,
+ palette,
+ DATA_("GP_Palette"),
+ '.',
+ offsetof(bGPDpalette, info),
+ sizeof(palette->info));
+
+ /* return palette */
+ return palette;
}
/* add a new gp-palettecolor */
static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const char *name)
{
- bGPDpalettecolor *palcolor;
-
- /* check that list is ok */
- if (palette == NULL) {
- return NULL;
- }
-
- /* allocate memory and add to end of list */
- palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
-
- /* add to datablock */
- BLI_addtail(&palette->colors, palcolor);
-
- /* set basic settings */
- copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
- ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
-
- /* auto-name */
- BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
- BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
- sizeof(palcolor->info));
-
- /* return palette color */
- return palcolor;
+ bGPDpalettecolor *palcolor;
+
+ /* check that list is ok */
+ if (palette == NULL) {
+ return NULL;
+ }
+
+ /* allocate memory and add to end of list */
+ palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
+
+ /* add to datablock */
+ BLI_addtail(&palette->colors, palcolor);
+
+ /* set basic settings */
+ copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
+ ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
+
+ /* auto-name */
+ BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
+ BLI_uniquename(&palette->colors,
+ palcolor,
+ DATA_("Color"),
+ '.',
+ offsetof(bGPDpalettecolor, info),
+ sizeof(palcolor->info));
+
+ /* return palette color */
+ return palcolor;
}
/**
@@ -148,111 +156,111 @@ static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, c
*/
static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabilization *stab)
{
- if (stab->rot_track) {
- if (!(stab->rot_track->flag & TRACK_USE_2D_STAB_ROT)) {
- stab->tot_rot_track++;
- stab->rot_track->flag |= TRACK_USE_2D_STAB_ROT;
- }
- }
- stab->rot_track = NULL; /* this field is now ignored */
+ if (stab->rot_track) {
+ if (!(stab->rot_track->flag & TRACK_USE_2D_STAB_ROT)) {
+ stab->tot_rot_track++;
+ stab->rot_track->flag |= TRACK_USE_2D_STAB_ROT;
+ }
+ }
+ stab->rot_track = NULL; /* this field is now ignored */
}
static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
{
- bConstraint *con;
-
- for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
- bTransformConstraint *data = (bTransformConstraint *)con->data;
- const float deg_to_rad_f = DEG2RADF(1.0f);
-
- if (data->from == TRANS_ROTATION) {
- mul_v3_fl(data->from_min, deg_to_rad_f);
- mul_v3_fl(data->from_max, deg_to_rad_f);
- }
-
- if (data->to == TRANS_ROTATION) {
- mul_v3_fl(data->to_min, deg_to_rad_f);
- mul_v3_fl(data->to_max, deg_to_rad_f);
- }
- }
- }
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
+ bTransformConstraint *data = (bTransformConstraint *)con->data;
+ const float deg_to_rad_f = DEG2RADF(1.0f);
+
+ if (data->from == TRANS_ROTATION) {
+ mul_v3_fl(data->from_min, deg_to_rad_f);
+ mul_v3_fl(data->from_max, deg_to_rad_f);
+ }
+
+ if (data->to == TRANS_ROTATION) {
+ mul_v3_fl(data->to_min, deg_to_rad_f);
+ mul_v3_fl(data->to_max, deg_to_rad_f);
+ }
+ }
+ }
}
static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
{
- bConstraint *con;
-
- for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
- bTransformConstraint *data = (bTransformConstraint *)con->data;
-
- if (data->from == TRANS_ROTATION) {
- copy_v3_v3(data->from_min_rot, data->from_min);
- copy_v3_v3(data->from_max_rot, data->from_max);
- }
- else if (data->from == TRANS_SCALE) {
- copy_v3_v3(data->from_min_scale, data->from_min);
- copy_v3_v3(data->from_max_scale, data->from_max);
- }
-
- if (data->to == TRANS_ROTATION) {
- copy_v3_v3(data->to_min_rot, data->to_min);
- copy_v3_v3(data->to_max_rot, data->to_max);
- }
- else if (data->to == TRANS_SCALE) {
- copy_v3_v3(data->to_min_scale, data->to_min);
- copy_v3_v3(data->to_max_scale, data->to_max);
- }
- }
- }
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
+ bTransformConstraint *data = (bTransformConstraint *)con->data;
+
+ if (data->from == TRANS_ROTATION) {
+ copy_v3_v3(data->from_min_rot, data->from_min);
+ copy_v3_v3(data->from_max_rot, data->from_max);
+ }
+ else if (data->from == TRANS_SCALE) {
+ copy_v3_v3(data->from_min_scale, data->from_min);
+ copy_v3_v3(data->from_max_scale, data->from_max);
+ }
+
+ if (data->to == TRANS_ROTATION) {
+ copy_v3_v3(data->to_min_rot, data->to_min);
+ copy_v3_v3(data->to_max_rot, data->to_max);
+ }
+ else if (data->to == TRANS_SCALE) {
+ copy_v3_v3(data->to_min_scale, data->to_min);
+ copy_v3_v3(data->to_max_scale, data->to_max);
+ }
+ }
+ }
}
static void do_version_constraints_stretch_to_limits(ListBase *lb)
{
- bConstraint *con;
-
- for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
- bStretchToConstraint *data = (bStretchToConstraint *)con->data;
- data->bulge_min = 1.0f;
- data->bulge_max = 1.0f;
- }
- }
+ bConstraint *con;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
+ bStretchToConstraint *data = (bStretchToConstraint *)con->data;
+ data->bulge_min = 1.0f;
+ data->bulge_max = 1.0f;
+ }
+ }
}
static void do_version_action_editor_properties_region(ListBase *regionbase)
{
- ARegion *ar;
-
- for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_UI) {
- /* already exists */
- return;
- }
- else if (ar->regiontype == RGN_TYPE_WINDOW) {
- /* add new region here */
- ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
-
- BLI_insertlinkbefore(regionbase, ar, arnew);
-
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return;
- }
- }
+ ARegion *ar;
+
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_UI) {
+ /* already exists */
+ return;
+ }
+ else if (ar->regiontype == RGN_TYPE_WINDOW) {
+ /* add new region here */
+ ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
+
+ BLI_insertlinkbefore(regionbase, ar, arnew);
+
+ arnew->regiontype = RGN_TYPE_UI;
+ arnew->alignment = RGN_ALIGN_RIGHT;
+ arnew->flag = RGN_FLAG_HIDDEN;
+
+ return;
+ }
+ }
}
static void do_version_bones_super_bbone(ListBase *lb)
{
- for (Bone *bone = lb->first; bone; bone = bone->next) {
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
+ for (Bone *bone = lb->first; bone; bone = bone->next) {
+ bone->scaleIn = 1.0f;
+ bone->scaleOut = 1.0f;
- do_version_bones_super_bbone(&bone->childbase);
- }
+ do_version_bones_super_bbone(&bone->childbase);
+ }
}
/* TODO(sergey): Consider making it somewhat more generic function in BLI_anim.h. */
@@ -261,1534 +269,1540 @@ static void anim_change_prop_name(FCurve *fcu,
const char *old_prop_name,
const char *new_prop_name)
{
- const char *old_path = BLI_sprintfN("%s.%s", prefix, old_prop_name);
- if (STREQ(fcu->rna_path, old_path)) {
- MEM_freeN(fcu->rna_path);
- fcu->rna_path = BLI_sprintfN("%s.%s", prefix, new_prop_name);
- }
- MEM_freeN((char *)old_path);
+ const char *old_path = BLI_sprintfN("%s.%s", prefix, old_prop_name);
+ if (STREQ(fcu->rna_path, old_path)) {
+ MEM_freeN(fcu->rna_path);
+ fcu->rna_path = BLI_sprintfN("%s.%s", prefix, new_prop_name);
+ }
+ MEM_freeN((char *)old_path);
}
static void do_version_hue_sat_node(bNodeTree *ntree, bNode *node)
{
- if (node->storage == NULL) {
- return;
- }
-
- /* Make sure new sockets are properly created. */
- node_verify_socket_templates(ntree, node);
- /* Convert value from old storage to new sockets. */
- NodeHueSat *nhs = node->storage;
- bNodeSocket *hue = nodeFindSocket(node, SOCK_IN, "Hue"),
- *saturation = nodeFindSocket(node, SOCK_IN, "Saturation"),
- *value = nodeFindSocket(node, SOCK_IN, "Value");
- ((bNodeSocketValueFloat *)hue->default_value)->value = nhs->hue;
- ((bNodeSocketValueFloat *)saturation->default_value)->value = nhs->sat;
- ((bNodeSocketValueFloat *)value->default_value)->value = nhs->val;
- /* Take care of possible animation. */
- AnimData *adt = BKE_animdata_from_id(&ntree->id);
- if (adt != NULL && adt->action != NULL) {
- const char *prefix = BLI_sprintfN("nodes[\"%s\"]", node->name);
- for (FCurve *fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) {
- if (STRPREFIX(fcu->rna_path, prefix)) {
- anim_change_prop_name(fcu, prefix, "color_hue", "inputs[1].default_value");
- anim_change_prop_name(fcu, prefix, "color_saturation", "inputs[2].default_value");
- anim_change_prop_name(fcu, prefix, "color_value", "inputs[3].default_value");
- }
- }
- MEM_freeN((char *)prefix);
- }
- /* Free storage, it is no longer used. */
- MEM_freeN(node->storage);
- node->storage = NULL;
+ if (node->storage == NULL) {
+ return;
+ }
+
+ /* Make sure new sockets are properly created. */
+ node_verify_socket_templates(ntree, node);
+ /* Convert value from old storage to new sockets. */
+ NodeHueSat *nhs = node->storage;
+ bNodeSocket *hue = nodeFindSocket(node, SOCK_IN, "Hue"),
+ *saturation = nodeFindSocket(node, SOCK_IN, "Saturation"),
+ *value = nodeFindSocket(node, SOCK_IN, "Value");
+ ((bNodeSocketValueFloat *)hue->default_value)->value = nhs->hue;
+ ((bNodeSocketValueFloat *)saturation->default_value)->value = nhs->sat;
+ ((bNodeSocketValueFloat *)value->default_value)->value = nhs->val;
+ /* Take care of possible animation. */
+ AnimData *adt = BKE_animdata_from_id(&ntree->id);
+ if (adt != NULL && adt->action != NULL) {
+ const char *prefix = BLI_sprintfN("nodes[\"%s\"]", node->name);
+ for (FCurve *fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) {
+ if (STRPREFIX(fcu->rna_path, prefix)) {
+ anim_change_prop_name(fcu, prefix, "color_hue", "inputs[1].default_value");
+ anim_change_prop_name(fcu, prefix, "color_saturation", "inputs[2].default_value");
+ anim_change_prop_name(fcu, prefix, "color_value", "inputs[3].default_value");
+ }
+ }
+ MEM_freeN((char *)prefix);
+ }
+ /* Free storage, it is no longer used. */
+ MEM_freeN(node->storage);
+ node->storage = NULL;
}
static void do_versions_compositor_render_passes_storage(bNode *node)
{
- int pass_index = 0;
- const char *sockname;
- for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; sock = sock->next, pass_index++) {
- if (sock->storage == NULL) {
- NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
- sock->storage = sockdata;
- BLI_strncpy(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index), sizeof(sockdata->pass_name));
-
- if (pass_index == 0) sockname = "Image";
- else if (pass_index == 1) sockname = "Alpha";
- else sockname = node_cmp_rlayers_sock_to_pass(pass_index);
- BLI_strncpy(sock->name, sockname, sizeof(sock->name));
- }
- }
+ int pass_index = 0;
+ const char *sockname;
+ for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31;
+ sock = sock->next, pass_index++) {
+ if (sock->storage == NULL) {
+ NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
+ sock->storage = sockdata;
+ BLI_strncpy(sockdata->pass_name,
+ node_cmp_rlayers_sock_to_pass(pass_index),
+ sizeof(sockdata->pass_name));
+
+ if (pass_index == 0)
+ sockname = "Image";
+ else if (pass_index == 1)
+ sockname = "Alpha";
+ else
+ sockname = node_cmp_rlayers_sock_to_pass(pass_index);
+ BLI_strncpy(sock->name, sockname, sizeof(sock->name));
+ }
+ }
}
static void do_versions_compositor_render_passes(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS) {
- /* First we make sure existing sockets have proper names.
- * This is important because otherwise verification will
- * drop links from sockets which were renamed.
- */
- do_versions_compositor_render_passes_storage(node);
- /* Make sure new sockets are properly created. */
- node_verify_socket_templates(ntree, node);
- /* Make sure all possibly created sockets have proper storage. */
- do_versions_compositor_render_passes_storage(node);
- }
- }
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_R_LAYERS) {
+ /* First we make sure existing sockets have proper names.
+ * This is important because otherwise verification will
+ * drop links from sockets which were renamed.
+ */
+ do_versions_compositor_render_passes_storage(node);
+ /* Make sure new sockets are properly created. */
+ node_verify_socket_templates(ntree, node);
+ /* Make sure all possibly created sockets have proper storage. */
+ do_versions_compositor_render_passes_storage(node);
+ }
+ }
}
-
static char *replace_bbone_easing_rnapath(char *old_path)
{
- char *new_path = NULL;
-
- /* NOTE: This will break paths for any bones/custom-properties
- * which happen be named after the bbone property id's
- */
- if (strstr(old_path, "bbone_in"))
- new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein");
- else if (strstr(old_path, "bbone_out"))
- new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout");
-
- if (new_path) {
- MEM_freeN(old_path);
- return new_path;
- }
- else {
- return old_path;
- }
+ char *new_path = NULL;
+
+ /* NOTE: This will break paths for any bones/custom-properties
+ * which happen be named after the bbone property id's
+ */
+ if (strstr(old_path, "bbone_in"))
+ new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein");
+ else if (strstr(old_path, "bbone_out"))
+ new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout");
+
+ if (new_path) {
+ MEM_freeN(old_path);
+ return new_path;
+ }
+ else {
+ return old_path;
+ }
}
-static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void *UNUSED(user_data))
+static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
+ FCurve *fcu,
+ void *UNUSED(user_data))
{
- /* F-Curve's path (for bbone_in/out) */
- if (fcu->rna_path) {
- fcu->rna_path = replace_bbone_easing_rnapath(fcu->rna_path);
- }
-
- /* Driver -> Driver Vars (for bbone_in/out) */
- if (fcu->driver) {
- for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER_BEGIN(dvar)
- {
- if (dtar->rna_path) {
- dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
- }
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* FModifiers -> Stepped (for frame_start/end) */
- if (fcu->modifiers.first) {
- for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
- if (fcm->type == FMODIFIER_TYPE_STEPPED) {
- FMod_Stepped *data = fcm->data;
-
- /* Modifier doesn't work if the modifier's copy of start/end frame are both 0
- * as those were only getting written to the fcm->data copy (T52009)
- */
- if ((fcm->sfra == fcm->efra) && (fcm->sfra == 0)) {
- fcm->sfra = data->start_frame;
- fcm->efra = data->end_frame;
- }
- }
- }
- }
+ /* F-Curve's path (for bbone_in/out) */
+ if (fcu->rna_path) {
+ fcu->rna_path = replace_bbone_easing_rnapath(fcu->rna_path);
+ }
+
+ /* Driver -> Driver Vars (for bbone_in/out) */
+ if (fcu->driver) {
+ for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ if (dtar->rna_path) {
+ dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
+ }
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* FModifiers -> Stepped (for frame_start/end) */
+ if (fcu->modifiers.first) {
+ for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
+ if (fcm->type == FMODIFIER_TYPE_STEPPED) {
+ FMod_Stepped *data = fcm->data;
+
+ /* Modifier doesn't work if the modifier's copy of start/end frame are both 0
+ * as those were only getting written to the fcm->data copy (T52009)
+ */
+ if ((fcm->sfra == fcm->efra) && (fcm->sfra == 0)) {
+ fcm->sfra = data->start_frame;
+ fcm->efra = data->end_frame;
+ }
+ }
+ }
+ }
}
-
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) {
-
- if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Bevel) {
- BevelModifierData *bmd = (BevelModifierData *)md;
- bmd->profile = 0.5f;
- bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
- }
- }
- }
- }
-
- /* nodes don't use fixed node->id any more, clean up */
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
- node->id = NULL;
- }
- }
- }
- } FOREACH_NODETREE_END;
-
- {
- bScreen *screen;
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *area;
- for (area = screen->areabase.first; area; area = area->next) {
- SpaceLink *space_link;
- for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
- if (space_link->spacetype == SPACE_CLIP) {
- SpaceClip *space_clip = (SpaceClip *)space_link;
- if (space_clip->mode != SC_MODE_MASKEDIT) {
- space_clip->mode = SC_MODE_TRACKING;
- }
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
- MovieClip *clip;
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- clip->tracking.settings.default_weight = 1.0f;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 1)) {
- Object *ob;
-
- /* Update Transform constraint (another deg -> rad stuff). */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- do_version_constraints_radians_degrees_270_1(&ob->constraints);
-
- if (ob->pose) {
- /* Bones constraints! */
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- do_version_constraints_radians_degrees_270_1(&pchan->constraints);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 2)) {
- Mesh *me;
-
- /* Mesh smoothresh deg->rad. */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- me->smoothresh = DEG2RADF(me->smoothresh);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 3)) {
- FreestyleLineStyle *linestyle;
-
- for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
- linestyle->flag |= LS_NO_SORTING;
- linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
- linestyle->integration_type = LS_INTEGRATION_MEAN;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 4)) {
- /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
- * This will always reset situation to a valid state.
- */
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- ARegion *ar;
- ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
-
- for (ar = lb->first; ar; ar = ar->next) {
- BLI_listbase_clear(&ar->ui_previews);
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 270, 5)) {
- Object *ob;
-
- /* Update Transform constraint (again :|). */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- do_version_constraints_radians_degrees_270_5(&ob->constraints);
-
- if (ob->pose) {
- /* Bones constraints! */
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- do_version_constraints_radians_degrees_270_5(&pchan->constraints);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 271, 0)) {
- if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
- Scene *sce;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->r.bake.flag = R_BAKE_CLEAR;
- sce->r.bake.width = 512;
- sce->r.bake.height = 512;
- sce->r.bake.margin = 16;
- sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
- sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
- sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
- sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
- BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
-
- sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
- sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
- sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
- sce->r.bake.im_format.quality = 90;
- sce->r.bake.im_format.compress = 15;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
- FreestyleLineStyle *linestyle;
-
- for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
- linestyle->flag |= LS_TEXTURE;
- linestyle->texstep = 1.0;
- }
- }
-
- {
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- int num_layers = BLI_listbase_count(&scene->r.layers);
- scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 271, 1)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
- Material *mat;
-
- for (mat = bmain->materials.first; mat; mat = mat->id.next) {
- mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
- mat->line_col[3] = mat->alpha;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->r.preview_start_resolution = 64;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 271, 3)) {
- Brush *br;
-
- for (br = bmain->brushes.first; br; br = br->id.next) {
- br->fill_threshold = 0.2f;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Bevel) {
- BevelModifierData *bmd = (BevelModifierData *)md;
- bmd->mat = -1;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 271, 6)) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
- if (pmd->psys && pmd->psys->clmd) {
- pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 272, 0)) {
- if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->r.preview_start_resolution = 64;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 272, 1)) {
- Brush *br;
- for (br = bmain->brushes.first; br; br = br->id.next) {
- if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
- br->alpha = 1.0f;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 272, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
- Image *image;
- for (image = bmain->images.first; image != NULL; image = image->id.next) {
- image->gen_color[3] = 1.0f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
- Object *ob;
-
- /* Update Transform constraint (again :|). */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- do_version_constraints_stretch_to_limits(&ob->constraints);
-
- if (ob->pose) {
- /* Bones constraints! */
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- do_version_constraints_stretch_to_limits(&pchan->constraints);
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 1)) {
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) {
+
+ if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Bevel) {
+ BevelModifierData *bmd = (BevelModifierData *)md;
+ bmd->profile = 0.5f;
+ bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
+ }
+ }
+ }
+ }
+
+ /* nodes don't use fixed node->id any more, clean up */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
+ node->id = NULL;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+
+ {
+ bScreen *screen;
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *area;
+ for (area = screen->areabase.first; area; area = area->next) {
+ SpaceLink *space_link;
+ for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
+ if (space_link->spacetype == SPACE_CLIP) {
+ SpaceClip *space_clip = (SpaceClip *)space_link;
+ if (space_clip->mode != SC_MODE_MASKEDIT) {
+ space_clip->mode = SC_MODE_TRACKING;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
+ MovieClip *clip;
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ clip->tracking.settings.default_weight = 1.0f;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 1)) {
+ Object *ob;
+
+ /* Update Transform constraint (another deg -> rad stuff). */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ do_version_constraints_radians_degrees_270_1(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_radians_degrees_270_1(&pchan->constraints);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 2)) {
+ Mesh *me;
+
+ /* Mesh smoothresh deg->rad. */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ me->smoothresh = DEG2RADF(me->smoothresh);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 3)) {
+ FreestyleLineStyle *linestyle;
+
+ for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
+ linestyle->flag |= LS_NO_SORTING;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 4)) {
+ /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
+ * This will always reset situation to a valid state.
+ */
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ ARegion *ar;
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+
+ for (ar = lb->first; ar; ar = ar->next) {
+ BLI_listbase_clear(&ar->ui_previews);
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 270, 5)) {
+ Object *ob;
+
+ /* Update Transform constraint (again :|). */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ do_version_constraints_radians_degrees_270_5(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_radians_degrees_270_5(&pchan->constraints);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 0)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
+ Scene *sce;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->r.bake.flag = R_BAKE_CLEAR;
+ sce->r.bake.width = 512;
+ sce->r.bake.height = 512;
+ sce->r.bake.margin = 16;
+ sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
+ sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
+ sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
+ sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
+ BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
+
+ sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
+ sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
+ sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
+ sce->r.bake.im_format.quality = 90;
+ sce->r.bake.im_format.compress = 15;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
+ FreestyleLineStyle *linestyle;
+
+ for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
+ linestyle->flag |= LS_TEXTURE;
+ linestyle->texstep = 1.0;
+ }
+ }
+
+ {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ int num_layers = BLI_listbase_count(&scene->r.layers);
+ scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 1)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
+ Material *mat;
+
+ for (mat = bmain->materials.first; mat; mat = mat->id.next) {
+ mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
+ mat->line_col[3] = mat->alpha;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->r.preview_start_resolution = 64;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 3)) {
+ Brush *br;
+
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ br->fill_threshold = 0.2f;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Bevel) {
+ BevelModifierData *bmd = (BevelModifierData *)md;
+ bmd->mat = -1;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 271, 6)) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
+ if (pmd->psys && pmd->psys->clmd) {
+ pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 0)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->r.preview_start_resolution = 64;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 1)) {
+ Brush *br;
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ if ((br->ob_mode & OB_MODE_SCULPT) &&
+ ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
+ br->alpha = 1.0f;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 272, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
+ Image *image;
+ for (image = bmain->images.first; image != NULL; image = image->id.next) {
+ image->gen_color[3] = 1.0f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
+ Object *ob;
+
+ /* Update Transform constraint (again :|). */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ do_version_constraints_stretch_to_limits(&ob->constraints);
+
+ if (ob->pose) {
+ /* Bones constraints! */
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_stretch_to_limits(&pchan->constraints);
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 1)) {
#define BRUSH_RAKE (1 << 7)
#define BRUSH_RANDOM_ROTATION (1 << 25)
- Brush *br;
-
- for (br = bmain->brushes.first; br; br = br->id.next) {
- if (br->flag & BRUSH_RAKE) {
- br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
- br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
- }
- else if (br->flag & BRUSH_RANDOM_ROTATION) {
- br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
- br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
- }
- br->mtex.random_angle = 2.0 * M_PI;
- br->mask_mtex.random_angle = 2.0 * M_PI;
- }
- }
+ Brush *br;
+
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ if (br->flag & BRUSH_RAKE) {
+ br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
+ br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
+ }
+ else if (br->flag & BRUSH_RANDOM_ROTATION) {
+ br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
+ br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
+ }
+ br->mtex.random_angle = 2.0 * M_PI;
+ br->mask_mtex.random_angle = 2.0 * M_PI;
+ }
+ }
#undef BRUSH_RAKE
#undef BRUSH_RANDOM_ROTATION
- /* Customizable Safe Areas */
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
- Scene *scene;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
- copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
- copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
- copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) {
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->clumpcurve)
- part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
- if (part->roughcurve)
- part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 6)) {
- if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
- Object *ob;
- ModifierData *md;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- clmd->sim_parms->bending_damping = 0.5f;
- }
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
- if (pmd->psys->clmd) {
- pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- part->clump_noise_size = 1.0f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- part->kink_extra_steps = 4;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- int a;
- for (a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = part->mtex[a];
- if (mtex) {
- mtex->kinkampfac = 1.0f;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Hook) {
- HookModifierData *hmd = (HookModifierData *)md;
- hmd->falloff_type = eHook_Falloff_InvSquare;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
- NodePlaneTrackDeformData *data = node->storage;
- data->flag = 0;
- data->motion_blur_samples = 16;
- data->motion_blur_shutter = 0.5f;
- }
- }
- }
- }
- FOREACH_NODETREE_END;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
- Camera *ca;
- for (ca = bmain->cameras.first; ca; ca = ca->id.next) {
- ca->gpu_dof.fstop = 128.0f;
- ca->gpu_dof.focal_length = 1.0f;
- ca->gpu_dof.focus_distance = 1.0f;
- ca->gpu_dof.sensor = 1.0f;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 8)) {
- Object *ob;
- for (ob = bmain->objects.first; ob != NULL; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.last; md != NULL; md = md->prev) {
- if (modifier_unique_name(&ob->modifiers, md)) {
- printf("Warning: Object '%s' had several modifiers with the "
- "same name, renamed one of them to '%s'.\n",
- ob->id.name + 2, md->name);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) {
- bScreen *scr;
- ScrArea *sa;
- SpaceLink *sl;
- ARegion *ar;
-
- /* Make sure sequencer preview area limits zoom */
- for (scr = bmain->screens.first; scr; scr = scr->id.next) {
- for (sa = scr->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SEQ) {
- for (ar = sl->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW) {
- ar->v2d.keepzoom |= V2D_LIMITZOOM;
- ar->v2d.minzoom = 0.001f;
- ar->v2d.maxzoom = 1000.0f;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 274, 1)) {
- /* particle systems need to be forced to redistribute for jitter mode fix */
- {
- Object *ob;
- ParticleSystem *psys;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
- psys->recalc |= ID_RECALC_PSYS_RESET;
- }
- }
- }
- }
-
- /* hysteresis setted to 10% but not actived */
- if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- LodLevel *level;
- for (level = ob->lodlevels.first; level; level = level->next) {
- level->obhysteresis = 10;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 274, 4)) {
- SceneRenderView *srv;
- wmWindowManager *wm;
- bScreen *screen;
- wmWindow *win;
- Scene *scene;
- Camera *cam;
- Image *ima;
-
- for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
-
- BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
- srv = scene->r.views.first;
- BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
-
- BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
- srv = scene->r.views.last;
- BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
-
- SEQ_BEGIN (scene->ed, seq)
- {
- seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
+ /* Customizable Safe Areas */
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
+ Scene *scene;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
+ copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
+ copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
+ copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) {
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (part->clumpcurve)
+ part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
+ if (part->roughcurve)
+ part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 6)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
+ Object *ob;
+ ModifierData *md;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ clmd->sim_parms->bending_damping = 0.5f;
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
+ if (pmd->psys->clmd) {
+ pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ part->clump_noise_size = 1.0f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ part->kink_extra_steps = 4;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ int a;
+ for (a = 0; a < MAX_MTEX; a++) {
+ MTex *mtex = part->mtex[a];
+ if (mtex) {
+ mtex->kinkampfac = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Hook) {
+ HookModifierData *hmd = (HookModifierData *)md;
+ hmd->falloff_type = eHook_Falloff_InvSquare;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
+ NodePlaneTrackDeformData *data = node->storage;
+ data->flag = 0;
+ data->motion_blur_samples = 16;
+ data->motion_blur_shutter = 0.5f;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
+ Camera *ca;
+ for (ca = bmain->cameras.first; ca; ca = ca->id.next) {
+ ca->gpu_dof.fstop = 128.0f;
+ ca->gpu_dof.focal_length = 1.0f;
+ ca->gpu_dof.focus_distance = 1.0f;
+ ca->gpu_dof.sensor = 1.0f;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 8)) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob != NULL; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.last; md != NULL; md = md->prev) {
+ if (modifier_unique_name(&ob->modifiers, md)) {
+ printf(
+ "Warning: Object '%s' had several modifiers with the "
+ "same name, renamed one of them to '%s'.\n",
+ ob->id.name + 2,
+ md->name);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) {
+ bScreen *scr;
+ ScrArea *sa;
+ SpaceLink *sl;
+ ARegion *ar;
+
+ /* Make sure sequencer preview area limits zoom */
+ for (scr = bmain->screens.first; scr; scr = scr->id.next) {
+ for (sa = scr->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SEQ) {
+ for (ar = sl->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
+ ar->v2d.keepzoom |= V2D_LIMITZOOM;
+ ar->v2d.minzoom = 0.001f;
+ ar->v2d.maxzoom = 1000.0f;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 1)) {
+ /* particle systems need to be forced to redistribute for jitter mode fix */
+ {
+ Object *ob;
+ ParticleSystem *psys;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
+ psys->recalc |= ID_RECALC_PSYS_RESET;
+ }
+ }
+ }
+ }
+
+ /* hysteresis setted to 10% but not actived */
+ if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ LodLevel *level;
+ for (level = ob->lodlevels.first; level; level = level->next) {
+ level->obhysteresis = 10;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 4)) {
+ SceneRenderView *srv;
+ wmWindowManager *wm;
+ bScreen *screen;
+ wmWindow *win;
+ Scene *scene;
+ Camera *cam;
+ Image *ima;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ Sequence *seq;
+
+ BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
+ srv = scene->r.views.first;
+ BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
+
+ BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
+ srv = scene->r.views.last;
+ BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
+
+ SEQ_BEGIN (scene->ed, seq) {
+ seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
- if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
- if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
- seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
- if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
- seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
- }
+ if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
+ seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
+ seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
+ }
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
-
- } SEQ_END;
- }
-
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D *)sl;
- v3d->stereo3d_camera = STEREO_3D_ID;
- v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
- v3d->stereo3d_convergence_alpha = 0.15f;
- v3d->stereo3d_volume_alpha = 0.05f;
- break;
- }
- case SPACE_IMAGE:
- {
- SpaceImage *sima = (SpaceImage *)sl;
- sima->iuser.flag |= IMA_SHOW_STEREO;
- break;
- }
- }
- }
- }
- }
-
- for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
- cam->stereo.interocular_distance = 0.065f;
- cam->stereo.convergence_distance = 30.0f * 0.065f;
- }
-
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
-
- if (ima->packedfile) {
- ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
- BLI_addtail(&ima->packedfiles, imapf);
-
- imapf->packedfile = ima->packedfile;
- BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
- ima->packedfile = NULL;
- }
- }
-
- for (wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (win = wm->windows.first; win; win = win->next) {
- win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 274, 6)) {
- bScreen *screen;
-
- if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- if (sfile->params) {
- sfile->params->thumbnail_size = 128;
- }
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
- scene->r.simplify_particles_render = scene->r.simplify_particles;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Decimate) {
- DecimateModifierData *dmd = (DecimateModifierData *)md;
- dmd->defgrp_factor = 1.0f;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 275, 3)) {
- Brush *br;
+ }
+ SEQ_END;
+ }
+
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+ v3d->stereo3d_camera = STEREO_3D_ID;
+ v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
+ v3d->stereo3d_convergence_alpha = 0.15f;
+ v3d->stereo3d_volume_alpha = 0.05f;
+ break;
+ }
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->iuser.flag |= IMA_SHOW_STEREO;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
+ cam->stereo.interocular_distance = 0.065f;
+ cam->stereo.convergence_distance = 30.0f * 0.065f;
+ }
+
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
+
+ if (ima->packedfile) {
+ ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
+ BLI_addtail(&ima->packedfiles, imapf);
+
+ imapf->packedfile = ima->packedfile;
+ BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
+ ima->packedfile = NULL;
+ }
+ }
+
+ for (wm = bmain->wm.first; wm; wm = wm->id.next) {
+ for (win = wm->windows.first; win; win = win->next) {
+ win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 274, 6)) {
+ bScreen *screen;
+
+ if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ if (sfile->params) {
+ sfile->params->thumbnail_size = 128;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
+ scene->r.simplify_particles_render = scene->r.simplify_particles;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Decimate) {
+ DecimateModifierData *dmd = (DecimateModifierData *)md;
+ dmd->defgrp_factor = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 275, 3)) {
+ Brush *br;
#define BRUSH_TORUS (1 << 1)
- for (br = bmain->brushes.first; br; br = br->id.next) {
- br->flag &= ~BRUSH_TORUS;
- }
+ for (br = bmain->brushes.first; br; br = br->id.next) {
+ br->flag &= ~BRUSH_TORUS;
+ }
#undef BRUSH_TORUS
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 276, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pose) {
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- pchan->custom_scale = 1.0f;
- }
- }
- }
- }
-
- {
- bScreen *screen;
-#define RV3D_VIEW_PERSPORTHO 7
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *sa;
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- ARegion *ar;
- ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- for (ar = lb->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->regiondata) {
- RegionView3D *rv3d = ar->regiondata;
- if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
- rv3d->view = RV3D_VIEW_USER;
- }
- }
- }
- }
- break;
- }
- }
- }
- }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pose) {
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ pchan->custom_scale = 1.0f;
+ }
+ }
+ }
+ }
+
+ {
+ bScreen *screen;
+#define RV3D_VIEW_PERSPORTHO 7
+ for (screen = bmain->screens.first; screen; screen = screen->id.next) {
+ ScrArea *sa;
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ ARegion *ar;
+ ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ar = lb->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (ar->regiondata) {
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
+ rv3d->view = RV3D_VIEW_USER;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
#undef RV3D_VIEW_PERSPORTHO
- }
-
- {
-#define LA_YF_PHOTON 5
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- if (la->type == LA_YF_PHOTON) {
- la->type = LA_LOCAL;
- }
- }
+ }
+
+ {
+#define LA_YF_PHOTON 5
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ if (la->type == LA_YF_PHOTON) {
+ la->type = LA_LOCAL;
+ }
+ }
#undef LA_YF_PHOTON
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 276, 3)) {
- if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
- curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
- curvemapping_initialize(curve_mapping);
- curvemap_reset(curve_mapping->cm,
- &curve_mapping->clipr,
- CURVE_PRESET_MAX,
- CURVEMAP_SLOPE_POS_NEG);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 276, 4)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
-
- if (ts->gp_sculpt.brush[0].size == 0) {
- GP_Sculpt_Settings *gset = &ts->gp_sculpt;
- GP_Sculpt_Data *brush;
-
- brush = &gset->brush[GP_SCULPT_TYPE_SMOOTH];
- brush->size = 25;
- brush->strength = 0.3f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_SMOOTH_PRESSURE;
-
- brush = &gset->brush[GP_SCULPT_TYPE_THICKNESS];
- brush->size = 25;
- brush->strength = 0.5f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_GRAB];
- brush->size = 50;
- brush->strength = 0.3f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_PUSH];
- brush->size = 25;
- brush->strength = 0.3f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_TWIST];
- brush->size = 50;
- brush->strength = 0.3f; // XXX?
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_PINCH];
- brush->size = 50;
- brush->strength = 0.5f; // XXX?
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_RANDOMIZE];
- brush->size = 25;
- brush->strength = 0.5f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
-
- brush = &gset->brush[GP_SCULPT_TYPE_CLONE];
- brush->size = 50;
- brush->strength = 1.0f;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 3)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
+ curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(curve_mapping);
+ curvemap_reset(
+ curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 4)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+
+ if (ts->gp_sculpt.brush[0].size == 0) {
+ GP_Sculpt_Settings *gset = &ts->gp_sculpt;
+ GP_Sculpt_Data *brush;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_SMOOTH];
+ brush->size = 25;
+ brush->strength = 0.3f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_SMOOTH_PRESSURE;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_THICKNESS];
+ brush->size = 25;
+ brush->strength = 0.5f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_GRAB];
+ brush->size = 50;
+ brush->strength = 0.3f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_PUSH];
+ brush->size = 25;
+ brush->strength = 0.3f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_TWIST];
+ brush->size = 50;
+ brush->strength = 0.3f; // XXX?
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_PINCH];
+ brush->size = 50;
+ brush->strength = 0.5f; // XXX?
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_RANDOMIZE];
+ brush->size = 25;
+ brush->strength = 0.5f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_CLONE];
+ brush->size = 50;
+ brush->strength = 1.0f;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
#if 0 /* XXX: Cannot do this, as we get random crashes... */
- if (scene->gpd) {
- bGPdata *gpd = scene->gpd;
-
- /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
- ts->gpencil_v3d_align = 0;
-
- if (gpd->flag & GP_DATA_VIEWALIGN) ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
- if (gpd->flag & GP_DATA_DEPTH_VIEW) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
- if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
-
- if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
- ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
- }
- else {
- /* Default to cursor for all standard 3D views */
- ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
- }
+ if (scene->gpd) {
+ bGPdata *gpd = scene->gpd;
+
+ /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
+ ts->gpencil_v3d_align = 0;
+
+ if (gpd->flag & GP_DATA_VIEWALIGN) ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
+ if (gpd->flag & GP_DATA_DEPTH_VIEW) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
+ if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
+
+ if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
+ ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
+ }
+ else {
+ /* Default to cursor for all standard 3D views */
+ ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
+ }
#endif
- ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
- ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
- ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
- ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
- }
- }
-
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- bool enabled = false;
-
- /* Ensure that the datablock's onionskinning toggle flag
- * stays in sync with the status of the actual layers
- */
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- if (gpl->flag & GP_LAYER_ONIONSKIN) {
- enabled = true;
- }
- }
-
- if (enabled)
- gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
- else
- gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
- }
- }
- if (!MAIN_VERSION_ATLEAST(bmain, 276, 5)) {
- ListBase *lbarray[MAX_LIBARRAY];
- int a;
-
- /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
- * with any new persistent flag we may add in the future. */
- a = set_listbasepointers(bmain, lbarray);
- while (a--) {
- for (ID *id = lbarray[a]->first; id; id = id->next) {
- id->flag &= LIB_FAKEUSER;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 276, 7)) {
- Scene *scene;
- for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 277, 1)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ParticleEditSettings *pset = &scene->toolsettings->particle;
- for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
- if (pset->brush[a].strength > 1.0f) {
- pset->brush[a].strength *= 0.01f;
- }
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- /* Bug: Was possible to add preview region to sequencer view by using AZones. */
- if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- if (sseq->view == SEQ_VIEW_SEQUENCE) {
- for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
- /* remove preview region for sequencer-only view! */
- if (ar->regiontype == RGN_TYPE_PREVIEW) {
- ar->flag |= RGN_FLAG_HIDDEN;
- ar->alignment = RGN_ALIGN_NONE;
- break;
- }
- }
- }
- }
- /* Remove old deprecated region from filebrowsers */
- else if (sl->spacetype == SPACE_FILE) {
- for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_CHANNELS) {
- /* Free old deprecated 'channel' region... */
- BKE_area_region_free(NULL, ar);
- BLI_freelinkN(regionbase, ar);
- break;
- }
- }
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
- if (cps->error_threshold == 0) {
- cps->curve_type = CU_BEZIER;
- cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
- cps->error_threshold = 8;
- cps->radius_max = 1.0f;
- cps->corner_angle = DEG2RADF(70.0f);
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
-
- SEQ_BEGIN (scene->ed, seq)
- {
- if (seq->type != SEQ_TYPE_TEXT) {
- continue;
- }
-
- if (seq->effectdata == NULL) {
- struct SeqEffectHandle effect_handle = BKE_sequence_get_effect(seq);
- effect_handle.init(seq);
- }
-
- TextVars *data = seq->effectdata;
- if (data->color[3] == 0.0f) {
- copy_v4_fl(data->color, 1.0f);
- data->shadow_color[3] = 1.0f;
- }
- } SEQ_END;
- }
-
- /* Adding "Properties" region to DopeSheet */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- /* handle pushed-back space data first */
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
- do_version_action_editor_properties_region(&saction->regionbase);
- }
- }
-
- /* active spacedata info must be handled too... */
- if (sa->spacetype == SPACE_ACTION) {
- do_version_action_editor_properties_region(&sa->regionbase);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 277, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
- for (bArmature *arm = bmain->armatures.first; arm; arm = arm->id.next) {
- do_version_bones_super_bbone(&arm->bonebase);
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pose) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* see do_version_bones_super_bbone()... */
- pchan->scaleIn = 1.0f;
- pchan->scaleOut = 1.0f;
-
- /* also make sure some legacy (unused for over a decade) flags are unset,
- * so that we can reuse them for stuff that matters now...
- * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
- *
- * These seem to have been runtime flags used by the IK solver, but that stuff
- * should be able to be recalculated automatically anyway, so it should be fine.
- */
- pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
- }
- }
- }
- }
-
- for (Camera *camera = bmain->cameras.first; camera != NULL; camera = camera->id.next) {
- if (camera->stereo.pole_merge_angle_from == 0.0f &&
- camera->stereo.pole_merge_angle_to == 0.0f)
- {
- camera->stereo.pole_merge_angle_from = DEG2RADF(60.0f);
- camera->stereo.pole_merge_angle_to = DEG2RADF(75.0f);
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_NormalEdit) {
- NormalEditModifierData *nemd = (NormalEditModifierData *)md;
- nemd->mix_limit = DEG2RADF(180.0f);
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Boolean) {
- BooleanModifierData *bmd = (BooleanModifierData *)md;
- bmd->double_threshold = 1e-6f;
- }
- }
- }
- }
-
- for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
- if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) {
- br->flag |= BRUSH_ACCUMULATE;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) {
- Object *ob;
- ModifierData *md;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- clmd->sim_parms->time_scale = 1.0f;
- }
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
- if (pmd->psys->clmd) {
- pmd->psys->clmd->sim_parms->time_scale = 1.0f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 277, 3)) {
- /* ------- init of grease pencil initialization --------------- */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- /* initialize use position for sculpt brushes */
- ts->gp_sculpt.flag |= GP_SCULPT_SETT_FLAG_APPLY_POSITION;
-
- /* new strength sculpt brush */
- if (ts->gp_sculpt.brush[0].size >= 11) {
- GP_Sculpt_Settings *gset = &ts->gp_sculpt;
- GP_Sculpt_Data *brush;
-
- brush = &gset->brush[GP_SCULPT_TYPE_STRENGTH];
- brush->size = 25;
- brush->strength = 0.5f;
- brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
- }
- }
- /* Convert Grease Pencil to new palettes/brushes
- * Loop all strokes and create the palette and all colors
- */
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- if (BLI_listbase_is_empty(&gpd->palettes)) {
- /* create palette */
- bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette");
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* create color using layer name */
- bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info);
- if (palcolor != NULL) {
- /* set color attributes */
- copy_v4_v4(palcolor->color, gpl->color);
- copy_v4_v4(palcolor->fill, gpl->fill);
-
- if (gpl->flag & GP_LAYER_HIDE) palcolor->flag |= PC_COLOR_HIDE;
- if (gpl->flag & GP_LAYER_LOCKED) palcolor->flag |= PC_COLOR_LOCKED;
- if (gpl->flag & GP_LAYER_ONIONSKIN) palcolor->flag |= PC_COLOR_ONIONSKIN;
- if (gpl->flag & GP_LAYER_VOLUMETRIC) palcolor->flag |= PC_COLOR_VOLUMETRIC;
-
- /* set layer opacity to 1 */
- gpl->opacity = 1.0f;
-
- /* set tint color */
- ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
-
- /* flush relevant layer-settings to strokes */
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- /* set stroke to palette and force recalculation */
- BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname));
- gps->thickness = gpl->thickness;
-
- /* set alpha strength to 1 */
- for (int i = 0; i < gps->totpoints; i++) {
- gps->points[i].strength = 1.0f;
- }
- }
- }
- }
- }
- }
- }
- }
- /* ------- end of grease pencil initialization --------------- */
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 278, 0)) {
- if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) {
- MovieClip *clip;
- for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *tracking_object;
- for (tracking_object = tracking->objects.first;
- tracking_object != NULL;
- tracking_object = tracking_object->next)
- {
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
- MovieTrackingTrack *track;
- for (track = tracksbase->first;
- track != NULL;
- track = track->next)
- {
- track->weight_stab = track->weight;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) {
- MovieClip *clip;
- for (clip = bmain->movieclips.first; clip != NULL; clip = clip->id.next) {
- if (clip->tracking.stabilization.rot_track) {
- migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
- }
- if (clip->tracking.stabilization.scale == 0.0f) {
- /* ensure init.
- * Was previously used for autoscale only,
- * now used always (as "target scale") */
- clip->tracking.stabilization.scale = 1.0f;
- }
- /* blender prefers 1-based frame counting;
- * thus using frame 1 as reference typically works best */
- clip->tracking.stabilization.anchor_frame = 1;
- /* by default show the track lists expanded, to improve "discoverability" */
- clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS;
- /* deprecated, not used anymore */
- clip->tracking.stabilization.ok = false;
- }
- }
- }
- if (!MAIN_VERSION_ATLEAST(bmain, 278, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* "medium" is the preset FFmpeg uses when no presets are given. */
- scene->r.ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM;
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "constant_rate_factor")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* fall back to behavior from before we introduced CRF for old files */
- scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SmokeModifierData", "float", "slice_per_voxel")) {
- Object *ob;
- ModifierData *md;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->domain) {
- smd->domain->slice_per_voxel = 5.0f;
- smd->domain->slice_depth = 0.5f;
- smd->domain->display_thickness = 1.0f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 278, 3)) {
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- if (scene->toolsettings != NULL) {
- ToolSettings *ts = scene->toolsettings;
- ParticleEditSettings *pset = &ts->particle;
- for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
- if (pset->brush[a].count == 0) {
- pset->brush[a].count = 10;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- RigidBodyCon *rbc = ob->rigidbody_constraint;
- if (rbc) {
- rbc->spring_stiffness_ang_x = 10.0;
- rbc->spring_stiffness_ang_y = 10.0;
- rbc->spring_stiffness_ang_z = 10.0;
- rbc->spring_damping_ang_x = 0.5;
- rbc->spring_damping_ang_y = 0.5;
- rbc->spring_damping_ang_z = 0.5;
- }
- }
- }
-
- /* constant detail for sculpting is now a resolution value instead of
- * a percentage, we reuse old DNA struct member but convert it */
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- if (scene->toolsettings != NULL) {
- ToolSettings *ts = scene->toolsettings;
- if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) {
- ts->sculpt->constant_detail = 100.0f / ts->sculpt->constant_detail;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 278, 4)) {
- const float sqrt_3 = (float)M_SQRT3;
- for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
- br->fill_threshold /= sqrt_3;
- }
-
- /* Custom motion paths */
- if (!DNA_struct_elem_find(fd->filesdna, "bMotionPath", "int", "line_thickness")) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- bMotionPath *mpath;
- bPoseChannel *pchan;
- mpath = ob->mpath;
- if (mpath) {
- mpath->color[0] = 1.0f;
- mpath->color[1] = 0.0f;
- mpath->color[2] = 0.0f;
- mpath->line_thickness = 1;
- mpath->flag |= MOTIONPATH_FLAG_LINES;
- }
- /* bones motion path */
- if (ob->pose) {
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- mpath = pchan->mpath;
- if (mpath) {
- mpath->color[0] = 1.0f;
- mpath->color[1] = 0.0f;
- mpath->color[2] = 0.0f;
- mpath->line_thickness = 1;
- mpath->flag |= MOTIONPATH_FLAG_LINES;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) {
- /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
- for (Mask *mask = bmain->masks.first; mask; mask = mask->id.next) {
- for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
- for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
- int i = 0;
- for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) {
- if (mspoint->parent.id_type == 0) {
- BKE_mask_parent_init(&mspoint->parent);
- }
- }
- }
- }
- }
-
- /* Fix for T50736, Glare comp node using same var for two different things. */
- if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- ntreeSetTypes(NULL, ntree);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_GLARE) {
- NodeGlare *ndg = node->storage;
- switch (ndg->type) {
- case 2: /* Grrrr! magic numbers :( */
- ndg->streaks = ndg->angle;
- break;
- case 0:
- ndg->star_45 = ndg->angle != 0;
- break;
- default:
- break;
- }
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_SurfaceDeform) {
- SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
- unit_m4(smd->mat);
- }
- }
- }
- }
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- do_versions_compositor_render_passes(ntree);
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
- scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
- }
- }
-
- /* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
- for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
- CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
- if (!DNA_struct_elem_find(fd->filesdna, "SmokeDomainSettings", "float", "clipping")) {
- Object *ob;
- ModifierData *md;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->domain) {
- smd->domain->clipping = 1e-3f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) {
- /* Fix for invalid state of screen due to bug in older versions. */
- for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- if (sa->full && sc->state == SCREENNORMAL) {
- sa->full = NULL;
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
- for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
- br->falloff_angle = DEG2RADF(80);
- br->flag &= ~(
- BRUSH_FLAG_UNUSED_1 | BRUSH_FLAG_UNUSED_6 |
- BRUSH_FLAG_UNUSED_7 | BRUSH_FLAG_UNUSED_17 |
- BRUSH_FRONTFACE_FALLOFF);
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- for (int i = 0; i < 2; i++) {
- VPaint *vp = i ? ts->vpaint : ts->wpaint;
- if (vp != NULL) {
- /* remove all other flags */
- vp->flag &= (VP_FLAG_VGROUP_RESTRICT);
- }
- }
- }
- }
-
- /* Simple deform modifier no longer assumes Z axis (X for bend type).
- * Must set previous defaults. */
- if (!DNA_struct_elem_find(fd->filesdna, "SimpleDeformModifierData", "char", "deform_axis")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_SimpleDeform) {
- SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
- smd->deform_axis = 2;
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- int preset = scene->r.ffcodecdata.ffmpeg_preset;
- if (preset == FFM_PRESET_NONE || preset >= FFM_PRESET_GOOD) {
- continue;
- }
- if (preset <= FFM_PRESET_FAST) {
- preset = FFM_PRESET_REALTIME;
- }
- else if (preset >= FFM_PRESET_SLOW) {
- preset = FFM_PRESET_BEST;
- }
- else {
- preset = FFM_PRESET_GOOD;
- }
- scene->r.ffcodecdata.ffmpeg_preset = preset;
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_ParticleInstance) {
- ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
- pimd->space = eParticleInstanceSpace_World;
- pimd->particle_amount = 1.0f;
- }
- }
- }
- }
- }
+ ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
+ ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
+ ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
+ ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
+ }
+ }
+
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ bool enabled = false;
+
+ /* Ensure that the datablock's onionskinning toggle flag
+ * stays in sync with the status of the actual layers
+ */
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ if (gpl->flag & GP_LAYER_ONIONSKIN) {
+ enabled = true;
+ }
+ }
+
+ if (enabled)
+ gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
+ else
+ gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
+ }
+ }
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 5)) {
+ ListBase *lbarray[MAX_LIBARRAY];
+ int a;
+
+ /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
+ * with any new persistent flag we may add in the future. */
+ a = set_listbasepointers(bmain, lbarray);
+ while (a--) {
+ for (ID *id = lbarray[a]->first; id; id = id->next) {
+ id->flag &= LIB_FAKEUSER;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 7)) {
+ Scene *scene;
+ for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 1)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ParticleEditSettings *pset = &scene->toolsettings->particle;
+ for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
+ if (pset->brush[a].strength > 1.0f) {
+ pset->brush[a].strength *= 0.01f;
+ }
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ /* Bug: Was possible to add preview region to sequencer view by using AZones. */
+ if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ if (sseq->view == SEQ_VIEW_SEQUENCE) {
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ /* remove preview region for sequencer-only view! */
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
+ ar->flag |= RGN_FLAG_HIDDEN;
+ ar->alignment = RGN_ALIGN_NONE;
+ break;
+ }
+ }
+ }
+ }
+ /* Remove old deprecated region from filebrowsers */
+ else if (sl->spacetype == SPACE_FILE) {
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_CHANNELS) {
+ /* Free old deprecated 'channel' region... */
+ BKE_area_region_free(NULL, ar);
+ BLI_freelinkN(regionbase, ar);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
+ if (cps->error_threshold == 0) {
+ cps->curve_type = CU_BEZIER;
+ cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
+ cps->error_threshold = 8;
+ cps->radius_max = 1.0f;
+ cps->corner_angle = DEG2RADF(70.0f);
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ Sequence *seq;
+
+ SEQ_BEGIN (scene->ed, seq) {
+ if (seq->type != SEQ_TYPE_TEXT) {
+ continue;
+ }
+
+ if (seq->effectdata == NULL) {
+ struct SeqEffectHandle effect_handle = BKE_sequence_get_effect(seq);
+ effect_handle.init(seq);
+ }
+
+ TextVars *data = seq->effectdata;
+ if (data->color[3] == 0.0f) {
+ copy_v4_fl(data->color, 1.0f);
+ data->shadow_color[3] = 1.0f;
+ }
+ }
+ SEQ_END;
+ }
+
+ /* Adding "Properties" region to DopeSheet */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ /* handle pushed-back space data first */
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)sl;
+ do_version_action_editor_properties_region(&saction->regionbase);
+ }
+ }
+
+ /* active spacedata info must be handled too... */
+ if (sa->spacetype == SPACE_ACTION) {
+ do_version_action_editor_properties_region(&sa->regionbase);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
+ for (bArmature *arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ do_version_bones_super_bbone(&arm->bonebase);
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pose) {
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* see do_version_bones_super_bbone()... */
+ pchan->scaleIn = 1.0f;
+ pchan->scaleOut = 1.0f;
+
+ /* also make sure some legacy (unused for over a decade) flags are unset,
+ * so that we can reuse them for stuff that matters now...
+ * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
+ *
+ * These seem to have been runtime flags used by the IK solver, but that stuff
+ * should be able to be recalculated automatically anyway, so it should be fine.
+ */
+ pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
+ }
+ }
+ }
+ }
+
+ for (Camera *camera = bmain->cameras.first; camera != NULL; camera = camera->id.next) {
+ if (camera->stereo.pole_merge_angle_from == 0.0f &&
+ camera->stereo.pole_merge_angle_to == 0.0f) {
+ camera->stereo.pole_merge_angle_from = DEG2RADF(60.0f);
+ camera->stereo.pole_merge_angle_to = DEG2RADF(75.0f);
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_NormalEdit) {
+ NormalEditModifierData *nemd = (NormalEditModifierData *)md;
+ nemd->mix_limit = DEG2RADF(180.0f);
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Boolean) {
+ BooleanModifierData *bmd = (BooleanModifierData *)md;
+ bmd->double_threshold = 1e-6f;
+ }
+ }
+ }
+ }
+
+ for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+ if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) {
+ br->flag |= BRUSH_ACCUMULATE;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) {
+ Object *ob;
+ ModifierData *md;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ clmd->sim_parms->time_scale = 1.0f;
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
+ if (pmd->psys->clmd) {
+ pmd->psys->clmd->sim_parms->time_scale = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 277, 3)) {
+ /* ------- init of grease pencil initialization --------------- */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ /* initialize use position for sculpt brushes */
+ ts->gp_sculpt.flag |= GP_SCULPT_SETT_FLAG_APPLY_POSITION;
+
+ /* new strength sculpt brush */
+ if (ts->gp_sculpt.brush[0].size >= 11) {
+ GP_Sculpt_Settings *gset = &ts->gp_sculpt;
+ GP_Sculpt_Data *brush;
+
+ brush = &gset->brush[GP_SCULPT_TYPE_STRENGTH];
+ brush->size = 25;
+ brush->strength = 0.5f;
+ brush->flag = GP_SCULPT_FLAG_USE_FALLOFF;
+ }
+ }
+ /* Convert Grease Pencil to new palettes/brushes
+ * Loop all strokes and create the palette and all colors
+ */
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (BLI_listbase_is_empty(&gpd->palettes)) {
+ /* create palette */
+ bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette");
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* create color using layer name */
+ bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info);
+ if (palcolor != NULL) {
+ /* set color attributes */
+ copy_v4_v4(palcolor->color, gpl->color);
+ copy_v4_v4(palcolor->fill, gpl->fill);
+
+ if (gpl->flag & GP_LAYER_HIDE)
+ palcolor->flag |= PC_COLOR_HIDE;
+ if (gpl->flag & GP_LAYER_LOCKED)
+ palcolor->flag |= PC_COLOR_LOCKED;
+ if (gpl->flag & GP_LAYER_ONIONSKIN)
+ palcolor->flag |= PC_COLOR_ONIONSKIN;
+ if (gpl->flag & GP_LAYER_VOLUMETRIC)
+ palcolor->flag |= PC_COLOR_VOLUMETRIC;
+
+ /* set layer opacity to 1 */
+ gpl->opacity = 1.0f;
+
+ /* set tint color */
+ ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
+
+ /* flush relevant layer-settings to strokes */
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* set stroke to palette and force recalculation */
+ BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname));
+ gps->thickness = gpl->thickness;
+
+ /* set alpha strength to 1 */
+ for (int i = 0; i < gps->totpoints; i++) {
+ gps->points[i].strength = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /* ------- end of grease pencil initialization --------------- */
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 0)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) {
+ MovieClip *clip;
+ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+ for (tracking_object = tracking->objects.first; tracking_object != NULL;
+ tracking_object = tracking_object->next) {
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ MovieTrackingTrack *track;
+ for (track = tracksbase->first; track != NULL; track = track->next) {
+ track->weight_stab = track->weight;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) {
+ MovieClip *clip;
+ for (clip = bmain->movieclips.first; clip != NULL; clip = clip->id.next) {
+ if (clip->tracking.stabilization.rot_track) {
+ migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
+ }
+ if (clip->tracking.stabilization.scale == 0.0f) {
+ /* ensure init.
+ * Was previously used for autoscale only,
+ * now used always (as "target scale") */
+ clip->tracking.stabilization.scale = 1.0f;
+ }
+ /* blender prefers 1-based frame counting;
+ * thus using frame 1 as reference typically works best */
+ clip->tracking.stabilization.anchor_frame = 1;
+ /* by default show the track lists expanded, to improve "discoverability" */
+ clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS;
+ /* deprecated, not used anymore */
+ clip->tracking.stabilization.ok = false;
+ }
+ }
+ }
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* "medium" is the preset FFmpeg uses when no presets are given. */
+ scene->r.ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM;
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "constant_rate_factor")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* fall back to behavior from before we introduced CRF for old files */
+ scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SmokeModifierData", "float", "slice_per_voxel")) {
+ Object *ob;
+ ModifierData *md;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if (smd->domain) {
+ smd->domain->slice_per_voxel = 5.0f;
+ smd->domain->slice_depth = 0.5f;
+ smd->domain->display_thickness = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 3)) {
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ if (scene->toolsettings != NULL) {
+ ToolSettings *ts = scene->toolsettings;
+ ParticleEditSettings *pset = &ts->particle;
+ for (int a = 0; a < ARRAY_SIZE(pset->brush); a++) {
+ if (pset->brush[a].count == 0) {
+ pset->brush[a].count = 10;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ RigidBodyCon *rbc = ob->rigidbody_constraint;
+ if (rbc) {
+ rbc->spring_stiffness_ang_x = 10.0;
+ rbc->spring_stiffness_ang_y = 10.0;
+ rbc->spring_stiffness_ang_z = 10.0;
+ rbc->spring_damping_ang_x = 0.5;
+ rbc->spring_damping_ang_y = 0.5;
+ rbc->spring_damping_ang_z = 0.5;
+ }
+ }
+ }
+
+ /* constant detail for sculpting is now a resolution value instead of
+ * a percentage, we reuse old DNA struct member but convert it */
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ if (scene->toolsettings != NULL) {
+ ToolSettings *ts = scene->toolsettings;
+ if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) {
+ ts->sculpt->constant_detail = 100.0f / ts->sculpt->constant_detail;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 4)) {
+ const float sqrt_3 = (float)M_SQRT3;
+ for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+ br->fill_threshold /= sqrt_3;
+ }
+
+ /* Custom motion paths */
+ if (!DNA_struct_elem_find(fd->filesdna, "bMotionPath", "int", "line_thickness")) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bMotionPath *mpath;
+ bPoseChannel *pchan;
+ mpath = ob->mpath;
+ if (mpath) {
+ mpath->color[0] = 1.0f;
+ mpath->color[1] = 0.0f;
+ mpath->color[2] = 0.0f;
+ mpath->line_thickness = 1;
+ mpath->flag |= MOTIONPATH_FLAG_LINES;
+ }
+ /* bones motion path */
+ if (ob->pose) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ mpath = pchan->mpath;
+ if (mpath) {
+ mpath->color[0] = 1.0f;
+ mpath->color[1] = 0.0f;
+ mpath->color[2] = 0.0f;
+ mpath->line_thickness = 1;
+ mpath->flag |= MOTIONPATH_FLAG_LINES;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) {
+ /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
+ for (Mask *mask = bmain->masks.first; mask; mask = mask->id.next) {
+ for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
+ for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
+ int i = 0;
+ for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point;
+ mspoint++, i++) {
+ if (mspoint->parent.id_type == 0) {
+ BKE_mask_parent_init(&mspoint->parent);
+ }
+ }
+ }
+ }
+ }
+
+ /* Fix for T50736, Glare comp node using same var for two different things. */
+ if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ ntreeSetTypes(NULL, ntree);
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_GLARE) {
+ NodeGlare *ndg = node->storage;
+ switch (ndg->type) {
+ case 2: /* Grrrr! magic numbers :( */
+ ndg->streaks = ndg->angle;
+ break;
+ case 0:
+ ndg->star_45 = ndg->angle != 0;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_SurfaceDeform) {
+ SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
+ unit_m4(smd->mat);
+ }
+ }
+ }
+ }
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ do_versions_compositor_render_passes(ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
+ scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
+ }
+ }
+
+ /* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
+ for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
+ CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "SmokeDomainSettings", "float", "clipping")) {
+ Object *ob;
+ ModifierData *md;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if (smd->domain) {
+ smd->domain->clipping = 1e-3f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) {
+ /* Fix for invalid state of screen due to bug in older versions. */
+ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ if (sa->full && sc->state == SCREENNORMAL) {
+ sa->full = NULL;
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) {
+ for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+ br->falloff_angle = DEG2RADF(80);
+ br->flag &= ~(BRUSH_FLAG_UNUSED_1 | BRUSH_FLAG_UNUSED_6 | BRUSH_FLAG_UNUSED_7 |
+ BRUSH_FLAG_UNUSED_17 | BRUSH_FRONTFACE_FALLOFF);
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ for (int i = 0; i < 2; i++) {
+ VPaint *vp = i ? ts->vpaint : ts->wpaint;
+ if (vp != NULL) {
+ /* remove all other flags */
+ vp->flag &= (VP_FLAG_VGROUP_RESTRICT);
+ }
+ }
+ }
+ }
+
+ /* Simple deform modifier no longer assumes Z axis (X for bend type).
+ * Must set previous defaults. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SimpleDeformModifierData", "char", "deform_axis")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_SimpleDeform) {
+ SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
+ smd->deform_axis = 2;
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ int preset = scene->r.ffcodecdata.ffmpeg_preset;
+ if (preset == FFM_PRESET_NONE || preset >= FFM_PRESET_GOOD) {
+ continue;
+ }
+ if (preset <= FFM_PRESET_FAST) {
+ preset = FFM_PRESET_REALTIME;
+ }
+ else if (preset >= FFM_PRESET_SLOW) {
+ preset = FFM_PRESET_BEST;
+ }
+ else {
+ preset = FFM_PRESET_GOOD;
+ }
+ scene->r.ffcodecdata.ffmpeg_preset = preset;
+ }
+
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_ParticleInstance) {
+ ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
+ pimd->space = eParticleInstanceSpace_World;
+ pimd->particle_amount = 1.0f;
+ }
+ }
+ }
+ }
+ }
}
void do_versions_after_linking_270(Main *bmain)
{
- /* To be added to next subversion bump! */
- if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_COMPOSIT) {
- ntreeSetTypes(NULL, ntree);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_HUE_SAT) {
- do_version_hue_sat_node(ntree, node);
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 279, 2)) {
- /* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */
- /* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */
- BKE_fcurves_main_cb(bmain, do_version_bbone_easing_fcurve_fix, NULL);
- }
+ /* To be added to next subversion bump! */
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ ntreeSetTypes(NULL, ntree);
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_HUE_SAT) {
+ do_version_hue_sat_node(ntree, node);
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 2)) {
+ /* B-Bones (bbone_in/out -> bbone_easein/out) + Stepped FMod Frame Start/End fix */
+ /* if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "bbone_easein")) */
+ BKE_fcurves_main_cb(bmain, do_version_bbone_easing_fcurve_fix, NULL);
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 528bfd2360f..0582bf05c25 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -98,70 +98,70 @@
static bScreen *screen_parent_find(const bScreen *screen)
{
- /* can avoid lookup if screen state isn't maximized/full (parent and child store the same state) */
- if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
- for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full && sa->full != screen) {
- BLI_assert(sa->full->state == screen->state);
- return sa->full;
- }
- }
- }
-
- return NULL;
+ /* can avoid lookup if screen state isn't maximized/full (parent and child store the same state) */
+ if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
+ for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ if (sa->full && sa->full != screen) {
+ BLI_assert(sa->full->state == screen->state);
+ return sa->full;
+ }
+ }
+ }
+
+ return NULL;
}
static void do_version_workspaces_create_from_screens(Main *bmain)
{
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- const bScreen *screen_parent = screen_parent_find(screen);
- WorkSpace *workspace;
- if (screen->temp) {
- continue;
- }
-
- if (screen_parent) {
- /* fullscreen with "Back to Previous" option, don't create
- * a new workspace, add layout workspace containing parent */
- workspace = BLI_findstring(
- &bmain->workspaces, screen_parent->id.name + 2, offsetof(ID, name) + 2);
- }
- else {
- workspace = BKE_workspace_add(bmain, screen->id.name + 2);
- }
- if (workspace == NULL) {
- continue; /* Not much we can do.. */
- }
- BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
- }
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ const bScreen *screen_parent = screen_parent_find(screen);
+ WorkSpace *workspace;
+ if (screen->temp) {
+ continue;
+ }
+
+ if (screen_parent) {
+ /* fullscreen with "Back to Previous" option, don't create
+ * a new workspace, add layout workspace containing parent */
+ workspace = BLI_findstring(
+ &bmain->workspaces, screen_parent->id.name + 2, offsetof(ID, name) + 2);
+ }
+ else {
+ workspace = BKE_workspace_add(bmain, screen->id.name + 2);
+ }
+ if (workspace == NULL) {
+ continue; /* Not much we can do.. */
+ }
+ BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
+ }
}
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
{
- SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
- SpaceAction *saction = (SpaceAction *)stype->new(area, scene);
- ARegion *region_channels;
-
- /* Properly free current regions */
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
- BKE_area_region_free(area->type, region);
- }
- BLI_freelistN(&area->regionbase);
-
- area->type = stype;
- area->spacetype = stype->spaceid;
-
- BLI_addhead(&area->spacedata, saction);
- area->regionbase = saction->regionbase;
- BLI_listbase_clear(&saction->regionbase);
-
- /* Different defaults for timeline */
- region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
- region_channels->flag |= RGN_FLAG_HIDDEN;
-
- saction->mode = SACTCONT_TIMELINE;
- saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
- saction->ads.filterflag |= ADS_FILTER_SUMMARY;
+ SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
+ SpaceAction *saction = (SpaceAction *)stype->new (area, scene);
+ ARegion *region_channels;
+
+ /* Properly free current regions */
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ BKE_area_region_free(area->type, region);
+ }
+ BLI_freelistN(&area->regionbase);
+
+ area->type = stype;
+ area->spacetype = stype->spaceid;
+
+ BLI_addhead(&area->spacedata, saction);
+ area->regionbase = saction->regionbase;
+ BLI_listbase_clear(&saction->regionbase);
+
+ /* Different defaults for timeline */
+ region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
+ region_channels->flag |= RGN_FLAG_HIDDEN;
+
+ saction->mode = SACTCONT_TIMELINE;
+ saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
+ saction->ads.filterflag |= ADS_FILTER_SUMMARY;
}
/**
@@ -177,2137 +177,2148 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc
*/
static void do_version_workspaces_after_lib_link(Main *bmain)
{
- BLI_assert(BLI_listbase_is_empty(&bmain->workspaces));
-
- do_version_workspaces_create_from_screens(bmain);
-
- for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- bScreen *screen_parent = screen_parent_find(win->screen);
- bScreen *screen = screen_parent ? screen_parent : win->screen;
-
- if (screen->temp) {
- /* We do not generate a new workspace for those screens... still need to set some data in win. */
- win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
- win->scene = screen->scene;
- /* Deprecated from now on! */
- win->screen = NULL;
- continue;
- }
-
- WorkSpace *workspace = BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
- BLI_assert(workspace != NULL);
- WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen);
- BLI_assert(layout != NULL);
-
- win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
-
- BKE_workspace_active_set(win->workspace_hook, workspace);
- BKE_workspace_active_layout_set(win->workspace_hook, layout);
-
- /* Move scene and view layer to window. */
- Scene *scene = screen->scene;
- ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
- if (!layer) {
- layer = BKE_view_layer_default_view(scene);
- }
-
- win->scene = scene;
- STRNCPY(win->view_layer_name, layer->name);
-
- /* Deprecated from now on! */
- win->screen = NULL;
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- /* Deprecated from now on! */
- BLI_freelistN(&screen->scene->transform_spaces);
- screen->scene = NULL;
- }
+ BLI_assert(BLI_listbase_is_empty(&bmain->workspaces));
+
+ do_version_workspaces_create_from_screens(bmain);
+
+ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ bScreen *screen_parent = screen_parent_find(win->screen);
+ bScreen *screen = screen_parent ? screen_parent : win->screen;
+
+ if (screen->temp) {
+ /* We do not generate a new workspace for those screens... still need to set some data in win. */
+ win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
+ win->scene = screen->scene;
+ /* Deprecated from now on! */
+ win->screen = NULL;
+ continue;
+ }
+
+ WorkSpace *workspace = BLI_findstring(
+ &bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
+ BLI_assert(workspace != NULL);
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen);
+ BLI_assert(layout != NULL);
+
+ win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
+
+ BKE_workspace_active_set(win->workspace_hook, workspace);
+ BKE_workspace_active_layout_set(win->workspace_hook, layout);
+
+ /* Move scene and view layer to window. */
+ Scene *scene = screen->scene;
+ ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
+ if (!layer) {
+ layer = BKE_view_layer_default_view(scene);
+ }
+
+ win->scene = scene;
+ STRNCPY(win->view_layer_name, layer->name);
+
+ /* Deprecated from now on! */
+ win->screen = NULL;
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ /* Deprecated from now on! */
+ BLI_freelistN(&screen->scene->transform_spaces);
+ screen->scene = NULL;
+ }
}
#ifdef USE_COLLECTION_COMPAT_28
enum {
- COLLECTION_DEPRECATED_VISIBLE = (1 << 0),
- COLLECTION_DEPRECATED_VIEWPORT = (1 << 0),
- COLLECTION_DEPRECATED_SELECTABLE = (1 << 1),
- COLLECTION_DEPRECATED_DISABLED = (1 << 2),
- COLLECTION_DEPRECATED_RENDER = (1 << 3),
+ COLLECTION_DEPRECATED_VISIBLE = (1 << 0),
+ COLLECTION_DEPRECATED_VIEWPORT = (1 << 0),
+ COLLECTION_DEPRECATED_SELECTABLE = (1 << 1),
+ COLLECTION_DEPRECATED_DISABLED = (1 << 2),
+ COLLECTION_DEPRECATED_RENDER = (1 << 3),
};
static void do_version_view_layer_visibility(ViewLayer *view_layer)
{
- /* Convert from deprecated VISIBLE flag to DISABLED */
- LayerCollection *lc;
- for (lc = view_layer->layer_collections.first;
- lc;
- lc = lc->next)
- {
- if (lc->flag & COLLECTION_DEPRECATED_DISABLED) {
- lc->flag &= ~COLLECTION_DEPRECATED_DISABLED;
- }
-
- if ((lc->flag & COLLECTION_DEPRECATED_VISIBLE) == 0) {
- lc->flag |= COLLECTION_DEPRECATED_DISABLED;
- }
-
- lc->flag |= COLLECTION_DEPRECATED_VIEWPORT | COLLECTION_DEPRECATED_RENDER;
- }
+ /* Convert from deprecated VISIBLE flag to DISABLED */
+ LayerCollection *lc;
+ for (lc = view_layer->layer_collections.first; lc; lc = lc->next) {
+ if (lc->flag & COLLECTION_DEPRECATED_DISABLED) {
+ lc->flag &= ~COLLECTION_DEPRECATED_DISABLED;
+ }
+
+ if ((lc->flag & COLLECTION_DEPRECATED_VISIBLE) == 0) {
+ lc->flag |= COLLECTION_DEPRECATED_DISABLED;
+ }
+
+ lc->flag |= COLLECTION_DEPRECATED_VIEWPORT | COLLECTION_DEPRECATED_RENDER;
+ }
}
-static void do_version_layer_collection_pre(
- ViewLayer *view_layer,
- ListBase *lb,
- GSet *enabled_set,
- GSet *selectable_set)
+static void do_version_layer_collection_pre(ViewLayer *view_layer,
+ ListBase *lb,
+ GSet *enabled_set,
+ GSet *selectable_set)
{
- /* Convert from deprecated DISABLED to new layer collection and collection flags */
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
- if (lc->scene_collection) {
- if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) {
- BLI_gset_insert(enabled_set, lc->scene_collection);
- }
- if (lc->flag & COLLECTION_DEPRECATED_SELECTABLE) {
- BLI_gset_insert(selectable_set, lc->scene_collection);
- }
- }
-
- do_version_layer_collection_pre(view_layer, &lc->layer_collections, enabled_set, selectable_set);
- }
+ /* Convert from deprecated DISABLED to new layer collection and collection flags */
+ for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ if (lc->scene_collection) {
+ if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) {
+ BLI_gset_insert(enabled_set, lc->scene_collection);
+ }
+ if (lc->flag & COLLECTION_DEPRECATED_SELECTABLE) {
+ BLI_gset_insert(selectable_set, lc->scene_collection);
+ }
+ }
+
+ do_version_layer_collection_pre(
+ view_layer, &lc->layer_collections, enabled_set, selectable_set);
+ }
}
-static void do_version_layer_collection_post(
- ViewLayer *view_layer,
- ListBase *lb,
- GSet *enabled_set,
- GSet *selectable_set,
- GHash *collection_map)
+static void do_version_layer_collection_post(ViewLayer *view_layer,
+ ListBase *lb,
+ GSet *enabled_set,
+ GSet *selectable_set,
+ GHash *collection_map)
{
- /* Apply layer collection exclude flags. */
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
- if (!(lc->collection->flag & COLLECTION_IS_MASTER)) {
- SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection);
- const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc));
- const bool selectable = (sc && BLI_gset_haskey(selectable_set, sc));
-
- if (!enabled) {
- lc->flag |= LAYER_COLLECTION_EXCLUDE;
- }
- if (enabled && !selectable) {
- lc->collection->flag |= COLLECTION_RESTRICT_SELECT;
- }
- }
-
- do_version_layer_collection_post(
- view_layer, &lc->layer_collections, enabled_set, selectable_set, collection_map);
- }
+ /* Apply layer collection exclude flags. */
+ for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ if (!(lc->collection->flag & COLLECTION_IS_MASTER)) {
+ SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection);
+ const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc));
+ const bool selectable = (sc && BLI_gset_haskey(selectable_set, sc));
+
+ if (!enabled) {
+ lc->flag |= LAYER_COLLECTION_EXCLUDE;
+ }
+ if (enabled && !selectable) {
+ lc->collection->flag |= COLLECTION_RESTRICT_SELECT;
+ }
+ }
+
+ do_version_layer_collection_post(
+ view_layer, &lc->layer_collections, enabled_set, selectable_set, collection_map);
+ }
}
static void do_version_scene_collection_convert(
- Main *bmain,
- ID *id,
- SceneCollection *sc,
- Collection *collection,
- GHash *collection_map)
+ Main *bmain, ID *id, SceneCollection *sc, Collection *collection, GHash *collection_map)
{
- if (collection_map) {
- BLI_ghash_insert(collection_map, collection, sc);
- }
-
- for (SceneCollection *nsc = sc->scene_collections.first; nsc;) {
- SceneCollection *nsc_next = nsc->next;
- Collection *ncollection = BKE_collection_add(bmain, collection, nsc->name);
- ncollection->id.lib = id->lib;
- do_version_scene_collection_convert(bmain, id, nsc, ncollection, collection_map);
- nsc = nsc_next;
- }
-
- for (LinkData *link = sc->objects.first; link; link = link->next) {
- Object *ob = link->data;
- if (ob) {
- BKE_collection_object_add(bmain, collection, ob);
- id_us_min(&ob->id);
- }
- }
-
- BLI_freelistN(&sc->objects);
- MEM_freeN(sc);
+ if (collection_map) {
+ BLI_ghash_insert(collection_map, collection, sc);
+ }
+
+ for (SceneCollection *nsc = sc->scene_collections.first; nsc;) {
+ SceneCollection *nsc_next = nsc->next;
+ Collection *ncollection = BKE_collection_add(bmain, collection, nsc->name);
+ ncollection->id.lib = id->lib;
+ do_version_scene_collection_convert(bmain, id, nsc, ncollection, collection_map);
+ nsc = nsc_next;
+ }
+
+ for (LinkData *link = sc->objects.first; link; link = link->next) {
+ Object *ob = link->data;
+ if (ob) {
+ BKE_collection_object_add(bmain, collection, ob);
+ id_us_min(&ob->id);
+ }
+ }
+
+ BLI_freelistN(&sc->objects);
+ MEM_freeN(sc);
}
static void do_version_group_collection_to_collection(Main *bmain, Collection *group)
{
- /* Convert old 2.8 group collections to new unified collections. */
- if (group->collection) {
- do_version_scene_collection_convert(bmain, &group->id, group->collection, group, NULL);
- }
-
- group->collection = NULL;
- group->view_layer = NULL;
- id_fake_user_set(&group->id);
+ /* Convert old 2.8 group collections to new unified collections. */
+ if (group->collection) {
+ do_version_scene_collection_convert(bmain, &group->id, group->collection, group, NULL);
+ }
+
+ group->collection = NULL;
+ group->view_layer = NULL;
+ id_fake_user_set(&group->id);
}
static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene)
{
- /* Convert old 2.8 scene collections to new unified collections. */
+ /* Convert old 2.8 scene collections to new unified collections. */
- /* Temporarily clear view layers so we don't do any layer collection syncing
- * and destroy old flags that we want to restore. */
- ListBase view_layers = scene->view_layers;
- BLI_listbase_clear(&scene->view_layers);
+ /* Temporarily clear view layers so we don't do any layer collection syncing
+ * and destroy old flags that we want to restore. */
+ ListBase view_layers = scene->view_layers;
+ BLI_listbase_clear(&scene->view_layers);
- if (!scene->master_collection) {
- scene->master_collection = BKE_collection_master_add();
- }
+ if (!scene->master_collection) {
+ scene->master_collection = BKE_collection_master_add();
+ }
- /* Convert scene collections. */
- GHash *collection_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- if (scene->collection) {
- do_version_scene_collection_convert(bmain, &scene->id, scene->collection, scene->master_collection, collection_map);
- scene->collection = NULL;
- }
+ /* Convert scene collections. */
+ GHash *collection_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ if (scene->collection) {
+ do_version_scene_collection_convert(
+ bmain, &scene->id, scene->collection, scene->master_collection, collection_map);
+ scene->collection = NULL;
+ }
- scene->view_layers = view_layers;
+ scene->view_layers = view_layers;
- /* Convert layer collections. */
- ViewLayer *view_layer;
- for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
- GSet *enabled_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- GSet *selectable_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ /* Convert layer collections. */
+ ViewLayer *view_layer;
+ for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+ GSet *enabled_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ GSet *selectable_set = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- do_version_layer_collection_pre(
- view_layer, &view_layer->layer_collections, enabled_set, selectable_set);
+ do_version_layer_collection_pre(
+ view_layer, &view_layer->layer_collections, enabled_set, selectable_set);
- BKE_layer_collection_sync(scene, view_layer);
+ BKE_layer_collection_sync(scene, view_layer);
- do_version_layer_collection_post(
- view_layer, &view_layer->layer_collections, enabled_set, selectable_set, collection_map);
+ do_version_layer_collection_post(
+ view_layer, &view_layer->layer_collections, enabled_set, selectable_set, collection_map);
- BLI_gset_free(enabled_set, NULL);
- BLI_gset_free(selectable_set, NULL);
+ BLI_gset_free(enabled_set, NULL);
+ BLI_gset_free(selectable_set, NULL);
- BKE_layer_collection_sync(scene, view_layer);
- }
+ BKE_layer_collection_sync(scene, view_layer);
+ }
- BLI_ghash_free(collection_map, NULL, NULL);
+ BLI_ghash_free(collection_map, NULL, NULL);
}
#endif
-
static void do_version_layers_to_collections(Main *bmain, Scene *scene)
{
- /* Since we don't have access to FileData we check the (always valid) first
- * render layer instead. */
- if (!scene->master_collection) {
- scene->master_collection = BKE_collection_master_add();
- }
-
- if (scene->view_layers.first) {
- return;
- }
-
- /* Create collections from layers. */
- Collection *collection_master = BKE_collection_master(scene);
- Collection *collections[20] = {NULL};
-
- for (int layer = 0; layer < 20; layer++) {
- for (Base *base = scene->base.first; base; base = base->next) {
- if (base->lay & (1 << layer)) {
- /* Create collections when needed only. */
- if (collections[layer] == NULL) {
- char name[MAX_NAME];
-
- BLI_snprintf(name,
- sizeof(collection_master->id.name),
- DATA_("Collection %d"),
- layer + 1);
-
- Collection *collection = BKE_collection_add(bmain, collection_master, name);
- collection->id.lib = scene->id.lib;
- collections[layer] = collection;
-
- if (!(scene->lay & (1 << layer))) {
- collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
- }
- }
-
- /* Note usually this would do slow collection syncing for view layers,
- * but since no view layers exists yet at this point it's fast. */
- BKE_collection_object_add(
- bmain,
- collections[layer], base->object);
- }
-
- if (base->flag & SELECT) {
- base->object->flag |= SELECT;
- }
- else {
- base->object->flag &= ~SELECT;
- }
- }
- }
-
- /* Handle legacy render layers. */
- bool have_override = false;
- const bool need_default_renderlayer = scene->r.layers.first == NULL;
-
- for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
- ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name);
-
- if (srl->layflag & SCE_LAY_DISABLE) {
- view_layer->flag &= ~VIEW_LAYER_RENDER;
- }
-
- if ((srl->layflag & SCE_LAY_FRS) == 0) {
- view_layer->flag &= ~VIEW_LAYER_FREESTYLE;
- }
-
- view_layer->layflag = srl->layflag;
- view_layer->passflag = srl->passflag;
- view_layer->pass_alpha_threshold = srl->pass_alpha_threshold;
- view_layer->samples = srl->samples;
- view_layer->mat_override = srl->mat_override;
-
- BKE_freestyle_config_free(&view_layer->freestyle_config, true);
- view_layer->freestyle_config = srl->freestyleConfig;
- view_layer->id_properties = srl->prop;
-
- /* Set exclusion and overrides. */
- for (int layer = 0; layer < 20; layer++) {
- Collection *collection = collections[layer];
- if (collection) {
- LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer, collection);
-
- if (srl->lay_exclude & (1 << layer)) {
- /* Disable excluded layer. */
- have_override = true;
- lc->flag |= LAYER_COLLECTION_EXCLUDE;
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
- nlc->flag |= LAYER_COLLECTION_EXCLUDE;
- }
- }
- else {
- if (srl->lay_zmask & (1 << layer)) {
- have_override = true;
- lc->flag |= LAYER_COLLECTION_HOLDOUT;
- }
-
- if ((srl->lay & (1 << layer)) == 0) {
- have_override = true;
- lc->flag |= LAYER_COLLECTION_INDIRECT_ONLY;
- }
- }
- }
- }
-
- /* for convenience set the same active object in all the layers */
- if (scene->basact) {
- view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
- }
-
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
- base->flag |= BASE_SELECTED;
- }
- }
- }
-
- BLI_freelistN(&scene->r.layers);
-
- /* If render layers included overrides, or there are no render layers,
- * we also create a vanilla viewport layer. */
- if (have_override || need_default_renderlayer) {
- ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport");
-
- /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */
- if (!BLI_listbase_is_single(&scene->view_layers)) {
- view_layer->flag &= ~VIEW_LAYER_RENDER;
- }
-
- /* convert active base */
- if (scene->basact) {
- view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
- }
-
- /* convert selected bases */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
- base->flag |= BASE_SELECTED;
- }
-
- /* keep lay around for forward compatibility (open those files in 2.79) */
- base->lay = base->object->lay;
- }
- }
-
- /* remove bases once and for all */
- for (Base *base = scene->base.first; base; base = base->next) {
- id_us_min(&base->object->id);
- }
-
- BLI_freelistN(&scene->base);
- scene->basact = NULL;
+ /* Since we don't have access to FileData we check the (always valid) first
+ * render layer instead. */
+ if (!scene->master_collection) {
+ scene->master_collection = BKE_collection_master_add();
+ }
+
+ if (scene->view_layers.first) {
+ return;
+ }
+
+ /* Create collections from layers. */
+ Collection *collection_master = BKE_collection_master(scene);
+ Collection *collections[20] = {NULL};
+
+ for (int layer = 0; layer < 20; layer++) {
+ for (Base *base = scene->base.first; base; base = base->next) {
+ if (base->lay & (1 << layer)) {
+ /* Create collections when needed only. */
+ if (collections[layer] == NULL) {
+ char name[MAX_NAME];
+
+ BLI_snprintf(
+ name, sizeof(collection_master->id.name), DATA_("Collection %d"), layer + 1);
+
+ Collection *collection = BKE_collection_add(bmain, collection_master, name);
+ collection->id.lib = scene->id.lib;
+ collections[layer] = collection;
+
+ if (!(scene->lay & (1 << layer))) {
+ collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
+ }
+ }
+
+ /* Note usually this would do slow collection syncing for view layers,
+ * but since no view layers exists yet at this point it's fast. */
+ BKE_collection_object_add(bmain, collections[layer], base->object);
+ }
+
+ if (base->flag & SELECT) {
+ base->object->flag |= SELECT;
+ }
+ else {
+ base->object->flag &= ~SELECT;
+ }
+ }
+ }
+
+ /* Handle legacy render layers. */
+ bool have_override = false;
+ const bool need_default_renderlayer = scene->r.layers.first == NULL;
+
+ for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
+ ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name);
+
+ if (srl->layflag & SCE_LAY_DISABLE) {
+ view_layer->flag &= ~VIEW_LAYER_RENDER;
+ }
+
+ if ((srl->layflag & SCE_LAY_FRS) == 0) {
+ view_layer->flag &= ~VIEW_LAYER_FREESTYLE;
+ }
+
+ view_layer->layflag = srl->layflag;
+ view_layer->passflag = srl->passflag;
+ view_layer->pass_alpha_threshold = srl->pass_alpha_threshold;
+ view_layer->samples = srl->samples;
+ view_layer->mat_override = srl->mat_override;
+
+ BKE_freestyle_config_free(&view_layer->freestyle_config, true);
+ view_layer->freestyle_config = srl->freestyleConfig;
+ view_layer->id_properties = srl->prop;
+
+ /* Set exclusion and overrides. */
+ for (int layer = 0; layer < 20; layer++) {
+ Collection *collection = collections[layer];
+ if (collection) {
+ LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer,
+ collection);
+
+ if (srl->lay_exclude & (1 << layer)) {
+ /* Disable excluded layer. */
+ have_override = true;
+ lc->flag |= LAYER_COLLECTION_EXCLUDE;
+ for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ nlc->flag |= LAYER_COLLECTION_EXCLUDE;
+ }
+ }
+ else {
+ if (srl->lay_zmask & (1 << layer)) {
+ have_override = true;
+ lc->flag |= LAYER_COLLECTION_HOLDOUT;
+ }
+
+ if ((srl->lay & (1 << layer)) == 0) {
+ have_override = true;
+ lc->flag |= LAYER_COLLECTION_INDIRECT_ONLY;
+ }
+ }
+ }
+ }
+
+ /* for convenience set the same active object in all the layers */
+ if (scene->basact) {
+ view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
+ }
+
+ for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
+ base->flag |= BASE_SELECTED;
+ }
+ }
+ }
+
+ BLI_freelistN(&scene->r.layers);
+
+ /* If render layers included overrides, or there are no render layers,
+ * we also create a vanilla viewport layer. */
+ if (have_override || need_default_renderlayer) {
+ ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport");
+
+ /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */
+ if (!BLI_listbase_is_single(&scene->view_layers)) {
+ view_layer->flag &= ~VIEW_LAYER_RENDER;
+ }
+
+ /* convert active base */
+ if (scene->basact) {
+ view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
+ }
+
+ /* convert selected bases */
+ for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
+ base->flag |= BASE_SELECTED;
+ }
+
+ /* keep lay around for forward compatibility (open those files in 2.79) */
+ base->lay = base->object->lay;
+ }
+ }
+
+ /* remove bases once and for all */
+ for (Base *base = scene->base.first; base; base = base->next) {
+ id_us_min(&base->object->id);
+ }
+
+ BLI_freelistN(&scene->base);
+ scene->basact = NULL;
}
static void do_version_collection_propagate_lib_to_children(Collection *collection)
{
- if (collection->id.lib != NULL) {
- for (CollectionChild *collection_child = collection->children.first;
- collection_child != NULL;
- collection_child = collection_child->next)
- {
- if (collection_child->collection->id.lib == NULL) {
- collection_child->collection->id.lib = collection->id.lib;
- }
- do_version_collection_propagate_lib_to_children(collection_child->collection);
- }
- }
+ if (collection->id.lib != NULL) {
+ for (CollectionChild *collection_child = collection->children.first; collection_child != NULL;
+ collection_child = collection_child->next) {
+ if (collection_child->collection->id.lib == NULL) {
+ collection_child->collection->id.lib = collection->id.lib;
+ }
+ do_version_collection_propagate_lib_to_children(collection_child->collection);
+ }
+ }
}
/** convert old annotations colors */
static void do_versions_fix_annotations(bGPdata *gpd)
{
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
- /* fix layers */
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* unlock/unhide layer */
- gpl->flag &= ~GP_LAYER_LOCKED;
- gpl->flag &= ~GP_LAYER_HIDE;
- /* set opacity to 1 */
- gpl->opacity = 1.0f;
- /* disable tint */
- gpl->tintcolor[3] = 0.0f;
-
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- if ((gps->colorname[0] != '\0') &&
- (STREQ(gps->colorname, palcolor->info)))
- {
- /* copy color settings */
- copy_v4_v4(gpl->color, palcolor->color);
- }
- }
- }
- }
- }
- }
+ for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
+ for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ /* fix layers */
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* unlock/unhide layer */
+ gpl->flag &= ~GP_LAYER_LOCKED;
+ gpl->flag &= ~GP_LAYER_HIDE;
+ /* set opacity to 1 */
+ gpl->opacity = 1.0f;
+ /* disable tint */
+ gpl->tintcolor[3] = 0.0f;
+
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ if ((gps->colorname[0] != '\0') && (STREQ(gps->colorname, palcolor->info))) {
+ /* copy color settings */
+ copy_v4_v4(gpl->color, palcolor->color);
+ }
+ }
+ }
+ }
+ }
+ }
}
void do_versions_after_linking_280(Main *bmain)
{
- bool use_collection_compat_28 = true;
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- use_collection_compat_28 = false;
-
- /* Convert group layer visibility flags to hidden nested collection. */
- for (Collection *collection = bmain->collections.first; collection; collection = collection->id.next) {
- /* Add fake user for all existing groups. */
- id_fake_user_set(&collection->id);
-
- if (collection->flag & (COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER)) {
- continue;
- }
-
- Collection *hidden_collection_array[20] = {NULL};
- for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
- cob_next = cob->next;
- Object *ob = cob->ob;
-
- if (!(ob->lay & collection->layer)) {
- /* Find or create hidden collection matching object's first layer. */
- Collection **collection_hidden = NULL;
- int coll_idx = 0;
- for (; coll_idx < 20; coll_idx++) {
- if (ob->lay & (1 << coll_idx)) {
- collection_hidden = &hidden_collection_array[coll_idx];
- break;
- }
- }
- BLI_assert(collection_hidden != NULL);
-
- if (*collection_hidden == NULL) {
- char name[MAX_ID_NAME];
- BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1);
- *collection_hidden = BKE_collection_add(bmain, collection, name);
- (*collection_hidden)->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
- }
-
- BKE_collection_object_add(bmain, *collection_hidden, ob);
- BKE_collection_object_remove(bmain, collection, ob, true);
- }
- }
- }
-
- /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll
- * end up with several datablocks sharing same name/library, which is FORBIDDEN!
- * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */
- for (Collection *collection = bmain->collections.first; collection != NULL; collection = collection->id.next) {
- do_version_collection_propagate_lib_to_children(collection);
- }
-
- /* Convert layers to collections. */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- do_version_layers_to_collections(bmain, scene);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- /* same render-layer as do_version_workspaces_after_lib_link will activate,
- * so same layer as BKE_view_layer_default_view would return */
- ViewLayer *layer = screen->scene->view_layers.first;
-
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
- if (space->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)space;
-
- soutliner->outlinevis = SO_VIEW_LAYER;
-
- if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) {
- if (soutliner->treestore == NULL) {
- soutliner->treestore = BLI_mempool_create(
- sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
- }
-
- /* Create a tree store element for the collection. This is normally
- * done in check_persistent (outliner_tree.c), but we need to access
- * it here :/ (expand element if it's the only one) */
- TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore);
- tselem->type = TSE_LAYER_COLLECTION;
- tselem->id = layer->layer_collections.first;
- tselem->nr = tselem->used = 0;
- tselem->flag &= ~TSE_CLOSED;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
- if (space->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)space;
- if ((sima) && (sima->gpd)) {
- sima->gpd->flag |= GP_DATA_ANNOTATIONS;
- do_versions_fix_annotations(sima->gpd);
- }
- }
- if (space->spacetype == SPACE_CLIP) {
- SpaceClip *spclip = (SpaceClip *)space;
- MovieClip *clip = spclip->clip;
- if ((clip) && (clip->gpd)) {
- clip->gpd->flag |= GP_DATA_ANNOTATIONS;
- do_versions_fix_annotations(clip->gpd);
- }
- }
- }
- }
- }
- }
-
- /* New workspace design */
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
- do_version_workspaces_after_lib_link(bmain);
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
- /* Cleanup any remaining SceneRenderLayer data for files that were created
- * with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
- if (srl->prop) {
- IDP_FreeProperty(srl->prop);
- MEM_freeN(srl->prop);
- }
- BKE_freestyle_config_free(&srl->freestyleConfig, true);
- }
- BLI_freelistN(&scene->r.layers);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
- /* Due to several changes to particle RNA and draw code particles from older files may no longer
- * be visible. Here we correct this by setting a default draw size for those files. */
- for (Object *object = bmain->objects.first; object; object = object->id.next) {
- for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
- if (psys->part->draw_size == 0.0f) {
- psys->part->draw_size = 0.1f;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
- for (Object *object = bmain->objects.first; object; object = object->id.next) {
- if (object->particlesystem.first) {
- object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
- for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
- if (psys->part->draw & PART_DRAW_EMITTER) {
- object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
- break;
- }
- }
- }
- else if (object->transflag & OB_DUPLI) {
- object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
- }
- else {
- object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER;
- }
- }
-
- /* Cleanup deprecated flag from particlesettings data-blocks. */
- for (ParticleSettings *part = bmain->particles.first; part; part = part->id.next) {
- part->draw &= ~PART_DRAW_EMITTER;
- }
- }
-
- /* SpaceTime & SpaceLogic removal/replacing */
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 9)) {
- const wmWindowManager *wm = bmain->wm.first;
- const Scene *scene = bmain->scenes.first;
-
- if (wm != NULL) {
- /* Action editors need a scene for creation. First, update active
- * screens using the active scene of the window they're displayed in.
- * Next, update remaining screens using first scene in main listbase. */
-
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
- do_version_area_change_space_to_space_action(area, win->scene);
-
- /* Don't forget to unset! */
- area->butspacetype = SPACE_EMPTY;
- }
- }
- }
- }
- if (scene != NULL) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
- /* Areas that were already handled won't be handled again */
- do_version_area_change_space_to_space_action(area, scene);
-
- /* Don't forget to unset! */
- area->butspacetype = SPACE_EMPTY;
- }
- }
- }
- }
- }
+ bool use_collection_compat_28 = true;
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ use_collection_compat_28 = false;
+
+ /* Convert group layer visibility flags to hidden nested collection. */
+ for (Collection *collection = bmain->collections.first; collection;
+ collection = collection->id.next) {
+ /* Add fake user for all existing groups. */
+ id_fake_user_set(&collection->id);
+
+ if (collection->flag & (COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER)) {
+ continue;
+ }
+
+ Collection *hidden_collection_array[20] = {NULL};
+ for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob;
+ cob = cob_next) {
+ cob_next = cob->next;
+ Object *ob = cob->ob;
+
+ if (!(ob->lay & collection->layer)) {
+ /* Find or create hidden collection matching object's first layer. */
+ Collection **collection_hidden = NULL;
+ int coll_idx = 0;
+ for (; coll_idx < 20; coll_idx++) {
+ if (ob->lay & (1 << coll_idx)) {
+ collection_hidden = &hidden_collection_array[coll_idx];
+ break;
+ }
+ }
+ BLI_assert(collection_hidden != NULL);
+
+ if (*collection_hidden == NULL) {
+ char name[MAX_ID_NAME];
+ BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1);
+ *collection_hidden = BKE_collection_add(bmain, collection, name);
+ (*collection_hidden)->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
+ }
+
+ BKE_collection_object_add(bmain, *collection_hidden, ob);
+ BKE_collection_object_remove(bmain, collection, ob, true);
+ }
+ }
+ }
+
+ /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll
+ * end up with several datablocks sharing same name/library, which is FORBIDDEN!
+ * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */
+ for (Collection *collection = bmain->collections.first; collection != NULL;
+ collection = collection->id.next) {
+ do_version_collection_propagate_lib_to_children(collection);
+ }
+
+ /* Convert layers to collections. */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ do_version_layers_to_collections(bmain, scene);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ /* same render-layer as do_version_workspaces_after_lib_link will activate,
+ * so same layer as BKE_view_layer_default_view would return */
+ ViewLayer *layer = screen->scene->view_layers.first;
+
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
+ if (space->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *soutliner = (SpaceOutliner *)space;
+
+ soutliner->outlinevis = SO_VIEW_LAYER;
+
+ if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) {
+ if (soutliner->treestore == NULL) {
+ soutliner->treestore = BLI_mempool_create(
+ sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
+ }
+
+ /* Create a tree store element for the collection. This is normally
+ * done in check_persistent (outliner_tree.c), but we need to access
+ * it here :/ (expand element if it's the only one) */
+ TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore);
+ tselem->type = TSE_LAYER_COLLECTION;
+ tselem->id = layer->layer_collections.first;
+ tselem->nr = tselem->used = 0;
+ tselem->flag &= ~TSE_CLOSED;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *space = sa->spacedata.first; space; space = space->next) {
+ if (space->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)space;
+ if ((sima) && (sima->gpd)) {
+ sima->gpd->flag |= GP_DATA_ANNOTATIONS;
+ do_versions_fix_annotations(sima->gpd);
+ }
+ }
+ if (space->spacetype == SPACE_CLIP) {
+ SpaceClip *spclip = (SpaceClip *)space;
+ MovieClip *clip = spclip->clip;
+ if ((clip) && (clip->gpd)) {
+ clip->gpd->flag |= GP_DATA_ANNOTATIONS;
+ do_versions_fix_annotations(clip->gpd);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* New workspace design */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
+ do_version_workspaces_after_lib_link(bmain);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
+ /* Cleanup any remaining SceneRenderLayer data for files that were created
+ * with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
+ if (srl->prop) {
+ IDP_FreeProperty(srl->prop);
+ MEM_freeN(srl->prop);
+ }
+ BKE_freestyle_config_free(&srl->freestyleConfig, true);
+ }
+ BLI_freelistN(&scene->r.layers);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+ /* Due to several changes to particle RNA and draw code particles from older files may no longer
+ * be visible. Here we correct this by setting a default draw size for those files. */
+ for (Object *object = bmain->objects.first; object; object = object->id.next) {
+ for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
+ if (psys->part->draw_size == 0.0f) {
+ psys->part->draw_size = 0.1f;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
+ for (Object *object = bmain->objects.first; object; object = object->id.next) {
+ if (object->particlesystem.first) {
+ object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
+ for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
+ if (psys->part->draw & PART_DRAW_EMITTER) {
+ object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
+ break;
+ }
+ }
+ }
+ else if (object->transflag & OB_DUPLI) {
+ object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
+ }
+ else {
+ object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER;
+ }
+ }
+
+ /* Cleanup deprecated flag from particlesettings data-blocks. */
+ for (ParticleSettings *part = bmain->particles.first; part; part = part->id.next) {
+ part->draw &= ~PART_DRAW_EMITTER;
+ }
+ }
+
+ /* SpaceTime & SpaceLogic removal/replacing */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 9)) {
+ const wmWindowManager *wm = bmain->wm.first;
+ const Scene *scene = bmain->scenes.first;
+
+ if (wm != NULL) {
+ /* Action editors need a scene for creation. First, update active
+ * screens using the active scene of the window they're displayed in.
+ * Next, update remaining screens using first scene in main listbase. */
+
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
+ do_version_area_change_space_to_space_action(area, win->scene);
+
+ /* Don't forget to unset! */
+ area->butspacetype = SPACE_EMPTY;
+ }
+ }
+ }
+ }
+ if (scene != NULL) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
+ /* Areas that were already handled won't be handled again */
+ do_version_area_change_space_to_space_action(area, scene);
+
+ /* Don't forget to unset! */
+ area->butspacetype = SPACE_EMPTY;
+ }
+ }
+ }
+ }
+ }
#ifdef USE_COLLECTION_COMPAT_28
- if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
- for (Collection *group = bmain->collections.first; group; group = group->id.next) {
- do_version_group_collection_to_collection(bmain, group);
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- do_version_scene_collection_to_collection(bmain, scene);
- }
- }
+ if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
+ for (Collection *group = bmain->collections.first; group; group = group->id.next) {
+ do_version_group_collection_to_collection(bmain, group);
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ do_version_scene_collection_to_collection(bmain, scene);
+ }
+ }
#endif
- /* Update Curve object Shape Key data layout to include the Radius property */
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 23)) {
- for (Curve *cu = bmain->curves.first; cu; cu = cu->id.next) {
- if (!cu->key || cu->key->elemsize != sizeof(float[4]))
- continue;
-
- cu->key->elemstr[0] = 3; /*KEYELEM_ELEM_SIZE_CURVE*/
- cu->key->elemsize = sizeof(float[3]);
-
- int new_count = BKE_keyblock_curve_element_count(&cu->nurb);
-
- for (KeyBlock *block = cu->key->block.first; block; block = block->next) {
- int old_count = block->totelem;
- void *old_data = block->data;
-
- if (!old_data || old_count <= 0)
- continue;
-
- block->totelem = new_count;
- block->data = MEM_callocN(sizeof(float[3]) * new_count, __func__);
-
- float *oldptr = old_data;
- float (*newptr)[3] = block->data;
-
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
- if (nu->bezt) {
- BezTriple *bezt = nu->bezt;
-
- for (int a = 0; a < nu->pntsu; a++, bezt++) {
- if ((old_count -= 3) < 0) {
- memcpy(newptr, bezt->vec, sizeof(float[3][3]));
- newptr[3][0] = bezt->tilt;
- }
- else {
- memcpy(newptr, oldptr, sizeof(float[3][4]));
- }
-
- newptr[3][1] = bezt->radius;
-
- oldptr += 3 * 4;
- newptr += 4; /*KEYELEM_ELEM_LEN_BEZTRIPLE*/
- }
- }
- else if (nu->bp) {
- BPoint *bp = nu->bp;
-
- for (int a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- if (--old_count < 0) {
- copy_v3_v3(newptr[0], bp->vec);
- newptr[1][0] = bp->tilt;
- }
- else {
- memcpy(newptr, oldptr, sizeof(float[4]));
- }
-
- newptr[1][1] = bp->radius;
-
- oldptr += 4;
- newptr += 2; /*KEYELEM_ELEM_LEN_BPOINT*/
- }
- }
- }
-
- MEM_freeN(old_data);
- }
- }
- }
-
- /* Move B-Bone custom handle settings from bPoseChannel to Bone. */
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- bArmature *arm = ob->data;
-
- /* If it is an armature from the same file. */
- if (ob->pose && arm && arm->id.lib == ob->id.lib) {
- bool rebuild = false;
-
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* If the 2.7 flag is enabled, processing is needed. */
- if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
- /* If the settings in the Bone are not set, copy. */
- if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO &&
- pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO &&
- pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL)
- {
- pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE;
- pchan->bone->bbone_next_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE;
-
- if (pchan->bbone_prev) {
- pchan->bone->bbone_prev = pchan->bbone_prev->bone;
- }
- if (pchan->bbone_next) {
- pchan->bone->bbone_next = pchan->bbone_next->bone;
- }
- }
-
- rebuild = true;
- pchan->bboneflag = 0;
- }
- }
-
- /* Tag pose rebuild for all objects that use this armature. */
- if (rebuild) {
- for (Object *ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
- if (ob2->pose && ob2->data == arm) {
- ob2->pose->flag |= POSE_RECALC;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
- for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->gpencil_settings != NULL) {
- brush->gpencil_tool = brush->gpencil_settings->brush_type;
- }
- }
- BKE_paint_toolslots_init_from_main(bmain);
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
- /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- RigidBodyWorld *rbw = scene->rigidbody_world;
-
- if (rbw == NULL) {
- continue;
- }
-
- BKE_rigidbody_objects_collection_validate(scene, rbw);
- BKE_rigidbody_constraints_collection_validate(scene, rbw);
- }
- }
+ /* Update Curve object Shape Key data layout to include the Radius property */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 23)) {
+ for (Curve *cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (!cu->key || cu->key->elemsize != sizeof(float[4]))
+ continue;
+
+ cu->key->elemstr[0] = 3; /*KEYELEM_ELEM_SIZE_CURVE*/
+ cu->key->elemsize = sizeof(float[3]);
+
+ int new_count = BKE_keyblock_curve_element_count(&cu->nurb);
+
+ for (KeyBlock *block = cu->key->block.first; block; block = block->next) {
+ int old_count = block->totelem;
+ void *old_data = block->data;
+
+ if (!old_data || old_count <= 0)
+ continue;
+
+ block->totelem = new_count;
+ block->data = MEM_callocN(sizeof(float[3]) * new_count, __func__);
+
+ float *oldptr = old_data;
+ float(*newptr)[3] = block->data;
+
+ for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu->bezt) {
+ BezTriple *bezt = nu->bezt;
+
+ for (int a = 0; a < nu->pntsu; a++, bezt++) {
+ if ((old_count -= 3) < 0) {
+ memcpy(newptr, bezt->vec, sizeof(float[3][3]));
+ newptr[3][0] = bezt->tilt;
+ }
+ else {
+ memcpy(newptr, oldptr, sizeof(float[3][4]));
+ }
+
+ newptr[3][1] = bezt->radius;
+
+ oldptr += 3 * 4;
+ newptr += 4; /*KEYELEM_ELEM_LEN_BEZTRIPLE*/
+ }
+ }
+ else if (nu->bp) {
+ BPoint *bp = nu->bp;
+
+ for (int a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
+ if (--old_count < 0) {
+ copy_v3_v3(newptr[0], bp->vec);
+ newptr[1][0] = bp->tilt;
+ }
+ else {
+ memcpy(newptr, oldptr, sizeof(float[4]));
+ }
+
+ newptr[1][1] = bp->radius;
+
+ oldptr += 4;
+ newptr += 2; /*KEYELEM_ELEM_LEN_BPOINT*/
+ }
+ }
+ }
+
+ MEM_freeN(old_data);
+ }
+ }
+ }
+
+ /* Move B-Bone custom handle settings from bPoseChannel to Bone. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bArmature *arm = ob->data;
+
+ /* If it is an armature from the same file. */
+ if (ob->pose && arm && arm->id.lib == ob->id.lib) {
+ bool rebuild = false;
+
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* If the 2.7 flag is enabled, processing is needed. */
+ if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
+ /* If the settings in the Bone are not set, copy. */
+ if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO &&
+ pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO &&
+ pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL) {
+ pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ?
+ BBONE_HANDLE_RELATIVE :
+ BBONE_HANDLE_ABSOLUTE;
+ pchan->bone->bbone_next_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ?
+ BBONE_HANDLE_RELATIVE :
+ BBONE_HANDLE_ABSOLUTE;
+
+ if (pchan->bbone_prev) {
+ pchan->bone->bbone_prev = pchan->bbone_prev->bone;
+ }
+ if (pchan->bbone_next) {
+ pchan->bone->bbone_next = pchan->bbone_next->bone;
+ }
+ }
+
+ rebuild = true;
+ pchan->bboneflag = 0;
+ }
+ }
+
+ /* Tag pose rebuild for all objects that use this armature. */
+ if (rebuild) {
+ for (Object *ob2 = bmain->objects.first; ob2; ob2 = ob2->id.next) {
+ if (ob2->pose && ob2->data == arm) {
+ ob2->pose->flag |= POSE_RECALC;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
+ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->gpencil_settings != NULL) {
+ brush->gpencil_tool = brush->gpencil_settings->brush_type;
+ }
+ }
+ BKE_paint_toolslots_init_from_main(bmain);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
+ /* Ensure we get valid rigidbody object/constraint data in relevant collections' objects. */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ RigidBodyWorld *rbw = scene->rigidbody_world;
+
+ if (rbw == NULL) {
+ continue;
+ }
+
+ BKE_rigidbody_objects_collection_validate(scene, rbw);
+ BKE_rigidbody_constraints_collection_validate(scene, rbw);
+ }
+ }
}
/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already.
* But in 2.79 another case generating non-unique names was discovered (see T55668, involving Meta strips)... */
static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
{
- for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
- BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
- if (seq->seqbase.first != NULL) {
- do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
- }
- }
+ for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
+ BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
+ if (seq->seqbase.first != NULL) {
+ do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
+ }
+ }
}
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
- bool use_collection_compat_28 = true;
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- use_collection_compat_28 = false;
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->r.gauss = 1.5f;
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "bleedexp")) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->bleedexp = 2.5f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
- for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
- ca->gpu_dof.ratio = 1.0f;
- }
- }
-
- /* MTexPoly now removed. */
- if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
- const int cd_mtexpoly = 15; /* CD_MTEXPOLY, deprecated */
- for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
- /* If we have UV's, so this file will have MTexPoly layers too! */
- if (me->mloopuv != NULL) {
- CustomData_update_typemap(&me->pdata);
- CustomData_free_layers(&me->pdata, cd_mtexpoly, me->totpoly);
- BKE_mesh_update_customdata_pointers(me, false);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "cascade_max_dist")) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->cascade_max_dist = 1000.0f;
- la->cascade_count = 4;
- la->cascade_exponent = 0.8f;
- la->cascade_fade = 0.1f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "contact_dist")) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->contact_dist = 0.2f;
- la->contact_bias = 0.03f;
- la->contact_spread = 0.2f;
- la->contact_thickness = 0.2f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "vis_bias")) {
- for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
- probe->vis_bias = 1.0f;
- probe->vis_blur = 0.2f;
- }
- }
-
- typedef enum eNTreeDoVersionErrors {
- NTREE_DOVERSION_NO_ERROR = 0,
- NTREE_DOVERSION_NEED_OUTPUT = (1 << 0),
- NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1),
- } eNTreeDoVersionErrors;
-
- /* Eevee shader nodes renamed because of the output node system.
- * Note that a new output node is not being added here, because it would be overkill
- * to handle this case in lib_verify_nodetree.
- *
- * Also, metallic node is now unified into the principled node. */
- eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
- STREQ(node->idname, "ShaderNodeOutputMetallic"))
- {
- BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
- error |= NTREE_DOVERSION_NEED_OUTPUT;
- }
-
- else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) {
- BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
- error |= NTREE_DOVERSION_NEED_OUTPUT;
- }
-
- else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ &&
- STREQ(node->idname, "ShaderNodeOutputEeveeMaterial"))
- {
- node->type = SH_NODE_OUTPUT_MATERIAL;
- BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname));
- }
-
- else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
- STREQ(node->idname, "ShaderNodeEeveeMetallic"))
- {
- node->type = SH_NODE_BSDF_PRINCIPLED;
- BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname));
- node->custom1 = SHD_GLOSSY_MULTI_GGX;
- error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION;
- }
- }
- }
- } FOREACH_NODETREE_END;
-
- if (error & NTREE_DOVERSION_NEED_OUTPUT) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
- printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
- }
-
- if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
- printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n");
- }
+ bool use_collection_compat_28 = true;
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ use_collection_compat_28 = false;
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->r.gauss = 1.5f;
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "bleedexp")) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->bleedexp = 2.5f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio")) {
+ for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
+ ca->gpu_dof.ratio = 1.0f;
+ }
+ }
+
+ /* MTexPoly now removed. */
+ if (DNA_struct_find(fd->filesdna, "MTexPoly")) {
+ const int cd_mtexpoly = 15; /* CD_MTEXPOLY, deprecated */
+ for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
+ /* If we have UV's, so this file will have MTexPoly layers too! */
+ if (me->mloopuv != NULL) {
+ CustomData_update_typemap(&me->pdata);
+ CustomData_free_layers(&me->pdata, cd_mtexpoly, me->totpoly);
+ BKE_mesh_update_customdata_pointers(me, false);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 2)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "cascade_max_dist")) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->cascade_max_dist = 1000.0f;
+ la->cascade_count = 4;
+ la->cascade_exponent = 0.8f;
+ la->cascade_fade = 0.1f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "contact_dist")) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->contact_dist = 0.2f;
+ la->contact_bias = 0.03f;
+ la->contact_spread = 0.2f;
+ la->contact_thickness = 0.2f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "vis_bias")) {
+ for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
+ probe->vis_bias = 1.0f;
+ probe->vis_blur = 0.2f;
+ }
+ }
+
+ typedef enum eNTreeDoVersionErrors {
+ NTREE_DOVERSION_NO_ERROR = 0,
+ NTREE_DOVERSION_NEED_OUTPUT = (1 << 0),
+ NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1),
+ } eNTreeDoVersionErrors;
+
+ /* Eevee shader nodes renamed because of the output node system.
+ * Note that a new output node is not being added here, because it would be overkill
+ * to handle this case in lib_verify_nodetree.
+ *
+ * Also, metallic node is now unified into the principled node. */
+ eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
+ STREQ(node->idname, "ShaderNodeOutputMetallic")) {
+ BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
+ error |= NTREE_DOVERSION_NEED_OUTPUT;
+ }
+
+ else if (node->type == SH_NODE_EEVEE_SPECULAR &&
+ STREQ(node->idname, "ShaderNodeOutputSpecular")) {
+ BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
+ error |= NTREE_DOVERSION_NEED_OUTPUT;
+ }
+
+ else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ &&
+ STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) {
+ node->type = SH_NODE_OUTPUT_MATERIAL;
+ BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname));
+ }
+
+ else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
+ STREQ(node->idname, "ShaderNodeEeveeMetallic")) {
+ node->type = SH_NODE_BSDF_PRINCIPLED;
+ BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname));
+ node->custom1 = SHD_GLOSSY_MULTI_GGX;
+ error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+
+ if (error & NTREE_DOVERSION_NEED_OUTPUT) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf(
+ "You need to connect Principled and Eevee Specular shader nodes to new material output "
+ "nodes.\n");
+ }
+
+ if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf(
+ "You need to combine transparency and emission shaders to the converted Principled "
+ "shader nodes.\n");
+ }
#ifdef USE_COLLECTION_COMPAT_28
- if (use_collection_compat_28 &&
- (DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) &&
- DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers"))
- {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ViewLayer *view_layer;
- for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
- view_layer->flag |= VIEW_LAYER_FREESTYLE;
- view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */
- view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
- view_layer->pass_alpha_threshold = 0.5f;
- BKE_freestyle_config_init(&view_layer->freestyle_config);
- }
- }
- }
+ if (use_collection_compat_28 &&
+ (DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") ==
+ false) &&
+ DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ViewLayer *view_layer;
+ for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+ view_layer->flag |= VIEW_LAYER_FREESTYLE;
+ view_layer->layflag = 0x7FFF; /* solid ztra halo edge strand */
+ view_layer->passflag = SCE_PASS_COMBINED | SCE_PASS_Z;
+ view_layer->pass_alpha_threshold = 0.5f;
+ BKE_freestyle_config_init(&view_layer->freestyle_config);
+ }
+ }
+ }
#endif
- {
- /* Grease pencil sculpt and paint cursors */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* sculpt brushes */
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if (gset) {
- gset->weighttype = GP_SCULPT_TYPE_WEIGHT;
- }
- }
- }
-
- {
- float curcolor_add[3], curcolor_sub[3];
- ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
- ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
- GP_Sculpt_Data *gp_brush;
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- /* sculpt brushes */
- GP_Sculpt_Settings *gset = &ts->gp_sculpt;
- for (int i = 0; i < GP_SCULPT_TYPE_MAX; ++i) {
- gp_brush = &gset->brush[i];
- gp_brush->flag |= GP_SCULPT_FLAG_ENABLE_CURSOR;
- copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
- copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
- }
- }
- }
-
- /* Init grease pencil edit line color */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
- }
- }
-
- /* Init grease pencil pixel size factor */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "pixfactor")) {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
- }
- }
-
- /* Grease pencil multiframe falloff curve */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* sculpt brushes */
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if ((gset) && (gset->cur_falloff == NULL)) {
- gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- curvemapping_initialize(gset->cur_falloff);
- curvemap_reset(gset->cur_falloff->cm,
- &gset->cur_falloff->clipr,
- CURVE_PRESET_GAUSS,
- CURVEMAP_SLOPE_POSITIVE);
- }
- }
- }
- }
- }
+ {
+ /* Grease pencil sculpt and paint cursors */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->weighttype = GP_SCULPT_TYPE_WEIGHT;
+ }
+ }
+ }
+
+ {
+ float curcolor_add[3], curcolor_sub[3];
+ ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
+ ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
+ GP_Sculpt_Data *gp_brush;
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ /* sculpt brushes */
+ GP_Sculpt_Settings *gset = &ts->gp_sculpt;
+ for (int i = 0; i < GP_SCULPT_TYPE_MAX; ++i) {
+ gp_brush = &gset->brush[i];
+ gp_brush->flag |= GP_SCULPT_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+ copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+ }
+ }
+ }
+
+ /* Init grease pencil edit line color */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f);
+ }
+ }
+
+ /* Init grease pencil pixel size factor */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "pixfactor")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
+ }
+ }
+
+ /* Grease pencil multiframe falloff curve */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if ((gset) && (gset->cur_falloff == NULL)) {
+ gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(gset->cur_falloff);
+ curvemap_reset(gset->cur_falloff->cm,
+ &gset->cur_falloff->clipr,
+ CURVE_PRESET_GAUSS,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ }
+ }
+ }
+ }
#ifdef USE_COLLECTION_COMPAT_28
- if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ViewLayer *view_layer;
- for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
- do_version_view_layer_visibility(view_layer);
- }
- }
-
- for (Collection *group = bmain->collections.first; group; group = group->id.next) {
- if (group->view_layer != NULL) {
- do_version_view_layer_visibility(group->view_layer);
- }
- }
- }
+ if (use_collection_compat_28 && !MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ViewLayer *view_layer;
+ for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+ do_version_view_layer_visibility(view_layer);
+ }
+ }
+
+ for (Collection *group = bmain->collections.first; group; group = group->id.next) {
+ if (group->view_layer != NULL) {
+ do_version_view_layer_visibility(group->view_layer);
+ }
+ }
+ }
#endif
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
- /* init grease pencil grids and paper */
- if (!DNA_struct_elem_find(fd->filesdna, "gp_paper_opacity", "float", "gpencil_paper_color[3]")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_paper_opacity = 0.5f;
- v3d->overlay.gpencil_grid_opacity = 0.9f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
- if (DNA_struct_elem_find(fd->filesdna, "SpaceOutliner", "int", "filter") == false) {
- bScreen *sc;
- ScrArea *sa;
- SpaceLink *sl;
-
- /* Update files using invalid (outdated) outlinevis Outliner values. */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
-
- if (!ELEM(so->outlinevis,
- SO_SCENES,
- SO_LIBRARIES,
- SO_SEQUENCE,
- SO_DATA_API,
- SO_ID_ORPHANS))
- {
- so->outlinevis = SO_VIEW_LAYER;
- }
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
- for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
- probe->intensity = 1.0f;
- }
- }
-
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- bConstraint *con, *con_next;
- con = ob->constraints.first;
- while (con) {
- con_next = con->next;
- if (con->type == 17) { /* CONSTRAINT_TYPE_RIGIDBODYJOINT */
- BLI_remlink(&ob->constraints, con);
- BKE_constraint_free_data(con);
- MEM_freeN(con);
- }
- con = con_next;
- }
- }
-
- for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.light = V3D_LIGHTING_STUDIO;
- v3d->shading.flag |= V3D_SHADING_OBJECT_OUTLINE;
-
- /* Assume (demo) files written with 2.8 want to show
- * Eevee renders in the viewport. */
- if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- v3d->drawtype = OB_MATERIAL;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 7)) {
- /* Render engine storage moved elsewhere and back during 2.8
- * development, we assume any files saved in 2.8 had Eevee set
- * as scene render engine. */
- if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
- /* Blender Internal removal */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (STREQ(scene->r.engine, "BLENDER_RENDER") ||
- STREQ(scene->r.engine, "BLENDER_GAME"))
- {
- BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
- }
-
- scene->r.bake_mode = 0;
- }
-
- for (Tex *tex = bmain->textures.first; tex; tex = tex->id.next) {
- /* Removed envmap, pointdensity, voxeldata, ocean textures. */
- if (ELEM(tex->type, 10, 14, 15, 16)) {
- tex->type = 0;
- }
- }
-
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
-
- /* Remove info editor, but only if at the top of the window. */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- /* Calculate window width/height from screen vertices */
- int win_width = 0, win_height = 0;
- for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
- win_width = MAX2(win_width, vert->vec.x);
- win_height = MAX2(win_height, vert->vec.y);
- }
-
- for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) {
- area_next = area->next;
-
- if (area->spacetype == SPACE_INFO) {
- if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) && (area->v4->vec.x == win_width)) {
- BKE_screen_area_free(area);
-
- BLI_remlink(&screen->areabase, area);
-
- BKE_screen_remove_double_scredges(screen);
- BKE_screen_remove_unused_scredges(screen);
- BKE_screen_remove_unused_scrverts(screen);
-
- MEM_freeN(area);
- }
- }
- /* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
- * which are deleted above, so don't need to unset it. Its slot/bit can be reused */
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- if (la->mode & (1 << 13)) { /* LA_SHAD_RAY */
- la->mode |= LA_SHADOW;
- la->mode &= ~(1 << 13);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
- /* Remove tool property regions. */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
-
- for (ARegion *region = regionbase->first, *region_next; region; region = region_next) {
- region_next = region->next;
-
- if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
- BKE_area_region_free(NULL, region);
- BLI_freelinkN(regionbase, region);
- }
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 13)) {
- /* Initialize specular factor. */
- if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "spec_fac")) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->spec_fac = 1.0f;
- }
- }
-
- /* Initialize new view3D options. */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.light = V3D_LIGHTING_STUDIO;
- v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
- copy_v3_fl(v3d->shading.single_color, 0.8f);
- v3d->shading.shadow_intensity = 0.5;
-
- v3d->overlay.backwire_opacity = 0.5f;
- v3d->overlay.normals_length = 0.1f;
- v3d->overlay.flag = 0;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
- /* Initialize new scene.SceneDisplay */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- copy_v3_v3(scene->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->display.shadow_shift = 0.1;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEDIAN;
- }
- }
-
- if (!DNA_struct_find(fd->filesdna, "SceneEEVEE")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* First set the default for all the properties. */
-
- scene->eevee.gi_diffuse_bounces = 3;
- scene->eevee.gi_cubemap_resolution = 512;
- scene->eevee.gi_visibility_resolution = 32;
-
- scene->eevee.taa_samples = 16;
- scene->eevee.taa_render_samples = 64;
-
- scene->eevee.sss_samples = 7;
- scene->eevee.sss_jitter_threshold = 0.3f;
-
- scene->eevee.ssr_quality = 0.25f;
- scene->eevee.ssr_max_roughness = 0.5f;
- scene->eevee.ssr_thickness = 0.2f;
- scene->eevee.ssr_border_fade = 0.075f;
- scene->eevee.ssr_firefly_fac = 10.0f;
-
- scene->eevee.volumetric_start = 0.1f;
- scene->eevee.volumetric_end = 100.0f;
- scene->eevee.volumetric_tile_size = 8;
- scene->eevee.volumetric_samples = 64;
- scene->eevee.volumetric_sample_distribution = 0.8f;
- scene->eevee.volumetric_light_clamp = 0.0f;
- scene->eevee.volumetric_shadow_samples = 16;
-
- scene->eevee.gtao_distance = 0.2f;
- scene->eevee.gtao_factor = 1.0f;
- scene->eevee.gtao_quality = 0.25f;
-
- scene->eevee.bokeh_max_size = 100.0f;
- scene->eevee.bokeh_threshold = 1.0f;
-
- copy_v3_fl(scene->eevee.bloom_color, 1.0f);
- scene->eevee.bloom_threshold = 0.8f;
- scene->eevee.bloom_knee = 0.5f;
- scene->eevee.bloom_intensity = 0.05f;
- scene->eevee.bloom_radius = 6.5f;
- scene->eevee.bloom_clamp = 0.0f;
-
- scene->eevee.motion_blur_samples = 8;
- scene->eevee.motion_blur_shutter = 0.5f;
-
- scene->eevee.shadow_method = SHADOW_ESM;
- scene->eevee.shadow_cube_size = 512;
- scene->eevee.shadow_cascade_size = 1024;
-
- scene->eevee.flag =
- SCE_EEVEE_VOLUMETRIC_LIGHTS |
- SCE_EEVEE_GTAO_BENT_NORMALS |
- SCE_EEVEE_GTAO_BOUNCE |
- SCE_EEVEE_TAA_REPROJECTION |
- SCE_EEVEE_SSR_HALF_RESOLUTION;
-
-
- /* If the file is pre-2.80 move on. */
- if (scene->layer_properties == NULL) {
- continue;
- }
-
- /* Now we handle eventual properties that may be set in the file. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
+ /* init grease pencil grids and paper */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "gp_paper_opacity", "float", "gpencil_paper_color[3]")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_paper_opacity = 0.5f;
+ v3d->overlay.gpencil_grid_opacity = 0.9f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 6)) {
+ if (DNA_struct_elem_find(fd->filesdna, "SpaceOutliner", "int", "filter") == false) {
+ bScreen *sc;
+ ScrArea *sa;
+ SpaceLink *sl;
+
+ /* Update files using invalid (outdated) outlinevis Outliner values. */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+
+ if (!ELEM(so->outlinevis,
+ SO_SCENES,
+ SO_LIBRARIES,
+ SO_SEQUENCE,
+ SO_DATA_API,
+ SO_ID_ORPHANS)) {
+ so->outlinevis = SO_VIEW_LAYER;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) {
+ for (LightProbe *probe = bmain->lightprobes.first; probe; probe = probe->id.next) {
+ probe->intensity = 1.0f;
+ }
+ }
+
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bConstraint *con, *con_next;
+ con = ob->constraints.first;
+ while (con) {
+ con_next = con->next;
+ if (con->type == 17) { /* CONSTRAINT_TYPE_RIGIDBODYJOINT */
+ BLI_remlink(&ob->constraints, con);
+ BKE_constraint_free_data(con);
+ MEM_freeN(con);
+ }
+ con = con_next;
+ }
+ }
+
+ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.light = V3D_LIGHTING_STUDIO;
+ v3d->shading.flag |= V3D_SHADING_OBJECT_OUTLINE;
+
+ /* Assume (demo) files written with 2.8 want to show
+ * Eevee renders in the viewport. */
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ v3d->drawtype = OB_MATERIAL;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 7)) {
+ /* Render engine storage moved elsewhere and back during 2.8
+ * development, we assume any files saved in 2.8 had Eevee set
+ * as scene render engine. */
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
+ /* Blender Internal removal */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (STREQ(scene->r.engine, "BLENDER_RENDER") || STREQ(scene->r.engine, "BLENDER_GAME")) {
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+ }
+
+ scene->r.bake_mode = 0;
+ }
+
+ for (Tex *tex = bmain->textures.first; tex; tex = tex->id.next) {
+ /* Removed envmap, pointdensity, voxeldata, ocean textures. */
+ if (ELEM(tex->type, 10, 14, 15, 16)) {
+ tex->type = 0;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
+
+ /* Remove info editor, but only if at the top of the window. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ /* Calculate window width/height from screen vertices */
+ int win_width = 0, win_height = 0;
+ for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
+ win_width = MAX2(win_width, vert->vec.x);
+ win_height = MAX2(win_height, vert->vec.y);
+ }
+
+ for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) {
+ area_next = area->next;
+
+ if (area->spacetype == SPACE_INFO) {
+ if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) &&
+ (area->v4->vec.x == win_width)) {
+ BKE_screen_area_free(area);
+
+ BLI_remlink(&screen->areabase, area);
+
+ BKE_screen_remove_double_scredges(screen);
+ BKE_screen_remove_unused_scredges(screen);
+ BKE_screen_remove_unused_scrverts(screen);
+
+ MEM_freeN(area);
+ }
+ }
+ /* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
+ * which are deleted above, so don't need to unset it. Its slot/bit can be reused */
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 11)) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ if (la->mode & (1 << 13)) { /* LA_SHAD_RAY */
+ la->mode |= LA_SHADOW;
+ la->mode &= ~(1 << 13);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
+ /* Remove tool property regions. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+
+ for (ARegion *region = regionbase->first, *region_next; region; region = region_next) {
+ region_next = region->next;
+
+ if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
+ BKE_area_region_free(NULL, region);
+ BLI_freelinkN(regionbase, region);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 13)) {
+ /* Initialize specular factor. */
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "spec_fac")) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->spec_fac = 1.0f;
+ }
+ }
+
+ /* Initialize new view3D options. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.light = V3D_LIGHTING_STUDIO;
+ v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
+ copy_v3_fl(v3d->shading.single_color, 0.8f);
+ v3d->shading.shadow_intensity = 0.5;
+
+ v3d->overlay.backwire_opacity = 0.5f;
+ v3d->overlay.normals_length = 0.1f;
+ v3d->overlay.flag = 0;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 14)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
+ /* Initialize new scene.SceneDisplay */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ copy_v3_v3(scene->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_shift")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->display.shadow_shift = 0.1;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "transform_pivot_point")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->toolsettings->transform_pivot_point = V3D_AROUND_CENTER_MEDIAN;
+ }
+ }
+
+ if (!DNA_struct_find(fd->filesdna, "SceneEEVEE")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* First set the default for all the properties. */
+
+ scene->eevee.gi_diffuse_bounces = 3;
+ scene->eevee.gi_cubemap_resolution = 512;
+ scene->eevee.gi_visibility_resolution = 32;
+
+ scene->eevee.taa_samples = 16;
+ scene->eevee.taa_render_samples = 64;
+
+ scene->eevee.sss_samples = 7;
+ scene->eevee.sss_jitter_threshold = 0.3f;
+
+ scene->eevee.ssr_quality = 0.25f;
+ scene->eevee.ssr_max_roughness = 0.5f;
+ scene->eevee.ssr_thickness = 0.2f;
+ scene->eevee.ssr_border_fade = 0.075f;
+ scene->eevee.ssr_firefly_fac = 10.0f;
+
+ scene->eevee.volumetric_start = 0.1f;
+ scene->eevee.volumetric_end = 100.0f;
+ scene->eevee.volumetric_tile_size = 8;
+ scene->eevee.volumetric_samples = 64;
+ scene->eevee.volumetric_sample_distribution = 0.8f;
+ scene->eevee.volumetric_light_clamp = 0.0f;
+ scene->eevee.volumetric_shadow_samples = 16;
+
+ scene->eevee.gtao_distance = 0.2f;
+ scene->eevee.gtao_factor = 1.0f;
+ scene->eevee.gtao_quality = 0.25f;
+
+ scene->eevee.bokeh_max_size = 100.0f;
+ scene->eevee.bokeh_threshold = 1.0f;
+
+ copy_v3_fl(scene->eevee.bloom_color, 1.0f);
+ scene->eevee.bloom_threshold = 0.8f;
+ scene->eevee.bloom_knee = 0.5f;
+ scene->eevee.bloom_intensity = 0.05f;
+ scene->eevee.bloom_radius = 6.5f;
+ scene->eevee.bloom_clamp = 0.0f;
+
+ scene->eevee.motion_blur_samples = 8;
+ scene->eevee.motion_blur_shutter = 0.5f;
+
+ scene->eevee.shadow_method = SHADOW_ESM;
+ scene->eevee.shadow_cube_size = 512;
+ scene->eevee.shadow_cascade_size = 1024;
+
+ scene->eevee.flag = SCE_EEVEE_VOLUMETRIC_LIGHTS | SCE_EEVEE_GTAO_BENT_NORMALS |
+ SCE_EEVEE_GTAO_BOUNCE | SCE_EEVEE_TAA_REPROJECTION |
+ SCE_EEVEE_SSR_HALF_RESOLUTION;
+
+ /* If the file is pre-2.80 move on. */
+ if (scene->layer_properties == NULL) {
+ continue;
+ }
+
+ /* Now we handle eventual properties that may be set in the file. */
#define EEVEE_GET_BOOL(_props, _name, _flag) \
- { \
- IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
- if (_idprop != NULL) { \
- const int _value = IDP_Int(_idprop); \
- if (_value) { \
- scene->eevee.flag |= _flag; \
- } \
- else { \
- scene->eevee.flag &= ~_flag; \
- } \
- } \
- } ((void)0)
+ { \
+ IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
+ if (_idprop != NULL) { \
+ const int _value = IDP_Int(_idprop); \
+ if (_value) { \
+ scene->eevee.flag |= _flag; \
+ } \
+ else { \
+ scene->eevee.flag &= ~_flag; \
+ } \
+ } \
+ } \
+ ((void)0)
#define EEVEE_GET_INT(_props, _name) \
- { \
- IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
- if (_idprop != NULL) { \
- scene->eevee._name = IDP_Int(_idprop); \
- } \
- } ((void)0)
+ { \
+ IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
+ if (_idprop != NULL) { \
+ scene->eevee._name = IDP_Int(_idprop); \
+ } \
+ } \
+ ((void)0)
#define EEVEE_GET_FLOAT(_props, _name) \
- { \
- IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
- if (_idprop != NULL) { \
- scene->eevee._name = IDP_Float(_idprop); \
- } \
- } ((void)0)
+ { \
+ IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
+ if (_idprop != NULL) { \
+ scene->eevee._name = IDP_Float(_idprop); \
+ } \
+ } \
+ ((void)0)
#define EEVEE_GET_FLOAT_ARRAY(_props, _name, _length) \
- { \
- IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
- if (_idprop != NULL) { \
- const float *_values = IDP_Array(_idprop); \
- for (int _i = 0; _i < _length; _i++) { \
- scene->eevee._name [_i] = _values[_i]; \
- } \
- } \
- } ((void)0)
-
- IDProperty *props = IDP_GetPropertyFromGroup(scene->layer_properties, RE_engine_id_BLENDER_EEVEE);
- EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
- EEVEE_GET_BOOL(props, volumetric_lights, SCE_EEVEE_VOLUMETRIC_LIGHTS);
- EEVEE_GET_BOOL(props, volumetric_shadows, SCE_EEVEE_VOLUMETRIC_SHADOWS);
- EEVEE_GET_BOOL(props, gtao_enable, SCE_EEVEE_GTAO_ENABLED);
- EEVEE_GET_BOOL(props, gtao_use_bent_normals, SCE_EEVEE_GTAO_BENT_NORMALS);
- EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE);
- EEVEE_GET_BOOL(props, dof_enable, SCE_EEVEE_DOF_ENABLED);
- EEVEE_GET_BOOL(props, bloom_enable, SCE_EEVEE_BLOOM_ENABLED);
- EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED);
- EEVEE_GET_BOOL(props, shadow_high_bitdepth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
- EEVEE_GET_BOOL(props, taa_reprojection, SCE_EEVEE_TAA_REPROJECTION);
- EEVEE_GET_BOOL(props, sss_enable, SCE_EEVEE_SSS_ENABLED);
- EEVEE_GET_BOOL(props, sss_separate_albedo, SCE_EEVEE_SSS_SEPARATE_ALBEDO);
- EEVEE_GET_BOOL(props, ssr_enable, SCE_EEVEE_SSR_ENABLED);
- EEVEE_GET_BOOL(props, ssr_refraction, SCE_EEVEE_SSR_REFRACTION);
- EEVEE_GET_BOOL(props, ssr_halfres, SCE_EEVEE_SSR_HALF_RESOLUTION);
-
- EEVEE_GET_INT(props, gi_diffuse_bounces);
- EEVEE_GET_INT(props, gi_diffuse_bounces);
- EEVEE_GET_INT(props, gi_cubemap_resolution);
- EEVEE_GET_INT(props, gi_visibility_resolution);
-
- EEVEE_GET_INT(props, taa_samples);
- EEVEE_GET_INT(props, taa_render_samples);
-
- EEVEE_GET_INT(props, sss_samples);
- EEVEE_GET_FLOAT(props, sss_jitter_threshold);
-
- EEVEE_GET_FLOAT(props, ssr_quality);
- EEVEE_GET_FLOAT(props, ssr_max_roughness);
- EEVEE_GET_FLOAT(props, ssr_thickness);
- EEVEE_GET_FLOAT(props, ssr_border_fade);
- EEVEE_GET_FLOAT(props, ssr_firefly_fac);
-
- EEVEE_GET_FLOAT(props, volumetric_start);
- EEVEE_GET_FLOAT(props, volumetric_end);
- EEVEE_GET_INT(props, volumetric_tile_size);
- EEVEE_GET_INT(props, volumetric_samples);
- EEVEE_GET_FLOAT(props, volumetric_sample_distribution);
- EEVEE_GET_FLOAT(props, volumetric_light_clamp);
- EEVEE_GET_INT(props, volumetric_shadow_samples);
-
- EEVEE_GET_FLOAT(props, gtao_distance);
- EEVEE_GET_FLOAT(props, gtao_factor);
- EEVEE_GET_FLOAT(props, gtao_quality);
-
- EEVEE_GET_FLOAT(props, bokeh_max_size);
- EEVEE_GET_FLOAT(props, bokeh_threshold);
-
- EEVEE_GET_FLOAT_ARRAY(props, bloom_color, 3);
- EEVEE_GET_FLOAT(props, bloom_threshold);
- EEVEE_GET_FLOAT(props, bloom_knee);
- EEVEE_GET_FLOAT(props, bloom_intensity);
- EEVEE_GET_FLOAT(props, bloom_radius);
- EEVEE_GET_FLOAT(props, bloom_clamp);
-
- EEVEE_GET_INT(props, motion_blur_samples);
- EEVEE_GET_FLOAT(props, motion_blur_shutter);
-
- EEVEE_GET_INT(props, shadow_method);
- EEVEE_GET_INT(props, shadow_cube_size);
- EEVEE_GET_INT(props, shadow_cascade_size);
-
- /* Cleanup. */
- IDP_FreeProperty(scene->layer_properties);
- MEM_freeN(scene->layer_properties);
- scene->layer_properties = NULL;
+ { \
+ IDProperty *_idprop = IDP_GetPropertyFromGroup(_props, #_name); \
+ if (_idprop != NULL) { \
+ const float *_values = IDP_Array(_idprop); \
+ for (int _i = 0; _i < _length; _i++) { \
+ scene->eevee._name[_i] = _values[_i]; \
+ } \
+ } \
+ } \
+ ((void)0)
+
+ IDProperty *props = IDP_GetPropertyFromGroup(scene->layer_properties,
+ RE_engine_id_BLENDER_EEVEE);
+ EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
+ EEVEE_GET_BOOL(props, volumetric_lights, SCE_EEVEE_VOLUMETRIC_LIGHTS);
+ EEVEE_GET_BOOL(props, volumetric_shadows, SCE_EEVEE_VOLUMETRIC_SHADOWS);
+ EEVEE_GET_BOOL(props, gtao_enable, SCE_EEVEE_GTAO_ENABLED);
+ EEVEE_GET_BOOL(props, gtao_use_bent_normals, SCE_EEVEE_GTAO_BENT_NORMALS);
+ EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE);
+ EEVEE_GET_BOOL(props, dof_enable, SCE_EEVEE_DOF_ENABLED);
+ EEVEE_GET_BOOL(props, bloom_enable, SCE_EEVEE_BLOOM_ENABLED);
+ EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED);
+ EEVEE_GET_BOOL(props, shadow_high_bitdepth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH);
+ EEVEE_GET_BOOL(props, taa_reprojection, SCE_EEVEE_TAA_REPROJECTION);
+ EEVEE_GET_BOOL(props, sss_enable, SCE_EEVEE_SSS_ENABLED);
+ EEVEE_GET_BOOL(props, sss_separate_albedo, SCE_EEVEE_SSS_SEPARATE_ALBEDO);
+ EEVEE_GET_BOOL(props, ssr_enable, SCE_EEVEE_SSR_ENABLED);
+ EEVEE_GET_BOOL(props, ssr_refraction, SCE_EEVEE_SSR_REFRACTION);
+ EEVEE_GET_BOOL(props, ssr_halfres, SCE_EEVEE_SSR_HALF_RESOLUTION);
+
+ EEVEE_GET_INT(props, gi_diffuse_bounces);
+ EEVEE_GET_INT(props, gi_diffuse_bounces);
+ EEVEE_GET_INT(props, gi_cubemap_resolution);
+ EEVEE_GET_INT(props, gi_visibility_resolution);
+
+ EEVEE_GET_INT(props, taa_samples);
+ EEVEE_GET_INT(props, taa_render_samples);
+
+ EEVEE_GET_INT(props, sss_samples);
+ EEVEE_GET_FLOAT(props, sss_jitter_threshold);
+
+ EEVEE_GET_FLOAT(props, ssr_quality);
+ EEVEE_GET_FLOAT(props, ssr_max_roughness);
+ EEVEE_GET_FLOAT(props, ssr_thickness);
+ EEVEE_GET_FLOAT(props, ssr_border_fade);
+ EEVEE_GET_FLOAT(props, ssr_firefly_fac);
+
+ EEVEE_GET_FLOAT(props, volumetric_start);
+ EEVEE_GET_FLOAT(props, volumetric_end);
+ EEVEE_GET_INT(props, volumetric_tile_size);
+ EEVEE_GET_INT(props, volumetric_samples);
+ EEVEE_GET_FLOAT(props, volumetric_sample_distribution);
+ EEVEE_GET_FLOAT(props, volumetric_light_clamp);
+ EEVEE_GET_INT(props, volumetric_shadow_samples);
+
+ EEVEE_GET_FLOAT(props, gtao_distance);
+ EEVEE_GET_FLOAT(props, gtao_factor);
+ EEVEE_GET_FLOAT(props, gtao_quality);
+
+ EEVEE_GET_FLOAT(props, bokeh_max_size);
+ EEVEE_GET_FLOAT(props, bokeh_threshold);
+
+ EEVEE_GET_FLOAT_ARRAY(props, bloom_color, 3);
+ EEVEE_GET_FLOAT(props, bloom_threshold);
+ EEVEE_GET_FLOAT(props, bloom_knee);
+ EEVEE_GET_FLOAT(props, bloom_intensity);
+ EEVEE_GET_FLOAT(props, bloom_radius);
+ EEVEE_GET_FLOAT(props, bloom_clamp);
+
+ EEVEE_GET_INT(props, motion_blur_samples);
+ EEVEE_GET_FLOAT(props, motion_blur_shutter);
+
+ EEVEE_GET_INT(props, shadow_method);
+ EEVEE_GET_INT(props, shadow_cube_size);
+ EEVEE_GET_INT(props, shadow_cascade_size);
+
+ /* Cleanup. */
+ IDP_FreeProperty(scene->layer_properties);
+ MEM_freeN(scene->layer_properties);
+ scene->layer_properties = NULL;
#undef EEVEE_GET_FLOAT_ARRAY
#undef EEVEE_GET_FLOAT
#undef EEVEE_GET_INT
#undef EEVEE_GET_BOOL
- }
- }
-
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 15)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->display.matcap_ssao_distance = 0.2f;
- scene->display.matcap_ssao_attenuation = 1.0f;
- scene->display.matcap_ssao_samples = 16;
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
- soops->filter_id_type = ID_GR;
- soops->outlinevis = SO_VIEW_LAYER;
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- switch (scene->toolsettings->snap_mode) {
- case 0: scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT; break;
- case 1: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX ; break;
- case 2: scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE ; break;
- case 3: scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE ; break;
- case 4: scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME ; break;
- }
- switch (scene->toolsettings->snap_node_mode) {
- case 5: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X; break;
- case 6: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y; break;
- case 7: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y; break;
- case 8: scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID ; break;
- }
- switch (scene->toolsettings->snap_uv_mode) {
- case 0: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT; break;
- case 1: scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX ; break;
- }
- }
-
- ParticleSettings *part;
- for (part = bmain->particles.first; part; part = part->id.next) {
- part->shape_flag = PART_SHAPE_CLOSE_TIP;
- part->shape = 0.0f;
- part->rad_root = 1.0f;
- part->rad_tip = 0.0f;
- part->rad_scale = 0.01f;
- }
- }
-
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 18)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "roughness")) {
- for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->use_nodes) {
- if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
- mat->roughness = mat->gloss_mir;
- }
- else {
- mat->roughness = 0.25f;
- }
- }
- else {
- mat->roughness = 1.0f - mat->gloss_mir;
- }
- mat->metallic = mat->ray_mirror;
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.xray_alpha = 0.5f;
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
- StudioLight *default_matcap = BKE_studiolight_find_default(STUDIOLIGHT_TYPE_MATCAP);
- /* when loading the internal file is loaded before the matcaps */
- if (default_matcap) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
- }
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.wireframe_threshold = 0.5f;
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.cavity_valley_factor = 1.0f;
- v3d->shading.cavity_ridge_factor = 1.0f;
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.xray_alpha_bone = 0.5f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 19)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "renderslot")) {
- for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
- if (ima->type == IMA_TYPE_R_RESULT) {
- for (int i = 0; i < 8; i++) {
- RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image Render Slot Init");
- BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", i + 1);
- BLI_addtail(&ima->renderslots, slot);
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
- /* "Dopesheet" should be default here, unless it looks like the Action Editor was active instead */
- if ((saction->mode_prev == 0) && (saction->action == NULL)) {
- saction->mode_prev = SACTCONT_DOPESHEET;
- }
- }
- }
- }
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->drawtype == OB_TEXTURE) {
- v3d->drawtype = OB_SOLID;
- v3d->shading.light = V3D_LIGHTING_STUDIO;
- v3d->shading.color_type = V3D_SHADING_TEXTURE_COLOR;
- }
- }
- }
- }
- }
-
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 21)) {
- for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
- if (sce->ed != NULL && sce->ed->seqbase.first != NULL) {
- do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- enum { V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15), };
- View3D *v3d = (View3D *)sl;
- float alpha = v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE ? 0.0f : 1.0f;
- v3d->overlay.texture_paint_mode_opacity = alpha;
- v3d->overlay.vertex_paint_mode_opacity = alpha;
- v3d->overlay.weight_paint_mode_opacity = alpha;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- copy_v3_fl(v3d->shading.background_color, 0.05f);
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->eevee.gi_irradiance_draw_size = 0.1f;
- scene->eevee.gi_cubemap_draw_size = 0.3f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- RigidBodyWorld *rbw = scene->rigidbody_world;
-
- if (rbw == NULL) {
- continue;
- }
-
- if (rbw->shared == NULL) {
- rbw->shared = MEM_callocN(sizeof(*rbw->shared), "RigidBodyWorld_Shared");
- }
-
- /* Move shared pointers from deprecated location to current location */
- rbw->shared->pointcache = rbw->pointcache;
- rbw->shared->ptcaches = rbw->ptcaches;
-
- rbw->pointcache = NULL;
- BLI_listbase_clear(&rbw->ptcaches);
-
- if (rbw->shared->pointcache == NULL) {
- rbw->shared->pointcache = BKE_ptcache_add(&(rbw->shared->ptcaches));
- }
-
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- SoftBody *sb = ob->soft;
- if (sb == NULL) {
- continue;
- }
- if (sb->shared == NULL) {
- sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
- }
-
- /* Move shared pointers from deprecated location to current location */
- sb->shared->pointcache = sb->pointcache;
- sb->shared->ptcaches = sb->ptcaches;
-
- sb->pointcache = NULL;
- BLI_listbase_clear(&sb->ptcaches);
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->drawtype == OB_RENDER) {
- v3d->drawtype = OB_SOLID;
- }
- v3d->shading.type = v3d->drawtype;
- v3d->shading.prev_type = OB_SOLID;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- BKE_screen_view3d_shading_init(&scene->display.shading);
- }
- }
- /* initialize grease pencil view data */
- if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
- for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->vertex_opacity = 1.0f;
- v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
- }
- }
- }
- }
- }
-
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 22)) {
- if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
- scene->toolsettings->annotate_thickness = 3;
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "short", "line_change")) {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- gpl->line_change = gpl->thickness;
- if ((gpl->thickness < 1) || (gpl->thickness > 10)) {
- gpl->thickness = 3;
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_paper_opacity = 0.5f;
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_grid_opacity = 0.5f;
- }
- }
- }
- }
- }
-
- /* default loc axis */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "lock_axis")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* lock axis */
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if (gset) {
- gset->lock_axis = GP_LOCKAXIS_Y;
- }
- }
- }
-
- /* Versioning code for Subsurf modifier. */
- if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
- for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
- if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) {
- smd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
- }
- else {
- smd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "quality")) {
- for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
- smd->quality = min_ii(smd->renderLevels, 3);
- }
- }
- }
- }
- /* Versioning code for Multires modifier. */
- if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) {
- for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Multires) {
- MultiresModifierData *mmd = (MultiresModifierData *)md;
- mmd->quality = 3;
- if (mmd->flags & eMultiresModifierFlag_PlainUv_DEPRECATED) {
- mmd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
- }
- else {
- mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- ClothModifierData *clmd = NULL;
- if (md->type == eModifierType_Cloth) {
- clmd = (ClothModifierData *)md;
- }
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
- ParticleSystem *psys = psmd->psys;
- clmd = psys->clmd;
- }
- if (clmd != NULL) {
- clmd->sim_parms->bending_model = CLOTH_BENDING_LINEAR;
- clmd->sim_parms->tension = clmd->sim_parms->structural;
- clmd->sim_parms->compression = clmd->sim_parms->structural;
- clmd->sim_parms->shear = clmd->sim_parms->structural;
- clmd->sim_parms->max_tension = clmd->sim_parms->max_struct;
- clmd->sim_parms->max_compression = clmd->sim_parms->max_struct;
- clmd->sim_parms->max_shear = clmd->sim_parms->max_struct;
- clmd->sim_parms->vgroup_shear = clmd->sim_parms->vgroup_struct;
- clmd->sim_parms->tension_damp = clmd->sim_parms->Cdis;
- clmd->sim_parms->compression_damp = clmd->sim_parms->Cdis;
- clmd->sim_parms->shear_damp = clmd->sim_parms->Cdis;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "era_strength_f")) {
- for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->gpencil_settings != NULL) {
- BrushGpencilSettings *gp = brush->gpencil_settings;
- if (gp->brush_type == GPAINT_TOOL_ERASE) {
- gp->era_strength_f = 100.0f;
- gp->era_thickness_f = 10.0f;
- }
- }
- }
- }
-
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)) {
- clmd->sim_parms->vgroup_mass = 0;
- }
-
- if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING)) {
- clmd->sim_parms->vgroup_struct = 0;
- clmd->sim_parms->vgroup_shear = 0;
- clmd->sim_parms->vgroup_bend = 0;
- }
-
- if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW)) {
- clmd->sim_parms->shrink_min = 0.0f;
- clmd->sim_parms->vgroup_shrink = 0;
- }
-
- if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) {
- clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES |
- V3D_OVERLAY_EDIT_SEAMS |
- V3D_OVERLAY_EDIT_SHARP |
- V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
- V3D_OVERLAY_EDIT_FREESTYLE_FACE |
- V3D_OVERLAY_EDIT_EDGES |
- V3D_OVERLAY_EDIT_CREASES |
- V3D_OVERLAY_EDIT_BWEIGHTS |
- V3D_OVERLAY_EDIT_CU_HANDLES |
- V3D_OVERLAY_EDIT_CU_NORMALS;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Shrinkwrap) {
- ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
- smd->shrinkMode = MOD_SHRINKWRAP_ABOVE_SURFACE;
- smd->shrinkOpts &= ~MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "PartDeflect", "float", "pdef_cfrict")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pd) {
- ob->pd->pdef_cfrict = 5.0f;
- }
-
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- clmd->coll_parms->selfepsilon = 0.015f;
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.xray_alpha_wire = 0.5f;
- }
- }
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.flag |= V3D_SHADING_XRAY_BONE;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- UnitSettings *unit = &scene->unit;
- if (unit->system != USER_UNIT_NONE) {
- unit->length_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_LENGTH);
- unit->mass_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_MASS);
- }
- unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME);
- }
-
- /* gpencil grid settings */
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
- ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
- gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 28)) {
- for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
- BKE_mesh_calc_edges_loose(mesh);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- enum { V3D_OCCLUDE_WIRE = (1 << 14) };
- View3D *v3d = (View3D *)sl;
- if (v3d->flag2 & V3D_OCCLUDE_WIRE) {
- v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_OCCLUDE_WIRE;
- v3d->flag2 &= ~V3D_OCCLUDE_WIRE;
- }
- }
- }
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_PROPERTIES) {
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- ARegion *ar = MEM_callocN(sizeof(ARegion), "navigation bar for properties");
- ARegion *ar_header = NULL;
-
- for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
- if (ar_header->regiontype == RGN_TYPE_HEADER) {
- break;
- }
- }
- BLI_assert(ar_header);
-
- BLI_insertlinkafter(regionbase, ar_header, ar);
-
- ar->regiontype = RGN_TYPE_NAV_BAR;
- ar->alignment = RGN_ALIGN_LEFT;
- }
- }
- }
- }
-
- /* grease pencil fade layer opacity */
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_fade_layer = 0.5f;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
- /* grease pencil main material show switches */
- for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->gp_style) {
- mat->gp_style->flag |= GP_STYLE_STROKE_SHOW;
- mat->gp_style->flag |= GP_STYLE_FILL_SHOW;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 33)) {
- /* Grease pencil reset sculpt brushes after struct rename */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
- float curcolor_add[3], curcolor_sub[3];
- ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
- ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* sculpt brushes */
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if (gset) {
- for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
- GP_Sculpt_Data *gp_brush = &gset->brush[i];
- gp_brush->size = 30;
- gp_brush->strength = 0.5f;
- gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
- copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
- copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "overscan")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->eevee.overscan = 3.0f;
- }
- }
-
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- /* Removed Hemi lights. */
- if (!ELEM(la->type, LA_LOCAL, LA_SUN, LA_SPOT, LA_AREA)) {
- la->type = LA_SUN;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "light_threshold")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->eevee.light_threshold = 0.01f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_irradiance_smoothing")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->eevee.gi_irradiance_smoothing = 0.1f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_filter_quality")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->eevee.gi_filter_quality = 1.0f;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "att_dist")) {
- for (Light *la = bmain->lights.first; la; la = la->id.next) {
- la->att_dist = la->clipend;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "Brush", "char", "weightpaint_tool")) {
- /* Magic defines from old files (2.7x) */
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 15)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->display.matcap_ssao_distance = 0.2f;
+ scene->display.matcap_ssao_attenuation = 1.0f;
+ scene->display.matcap_ssao_samples = 16;
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *soops = (SpaceOutliner *)sl;
+ soops->filter_id_type = ID_GR;
+ soops->outlinevis = SO_VIEW_LAYER;
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ switch (scene->toolsettings->snap_mode) {
+ case 0:
+ scene->toolsettings->snap_mode = SCE_SNAP_MODE_INCREMENT;
+ break;
+ case 1:
+ scene->toolsettings->snap_mode = SCE_SNAP_MODE_VERTEX;
+ break;
+ case 2:
+ scene->toolsettings->snap_mode = SCE_SNAP_MODE_EDGE;
+ break;
+ case 3:
+ scene->toolsettings->snap_mode = SCE_SNAP_MODE_FACE;
+ break;
+ case 4:
+ scene->toolsettings->snap_mode = SCE_SNAP_MODE_VOLUME;
+ break;
+ }
+ switch (scene->toolsettings->snap_node_mode) {
+ case 5:
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X;
+ break;
+ case 6:
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_Y;
+ break;
+ case 7:
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y;
+ break;
+ case 8:
+ scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ break;
+ }
+ switch (scene->toolsettings->snap_uv_mode) {
+ case 0:
+ scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_INCREMENT;
+ break;
+ case 1:
+ scene->toolsettings->snap_uv_mode = SCE_SNAP_MODE_VERTEX;
+ break;
+ }
+ }
+
+ ParticleSettings *part;
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ part->shape_flag = PART_SHAPE_CLOSE_TIP;
+ part->shape = 0.0f;
+ part->rad_root = 1.0f;
+ part->rad_tip = 0.0f;
+ part->rad_scale = 0.01f;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 18)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "roughness")) {
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ if (mat->use_nodes) {
+ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
+ mat->roughness = mat->gloss_mir;
+ }
+ else {
+ mat->roughness = 0.25f;
+ }
+ }
+ else {
+ mat->roughness = 1.0f - mat->gloss_mir;
+ }
+ mat->metallic = mat->ray_mirror;
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.xray_alpha = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
+ StudioLight *default_matcap = BKE_studiolight_find_default(STUDIOLIGHT_TYPE_MATCAP);
+ /* when loading the internal file is loaded before the matcaps */
+ if (default_matcap) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.wireframe_threshold = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.cavity_valley_factor = 1.0f;
+ v3d->shading.cavity_ridge_factor = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.xray_alpha_bone = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 19)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Image", "ListBase", "renderslot")) {
+ for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (ima->type == IMA_TYPE_R_RESULT) {
+ for (int i = 0; i < 8; i++) {
+ RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image Render Slot Init");
+ BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", i + 1);
+ BLI_addtail(&ima->renderslots, slot);
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)sl;
+ /* "Dopesheet" should be default here, unless it looks like the Action Editor was active instead */
+ if ((saction->mode_prev == 0) && (saction->action == NULL)) {
+ saction->mode_prev = SACTCONT_DOPESHEET;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_TEXTURE) {
+ v3d->drawtype = OB_SOLID;
+ v3d->shading.light = V3D_LIGHTING_STUDIO;
+ v3d->shading.color_type = V3D_SHADING_TEXTURE_COLOR;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 21)) {
+ for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
+ if (sce->ed != NULL && sce->ed->seqbase.first != NULL) {
+ do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase);
+ }
+ }
+
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ enum {
+ V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15),
+ };
+ View3D *v3d = (View3D *)sl;
+ float alpha = v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE ? 0.0f : 1.0f;
+ v3d->overlay.texture_paint_mode_opacity = alpha;
+ v3d->overlay.vertex_paint_mode_opacity = alpha;
+ v3d->overlay.weight_paint_mode_opacity = alpha;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ copy_v3_fl(v3d->shading.background_color, 0.05f);
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->eevee.gi_irradiance_draw_size = 0.1f;
+ scene->eevee.gi_cubemap_draw_size = 0.3f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ RigidBodyWorld *rbw = scene->rigidbody_world;
+
+ if (rbw == NULL) {
+ continue;
+ }
+
+ if (rbw->shared == NULL) {
+ rbw->shared = MEM_callocN(sizeof(*rbw->shared), "RigidBodyWorld_Shared");
+ }
+
+ /* Move shared pointers from deprecated location to current location */
+ rbw->shared->pointcache = rbw->pointcache;
+ rbw->shared->ptcaches = rbw->ptcaches;
+
+ rbw->pointcache = NULL;
+ BLI_listbase_clear(&rbw->ptcaches);
+
+ if (rbw->shared->pointcache == NULL) {
+ rbw->shared->pointcache = BKE_ptcache_add(&(rbw->shared->ptcaches));
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SoftBody", "SoftBody_Shared", "*shared")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ SoftBody *sb = ob->soft;
+ if (sb == NULL) {
+ continue;
+ }
+ if (sb->shared == NULL) {
+ sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
+ }
+
+ /* Move shared pointers from deprecated location to current location */
+ sb->shared->pointcache = sb->pointcache;
+ sb->shared->ptcaches = sb->ptcaches;
+
+ sb->pointcache = NULL;
+ BLI_listbase_clear(&sb->ptcaches);
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->drawtype == OB_RENDER) {
+ v3d->drawtype = OB_SOLID;
+ }
+ v3d->shading.type = v3d->drawtype;
+ v3d->shading.prev_type = OB_SOLID;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "View3DShading", "shading")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ BKE_screen_view3d_shading_init(&scene->display.shading);
+ }
+ }
+ /* initialize grease pencil view data */
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
+ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->vertex_opacity = 1.0f;
+ v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 22)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "annotate_v3d_align")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->toolsettings->annotate_v3d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+ scene->toolsettings->annotate_thickness = 3;
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "short", "line_change")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ gpl->line_change = gpl->thickness;
+ if ((gpl->thickness < 1) || (gpl->thickness > 10)) {
+ gpl->thickness = 3;
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_paper_opacity = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_grid_opacity = 0.5f;
+ }
+ }
+ }
+ }
+ }
+
+ /* default loc axis */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "lock_axis")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* lock axis */
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->lock_axis = GP_LOCKAXIS_Y;
+ }
+ }
+ }
+
+ /* Versioning code for Subsurf modifier. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
+ if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) {
+ smd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
+ }
+ else {
+ smd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "quality")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
+ smd->quality = min_ii(smd->renderLevels, 3);
+ }
+ }
+ }
+ }
+ /* Versioning code for Multires modifier. */
+ if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Multires) {
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
+ mmd->quality = 3;
+ if (mmd->flags & eMultiresModifierFlag_PlainUv_DEPRECATED) {
+ mmd->uv_smooth = SUBSURF_UV_SMOOTH_NONE;
+ }
+ else {
+ mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ ClothModifierData *clmd = NULL;
+ if (md->type == eModifierType_Cloth) {
+ clmd = (ClothModifierData *)md;
+ }
+ else if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
+ ParticleSystem *psys = psmd->psys;
+ clmd = psys->clmd;
+ }
+ if (clmd != NULL) {
+ clmd->sim_parms->bending_model = CLOTH_BENDING_LINEAR;
+ clmd->sim_parms->tension = clmd->sim_parms->structural;
+ clmd->sim_parms->compression = clmd->sim_parms->structural;
+ clmd->sim_parms->shear = clmd->sim_parms->structural;
+ clmd->sim_parms->max_tension = clmd->sim_parms->max_struct;
+ clmd->sim_parms->max_compression = clmd->sim_parms->max_struct;
+ clmd->sim_parms->max_shear = clmd->sim_parms->max_struct;
+ clmd->sim_parms->vgroup_shear = clmd->sim_parms->vgroup_struct;
+ clmd->sim_parms->tension_damp = clmd->sim_parms->Cdis;
+ clmd->sim_parms->compression_damp = clmd->sim_parms->Cdis;
+ clmd->sim_parms->shear_damp = clmd->sim_parms->Cdis;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "era_strength_f")) {
+ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->gpencil_settings != NULL) {
+ BrushGpencilSettings *gp = brush->gpencil_settings;
+ if (gp->brush_type == GPAINT_TOOL_ERASE) {
+ gp->era_strength_f = 100.0f;
+ gp->era_thickness_f = 10.0f;
+ }
+ }
+ }
+ }
+
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)) {
+ clmd->sim_parms->vgroup_mass = 0;
+ }
+
+ if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING)) {
+ clmd->sim_parms->vgroup_struct = 0;
+ clmd->sim_parms->vgroup_shear = 0;
+ clmd->sim_parms->vgroup_bend = 0;
+ }
+
+ if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW)) {
+ clmd->sim_parms->shrink_min = 0.0f;
+ clmd->sim_parms->vgroup_shrink = 0;
+ }
+
+ if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) {
+ clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
+ V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
+ V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |
+ V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
+ V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Shrinkwrap) {
+ ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
+ if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
+ smd->shrinkMode = MOD_SHRINKWRAP_ABOVE_SURFACE;
+ smd->shrinkOpts &= ~MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "PartDeflect", "float", "pdef_cfrict")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pd) {
+ ob->pd->pdef_cfrict = 5.0f;
+ }
+
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ clmd->coll_parms->selfepsilon = 0.015f;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.xray_alpha_wire = 0.5f;
+ }
+ }
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_XRAY_BONE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ UnitSettings *unit = &scene->unit;
+ if (unit->system != USER_UNIT_NONE) {
+ unit->length_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_LENGTH);
+ unit->mass_unit = bUnit_GetBaseUnitOfType(scene->unit.system, B_UNIT_MASS);
+ }
+ unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME);
+ }
+
+ /* gpencil grid settings */
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
+ ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
+ gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 28)) {
+ for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
+ BKE_mesh_calc_edges_loose(mesh);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ enum { V3D_OCCLUDE_WIRE = (1 << 14) };
+ View3D *v3d = (View3D *)sl;
+ if (v3d->flag2 & V3D_OCCLUDE_WIRE) {
+ v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_OCCLUDE_WIRE;
+ v3d->flag2 &= ~V3D_OCCLUDE_WIRE;
+ }
+ }
+ }
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_PROPERTIES) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ ARegion *ar = MEM_callocN(sizeof(ARegion), "navigation bar for properties");
+ ARegion *ar_header = NULL;
+
+ for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
+ if (ar_header->regiontype == RGN_TYPE_HEADER) {
+ break;
+ }
+ }
+ BLI_assert(ar_header);
+
+ BLI_insertlinkafter(regionbase, ar_header, ar);
+
+ ar->regiontype = RGN_TYPE_NAV_BAR;
+ ar->alignment = RGN_ALIGN_LEFT;
+ }
+ }
+ }
+ }
+
+ /* grease pencil fade layer opacity */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.gpencil_fade_layer = 0.5f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 30)) {
+ /* grease pencil main material show switches */
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ if (mat->gp_style) {
+ mat->gp_style->flag |= GP_STYLE_STROKE_SHOW;
+ mat->gp_style->flag |= GP_STYLE_FILL_SHOW;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 33)) {
+ /* Grease pencil reset sculpt brushes after struct rename */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "int", "weighttype")) {
+ float curcolor_add[3], curcolor_sub[3];
+ ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
+ ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
+ GP_Sculpt_Data *gp_brush = &gset->brush[i];
+ gp_brush->size = 30;
+ gp_brush->strength = 0.5f;
+ gp_brush->flag = GP_SCULPT_FLAG_USE_FALLOFF | GP_SCULPT_FLAG_ENABLE_CURSOR;
+ copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
+ copy_v3_v3(gp_brush->curcolor_sub, curcolor_sub);
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "overscan")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->eevee.overscan = 3.0f;
+ }
+ }
+
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ /* Removed Hemi lights. */
+ if (!ELEM(la->type, LA_LOCAL, LA_SUN, LA_SPOT, LA_AREA)) {
+ la->type = LA_SUN;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "light_threshold")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->eevee.light_threshold = 0.01f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_irradiance_smoothing")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->eevee.gi_irradiance_smoothing = 0.1f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_filter_quality")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->eevee.gi_filter_quality = 1.0f;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "att_dist")) {
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ la->att_dist = la->clipend;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Brush", "char", "weightpaint_tool")) {
+ /* Magic defines from old files (2.7x) */
#define PAINT_BLEND_MIX 0
#define PAINT_BLEND_ADD 1
@@ -2331,56 +2342,98 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
#define PAINT_BLEND_ALPHA_SUB 19
#define PAINT_BLEND_ALPHA_ADD 20
- for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->ob_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
- const char tool_init = brush->vertexpaint_tool;
- bool is_blend = false;
-
- {
- char tool = tool_init;
- switch (tool_init) {
- case PAINT_BLEND_MIX: tool = VPAINT_TOOL_DRAW; break;
- case PAINT_BLEND_BLUR: tool = VPAINT_TOOL_BLUR; break;
- case PAINT_BLEND_AVERAGE: tool = VPAINT_TOOL_AVERAGE; break;
- case PAINT_BLEND_SMEAR: tool = VPAINT_TOOL_SMEAR; break;
- default:
- tool = VPAINT_TOOL_DRAW;
- is_blend = true;
- break;
- }
- brush->vertexpaint_tool = tool;
- }
-
- if (is_blend == false) {
- brush->blend = IMB_BLEND_MIX;
- }
- else {
- short blend = IMB_BLEND_MIX;
- switch (tool_init) {
- case PAINT_BLEND_ADD: blend = IMB_BLEND_ADD; break;
- case PAINT_BLEND_SUB: blend = IMB_BLEND_SUB; break;
- case PAINT_BLEND_MUL: blend = IMB_BLEND_MUL; break;
- case PAINT_BLEND_LIGHTEN: blend = IMB_BLEND_LIGHTEN; break;
- case PAINT_BLEND_DARKEN: blend = IMB_BLEND_DARKEN; break;
- case PAINT_BLEND_COLORDODGE: blend = IMB_BLEND_COLORDODGE; break;
- case PAINT_BLEND_DIFFERENCE: blend = IMB_BLEND_DIFFERENCE; break;
- case PAINT_BLEND_SCREEN: blend = IMB_BLEND_SCREEN; break;
- case PAINT_BLEND_HARDLIGHT: blend = IMB_BLEND_HARDLIGHT; break;
- case PAINT_BLEND_OVERLAY: blend = IMB_BLEND_OVERLAY; break;
- case PAINT_BLEND_SOFTLIGHT: blend = IMB_BLEND_SOFTLIGHT; break;
- case PAINT_BLEND_EXCLUSION: blend = IMB_BLEND_EXCLUSION; break;
- case PAINT_BLEND_LUMINOSITY: blend = IMB_BLEND_LUMINOSITY; break;
- case PAINT_BLEND_SATURATION: blend = IMB_BLEND_SATURATION; break;
- case PAINT_BLEND_HUE: blend = IMB_BLEND_HUE; break;
- case PAINT_BLEND_ALPHA_SUB: blend = IMB_BLEND_ERASE_ALPHA; break;
- case PAINT_BLEND_ALPHA_ADD: blend = IMB_BLEND_ADD_ALPHA; break;
- }
- brush->blend = blend;
- }
- }
- /* For now these match, in the future new items may not. */
- brush->weightpaint_tool = brush->vertexpaint_tool;
- }
+ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->ob_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ const char tool_init = brush->vertexpaint_tool;
+ bool is_blend = false;
+
+ {
+ char tool = tool_init;
+ switch (tool_init) {
+ case PAINT_BLEND_MIX:
+ tool = VPAINT_TOOL_DRAW;
+ break;
+ case PAINT_BLEND_BLUR:
+ tool = VPAINT_TOOL_BLUR;
+ break;
+ case PAINT_BLEND_AVERAGE:
+ tool = VPAINT_TOOL_AVERAGE;
+ break;
+ case PAINT_BLEND_SMEAR:
+ tool = VPAINT_TOOL_SMEAR;
+ break;
+ default:
+ tool = VPAINT_TOOL_DRAW;
+ is_blend = true;
+ break;
+ }
+ brush->vertexpaint_tool = tool;
+ }
+
+ if (is_blend == false) {
+ brush->blend = IMB_BLEND_MIX;
+ }
+ else {
+ short blend = IMB_BLEND_MIX;
+ switch (tool_init) {
+ case PAINT_BLEND_ADD:
+ blend = IMB_BLEND_ADD;
+ break;
+ case PAINT_BLEND_SUB:
+ blend = IMB_BLEND_SUB;
+ break;
+ case PAINT_BLEND_MUL:
+ blend = IMB_BLEND_MUL;
+ break;
+ case PAINT_BLEND_LIGHTEN:
+ blend = IMB_BLEND_LIGHTEN;
+ break;
+ case PAINT_BLEND_DARKEN:
+ blend = IMB_BLEND_DARKEN;
+ break;
+ case PAINT_BLEND_COLORDODGE:
+ blend = IMB_BLEND_COLORDODGE;
+ break;
+ case PAINT_BLEND_DIFFERENCE:
+ blend = IMB_BLEND_DIFFERENCE;
+ break;
+ case PAINT_BLEND_SCREEN:
+ blend = IMB_BLEND_SCREEN;
+ break;
+ case PAINT_BLEND_HARDLIGHT:
+ blend = IMB_BLEND_HARDLIGHT;
+ break;
+ case PAINT_BLEND_OVERLAY:
+ blend = IMB_BLEND_OVERLAY;
+ break;
+ case PAINT_BLEND_SOFTLIGHT:
+ blend = IMB_BLEND_SOFTLIGHT;
+ break;
+ case PAINT_BLEND_EXCLUSION:
+ blend = IMB_BLEND_EXCLUSION;
+ break;
+ case PAINT_BLEND_LUMINOSITY:
+ blend = IMB_BLEND_LUMINOSITY;
+ break;
+ case PAINT_BLEND_SATURATION:
+ blend = IMB_BLEND_SATURATION;
+ break;
+ case PAINT_BLEND_HUE:
+ blend = IMB_BLEND_HUE;
+ break;
+ case PAINT_BLEND_ALPHA_SUB:
+ blend = IMB_BLEND_ERASE_ALPHA;
+ break;
+ case PAINT_BLEND_ALPHA_ADD:
+ blend = IMB_BLEND_ADD_ALPHA;
+ break;
+ }
+ brush->blend = blend;
+ }
+ }
+ /* For now these match, in the future new items may not. */
+ brush->weightpaint_tool = brush->vertexpaint_tool;
+ }
#undef PAINT_BLEND_MIX
#undef PAINT_BLEND_ADD
@@ -2403,760 +2456,672 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
#undef PAINT_BLEND_HUE
#undef PAINT_BLEND_ALPHA_SUB
#undef PAINT_BLEND_ALPHA_ADD
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
- if (slink->spacetype == SPACE_USERPREF) {
- ARegion *navigation_region = BKE_spacedata_find_region_type(slink, area, RGN_TYPE_NAV_BAR);
-
- if (!navigation_region) {
- ARegion *main_region = BKE_spacedata_find_region_type(slink, area, RGN_TYPE_WINDOW);
- ListBase *regionbase = (slink == area->spacedata.first) ?
- &area->regionbase : &slink->regionbase;
-
- navigation_region = MEM_callocN(sizeof(ARegion), "userpref navigation-region do_versions");
-
- BLI_insertlinkbefore(regionbase, main_region, navigation_region); /* order matters, addhead not addtail! */
- navigation_region->regiontype = RGN_TYPE_NAV_BAR;
- navigation_region->alignment = RGN_ALIGN_LEFT;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) {
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.curvature_ridge_factor = 1.0f;
- v3d->shading.curvature_valley_factor = 1.0f;
- }
- }
- }
- }
- }
-
- /* Rename OpenGL to Workbench. */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (STREQ(scene->r.engine, "BLENDER_OPENGL")) {
- STRNCPY(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH);
- }
- }
-
- /* init Annotations onion skin */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "int", "gstep")) {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.302f, 0.851f, 0.302f);
- ARRAY_SET_ITEMS(gpl->gcolor_next, 0.250f, 0.1f, 1.0f);
- }
- }
- }
-
- /* Move studio_light selection to lookdev_light. */
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
- }
- }
- }
- }
- }
-
- /* Change Solid mode shadow orientation. */
- if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- float *dir = scene->display.light_direction;
- SWAP(float, dir[2], dir[1]);
- dir[2] = -dir[2];
- dir[0] = -dir[0];
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {
- for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
- ca->drawsize *= 2.0f;
- }
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->type != OB_EMPTY) {
- if (UNLIKELY(ob->transflag & OB_DUPLICOLLECTION)) {
- BKE_object_type_set_empty_for_versioning(ob);
- }
- }
- }
-
- /* Grease pencil primitive curve */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if ((gset) && (gset->cur_primitive == NULL)) {
- gset->cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- curvemapping_initialize(gset->cur_primitive);
- curvemap_reset(
- gset->cur_primitive->cm,
- &gset->cur_primitive->clipr,
- CURVE_PRESET_BELL,
- CURVEMAP_SLOPE_POSITIVE);
- }
- }
- }
- }
-
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
- if (DNA_struct_elem_find(fd->filesdna, "Object", "char", "empty_image_visibility_flag")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- ob->empty_image_visibility_flag ^= (
- OB_EMPTY_IMAGE_HIDE_PERSPECTIVE |
- OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC |
- OB_EMPTY_IMAGE_HIDE_BACK);
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_IMAGE:
- {
- SpaceImage *sima = (SpaceImage *)sl;
- sima->flag &= ~(
- SI_FLAG_UNUSED_0 |
- SI_FLAG_UNUSED_1 |
- SI_FLAG_UNUSED_3 |
- SI_FLAG_UNUSED_6 |
- SI_FLAG_UNUSED_7 |
- SI_FLAG_UNUSED_8 |
- SI_FLAG_UNUSED_17 |
- SI_FLAG_UNUSED_18 |
- SI_FLAG_UNUSED_23 |
- SI_FLAG_UNUSED_24);
- break;
- }
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D *)sl;
- v3d->flag &= ~(
- V3D_FLAG_UNUSED_0 |
- V3D_FLAG_UNUSED_1 |
- V3D_FLAG_UNUSED_10 |
- V3D_FLAG_UNUSED_12);
- v3d->flag2 &= ~(
- V3D_FLAG2_UNUSED_3 |
- V3D_FLAG2_UNUSED_6 |
- V3D_FLAG2_UNUSED_12 |
- V3D_FLAG2_UNUSED_13 |
- V3D_FLAG2_UNUSED_14 |
- V3D_FLAG2_UNUSED_15);
- break;
- }
- case SPACE_OUTLINER:
- {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->filter &= ~(
- SO_FILTER_UNUSED_1 |
- SO_FILTER_UNUSED_5 |
- SO_FILTER_UNUSED_12);
- so->storeflag &= ~(
- SO_TREESTORE_UNUSED_1);
- break;
- }
- case SPACE_FILE:
- {
- SpaceFile *sfile = (SpaceFile *)sl;
- if (sfile->params) {
- sfile->params->flag &= ~(
- FILE_PARAMS_FLAG_UNUSED_1 |
- FILE_PARAMS_FLAG_UNUSED_6 |
- FILE_PARAMS_FLAG_UNUSED_9);
- }
- break;
- }
- case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- snode->flag &= ~(
- SNODE_FLAG_UNUSED_6 |
- SNODE_FLAG_UNUSED_10 |
- SNODE_FLAG_UNUSED_11);
- break;
- }
- case SPACE_PROPERTIES:
- {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- sbuts->flag &= ~(
- SB_FLAG_UNUSED_2 |
- SB_FLAG_UNUSED_3);
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- snla->flag &= ~(
- SNLA_FLAG_UNUSED_0 |
- SNLA_FLAG_UNUSED_1 |
- SNLA_FLAG_UNUSED_3);
- break;
- }
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->r.mode &= ~(
- R_MODE_UNUSED_1 |
- R_MODE_UNUSED_2 |
- R_MODE_UNUSED_3 |
- R_MODE_UNUSED_4 |
- R_MODE_UNUSED_5 |
- R_MODE_UNUSED_6 |
- R_MODE_UNUSED_7 |
- R_MODE_UNUSED_8 |
- R_MODE_UNUSED_10 |
- R_MODE_UNUSED_13 |
- R_MODE_UNUSED_16 |
- R_MODE_UNUSED_17 |
- R_MODE_UNUSED_18 |
- R_MODE_UNUSED_19 |
- R_MODE_UNUSED_20 |
- R_MODE_UNUSED_21 |
- R_MODE_UNUSED_27);
-
- scene->r.scemode &= ~(
- R_SCEMODE_UNUSED_8 |
- R_SCEMODE_UNUSED_11 |
- R_SCEMODE_UNUSED_13 |
- R_SCEMODE_UNUSED_16 |
- R_SCEMODE_UNUSED_17 |
- R_SCEMODE_UNUSED_19);
-
- if (scene->toolsettings->sculpt) {
- scene->toolsettings->sculpt->flags &= ~(
- SCULPT_FLAG_UNUSED_0 |
- SCULPT_FLAG_UNUSED_1 |
- SCULPT_FLAG_UNUSED_2);
- }
-
- if (scene->ed) {
- Sequence *seq;
- SEQ_BEGIN (scene->ed, seq)
- {
- seq->flag &= ~(
- SEQ_FLAG_UNUSED_6 |
- SEQ_FLAG_UNUSED_18 |
- SEQ_FLAG_UNUSED_19 |
- SEQ_FLAG_UNUSED_21);
- if (seq->type == SEQ_TYPE_SPEED) {
- SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
- s->flags &= ~(
- SEQ_SPEED_UNUSED_1);
- }
- } SEQ_END;
- }
- }
-
- for (World *world = bmain->worlds.first; world; world = world->id.next) {
- world->flag &= ~(
- WO_MODE_UNUSED_1 |
- WO_MODE_UNUSED_2 |
- WO_MODE_UNUSED_3 |
- WO_MODE_UNUSED_4 |
- WO_MODE_UNUSED_5 |
- WO_MODE_UNUSED_7);
- }
-
- for (Image *image = bmain->images.first; image; image = image->id.next) {
- image->flag &= ~(
- IMA_FLAG_UNUSED_0 |
- IMA_FLAG_UNUSED_1 |
- IMA_FLAG_UNUSED_4 |
- IMA_FLAG_UNUSED_6 |
- IMA_FLAG_UNUSED_8 |
- IMA_FLAG_UNUSED_15 |
- IMA_FLAG_UNUSED_16);
- }
-
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- ob->flag &= ~(
- OB_FLAG_UNUSED_11 |
- OB_FLAG_UNUSED_12);
- ob->transflag &= ~(
- OB_TRANSFLAG_UNUSED_0 |
- OB_TRANSFLAG_UNUSED_1);
- ob->shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
- }
-
- for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
- me->flag &= ~(
- ME_FLAG_UNUSED_0 |
- ME_FLAG_UNUSED_1 |
- ME_FLAG_UNUSED_3 |
- ME_FLAG_UNUSED_4 |
- ME_FLAG_UNUSED_6 |
- ME_FLAG_UNUSED_7 |
- ME_FLAG_UNUSED_8);
- }
-
- for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- mat->blend_flag &= ~(
- MA_BL_FLAG_UNUSED_2);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 40)) {
- if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "snap_transform_mode_flag")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- scene->toolsettings->snap_transform_mode_flag =
- SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- enum { V3D_BACKFACE_CULLING = (1 << 10) };
- View3D *v3d = (View3D *)sl;
- if (v3d->flag2 & V3D_BACKFACE_CULLING) {
- v3d->flag2 &= ~V3D_BACKFACE_CULLING;
- v3d->shading.flag |= V3D_SHADING_BACKFACE_CULLING;
- }
- break;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_find(fd->filesdna, "TransformOrientationSlot")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (int i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
- scene->orientation_slots[i].index_custom = -1;
- }
- }
- }
-
- /* Grease pencil target weight */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "weight")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* sculpt brushes */
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if (gset) {
- for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
- GP_Sculpt_Data *gp_brush = &gset->brush[i];
- gp_brush->weight = 1.0f;
- }
- }
- }
- }
-
- /* Grease pencil cutter/select segment intersection threshold */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "isect_threshold")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- if (gset) {
- gset->isect_threshold = 0.1f;
- }
- }
- }
-
- /* Fix anamorphic bokeh eevee rna limits.*/
- for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
- if (ca->gpu_dof.ratio < 0.01f) {
- ca->gpu_dof.ratio = 0.01f;
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_USERPREF) {
- ARegion *execute_region = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_EXECUTE);
-
- if (!execute_region) {
- ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- ARegion *ar_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR);
-
- execute_region = MEM_callocN(sizeof(ARegion), "execute region for properties");
-
- BLI_assert(ar_navbar);
-
- BLI_insertlinkafter(regionbase, ar_navbar, execute_region);
-
- execute_region->regiontype = RGN_TYPE_EXECUTE;
- execute_region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
- execute_region->flag |= RGN_FLAG_DYNAMIC_SIZE;
- }
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 43)) {
- ListBase *lb = which_libbase(bmain, ID_BR);
- BKE_main_id_repair_duplicate_names_listbase(lb);
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 44)) {
- if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "a")) {
- for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- mat->a = 1.0f;
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- enum {
- R_ALPHAKEY = 2,
- };
- scene->r.seq_flag &= ~(
- R_SEQ_UNUSED_0 |
- R_SEQ_UNUSED_1 |
- R_SEQ_UNUSED_2);
- scene->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT_UNUSED_1;
- if (scene->r.alphamode == R_ALPHAKEY) {
- scene->r.alphamode = R_ADDSKY;
- }
- ToolSettings *ts = scene->toolsettings;
- ts->particle.flag &= ~PE_UNUSED_6;
- if (ts->sculpt != NULL) {
- ts->sculpt->flags &= ~SCULPT_FLAG_UNUSED_6;
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 45)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- sseq->flag |= SEQ_SHOW_MARKER_LINES;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 46)) {
- /* Add wireframe color. */
- if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR;
- }
- }
- }
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "View3DCursor", "short", "rotation_mode")) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (is_zero_v3(scene->cursor.rotation_axis)) {
- scene->cursor.rotation_mode = ROT_MODE_XYZ;
- scene->cursor.rotation_quaternion[0] = 1.0f;
- scene->cursor.rotation_axis[1] = 1.0f;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 47)) {
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- ParticleEditSettings *pset = &scene->toolsettings->particle;
- if (pset->brushtype < 0) {
- pset->brushtype = PE_BRUSH_COMB;
- }
- }
-
- LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
- {
- enum { PARCURVE = 1, PARKEY = 2, PAR_DEPRECATED = 16};
- if (ELEM(ob->partype, PARCURVE, PARKEY, PAR_DEPRECATED)) {
- ob->partype = PAROBJECT;
- }
- }
-
- {
- enum { OB_WAVE = 21, OB_LIFE = 23, OB_SECTOR = 24};
- if (ELEM(ob->type, OB_WAVE, OB_LIFE, OB_SECTOR)) {
- ob->type = OB_EMPTY;
- }
- }
-
- ob->transflag &= ~(
- OB_TRANSFLAG_UNUSED_0 |
- OB_TRANSFLAG_UNUSED_1 |
- OB_TRANSFLAG_UNUSED_3 |
- OB_TRANSFLAG_UNUSED_6 |
- OB_TRANSFLAG_UNUSED_12);
-
- ob->nlaflag &= ~(OB_ADS_UNUSED_1 | OB_ADS_UNUSED_2);
- }
-
- LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
- arm->flag &= ~(
- ARM_FLAG_UNUSED_1 |
- ARM_FLAG_UNUSED_5 |
- ARM_FLAG_UNUSED_7 |
- ARM_FLAG_UNUSED_12);
- }
-
- LISTBASE_FOREACH (Text *, text, &bmain->texts) {
- text->flags &= ~(TXT_FLAG_UNUSED_8 | TXT_FLAG_UNUSED_9);
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 48)) {
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- /* Those are not currently used, but are accessible through RNA API and were not
- * properly initialized previously. This is mere copy of BKE_init_scene() code. */
- if (scene->r.im_format.view_settings.look[0] == '\0') {
- BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
- BKE_color_managed_view_settings_init_render(&scene->r.im_format.view_settings,
- &scene->r.im_format.display_settings,
- "Filmic");
- }
-
- if (scene->r.bake.im_format.view_settings.look[0] == '\0') {
- BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
- BKE_color_managed_view_settings_init_render(&scene->r.bake.im_format.view_settings,
- &scene->r.bake.im_format.display_settings,
- "Filmic");
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) {
- /* All tool names changed, reset to defaults. */
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- while (!BLI_listbase_is_empty(&workspace->tools)) {
- BKE_workspace_tool_remove(workspace, workspace->tools.first);
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 52)) {
- LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
- /* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */
- if (part->ren_as == PART_DRAW_BB) {
- part->ren_as = PART_DRAW_NOT;
- }
- if (part->draw_as == PART_DRAW_BB) {
- part->draw_as = PART_DRAW_NOT;
- }
- }
-
- if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Triangulate) {
- TriangulateModifierData *smd = (TriangulateModifierData *)md;
- smd->min_vertices = 4;
- }
- }
- }
- }
-
- FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
- /* Fix missing version patching from earlier changes. */
- if (STREQ(node->idname, "ShaderNodeOutputLamp")) {
- STRNCPY(node->idname, "ShaderNodeOutputLight");
- }
- if (node->type == SH_NODE_BSDF_PRINCIPLED && node->custom2 == 0) {
- node->custom2 = SHD_SUBSURFACE_BURLEY;
- }
- }
- }
- } FOREACH_NODETREE_END;
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 53)) {
- for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
- /* Eevee: Keep material appearance consistent with previous behavior. */
- if (!mat->use_nodes || !mat->nodetree || mat->blend_method == MA_BM_SOLID) {
- mat->blend_shadow = MA_BS_SOLID;
- }
- }
-
- /* grease pencil default animation channel color */
- {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- if (gpd->flag & GP_DATA_ANNOTATIONS) {
- continue;
- }
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* default channel color */
- ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 54)) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- bool is_first_subdiv = true;
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
- if (is_first_subdiv) {
- smd->flags |= eSubsurfModifierFlag_UseCrease;
- }
- else {
- smd->flags &= ~eSubsurfModifierFlag_UseCrease;
- }
- is_first_subdiv = false;
- }
- else if (md->type == eModifierType_Multires) {
- MultiresModifierData *mmd = (MultiresModifierData *)md;
- if (is_first_subdiv) {
- mmd->flags |= eMultiresModifierFlag_UseCrease;
- }
- else {
- mmd->flags &= ~eMultiresModifierFlag_UseCrease;
- }
- is_first_subdiv = false;
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_TEXT) {
- ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- ARegion *ar = MEM_callocN(sizeof(ARegion), "footer for text");
-
- /* Remove multiple footers that were added by mistake. */
- ARegion *ar_footer, *ar_next;
- for (ar_footer = regionbase->first; ar_footer; ar_footer = ar_next) {
- ar_next = ar_footer->next;
- if (ar_footer->regiontype == RGN_TYPE_FOOTER) {
- BLI_freelinkN(regionbase, ar_footer);
- }
- }
-
- /* Add footer. */
- ARegion *ar_header = NULL;
-
- for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
- if (ar_header->regiontype == RGN_TYPE_HEADER) {
- break;
- }
- }
- BLI_assert(ar_header);
-
- BLI_insertlinkafter(regionbase, ar_header, ar);
-
- ar->regiontype = RGN_TYPE_FOOTER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 56)) {
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->gizmo_show_armature = V3D_GIZMO_SHOW_ARMATURE_BBONE | V3D_GIZMO_SHOW_ARMATURE_ROLL;
- v3d->gizmo_show_empty = V3D_GIZMO_SHOW_EMPTY_IMAGE | V3D_GIZMO_SHOW_EMPTY_FORCE_FIELD;
- v3d->gizmo_show_light = V3D_GIZMO_SHOW_LIGHT_SIZE | V3D_GIZMO_SHOW_LIGHT_LOOK_AT;
- v3d->gizmo_show_camera = V3D_GIZMO_SHOW_CAMERA_LENS | V3D_GIZMO_SHOW_CAMERA_DOF_DIST;
- }
- }
- }
- }
- }
-
- if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) {
- /* Enable Show Interpolation in dopesheet by default. */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
- if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) {
- saction->flag |= SACTION_SHOW_INTERPOLATION;
- }
- }
- }
- }
- }
-
- /* init grease pencil brush gradients */
- if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "gradient_f")) {
- for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->gpencil_settings != NULL) {
- BrushGpencilSettings *gp = brush->gpencil_settings;
- gp->gradient_f = 1.0f;
- gp->gradient_s[0] = 1.0f;
- gp->gradient_s[1] = 1.0f;
- }
- }
- }
-
- /* init grease pencil stroke gradients */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "float", "gradient_f")) {
- for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- gps->gradient_f = 1.0f;
- gps->gradient_s[0] = 1.0f;
- gps->gradient_s[1] = 1.0f;
- }
- }
- }
- }
- }
- }
-
- {
- if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pose) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (bConstraint *con = pchan->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
- bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
- if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) {
- data->yScaleMode = CONSTRAINT_SPLINEIK_YS_FIT_CURVE;
- }
- }
- }
- }
- }
- }
- }
-
- /* Versioning code until next subversion bump goes here. */
- }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
+ if (slink->spacetype == SPACE_USERPREF) {
+ ARegion *navigation_region = BKE_spacedata_find_region_type(
+ slink, area, RGN_TYPE_NAV_BAR);
+
+ if (!navigation_region) {
+ ARegion *main_region = BKE_spacedata_find_region_type(slink, area, RGN_TYPE_WINDOW);
+ ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase :
+ &slink->regionbase;
+
+ navigation_region = MEM_callocN(sizeof(ARegion),
+ "userpref navigation-region do_versions");
+
+ BLI_insertlinkbefore(regionbase,
+ main_region,
+ navigation_region); /* order matters, addhead not addtail! */
+ navigation_region->regiontype = RGN_TYPE_NAV_BAR;
+ navigation_region->alignment = RGN_ALIGN_LEFT;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.curvature_ridge_factor = 1.0f;
+ v3d->shading.curvature_valley_factor = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ /* Rename OpenGL to Workbench. */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (STREQ(scene->r.engine, "BLENDER_OPENGL")) {
+ STRNCPY(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH);
+ }
+ }
+
+ /* init Annotations onion skin */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "int", "gstep")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.302f, 0.851f, 0.302f);
+ ARRAY_SET_ITEMS(gpl->gcolor_next, 0.250f, 0.1f, 1.0f);
+ }
+ }
+ }
+
+ /* Move studio_light selection to lookdev_light. */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
+ }
+ }
+ }
+ }
+ }
+
+ /* Change Solid mode shadow orientation. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ float *dir = scene->display.light_direction;
+ SWAP(float, dir[2], dir[1]);
+ dir[2] = -dir[2];
+ dir[0] = -dir[0];
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {
+ for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
+ ca->drawsize *= 2.0f;
+ }
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->type != OB_EMPTY) {
+ if (UNLIKELY(ob->transflag & OB_DUPLICOLLECTION)) {
+ BKE_object_type_set_empty_for_versioning(ob);
+ }
+ }
+ }
+
+ /* Grease pencil primitive curve */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if ((gset) && (gset->cur_primitive == NULL)) {
+ gset->cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(gset->cur_primitive);
+ curvemap_reset(gset->cur_primitive->cm,
+ &gset->cur_primitive->clipr,
+ CURVE_PRESET_BELL,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 38)) {
+ if (DNA_struct_elem_find(fd->filesdna, "Object", "char", "empty_image_visibility_flag")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ob->empty_image_visibility_flag ^= (OB_EMPTY_IMAGE_HIDE_PERSPECTIVE |
+ OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC |
+ OB_EMPTY_IMAGE_HIDE_BACK);
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->flag &= ~(SI_FLAG_UNUSED_0 | SI_FLAG_UNUSED_1 | SI_FLAG_UNUSED_3 |
+ SI_FLAG_UNUSED_6 | SI_FLAG_UNUSED_7 | SI_FLAG_UNUSED_8 |
+ SI_FLAG_UNUSED_17 | SI_FLAG_UNUSED_18 | SI_FLAG_UNUSED_23 |
+ SI_FLAG_UNUSED_24);
+ break;
+ }
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+ v3d->flag &= ~(V3D_FLAG_UNUSED_0 | V3D_FLAG_UNUSED_1 | V3D_FLAG_UNUSED_10 |
+ V3D_FLAG_UNUSED_12);
+ v3d->flag2 &= ~(V3D_FLAG2_UNUSED_3 | V3D_FLAG2_UNUSED_6 | V3D_FLAG2_UNUSED_12 |
+ V3D_FLAG2_UNUSED_13 | V3D_FLAG2_UNUSED_14 | V3D_FLAG2_UNUSED_15);
+ break;
+ }
+ case SPACE_OUTLINER: {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+ so->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | SO_FILTER_UNUSED_12);
+ so->storeflag &= ~(SO_TREESTORE_UNUSED_1);
+ break;
+ }
+ case SPACE_FILE: {
+ SpaceFile *sfile = (SpaceFile *)sl;
+ if (sfile->params) {
+ sfile->params->flag &= ~(FILE_PARAMS_FLAG_UNUSED_1 | FILE_PARAMS_FLAG_UNUSED_6 |
+ FILE_PARAMS_FLAG_UNUSED_9);
+ }
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)sl;
+ snode->flag &= ~(SNODE_FLAG_UNUSED_6 | SNODE_FLAG_UNUSED_10 | SNODE_FLAG_UNUSED_11);
+ break;
+ }
+ case SPACE_PROPERTIES: {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+ sbuts->flag &= ~(SB_FLAG_UNUSED_2 | SB_FLAG_UNUSED_3);
+ break;
+ }
+ case SPACE_NLA: {
+ SpaceNla *snla = (SpaceNla *)sl;
+ snla->flag &= ~(SNLA_FLAG_UNUSED_0 | SNLA_FLAG_UNUSED_1 | SNLA_FLAG_UNUSED_3);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->r.mode &= ~(R_MODE_UNUSED_1 | R_MODE_UNUSED_2 | R_MODE_UNUSED_3 | R_MODE_UNUSED_4 |
+ R_MODE_UNUSED_5 | R_MODE_UNUSED_6 | R_MODE_UNUSED_7 | R_MODE_UNUSED_8 |
+ R_MODE_UNUSED_10 | R_MODE_UNUSED_13 | R_MODE_UNUSED_16 |
+ R_MODE_UNUSED_17 | R_MODE_UNUSED_18 | R_MODE_UNUSED_19 |
+ R_MODE_UNUSED_20 | R_MODE_UNUSED_21 | R_MODE_UNUSED_27);
+
+ scene->r.scemode &= ~(R_SCEMODE_UNUSED_8 | R_SCEMODE_UNUSED_11 | R_SCEMODE_UNUSED_13 |
+ R_SCEMODE_UNUSED_16 | R_SCEMODE_UNUSED_17 | R_SCEMODE_UNUSED_19);
+
+ if (scene->toolsettings->sculpt) {
+ scene->toolsettings->sculpt->flags &= ~(SCULPT_FLAG_UNUSED_0 | SCULPT_FLAG_UNUSED_1 |
+ SCULPT_FLAG_UNUSED_2);
+ }
+
+ if (scene->ed) {
+ Sequence *seq;
+ SEQ_BEGIN (scene->ed, seq) {
+ seq->flag &= ~(SEQ_FLAG_UNUSED_6 | SEQ_FLAG_UNUSED_18 | SEQ_FLAG_UNUSED_19 |
+ SEQ_FLAG_UNUSED_21);
+ if (seq->type == SEQ_TYPE_SPEED) {
+ SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
+ s->flags &= ~(SEQ_SPEED_UNUSED_1);
+ }
+ }
+ SEQ_END;
+ }
+ }
+
+ for (World *world = bmain->worlds.first; world; world = world->id.next) {
+ world->flag &= ~(WO_MODE_UNUSED_1 | WO_MODE_UNUSED_2 | WO_MODE_UNUSED_3 | WO_MODE_UNUSED_4 |
+ WO_MODE_UNUSED_5 | WO_MODE_UNUSED_7);
+ }
+
+ for (Image *image = bmain->images.first; image; image = image->id.next) {
+ image->flag &= ~(IMA_FLAG_UNUSED_0 | IMA_FLAG_UNUSED_1 | IMA_FLAG_UNUSED_4 |
+ IMA_FLAG_UNUSED_6 | IMA_FLAG_UNUSED_8 | IMA_FLAG_UNUSED_15 |
+ IMA_FLAG_UNUSED_16);
+ }
+
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ob->flag &= ~(OB_FLAG_UNUSED_11 | OB_FLAG_UNUSED_12);
+ ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1);
+ ob->shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
+ }
+
+ for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
+ me->flag &= ~(ME_FLAG_UNUSED_0 | ME_FLAG_UNUSED_1 | ME_FLAG_UNUSED_3 | ME_FLAG_UNUSED_4 |
+ ME_FLAG_UNUSED_6 | ME_FLAG_UNUSED_7 | ME_FLAG_UNUSED_8);
+ }
+
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ mat->blend_flag &= ~(MA_BL_FLAG_UNUSED_2);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 40)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "snap_transform_mode_flag")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ scene->toolsettings->snap_transform_mode_flag = SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ enum { V3D_BACKFACE_CULLING = (1 << 10) };
+ View3D *v3d = (View3D *)sl;
+ if (v3d->flag2 & V3D_BACKFACE_CULLING) {
+ v3d->flag2 &= ~V3D_BACKFACE_CULLING;
+ v3d->shading.flag |= V3D_SHADING_BACKFACE_CULLING;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_find(fd->filesdna, "TransformOrientationSlot")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ for (int i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
+ scene->orientation_slots[i].index_custom = -1;
+ }
+ }
+ }
+
+ /* Grease pencil target weight */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "weight")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ for (int i = 0; i < GP_SCULPT_TYPE_MAX; i++) {
+ GP_Sculpt_Data *gp_brush = &gset->brush[i];
+ gp_brush->weight = 1.0f;
+ }
+ }
+ }
+ }
+
+ /* Grease pencil cutter/select segment intersection threshold */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "float", "isect_threshold")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->isect_threshold = 0.1f;
+ }
+ }
+ }
+
+ /* Fix anamorphic bokeh eevee rna limits.*/
+ for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
+ if (ca->gpu_dof.ratio < 0.01f) {
+ ca->gpu_dof.ratio = 0.01f;
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_USERPREF) {
+ ARegion *execute_region = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_EXECUTE);
+
+ if (!execute_region) {
+ ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
+ &sl->regionbase;
+ ARegion *ar_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR);
+
+ execute_region = MEM_callocN(sizeof(ARegion), "execute region for properties");
+
+ BLI_assert(ar_navbar);
+
+ BLI_insertlinkafter(regionbase, ar_navbar, execute_region);
+
+ execute_region->regiontype = RGN_TYPE_EXECUTE;
+ execute_region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+ execute_region->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 43)) {
+ ListBase *lb = which_libbase(bmain, ID_BR);
+ BKE_main_id_repair_duplicate_names_listbase(lb);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 44)) {
+ if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "a")) {
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ mat->a = 1.0f;
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ enum {
+ R_ALPHAKEY = 2,
+ };
+ scene->r.seq_flag &= ~(R_SEQ_UNUSED_0 | R_SEQ_UNUSED_1 | R_SEQ_UNUSED_2);
+ scene->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT_UNUSED_1;
+ if (scene->r.alphamode == R_ALPHAKEY) {
+ scene->r.alphamode = R_ADDSKY;
+ }
+ ToolSettings *ts = scene->toolsettings;
+ ts->particle.flag &= ~PE_UNUSED_6;
+ if (ts->sculpt != NULL) {
+ ts->sculpt->flags &= ~SCULPT_FLAG_UNUSED_6;
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 45)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ sseq->flag |= SEQ_SHOW_MARKER_LINES;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 46)) {
+ /* Add wireframe color. */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR;
+ }
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DCursor", "short", "rotation_mode")) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (is_zero_v3(scene->cursor.rotation_axis)) {
+ scene->cursor.rotation_mode = ROT_MODE_XYZ;
+ scene->cursor.rotation_quaternion[0] = 1.0f;
+ scene->cursor.rotation_axis[1] = 1.0f;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 47)) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ ParticleEditSettings *pset = &scene->toolsettings->particle;
+ if (pset->brushtype < 0) {
+ pset->brushtype = PE_BRUSH_COMB;
+ }
+ }
+
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ {
+ enum { PARCURVE = 1, PARKEY = 2, PAR_DEPRECATED = 16 };
+ if (ELEM(ob->partype, PARCURVE, PARKEY, PAR_DEPRECATED)) {
+ ob->partype = PAROBJECT;
+ }
+ }
+
+ {
+ enum { OB_WAVE = 21, OB_LIFE = 23, OB_SECTOR = 24 };
+ if (ELEM(ob->type, OB_WAVE, OB_LIFE, OB_SECTOR)) {
+ ob->type = OB_EMPTY;
+ }
+ }
+
+ ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1 | OB_TRANSFLAG_UNUSED_3 |
+ OB_TRANSFLAG_UNUSED_6 | OB_TRANSFLAG_UNUSED_12);
+
+ ob->nlaflag &= ~(OB_ADS_UNUSED_1 | OB_ADS_UNUSED_2);
+ }
+
+ LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
+ arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_FLAG_UNUSED_5 | ARM_FLAG_UNUSED_7 |
+ ARM_FLAG_UNUSED_12);
+ }
+
+ LISTBASE_FOREACH (Text *, text, &bmain->texts) {
+ text->flags &= ~(TXT_FLAG_UNUSED_8 | TXT_FLAG_UNUSED_9);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 48)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* Those are not currently used, but are accessible through RNA API and were not
+ * properly initialized previously. This is mere copy of BKE_init_scene() code. */
+ if (scene->r.im_format.view_settings.look[0] == '\0') {
+ BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(
+ &scene->r.im_format.view_settings, &scene->r.im_format.display_settings, "Filmic");
+ }
+
+ if (scene->r.bake.im_format.view_settings.look[0] == '\0') {
+ BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(&scene->r.bake.im_format.view_settings,
+ &scene->r.bake.im_format.display_settings,
+ "Filmic");
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) {
+ /* All tool names changed, reset to defaults. */
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ while (!BLI_listbase_is_empty(&workspace->tools)) {
+ BKE_workspace_tool_remove(workspace, workspace->tools.first);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 52)) {
+ LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
+ /* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */
+ if (part->ren_as == PART_DRAW_BB) {
+ part->ren_as = PART_DRAW_NOT;
+ }
+ if (part->draw_as == PART_DRAW_BB) {
+ part->draw_as = PART_DRAW_NOT;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Triangulate) {
+ TriangulateModifierData *smd = (TriangulateModifierData *)md;
+ smd->min_vertices = 4;
+ }
+ }
+ }
+ }
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ /* Fix missing version patching from earlier changes. */
+ if (STREQ(node->idname, "ShaderNodeOutputLamp")) {
+ STRNCPY(node->idname, "ShaderNodeOutputLight");
+ }
+ if (node->type == SH_NODE_BSDF_PRINCIPLED && node->custom2 == 0) {
+ node->custom2 = SHD_SUBSURFACE_BURLEY;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 53)) {
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ /* Eevee: Keep material appearance consistent with previous behavior. */
+ if (!mat->use_nodes || !mat->nodetree || mat->blend_method == MA_BM_SOLID) {
+ mat->blend_shadow = MA_BS_SOLID;
+ }
+ }
+
+ /* grease pencil default animation channel color */
+ {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (gpd->flag & GP_DATA_ANNOTATIONS) {
+ continue;
+ }
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* default channel color */
+ ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 54)) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ bool is_first_subdiv = true;
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
+ if (is_first_subdiv) {
+ smd->flags |= eSubsurfModifierFlag_UseCrease;
+ }
+ else {
+ smd->flags &= ~eSubsurfModifierFlag_UseCrease;
+ }
+ is_first_subdiv = false;
+ }
+ else if (md->type == eModifierType_Multires) {
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
+ if (is_first_subdiv) {
+ mmd->flags |= eMultiresModifierFlag_UseCrease;
+ }
+ else {
+ mmd->flags &= ~eMultiresModifierFlag_UseCrease;
+ }
+ is_first_subdiv = false;
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_TEXT) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ ARegion *ar = MEM_callocN(sizeof(ARegion), "footer for text");
+
+ /* Remove multiple footers that were added by mistake. */
+ ARegion *ar_footer, *ar_next;
+ for (ar_footer = regionbase->first; ar_footer; ar_footer = ar_next) {
+ ar_next = ar_footer->next;
+ if (ar_footer->regiontype == RGN_TYPE_FOOTER) {
+ BLI_freelinkN(regionbase, ar_footer);
+ }
+ }
+
+ /* Add footer. */
+ ARegion *ar_header = NULL;
+
+ for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
+ if (ar_header->regiontype == RGN_TYPE_HEADER) {
+ break;
+ }
+ }
+ BLI_assert(ar_header);
+
+ BLI_insertlinkafter(regionbase, ar_header, ar);
+
+ ar->regiontype = RGN_TYPE_FOOTER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 56)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->gizmo_show_armature = V3D_GIZMO_SHOW_ARMATURE_BBONE |
+ V3D_GIZMO_SHOW_ARMATURE_ROLL;
+ v3d->gizmo_show_empty = V3D_GIZMO_SHOW_EMPTY_IMAGE | V3D_GIZMO_SHOW_EMPTY_FORCE_FIELD;
+ v3d->gizmo_show_light = V3D_GIZMO_SHOW_LIGHT_SIZE | V3D_GIZMO_SHOW_LIGHT_LOOK_AT;
+ v3d->gizmo_show_camera = V3D_GIZMO_SHOW_CAMERA_LENS | V3D_GIZMO_SHOW_CAMERA_DOF_DIST;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) {
+ /* Enable Show Interpolation in dopesheet by default. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)sl;
+ if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) {
+ saction->flag |= SACTION_SHOW_INTERPOLATION;
+ }
+ }
+ }
+ }
+ }
+
+ /* init grease pencil brush gradients */
+ if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "gradient_f")) {
+ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ if (brush->gpencil_settings != NULL) {
+ BrushGpencilSettings *gp = brush->gpencil_settings;
+ gp->gradient_f = 1.0f;
+ gp->gradient_s[0] = 1.0f;
+ gp->gradient_s[1] = 1.0f;
+ }
+ }
+ }
+
+ /* init grease pencil stroke gradients */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "float", "gradient_f")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ gps->gradient_f = 1.0f;
+ gps->gradient_s[0] = 1.0f;
+ gps->gradient_s[1] = 1.0f;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ {
+ if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pose) {
+ for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (bConstraint *con = pchan->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
+ bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
+ if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) {
+ data->yScaleMode = CONSTRAINT_SPLINEIK_YS_FIT_CURVE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* Versioning code until next subversion bump goes here. */
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 973057fa362..25bd738ce45 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -56,87 +56,86 @@
*/
void BLO_update_defaults_userpref_blend(void)
{
- /* default so DPI is detected automatically */
- U.dpi = 0;
- U.ui_scale = 1.0f;
+ /* default so DPI is detected automatically */
+ U.dpi = 0;
+ U.ui_scale = 1.0f;
#ifdef WITH_PYTHON_SECURITY
- /* use alternative setting for security nuts
- * otherwise we'd need to patch the binary blob - startup.blend.c */
- U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
+ /* use alternative setting for security nuts
+ * otherwise we'd need to patch the binary blob - startup.blend.c */
+ U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
#else
- U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
+ U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
#endif
- /* Clear addon preferences. */
- for (bAddon *addon = U.addons.first, *addon_next;
- addon != NULL;
- addon = addon_next)
- {
- addon_next = addon->next;
+ /* Clear addon preferences. */
+ for (bAddon *addon = U.addons.first, *addon_next; addon != NULL; addon = addon_next) {
+ addon_next = addon->next;
- if (addon->prop) {
- IDP_FreeProperty(addon->prop);
- MEM_freeN(addon->prop);
- addon->prop = NULL;
- }
- }
+ if (addon->prop) {
+ IDP_FreeProperty(addon->prop);
+ MEM_freeN(addon->prop);
+ addon->prop = NULL;
+ }
+ }
- /* Transform tweak with single click and drag. */
- U.flag |= USER_RELEASECONFIRM;
+ /* Transform tweak with single click and drag. */
+ U.flag |= USER_RELEASECONFIRM;
- /* Ignore the theme saved in the blend file,
- * instead use the theme from 'userdef_default_theme.c' */
- {
- bTheme *theme = U.themes.first;
- memcpy(theme, &U_theme_default, sizeof(bTheme));
- }
+ /* Ignore the theme saved in the blend file,
+ * instead use the theme from 'userdef_default_theme.c' */
+ {
+ bTheme *theme = U.themes.first;
+ memcpy(theme, &U_theme_default, sizeof(bTheme));
+ }
- /* Leave temp directory empty, will then get appropriate value per OS. */
- U.tempdir[0] = '\0';
+ /* Leave temp directory empty, will then get appropriate value per OS. */
+ U.tempdir[0] = '\0';
- /* Only enable tooltips translation by default, without actually enabling translation itself, for now. */
- U.transopts = USER_TR_TOOLTIPS;
- U.memcachelimit = 4096;
+ /* Only enable tooltips translation by default, without actually enabling translation itself, for now. */
+ U.transopts = USER_TR_TOOLTIPS;
+ U.memcachelimit = 4096;
- /* Auto perspective. */
- U.uiflag |= USER_AUTOPERSP;
+ /* Auto perspective. */
+ U.uiflag |= USER_AUTOPERSP;
- /* Init weight paint range. */
- BKE_colorband_init(&U.coba_weight, true);
+ /* Init weight paint range. */
+ BKE_colorband_init(&U.coba_weight, true);
- /* Default visible section. */
- U.userpref = USER_SECTION_INTERFACE;
+ /* Default visible section. */
+ U.userpref = USER_SECTION_INTERFACE;
- /* Default to left click select. */
- BKE_keyconfig_pref_set_select_mouse(&U, 0, true);
+ /* Default to left click select. */
+ BKE_keyconfig_pref_set_select_mouse(&U, 0, true);
}
-
/**
* Rename if the ID doesn't exist.
*/
-static ID *rename_id_for_versioning(Main *bmain, const short id_type, const char *name_src, const char *name_dst)
+static ID *rename_id_for_versioning(Main *bmain,
+ const short id_type,
+ const char *name_src,
+ const char *name_dst)
{
- /* We can ignore libraries */
- ListBase *lb = which_libbase(bmain, id_type);
- ID *id = NULL;
- for (ID *idtest = lb->first; idtest; idtest = idtest->next) {
- if (idtest->lib == NULL) {
- if (STREQ(idtest->name + 2, name_src)) {
- id = idtest;
- }
- if (STREQ(idtest->name + 2, name_dst)) {
- return NULL;
- }
- }
- }
- if (id != NULL) {
- BLI_strncpy(id->name + 2, name_dst, sizeof(id->name) - 2);
- /* We know it's unique, this just sorts. */
- BLI_libblock_ensure_unique_name(bmain, id->name);
- }
- return id;
+ /* We can ignore libraries */
+ ListBase *lb = which_libbase(bmain, id_type);
+ ID *id = NULL;
+ for (ID *idtest = lb->first; idtest; idtest = idtest->next) {
+ if (idtest->lib == NULL) {
+ if (STREQ(idtest->name + 2, name_src)) {
+ id = idtest;
+ }
+ if (STREQ(idtest->name + 2, name_dst)) {
+ return NULL;
+ }
+ }
+ }
+ if (id != NULL) {
+ BLI_strncpy(id->name + 2, name_dst, sizeof(id->name) - 2);
+ /* We know it's unique, this just sorts. */
+ BLI_libblock_ensure_unique_name(bmain, id->name);
+ }
+ return id;
}
/**
@@ -144,217 +143,214 @@ static ID *rename_id_for_versioning(Main *bmain, const short id_type, const char
* This function can be emptied each time the startup.blend is updated. */
void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
{
- /* For all startup.blend files. */
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
- BKE_area_region_panels_free(&ar->panels);
-
- /* some toolbars have been saved as initialized,
- * we don't want them to have odd zoom-level or scrolling set, see: T47047 */
- if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
- ar->v2d.flag &= ~V2D_IS_INITIALISED;
- }
- }
-
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D:
- {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.texture_paint_mode_opacity = 1.0f;
- v3d->overlay.weight_paint_mode_opacity = 1.0f;
- v3d->overlay.vertex_paint_mode_opacity = 1.0f;
- /* grease pencil settings */
- v3d->vertex_opacity = 1.0f;
- v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
- /* Skip startups that use the viewport color by default. */
- if (v3d->shading.background_type != V3D_SHADING_BACKGROUND_VIEWPORT) {
- copy_v3_fl(v3d->shading.background_color, 0.05f);
- }
- break;
- }
- case SPACE_FILE:
- {
- SpaceFile *sfile = (SpaceFile *)sl;
- if (sfile->params) {
- const char *dir_default = BKE_appdir_folder_default();
- if (dir_default) {
- STRNCPY(sfile->params->dir, dir_default);
- sfile->params->file[0] = '\0';
- }
- }
- break;
- }
- }
- }
- }
- }
-
- if (app_template == NULL) {
- /* Name all screens by their workspaces (avoids 'Default.###' names). */
- {
- /* Default only has one window. */
- wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook, workspace);
- bScreen *screen = layout->screen;
- BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
- BLI_libblock_ensure_unique_name(bmain, screen->id.name);
- }
- }
-
- {
- /* 'UV Editing' should use UV mode. */
- bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
- if (sima->mode == SI_MODE_VIEW) {
- sima->mode = SI_MODE_UV;
- }
- }
- }
- }
- }
- }
-
- /* For 2D animation template. */
- if (app_template && STREQ(app_template, "2D_Animation")) {
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- const char *name = workspace->id.name + 2;
-
- if (STREQ(name, "Drawing")) {
- workspace->object_mode = OB_MODE_PAINT_GPENCIL;
- }
- }
- /* set object in drawing mode */
- for (Object *object = bmain->objects.first; object; object = object->id.next) {
- if (object->type == OB_GPENCIL) {
- bGPdata *gpd = (bGPdata *)object->data;
- object->mode = OB_MODE_PAINT_GPENCIL;
- gpd->flag |= GP_DATA_STROKE_PAINTMODE;
- break;
- }
- }
-
- /* Be sure curfalloff and primitive are initializated */
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- ToolSettings *ts = scene->toolsettings;
- if (ts->gp_sculpt.cur_falloff == NULL) {
- ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
- curvemapping_initialize(gp_falloff_curve);
- curvemap_reset(
- gp_falloff_curve->cm,
- &gp_falloff_curve->clipr,
- CURVE_PRESET_GAUSS,
- CURVEMAP_SLOPE_POSITIVE);
- }
- if (ts->gp_sculpt.cur_primitive == NULL) {
- ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
- curvemapping_initialize(gp_primitive_curve);
- curvemap_reset(
- gp_primitive_curve->cm,
- &gp_primitive_curve->clipr,
- CURVE_PRESET_BELL,
- CURVEMAP_SLOPE_POSITIVE);
- }
- }
- }
-
- /* For all builtin templates shipped with Blender. */
- bool builtin_template = (
- !app_template ||
- STREQ(app_template, "2D_Animation") ||
- STREQ(app_template, "Sculpting") ||
- STREQ(app_template, "VFX") ||
- STREQ(app_template, "Video_Editing"));
-
- if (builtin_template) {
- /* Clear all tools to use default options instead, ignore the tool saved in the file. */
- for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
- while (!BLI_listbase_is_empty(&workspace->tools)) {
- BKE_workspace_tool_remove(workspace, workspace->tools.first);
- }
- }
-
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- /* Hide channels in timelines. */
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- SpaceAction *saction = (sa->spacetype == SPACE_ACTION) ? sa->spacedata.first : NULL;
-
- if (saction && saction->mode == SACTCONT_TIMELINE) {
- for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_CHANNELS) {
- ar->flag |= RGN_FLAG_HIDDEN;
- }
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
-
- scene->r.cfra = 1.0f;
- scene->r.displaymode = R_OUTPUT_WINDOW;
-
- if (app_template && STREQ(app_template, "Video_Editing")) {
- /* Filmic is too slow, use default until it is optimized. */
- STRNCPY(scene->view_settings.view_transform, "Default");
- STRNCPY(scene->view_settings.look, "None");
- }
- else {
- /* AV Sync break physics sim caching, disable until that is fixed. */
- scene->audio.flag &= ~AUDIO_SYNC;
- scene->flag &= ~SCE_FRAME_DROP;
- }
-
- /* Don't enable compositing nodes. */
- if (scene->nodetree) {
- ntreeFreeNestedTree(scene->nodetree);
- MEM_freeN(scene->nodetree);
- scene->nodetree = NULL;
- scene->use_nodes = false;
- }
-
- /* Rename render layers. */
- BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
-
- /* New EEVEE defaults. */
- scene->eevee.bloom_intensity = 0.05f;
- scene->eevee.bloom_clamp = 0.0f;
- scene->eevee.motion_blur_shutter = 0.5f;
- }
-
- /* Rename light objects. */
- rename_id_for_versioning(bmain, ID_OB, "Light", "Light");
- rename_id_for_versioning(bmain, ID_LA, "Light", "Light");
-
- for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
- /* Match default for new meshes. */
- mesh->smoothresh = DEG2RADF(30);
- }
- }
-
- for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
- }
- }
- }
- }
-
- for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
- copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f);
- copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
- }
+ /* For all startup.blend files. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+ /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
+ BKE_area_region_panels_free(&ar->panels);
+
+ /* some toolbars have been saved as initialized,
+ * we don't want them to have odd zoom-level or scrolling set, see: T47047 */
+ if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
+ ar->v2d.flag &= ~V2D_IS_INITIALISED;
+ }
+ }
+
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.texture_paint_mode_opacity = 1.0f;
+ v3d->overlay.weight_paint_mode_opacity = 1.0f;
+ v3d->overlay.vertex_paint_mode_opacity = 1.0f;
+ /* grease pencil settings */
+ v3d->vertex_opacity = 1.0f;
+ v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
+ /* Skip startups that use the viewport color by default. */
+ if (v3d->shading.background_type != V3D_SHADING_BACKGROUND_VIEWPORT) {
+ copy_v3_fl(v3d->shading.background_color, 0.05f);
+ }
+ break;
+ }
+ case SPACE_FILE: {
+ SpaceFile *sfile = (SpaceFile *)sl;
+ if (sfile->params) {
+ const char *dir_default = BKE_appdir_folder_default();
+ if (dir_default) {
+ STRNCPY(sfile->params->dir, dir_default);
+ sfile->params->file[0] = '\0';
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (app_template == NULL) {
+ /* Name all screens by their workspaces (avoids 'Default.###' names). */
+ {
+ /* Default only has one window. */
+ wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook,
+ workspace);
+ bScreen *screen = layout->screen;
+ BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
+ BLI_libblock_ensure_unique_name(bmain, screen->id.name);
+ }
+ }
+
+ {
+ /* 'UV Editing' should use UV mode. */
+ bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ if (sima->mode == SI_MODE_VIEW) {
+ sima->mode = SI_MODE_UV;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* For 2D animation template. */
+ if (app_template && STREQ(app_template, "2D_Animation")) {
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ const char *name = workspace->id.name + 2;
+
+ if (STREQ(name, "Drawing")) {
+ workspace->object_mode = OB_MODE_PAINT_GPENCIL;
+ }
+ }
+ /* set object in drawing mode */
+ for (Object *object = bmain->objects.first; object; object = object->id.next) {
+ if (object->type == OB_GPENCIL) {
+ bGPdata *gpd = (bGPdata *)object->data;
+ object->mode = OB_MODE_PAINT_GPENCIL;
+ gpd->flag |= GP_DATA_STROKE_PAINTMODE;
+ break;
+ }
+ }
+
+ /* Be sure curfalloff and primitive are initializated */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ ToolSettings *ts = scene->toolsettings;
+ if (ts->gp_sculpt.cur_falloff == NULL) {
+ ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
+ curvemapping_initialize(gp_falloff_curve);
+ curvemap_reset(gp_falloff_curve->cm,
+ &gp_falloff_curve->clipr,
+ CURVE_PRESET_GAUSS,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ if (ts->gp_sculpt.cur_primitive == NULL) {
+ ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
+ curvemapping_initialize(gp_primitive_curve);
+ curvemap_reset(gp_primitive_curve->cm,
+ &gp_primitive_curve->clipr,
+ CURVE_PRESET_BELL,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ }
+ }
+
+ /* For all builtin templates shipped with Blender. */
+ bool builtin_template = (!app_template || STREQ(app_template, "2D_Animation") ||
+ STREQ(app_template, "Sculpting") || STREQ(app_template, "VFX") ||
+ STREQ(app_template, "Video_Editing"));
+
+ if (builtin_template) {
+ /* Clear all tools to use default options instead, ignore the tool saved in the file. */
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ while (!BLI_listbase_is_empty(&workspace->tools)) {
+ BKE_workspace_tool_remove(workspace, workspace->tools.first);
+ }
+ }
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ /* Hide channels in timelines. */
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ SpaceAction *saction = (sa->spacetype == SPACE_ACTION) ? sa->spacedata.first : NULL;
+
+ if (saction && saction->mode == SACTCONT_TIMELINE) {
+ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_CHANNELS) {
+ ar->flag |= RGN_FLAG_HIDDEN;
+ }
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
+
+ scene->r.cfra = 1.0f;
+ scene->r.displaymode = R_OUTPUT_WINDOW;
+
+ if (app_template && STREQ(app_template, "Video_Editing")) {
+ /* Filmic is too slow, use default until it is optimized. */
+ STRNCPY(scene->view_settings.view_transform, "Default");
+ STRNCPY(scene->view_settings.look, "None");
+ }
+ else {
+ /* AV Sync break physics sim caching, disable until that is fixed. */
+ scene->audio.flag &= ~AUDIO_SYNC;
+ scene->flag &= ~SCE_FRAME_DROP;
+ }
+
+ /* Don't enable compositing nodes. */
+ if (scene->nodetree) {
+ ntreeFreeNestedTree(scene->nodetree);
+ MEM_freeN(scene->nodetree);
+ scene->nodetree = NULL;
+ scene->use_nodes = false;
+ }
+
+ /* Rename render layers. */
+ BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
+
+ /* New EEVEE defaults. */
+ scene->eevee.bloom_intensity = 0.05f;
+ scene->eevee.bloom_clamp = 0.0f;
+ scene->eevee.motion_blur_shutter = 0.5f;
+ }
+
+ /* Rename light objects. */
+ rename_id_for_versioning(bmain, ID_OB, "Light", "Light");
+ rename_id_for_versioning(bmain, ID_LA, "Light", "Light");
+
+ for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
+ /* Match default for new meshes. */
+ mesh->smoothresh = DEG2RADF(30);
+ }
+ }
+
+ for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
+ copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f);
+ copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_dna.c b/source/blender/blenloader/intern/versioning_dna.c
index 8032f4c6b51..aee54b94833 100644
--- a/source/blender/blenloader/intern/versioning_dna.c
+++ b/source/blender/blenloader/intern/versioning_dna.c
@@ -42,21 +42,21 @@
void blo_do_versions_dna(SDNA *sdna, const int versionfile, const int subversionfile)
{
#define DNA_VERSION_ATLEAST(ver, subver) \
- (versionfile > (ver) || (versionfile == (ver) && (subversionfile >= (subver))))
+ (versionfile > (ver) || (versionfile == (ver) && (subversionfile >= (subver))))
- if (!DNA_VERSION_ATLEAST(280, 2)) {
- /* Version files created in the 'blender2.8' branch
- * between October 2016, and November 2017 (>=280.0 and < 280.2). */
- if (versionfile >= 280) {
- DNA_sdna_patch_struct(sdna, "SceneLayer", "ViewLayer");
- DNA_sdna_patch_struct(sdna, "SceneLayerEngineData", "ViewLayerEngineData");
- DNA_sdna_patch_struct_member(sdna, "FileGlobal", "cur_render_layer", "cur_view_layer");
- DNA_sdna_patch_struct_member(sdna, "ParticleEditSettings", "scene_layer", "view_layer");
- DNA_sdna_patch_struct_member(sdna, "Scene", "active_layer", "active_view_layer");
- DNA_sdna_patch_struct_member(sdna, "Scene", "render_layers", "view_layers");
- DNA_sdna_patch_struct_member(sdna, "WorkSpace", "render_layer", "view_layer");
- }
- }
+ if (!DNA_VERSION_ATLEAST(280, 2)) {
+ /* Version files created in the 'blender2.8' branch
+ * between October 2016, and November 2017 (>=280.0 and < 280.2). */
+ if (versionfile >= 280) {
+ DNA_sdna_patch_struct(sdna, "SceneLayer", "ViewLayer");
+ DNA_sdna_patch_struct(sdna, "SceneLayerEngineData", "ViewLayerEngineData");
+ DNA_sdna_patch_struct_member(sdna, "FileGlobal", "cur_render_layer", "cur_view_layer");
+ DNA_sdna_patch_struct_member(sdna, "ParticleEditSettings", "scene_layer", "view_layer");
+ DNA_sdna_patch_struct_member(sdna, "Scene", "active_layer", "active_view_layer");
+ DNA_sdna_patch_struct_member(sdna, "Scene", "render_layers", "view_layers");
+ DNA_sdna_patch_struct_member(sdna, "WorkSpace", "render_layer", "view_layer");
+ }
+ }
#undef DNA_VERSION_ATLEAST
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 5d7905b200e..7fea9dffece 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -21,14 +21,13 @@
* \ingroup blenloader
*/
-
#include <limits.h>
#ifndef WIN32
-# include <unistd.h> // for read close
+# include <unistd.h> // for read close
#else
-# include <zlib.h> /* odd include order-issue */
-# include <io.h> // for open close read
+# include <zlib.h> /* odd include order-issue */
+# include <io.h> // for open close read
# include "winsock2.h"
# include "BLI_winstuff.h"
#endif
@@ -74,8 +73,8 @@
#include "BKE_fcurve.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
-#include "BKE_main.h" // for Main
-#include "BKE_mesh.h" // for ME_ defines (patching)
+#include "BKE_main.h" // for Main
+#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -94,2451 +93,2437 @@
static void vcol_to_fcol(Mesh *me)
{
- MFace *mface;
- uint *mcol, *mcoln, *mcolmain;
- int a;
-
- if (me->totface == 0 || me->mcol == NULL)
- return;
-
- mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
- mcol = (uint *)me->mcol;
- mface = me->mface;
- for (a = me->totface; a > 0; a--, mface++) {
- mcoln[0] = mcol[mface->v1];
- mcoln[1] = mcol[mface->v2];
- mcoln[2] = mcol[mface->v3];
- mcoln[3] = mcol[mface->v4];
- mcoln += 4;
- }
-
- MEM_freeN(me->mcol);
- me->mcol = (MCol *)mcolmain;
+ MFace *mface;
+ uint *mcol, *mcoln, *mcolmain;
+ int a;
+
+ if (me->totface == 0 || me->mcol == NULL)
+ return;
+
+ mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
+ mcol = (uint *)me->mcol;
+ mface = me->mface;
+ for (a = me->totface; a > 0; a--, mface++) {
+ mcoln[0] = mcol[mface->v1];
+ mcoln[1] = mcol[mface->v2];
+ mcoln[2] = mcol[mface->v3];
+ mcoln[3] = mcol[mface->v4];
+ mcoln += 4;
+ }
+
+ MEM_freeN(me->mcol);
+ me->mcol = (MCol *)mcolmain;
}
static void do_version_bone_head_tail_237(Bone *bone)
{
- Bone *child;
- float vec[3];
+ Bone *child;
+ float vec[3];
- /* head */
- copy_v3_v3(bone->arm_head, bone->arm_mat[3]);
+ /* head */
+ copy_v3_v3(bone->arm_head, bone->arm_mat[3]);
- /* tail is in current local coord system */
- copy_v3_v3(vec, bone->arm_mat[1]);
- mul_v3_fl(vec, bone->length);
- add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
+ /* tail is in current local coord system */
+ copy_v3_v3(vec, bone->arm_mat[1]);
+ mul_v3_fl(vec, bone->length);
+ add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
- for (child = bone->childbase.first; child; child = child->next)
- do_version_bone_head_tail_237(child);
+ for (child = bone->childbase.first; child; child = child->next)
+ do_version_bone_head_tail_237(child);
}
static void bone_version_238(ListBase *lb)
{
- Bone *bone;
-
- for (bone = lb->first; bone; bone = bone->next) {
- if (bone->rad_tail == 0.0f && bone->rad_head == 0.0f) {
- bone->rad_head = 0.25f * bone->length;
- bone->rad_tail = 0.1f * bone->length;
-
- bone->dist -= bone->rad_head;
- if (bone->dist <= 0.0f)
- bone->dist = 0.0f;
- }
- bone_version_238(&bone->childbase);
- }
+ Bone *bone;
+
+ for (bone = lb->first; bone; bone = bone->next) {
+ if (bone->rad_tail == 0.0f && bone->rad_head == 0.0f) {
+ bone->rad_head = 0.25f * bone->length;
+ bone->rad_tail = 0.1f * bone->length;
+
+ bone->dist -= bone->rad_head;
+ if (bone->dist <= 0.0f)
+ bone->dist = 0.0f;
+ }
+ bone_version_238(&bone->childbase);
+ }
}
static void bone_version_239(ListBase *lb)
{
- Bone *bone;
+ Bone *bone;
- for (bone = lb->first; bone; bone = bone->next) {
- if (bone->layer == 0)
- bone->layer = 1;
- bone_version_239(&bone->childbase);
- }
+ for (bone = lb->first; bone; bone = bone->next) {
+ if (bone->layer == 0)
+ bone->layer = 1;
+ bone_version_239(&bone->childbase);
+ }
}
static void ntree_version_241(bNodeTree *ntree)
{
- bNode *node;
-
- if (ntree->type == NTREE_COMPOSIT) {
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_BLUR) {
- if (node->storage == NULL) {
- NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch");
- nbd->sizex = node->custom1;
- nbd->sizey = node->custom2;
- nbd->filtertype = R_FILTER_QUAD;
- node->storage = nbd;
- }
- }
- else if (node->type == CMP_NODE_VECBLUR) {
- if (node->storage == NULL) {
- NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch");
- nbd->samples = node->custom1;
- nbd->maxspeed = node->custom2;
- nbd->fac = 1.0f;
- node->storage = nbd;
- }
- }
- }
- }
+ bNode *node;
+
+ if (ntree->type == NTREE_COMPOSIT) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_BLUR) {
+ if (node->storage == NULL) {
+ NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch");
+ nbd->sizex = node->custom1;
+ nbd->sizey = node->custom2;
+ nbd->filtertype = R_FILTER_QUAD;
+ node->storage = nbd;
+ }
+ }
+ else if (node->type == CMP_NODE_VECBLUR) {
+ if (node->storage == NULL) {
+ NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch");
+ nbd->samples = node->custom1;
+ nbd->maxspeed = node->custom2;
+ nbd->fac = 1.0f;
+ node->storage = nbd;
+ }
+ }
+ }
+ }
}
static void ntree_version_242(bNodeTree *ntree)
{
- bNode *node;
-
- if (ntree->type == NTREE_COMPOSIT) {
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_HUE_SAT) {
- if (node->storage) {
- NodeHueSat *nhs = node->storage;
- if (nhs->val == 0.0f)
- nhs->val = 1.0f;
- }
- }
- }
- }
+ bNode *node;
+
+ if (ntree->type == NTREE_COMPOSIT) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_HUE_SAT) {
+ if (node->storage) {
+ NodeHueSat *nhs = node->storage;
+ if (nhs->val == 0.0f)
+ nhs->val = 1.0f;
+ }
+ }
+ }
+ }
}
static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
{
- bNode *node;
- NodeTwoFloats *ntf;
- ID *nodeid;
- Image *image;
- ImageUser *iuser;
-
- if (ntree->type == NTREE_COMPOSIT) {
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_ALPHAOVER) {
- if (!node->storage) {
- ntf = MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats");
- node->storage = ntf;
- if (node->custom1)
- ntf->x = 1.0f;
- }
- }
-
- /* fix for temporary flag changes during 245 cycle */
- nodeid = blo_do_versions_newlibadr(fd, lib, node->id);
- if (node->storage && nodeid && GS(nodeid->name) == ID_IM) {
- image = (Image *)nodeid;
- iuser = node->storage;
- if (iuser->flag & IMA_OLD_PREMUL) {
- iuser->flag &= ~IMA_OLD_PREMUL;
- }
- if (iuser->flag & IMA_DO_PREMUL) {
- image->flag &= ~IMA_OLD_PREMUL;
- image->alpha_mode = IMA_ALPHA_STRAIGHT;
- }
- }
- }
- }
+ bNode *node;
+ NodeTwoFloats *ntf;
+ ID *nodeid;
+ Image *image;
+ ImageUser *iuser;
+
+ if (ntree->type == NTREE_COMPOSIT) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_ALPHAOVER) {
+ if (!node->storage) {
+ ntf = MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats");
+ node->storage = ntf;
+ if (node->custom1)
+ ntf->x = 1.0f;
+ }
+ }
+
+ /* fix for temporary flag changes during 245 cycle */
+ nodeid = blo_do_versions_newlibadr(fd, lib, node->id);
+ if (node->storage && nodeid && GS(nodeid->name) == ID_IM) {
+ image = (Image *)nodeid;
+ iuser = node->storage;
+ if (iuser->flag & IMA_OLD_PREMUL) {
+ iuser->flag &= ~IMA_OLD_PREMUL;
+ }
+ if (iuser->flag & IMA_DO_PREMUL) {
+ image->flag &= ~IMA_OLD_PREMUL;
+ image->alpha_mode = IMA_ALPHA_STRAIGHT;
+ }
+ }
+ }
+ }
}
static void idproperties_fix_groups_lengths_recurse(IDProperty *prop)
{
- IDProperty *loop;
- int i;
-
- for (loop = prop->data.group.first, i = 0; loop; loop = loop->next, i++) {
- if (loop->type == IDP_GROUP)
- idproperties_fix_groups_lengths_recurse(loop);
- }
-
- if (prop->len != i) {
- printf("Found and fixed bad id property group length.\n");
- prop->len = i;
- }
+ IDProperty *loop;
+ int i;
+
+ for (loop = prop->data.group.first, i = 0; loop; loop = loop->next, i++) {
+ if (loop->type == IDP_GROUP)
+ idproperties_fix_groups_lengths_recurse(loop);
+ }
+
+ if (prop->len != i) {
+ printf("Found and fixed bad id property group length.\n");
+ prop->len = i;
+ }
}
static void idproperties_fix_group_lengths(ListBase idlist)
{
- ID *id;
+ ID *id;
- for (id = idlist.first; id; id = id->next) {
- if (id->properties) {
- idproperties_fix_groups_lengths_recurse(id->properties);
- }
- }
+ for (id = idlist.first; id; id = id->next) {
+ if (id->properties) {
+ idproperties_fix_groups_lengths_recurse(id->properties);
+ }
+ }
}
static void customdata_version_242(Mesh *me)
{
- CustomDataLayer *layer;
- MTFace *mtf;
- MCol *mcol;
- TFace *tf;
- int a, mtfacen, mcoln;
-
- if (!me->vdata.totlayer) {
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
-
- if (me->dvert)
- CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
- }
-
- if (!me->edata.totlayer)
- CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
-
- if (!me->fdata.totlayer) {
- CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
-
- if (me->tface) {
- if (me->mcol)
- MEM_freeN(me->mcol);
-
- me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
- me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
-
- mtf = me->mtface;
- mcol = me->mcol;
- tf = me->tface;
-
- for (a = 0; a < me->totface; a++, mtf++, tf++, mcol += 4) {
- memcpy(mcol, tf->col, sizeof(tf->col));
- memcpy(mtf->uv, tf->uv, sizeof(tf->uv));
- }
-
- MEM_freeN(me->tface);
- me->tface = NULL;
- }
- else if (me->mcol) {
- me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface);
- }
- }
-
- if (me->tface) {
- MEM_freeN(me->tface);
- me->tface = NULL;
- }
-
- for (a = 0, mtfacen = 0, mcoln = 0; a < me->fdata.totlayer; a++) {
- layer = &me->fdata.layers[a];
-
- if (layer->type == CD_MTFACE) {
- if (layer->name[0] == 0) {
- if (mtfacen == 0) strcpy(layer->name, "UVMap");
- else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
- }
- mtfacen++;
- }
- else if (layer->type == CD_MCOL) {
- if (layer->name[0] == 0) {
- if (mcoln == 0)
- strcpy(layer->name, "Col");
- else
- BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
- }
- mcoln++;
- }
- }
-
- BKE_mesh_update_customdata_pointers(me, true);
+ CustomDataLayer *layer;
+ MTFace *mtf;
+ MCol *mcol;
+ TFace *tf;
+ int a, mtfacen, mcoln;
+
+ if (!me->vdata.totlayer) {
+ CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
+
+ if (me->dvert)
+ CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
+ }
+
+ if (!me->edata.totlayer)
+ CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
+
+ if (!me->fdata.totlayer) {
+ CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
+
+ if (me->tface) {
+ if (me->mcol)
+ MEM_freeN(me->mcol);
+
+ me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
+ me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
+
+ mtf = me->mtface;
+ mcol = me->mcol;
+ tf = me->tface;
+
+ for (a = 0; a < me->totface; a++, mtf++, tf++, mcol += 4) {
+ memcpy(mcol, tf->col, sizeof(tf->col));
+ memcpy(mtf->uv, tf->uv, sizeof(tf->uv));
+ }
+
+ MEM_freeN(me->tface);
+ me->tface = NULL;
+ }
+ else if (me->mcol) {
+ me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface);
+ }
+ }
+
+ if (me->tface) {
+ MEM_freeN(me->tface);
+ me->tface = NULL;
+ }
+
+ for (a = 0, mtfacen = 0, mcoln = 0; a < me->fdata.totlayer; a++) {
+ layer = &me->fdata.layers[a];
+
+ if (layer->type == CD_MTFACE) {
+ if (layer->name[0] == 0) {
+ if (mtfacen == 0)
+ strcpy(layer->name, "UVMap");
+ else
+ BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
+ }
+ mtfacen++;
+ }
+ else if (layer->type == CD_MCOL) {
+ if (layer->name[0] == 0) {
+ if (mcoln == 0)
+ strcpy(layer->name, "Col");
+ else
+ BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
+ }
+ mcoln++;
+ }
+ }
+
+ BKE_mesh_update_customdata_pointers(me, true);
}
/*only copy render texface layer from active*/
static void customdata_version_243(Mesh *me)
{
- CustomDataLayer *layer;
- int a;
+ CustomDataLayer *layer;
+ int a;
- for (a = 0; a < me->fdata.totlayer; a++) {
- layer = &me->fdata.layers[a];
- layer->active_rnd = layer->active;
- }
+ for (a = 0; a < me->fdata.totlayer; a++) {
+ layer = &me->fdata.layers[a];
+ layer->active_rnd = layer->active;
+ }
}
/* struct NodeImageAnim moved to ImageUser, and we make it default available */
static void do_version_ntree_242_2(bNodeTree *ntree)
{
- bNode *node;
-
- if (ntree->type == NTREE_COMPOSIT) {
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
- /* only image had storage */
- if (node->storage) {
- NodeImageAnim *nia = node->storage;
- ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "ima user node");
-
- iuser->frames = nia->frames;
- iuser->sfra = nia->sfra;
- iuser->offset = nia->nr - 1;
- iuser->cycl = nia->cyclic;
- iuser->ok = 1;
-
- node->storage = iuser;
- MEM_freeN(nia);
- }
- else {
- ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user");
- iuser->sfra = 1;
- iuser->ok = 1;
- }
- }
- }
- }
+ bNode *node;
+
+ if (ntree->type == NTREE_COMPOSIT) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+ /* only image had storage */
+ if (node->storage) {
+ NodeImageAnim *nia = node->storage;
+ ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "ima user node");
+
+ iuser->frames = nia->frames;
+ iuser->sfra = nia->sfra;
+ iuser->offset = nia->nr - 1;
+ iuser->cycl = nia->cyclic;
+ iuser->ok = 1;
+
+ node->storage = iuser;
+ MEM_freeN(nia);
+ }
+ else {
+ ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user");
+ iuser->sfra = 1;
+ iuser->ok = 1;
+ }
+ }
+ }
+ }
}
static void do_version_free_effect_245(Effect *eff)
{
- PartEff *paf;
-
- if (eff->type == EFF_PARTICLE) {
- paf = (PartEff *)eff;
- if (paf->keys)
- MEM_freeN(paf->keys);
- }
- MEM_freeN(eff);
+ PartEff *paf;
+
+ if (eff->type == EFF_PARTICLE) {
+ paf = (PartEff *)eff;
+ if (paf->keys)
+ MEM_freeN(paf->keys);
+ }
+ MEM_freeN(eff);
}
static void do_version_free_effects_245(ListBase *lb)
{
- Effect *eff;
+ Effect *eff;
- while ((eff = BLI_pophead(lb))) {
- do_version_free_effect_245(eff);
- }
+ while ((eff = BLI_pophead(lb))) {
+ do_version_free_effect_245(eff);
+ }
}
static void do_version_constraints_245(ListBase *lb)
{
- bConstraint *con;
- bConstraintTarget *ct;
-
- for (con = lb->first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_PYTHON) {
- bPythonConstraint *data = (bPythonConstraint *)con->data;
- if (data->tar) {
- /* version patching needs to be done */
- ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
-
- ct->tar = data->tar;
- BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
- ct->space = con->tarspace;
-
- BLI_addtail(&data->targets, ct);
- data->tarnum++;
-
- /* clear old targets to avoid problems */
- data->tar = NULL;
- data->subtarget[0] = '\0';
- }
- }
- else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
- bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data;
-
- /* new headtail functionality makes Bone-Tip function obsolete */
- if (data->flag & LOCLIKE_TIP)
- con->headtail = 1.0f;
- }
- }
+ bConstraint *con;
+ bConstraintTarget *ct;
+
+ for (con = lb->first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_PYTHON) {
+ bPythonConstraint *data = (bPythonConstraint *)con->data;
+ if (data->tar) {
+ /* version patching needs to be done */
+ ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
+
+ ct->tar = data->tar;
+ BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget));
+ ct->space = con->tarspace;
+
+ BLI_addtail(&data->targets, ct);
+ data->tarnum++;
+
+ /* clear old targets to avoid problems */
+ data->tar = NULL;
+ data->subtarget[0] = '\0';
+ }
+ }
+ else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
+ bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data;
+
+ /* new headtail functionality makes Bone-Tip function obsolete */
+ if (data->flag & LOCLIKE_TIP)
+ con->headtail = 1.0f;
+ }
+ }
}
PartEff *blo_do_version_give_parteff_245(Object *ob)
{
- PartEff *paf;
-
- paf = ob->effect.first;
- while (paf) {
- if (paf->type == EFF_PARTICLE)
- return paf;
- paf = paf->next;
- }
- return NULL;
+ PartEff *paf;
+
+ paf = ob->effect.first;
+ while (paf) {
+ if (paf->type == EFF_PARTICLE)
+ return paf;
+ paf = paf->next;
+ }
+ return NULL;
}
/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
void blo_do_version_old_trackto_to_constraints(Object *ob)
{
- /* create new trackto constraint from the relationship */
- if (ob->track) {
- bConstraint *con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
- bTrackToConstraint *data = con->data;
-
- /* copy tracking settings from the object */
- data->tar = ob->track;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
-
- /* clear old track setting */
- ob->track = NULL;
+ /* create new trackto constraint from the relationship */
+ if (ob->track) {
+ bConstraint *con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
+ bTrackToConstraint *data = con->data;
+
+ /* copy tracking settings from the object */
+ data->tar = ob->track;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+
+ /* clear old track setting */
+ ob->track = NULL;
}
void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
- /* WATCH IT!!!: pointers from libdata have not been converted */
-
- if (bmain->versionfile == 100) {
- /* tex->extend and tex->imageflag have changed: */
- Tex *tex = bmain->textures.first;
- while (tex) {
- if (tex->id.tag & LIB_TAG_NEED_LINK) {
-
- if (tex->extend == 0) {
- if (tex->xrepeat || tex->yrepeat) {
- tex->extend = TEX_REPEAT;
- }
- else {
- tex->extend = TEX_EXTEND;
- tex->xrepeat = tex->yrepeat = 1;
- }
- }
-
- }
- tex = tex->id.next;
- }
- }
-
- if (bmain->versionfile <= 101) {
- /* frame mapping */
- Scene *sce = bmain->scenes.first;
- while (sce) {
- sce->r.framapto = 100;
- sce->r.images = 100;
- sce->r.framelen = 1.0;
- sce = sce->id.next;
- }
- }
-
- if (bmain->versionfile <= 103) {
- /* new variable in object: colbits */
- Object *ob = bmain->objects.first;
- int a;
- while (ob) {
- ob->colbits = 0;
- if (ob->totcol) {
- for (a = 0; a < ob->totcol; a++) {
- if (ob->mat[a])
- ob->colbits |= (1 << a);
- }
- }
- ob = ob->id.next;
- }
- }
-
- if (bmain->versionfile <= 104) {
- /* timeoffs moved */
- Object *ob = bmain->objects.first;
- while (ob) {
- if (ob->transflag & 1) {
- ob->transflag -= 1;
- }
- ob = ob->id.next;
- }
- }
-
- if (bmain->versionfile <= 106) {
- /* mcol changed */
- Mesh *me = bmain->meshes.first;
- while (me) {
- if (me->mcol)
- vcol_to_fcol(me);
- me = me->id.next;
- }
-
- }
-
- if (bmain->versionfile <= 107) {
- Object *ob;
- ob = bmain->objects.first;
- while (ob) {
- if (ob->dt == 0)
- ob->dt = OB_SOLID;
- ob = ob->id.next;
- }
-
- }
-
- if (bmain->versionfile <= 109) {
- /* new variable: gridlines */
- bScreen *sc = bmain->screens.first;
- while (sc) {
- ScrArea *sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl = sa->spacedata.first;
- while (sl) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- if (v3d->gridlines == 0)
- v3d->gridlines = 20;
- }
- sl = sl->next;
- }
- sa = sa->next;
- }
- sc = sc->id.next;
- }
- }
-
- if (bmain->versionfile <= 134) {
- Tex *tex = bmain->textures.first;
- while (tex) {
- if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f))
- {
- tex->rfac = 1.0f;
- tex->gfac = 1.0f;
- tex->bfac = 1.0f;
- tex->filtersize = 1.0f;
- }
- tex = tex->id.next;
- }
- }
-
- if (bmain->versionfile <= 140) {
- /* r-g-b-fac in texture */
- Tex *tex = bmain->textures.first;
- while (tex) {
- if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f))
- {
- tex->rfac = 1.0f;
- tex->gfac = 1.0f;
- tex->bfac = 1.0f;
- tex->filtersize = 1.0f;
- }
- tex = tex->id.next;
- }
- }
-
- if (bmain->versionfile <= 153) {
- Scene *sce = bmain->scenes.first;
- while (sce) {
- if (sce->r.blurfac == 0.0f)
- sce->r.blurfac = 1.0f;
- sce = sce->id.next;
- }
- }
-
- if (bmain->versionfile <= 163) {
- Scene *sce = bmain->scenes.first;
- while (sce) {
- if (sce->r.frs_sec == 0)
- sce->r.frs_sec = 25;
- sce = sce->id.next;
- }
- }
-
- if (bmain->versionfile <= 164) {
- Mesh *me = bmain->meshes.first;
- while (me) {
- me->smoothresh = 30;
- me = me->id.next;
- }
- }
-
- if (bmain->versionfile <= 165) {
- Mesh *me = bmain->meshes.first;
- TFace *tface;
- int nr;
- char *cp;
-
- while (me) {
- if (me->tface) {
- nr = me->totface;
- tface = me->tface;
- while (nr--) {
- int j;
- for (j = 0; j < 4; j++) {
- int k;
- cp = ((char *)&tface->col[j]) + 1;
- for (k = 0; k < 3; k++) {
- cp[k] = (cp[k] > 126) ? 255 : cp[k] * 2;
- }
- }
-
- tface++;
- }
- }
- me = me->id.next;
- }
- }
-
- if (bmain->versionfile <= 169) {
- Mesh *me = bmain->meshes.first;
- while (me) {
- if (me->subdiv == 0)
- me->subdiv = 1;
- me = me->id.next;
- }
- }
-
- if (bmain->versionfile <= 169) {
- bScreen *sc = bmain->screens.first;
- while (sc) {
- ScrArea *sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl = sa->spacedata.first;
- while (sl) {
- if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- sipo->v2d.max[0] = 15000.0;
- }
- sl = sl->next;
- }
- sa = sa->next;
- }
- sc = sc->id.next;
- }
- }
-
- if (bmain->versionfile <= 170) {
- Object *ob = bmain->objects.first;
- PartEff *paf;
- while (ob) {
- paf = blo_do_version_give_parteff_245(ob);
- if (paf) {
- if (paf->staticstep == 0) {
- paf->staticstep = 5;
- }
- }
- ob = ob->id.next;
- }
- }
-
- if (bmain->versionfile <= 171) {
- bScreen *sc = bmain->screens.first;
- while (sc) {
- ScrArea *sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl = sa->spacedata.first;
- while (sl) {
- if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText *)sl;
- st->lheight = 12;
- }
- sl = sl->next;
- }
- sa = sa->next;
- }
- sc = sc->id.next;
- }
- }
-
- if (bmain->versionfile <= 173) {
- int a, b;
- Mesh *me = bmain->meshes.first;
- while (me) {
- if (me->tface) {
- TFace *tface = me->tface;
- for (a = 0; a < me->totface; a++, tface++) {
- for (b = 0; b < 4; b++) {
- tface->uv[b][0] /= 32767.0f;
- tface->uv[b][1] /= 32767.0f;
- }
- }
- }
- me = me->id.next;
- }
- }
-
- if (bmain->versionfile <= 204) {
- bSound *sound;
-
- sound = bmain->sounds.first;
- while (sound) {
- if (sound->volume < 0.01f) {
- sound->volume = 1.0f;
- }
- sound = sound->id.next;
- }
- }
-
- if (bmain->versionfile <= 212) {
- bSound *sound;
- Mesh *me;
-
- sound = bmain->sounds.first;
- while (sound) {
- sound->max_gain = 1.0;
- sound->min_gain = 0.0;
- sound->distance = 1.0;
-
- if (sound->attenuation > 0.0f)
- sound->flags |= SOUND_FLAGS_3D;
- else
- sound->flags &= ~SOUND_FLAGS_3D;
-
- sound = sound->id.next;
- }
-
- /* me->subdiv changed to reflect the actual reparametization
- * better, and smeshes were removed - if it was a smesh make
- * it a subsurf, and reset the subdiv level because subsurf
- * takes a lot more work to calculate.
- */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- enum {
- ME_SMESH = (1 << 6),
- ME_SUBSURF = (1 << 7),
- };
- if (me->flag & ME_SMESH) {
- me->flag &= ~ME_SMESH;
- me->flag |= ME_SUBSURF;
-
- me->subdiv = 1;
- }
- else {
- if (me->subdiv < 2)
- me->subdiv = 1;
- else
- me->subdiv--;
- }
- }
- }
-
- if (bmain->versionfile <= 220) {
- Mesh *me;
-
- /* Began using alpha component of vertex colors, but
- * old file vertex colors are undefined, reset them
- * to be fully opaque. -zr
- */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- if (me->mcol) {
- int i;
-
- for (i = 0; i < me->totface * 4; i++) {
- MCol *mcol = &me->mcol[i];
- mcol->a = 255;
- }
- }
- if (me->tface) {
- int i, j;
-
- for (i = 0; i < me->totface; i++) {
- TFace *tf = &((TFace *)me->tface)[i];
-
- for (j = 0; j < 4; j++) {
- char *col = (char *)&tf->col[j];
-
- col[0] = 255;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 223) {
- VFont *vf;
- for (vf = bmain->fonts.first; vf; vf = vf->id.next) {
- if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
- strcpy(vf->name, FO_BUILTIN_NAME);
- }
- }
- }
-
- if (bmain->versionfile <= 224) {
- bSound *sound;
- Scene *sce;
- Mesh *me;
- bScreen *sc;
-
- for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
- if (sound->packedfile) {
- if (sound->newpackedfile == NULL) {
- sound->newpackedfile = sound->packedfile;
- }
- sound->packedfile = NULL;
- }
- }
- /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- enum { ME_SUBSURF = (1 << 7) };
- if ((me->flag & ME_SUBSURF) && (me->subdivr == 0)) {
- me->subdivr = me->subdiv;
- }
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->r.stereomode = 1; // no stereo
- }
-
- /* some oldfile patch, moved from set_func_space */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_GRAPH) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- sseq->v2d.keeptot = 0;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 227) {
- Scene *sce;
- bScreen *sc;
- Object *ob;
-
- /* As of now, this insures that the transition from the old Track system
- * to the new full constraint Track is painless for everyone. - theeth
- */
- ob = bmain->objects.first;
-
- while (ob) {
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing TrackTo constraint
- * set their track and up flag correctly
- */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon = curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
- }
- }
-
- /* Change Ob->Track in real TrackTo constraint */
- blo_do_version_old_trackto_to_constraints(ob);
-
- ob = ob->id.next;
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->audio.mixrate = 48000;
- sce->audio.flag |= AUDIO_SCRUB;
- }
-
- /* patch for old wrong max view2d settings, allows zooming out more */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *sac = (SpaceAction *)sl;
- sac->v2d.max[0] = 32000;
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *sla = (SpaceNla *)sl;
- sla->v2d.max[0] = 32000;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 228) {
- bScreen *sc;
- Object *ob;
-
- /* As of now, this insures that the transition from the old Track system
- * to the new full constraint Track is painless for everyone.
- */
- ob = bmain->objects.first;
-
- while (ob) {
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing TrackTo constraint
- * set their track and up flag correctly */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon = curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
- if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
- bTrackToConstraint *data = curcon->data;
- data->reserved1 = ob->trackflag;
- data->reserved2 = ob->upflag;
- }
- }
- }
- }
- }
-
- ob = ob->id.next;
- }
-
- /* convert old mainb values for new button panels */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_PROPERTIES) {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
-
- sbuts->v2d.maxzoom = 1.2f;
-
- if (sbuts->mainb == BUTS_LAMP) {
- sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
- }
- else if (sbuts->mainb == BUTS_MAT) {
- sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
- }
- else if (sbuts->mainb == BUTS_TEX) {
- sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
- }
- else if (sbuts->mainb == BUTS_ANIM) {
- sbuts->mainb = CONTEXT_OBJECT;
- }
- else if (sbuts->mainb == BUTS_WORLD) {
- sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
- }
- else if (sbuts->mainb == BUTS_RENDER) {
- sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
- }
- else if (sbuts->mainb == BUTS_FPAINT) {
- sbuts->mainb = CONTEXT_EDITING;
- }
- else if (sbuts->mainb == BUTS_RADIO) {
- sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
- }
- else if (sbuts->mainb == BUTS_CONSTRAINT) {
- sbuts->mainb = CONTEXT_OBJECT;
- }
- else if (sbuts->mainb == BUTS_SCRIPT) {
- sbuts->mainb = CONTEXT_OBJECT;
- }
- else if (sbuts->mainb == BUTS_EDIT) {
- sbuts->mainb = CONTEXT_EDITING;
- }
- else {
- sbuts->mainb = CONTEXT_SCENE;
- }
- }
- }
- }
- }
- }
-
- /* ton: made this 230 instead of 229,
- * to be sure (tuho files) and this is a reliable check anyway
- * nevertheless, we might need to think over a fitness (initialize)
- * check apart from the do_versions()
- */
-
- if (bmain->versionfile <= 230) {
- bScreen *sc;
-
- /* new variable blockscale, for panels in any area */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- /* added: 5x better zoom in for action */
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *sac = (SpaceAction *)sl;
- sac->v2d.maxzoom = 50;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 231) {
- bScreen *sc = bmain->screens.first;
-
- /* new bit flags for showing/hiding grid floor and axes */
-
- while (sc) {
- ScrArea *sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl = sa->spacedata.first;
- while (sl) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- if (v3d->gridflag == 0) {
- v3d->gridflag |= V3D_SHOW_X;
- v3d->gridflag |= V3D_SHOW_Y;
- v3d->gridflag |= V3D_SHOW_FLOOR;
- v3d->gridflag &= ~V3D_SHOW_Z;
- }
- }
- sl = sl->next;
- }
- sa = sa->next;
- }
- sc = sc->id.next;
- }
- }
-
- if (bmain->versionfile <= 232) {
- Tex *tex = bmain->textures.first;
- World *wrld = bmain->worlds.first;
- bScreen *sc;
-
- while (tex) {
- if ((tex->flag & (TEX_CHECKER_ODD + TEX_CHECKER_EVEN)) == 0) {
- tex->flag |= TEX_CHECKER_ODD;
- }
- /* copied from kernel texture.c */
- if (tex->ns_outscale == 0.0f) {
- /* musgrave */
- tex->mg_H = 1.0f;
- tex->mg_lacunarity = 2.0f;
- tex->mg_octaves = 2.0f;
- tex->mg_offset = 1.0f;
- tex->mg_gain = 1.0f;
- tex->ns_outscale = 1.0f;
- /* distnoise */
- tex->dist_amount = 1.0f;
- /* voronoi */
- tex->vn_w1 = 1.0f;
- tex->vn_mexp = 2.5f;
- }
- tex = tex->id.next;
- }
-
- while (wrld) {
- if (wrld->aodist == 0.0f) {
- wrld->aodist = 10.0f;
- }
- if (wrld->aoenergy == 0.0f)
- wrld->aoenergy = 1.0f;
- wrld = wrld->id.next;
- }
-
- /* new variable blockscale, for panels in any area, do again because new
- * areas didnt initialize it to 0.7 yet
- */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- /* added: 5x better zoom in for nla */
- if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
- snla->v2d.maxzoom = 50;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 233) {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->flag |= V3D_SELECT_OUTLINE;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 234) {
- bScreen *sc;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText *)sl;
- if (st->tabnumber == 0)
- st->tabnumber = 2;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 235) {
- Tex *tex = bmain->textures.first;
- Scene *sce = bmain->scenes.first;
- Sequence *seq;
- Editing *ed;
-
- while (tex) {
- if (tex->nabla == 0.0f)
- tex->nabla = 0.025f;
- tex = tex->id.next;
- }
- while (sce) {
- ed = sce->ed;
- if (ed) {
- SEQ_BEGIN(sce->ed, seq)
- {
- if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE)
- seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
- } SEQ_END;
- }
-
- sce = sce->id.next;
- }
- }
-
- if (bmain->versionfile <= 236) {
- Object *ob;
- Camera *cam = bmain->cameras.first;
-
- while (cam) {
- if (cam->ortho_scale == 0.0f) {
- cam->ortho_scale = 256.0f / cam->lens;
- if (cam->type == CAM_ORTHO)
- printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
- }
- cam = cam->id.next;
- }
- /* force oops draw if depgraph was set*/
- /* set time line var */
-
- /* softbody init new vars */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->soft) {
- if (ob->soft->defgoal == 0.0f)
- ob->soft->defgoal = 0.7f;
- if (ob->soft->physics_speed == 0.0f)
- ob->soft->physics_speed = 1.0f;
-
- if (ob->soft->interval == 0) {
- ob->soft->interval = 2;
- ob->soft->sfra = 1;
- ob->soft->efra = 100;
- }
- }
- if (ob->soft && ob->soft->vertgroup == 0) {
- bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL");
- if (locGroup) {
- /* retrieve index for that group */
- ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup);
- }
- }
- }
- }
-
- if (bmain->versionfile <= 237) {
- bArmature *arm;
- bConstraint *con;
- Object *ob;
- Bone *bone;
-
- /* armature recode checks */
- for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
- BKE_armature_where_is(arm);
-
- for (bone = arm->bonebase.first; bone; bone = bone->next)
- do_version_bone_head_tail_237(bone);
- }
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->parent) {
- Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
- if (parent && parent->type == OB_LATTICE)
- ob->partype = PARSKEL;
- }
-
- /* btw. armature_rebuild_pose is further only called on leave editmode */
- if (ob->type == OB_ARMATURE) {
- if (ob->pose)
- BKE_pose_tag_recalc(bmain, ob->pose);
-
- /* cannot call stuff now (pointers!), done in setup_app_data */
- ob->id.recalc |= ID_RECALC_ALL;
-
- /* new generic xray option */
- arm = blo_do_versions_newlibadr(fd, lib, ob->data);
- enum { ARM_DRAWXRAY = (1 << 1) };
- if (arm->flag & ARM_DRAWXRAY) {
- ob->dtx |= OB_DRAWXRAY;
- }
- }
- else if (ob->type == OB_MESH) {
- Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
-
- enum {
- ME_SUBSURF = (1 << 7),
- ME_OPT_EDGES = (1 << 8),
- };
-
- if ((me->flag & ME_SUBSURF)) {
- SubsurfModifierData *smd = (SubsurfModifierData *)modifier_new(eModifierType_Subsurf);
-
- smd->levels = MAX2(1, me->subdiv);
- smd->renderLevels = MAX2(1, me->subdivr);
- smd->subdivType = me->subsurftype;
-
- smd->modifier.mode = 0;
- if (me->subdiv != 0)
- smd->modifier.mode |= 1;
- if (me->subdivr != 0)
- smd->modifier.mode |= 2;
-
- if (me->flag & ME_OPT_EDGES)
- smd->flags |= eSubsurfModifierFlag_ControlEdges;
-
- BLI_addtail(&ob->modifiers, smd);
-
- modifier_unique_name(&ob->modifiers, (ModifierData *)smd);
- }
- }
-
- /* follow path constraint needs to set the 'path' option in curves... */
- for (con = ob->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
- bFollowPathConstraint *data = con->data;
- Object *obc = blo_do_versions_newlibadr(fd, lib, data->tar);
-
- if (obc && obc->type == OB_CURVE) {
- Curve *cu = blo_do_versions_newlibadr(fd, lib, obc->data);
- if (cu)
- cu->flag |= CU_PATH;
- }
- }
- }
- }
- }
-
- if (bmain->versionfile <= 238) {
- Lattice *lt;
- Object *ob;
- bArmature *arm;
- Mesh *me;
- Key *key;
- Scene *sce = bmain->scenes.first;
-
- while (sce) {
- if (sce->toolsettings == NULL) {
- sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct");
- sce->toolsettings->doublimit = 0.001f;
- }
- sce = sce->id.next;
- }
-
- for (lt = bmain->lattices.first; lt; lt = lt->id.next) {
- if (lt->fu == 0.0f && lt->fv == 0.0f && lt->fw == 0.0f) {
- calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
- calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
- calc_lat_fudu(lt->flag, lt->pntsw, &lt->fw, &lt->dw);
- }
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- PartEff *paf;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
-
- smd->flags &= ~(eSubsurfModifierFlag_Incremental | eSubsurfModifierFlag_DebugIncr);
- }
- }
-
- if ((ob->softflag & OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) {
- if (ob->softflag & OB_SB_POSTDEF) {
- md = ob->modifiers.first;
-
- while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) {
- md = md->next;
- }
-
- BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody));
- }
- else {
- BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody));
- }
-
- ob->softflag &= ~OB_SB_ENABLE;
- }
-
- if (ob->pose) {
- bPoseChannel *pchan;
- bConstraint *con;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* note, pchan->bone is also lib-link stuff */
- if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) {
- pchan->limitmin[0] = pchan->limitmin[1] = pchan->limitmin[2] = -180.0f;
- pchan->limitmax[0] = pchan->limitmax[1] = pchan->limitmax[2] = 180.0f;
-
- for (con = pchan->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = (bKinematicConstraint *)con->data;
- data->weight = 1.0f;
- data->orientweight = 1.0f;
- data->flag &= ~CONSTRAINT_IK_ROT;
-
- /* enforce conversion from old IK_TOPARENT to rootbone index */
- data->rootbone = -1;
-
- /* update_pose_etc handles rootbone == -1 */
- BKE_pose_tag_recalc(bmain, ob->pose);
- }
- }
- }
- }
- }
-
- paf = blo_do_version_give_parteff_245(ob);
- if (paf) {
- if (paf->disp == 0)
- paf->disp = 100;
- if (paf->speedtex == 0)
- paf->speedtex = 8;
- if (paf->omat == 0)
- paf->omat = 1;
- }
- }
-
- for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
- bone_version_238(&arm->bonebase);
- arm->deformflag |= ARM_DEF_VGROUP;
- }
-
- for (me = bmain->meshes.first; me; me = me->id.next) {
- if (!me->medge) {
- BKE_mesh_calc_edges_legacy(me, true); /* true = use mface->edcode */
- }
- else {
- BKE_mesh_strip_loose_faces(me);
- }
- }
-
- for (key = bmain->shapekeys.first; key; key = key->id.next) {
- KeyBlock *kb;
- int index = 1;
-
- for (kb = key->block.first; kb; kb = kb->next) {
- if (kb == key->refkey) {
- if (kb->name[0] == 0)
- strcpy(kb->name, "Basis");
- }
- else {
- if (kb->name[0] == 0) {
- BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
- }
- index++;
- }
- }
- }
- }
-
- if (bmain->versionfile <= 239) {
- bArmature *arm;
- Object *ob;
- Scene *sce = bmain->scenes.first;
- Camera *cam = bmain->cameras.first;
- int set_passepartout = 0;
-
- /* deformflag is local in modifier now */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Armature) {
- ArmatureModifierData *amd = (ArmatureModifierData *)md;
- if (amd->object && amd->deformflag == 0) {
- Object *oba = blo_do_versions_newlibadr(fd, lib, amd->object);
- arm = blo_do_versions_newlibadr(fd, lib, oba->data);
- amd->deformflag = arm->deformflag;
- }
- }
- }
- }
-
- /* updating stepsize for ghost drawing */
- for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
- bone_version_239(&arm->bonebase);
- if (arm->layer == 0)
- arm->layer = 1;
- }
-
- for (; sce; sce = sce->id.next) {
- if (sce->r.scemode & R_PASSEPARTOUT) {
- set_passepartout = 1;
- sce->r.scemode &= ~R_PASSEPARTOUT;
- }
- }
-
- for (; cam; cam = cam->id.next) {
- if (set_passepartout)
- cam->flag |= CAM_SHOWPASSEPARTOUT;
-
- /* make sure old cameras have title safe on */
- if (!(cam->flag & CAM_SHOW_SAFE_MARGINS))
- cam->flag |= CAM_SHOW_SAFE_MARGINS;
-
- /* set an appropriate camera passepartout alpha */
- if (!(cam->passepartalpha))
- cam->passepartalpha = 0.2f;
- }
- }
-
- if (bmain->versionfile <= 241) {
- Object *ob;
- Scene *sce;
- Light *la;
- bArmature *arm;
- bNodeTree *ntree;
-
- /* updating layers still */
- for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
- bone_version_239(&arm->bonebase);
- if (arm->layer == 0)
- arm->layer = 1;
- }
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->audio.mixrate == 0)
- sce->audio.mixrate = 48000;
-
- /* We don't add default layer since blender2.8 because the layers
- * are now in Scene->view_layers and a default layer is created in
- * the doversion later on.
- */
- SceneRenderLayer *srl;
- /* new layer flag for sky, was default for solid */
- for (srl = sce->r.layers.first; srl; srl = srl->next) {
- if (srl->layflag & SCE_LAY_SOLID)
- srl->layflag |= SCE_LAY_SKY;
- srl->passflag &= (SCE_PASS_COMBINED | SCE_PASS_Z | SCE_PASS_NORMAL | SCE_PASS_VECTOR);
- }
-
- /* node version changes */
- if (sce->nodetree)
- ntree_version_241(sce->nodetree);
-
- /* uv calculation options moved to toolsettings */
- if (sce->toolsettings->unwrapper == 0) {
- sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
- sce->toolsettings->unwrapper = 1;
- }
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- ntree_version_241(ntree);
-
- for (la = bmain->lights.first; la; la = la->id.next)
- if (la->buffers == 0)
- la->buffers = 1;
-
- /* for empty drawsize and drawtype */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->empty_drawsize == 0.0f) {
- ob->empty_drawtype = OB_ARROWS;
- ob->empty_drawsize = 1.0;
- }
- }
-
- /* during 2.41 images with this name were used for viewer node output, lets fix that */
- if (bmain->versionfile == 241) {
- Image *ima;
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- if (STREQ(ima->name, "Compositor")) {
- strcpy(ima->id.name + 2, "Viewer Node");
- strcpy(ima->name, "Viewer Node");
- }
- }
- }
- }
-
- if (bmain->versionfile <= 242) {
- Scene *sce;
- bScreen *sc;
- Object *ob;
- Curve *cu;
- Material *ma;
- Mesh *me;
- Collection *collection;
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- bNodeTree *ntree;
- int a;
-
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- if (v3d->gridsubdiv == 0)
- v3d->gridsubdiv = 10;
- }
- }
- sa = sa->next;
- }
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- enum {
- R_THREADS = (1 << 19),
- };
- if (sce->toolsettings->select_thresh == 0.0f)
- sce->toolsettings->select_thresh = 0.01f;
- if (sce->r.threads == 0) {
- if (sce->r.mode & R_THREADS)
- sce->r.threads = 2;
- else
- sce->r.threads = 1;
- }
- if (sce->nodetree)
- ntree_version_242(sce->nodetree);
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- ntree_version_242(ntree);
-
- /* add default radius values to old curve points */
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- if (nu) {
- if (nu->bezt) {
- for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
- if (!bezt->radius)
- bezt->radius = 1.0;
- }
- }
- else if (nu->bp) {
- for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- if (!bp->radius)
- bp->radius = 1.0;
- }
- }
- }
- }
- }
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md;
- ListBase *list;
- list = &ob->constraints;
-
- /* check for already existing MinMax (floor) constraint
- * and update the sticky flagging */
-
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon = curcon->next) {
- switch (curcon->type) {
- case CONSTRAINT_TYPE_MINMAX:
- {
- bMinMaxConstraint *data = curcon->data;
- if (data->sticky == 1)
- data->flag |= MINMAX_STICKY;
- else
- data->flag &= ~MINMAX_STICKY;
-
- break;
- }
- case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data = curcon->data;
-
- /* version patch from buttons_object.c */
- if (data->flag == 0)
- data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
-
- break;
- }
- }
- }
- }
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
- switch (curcon->type) {
- case CONSTRAINT_TYPE_MINMAX:
- {
- bMinMaxConstraint *data = curcon->data;
- if (data->sticky == 1)
- data->flag |= MINMAX_STICKY;
- else
- data->flag &= ~MINMAX_STICKY;
- break;
- }
- case CONSTRAINT_TYPE_KINEMATIC:
- {
- bKinematicConstraint *data = curcon->data;
- if (!(data->flag & CONSTRAINT_IK_POS)) {
- data->flag |= CONSTRAINT_IK_POS;
- data->flag |= CONSTRAINT_IK_STRETCH;
- }
- break;
- }
- case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data = curcon->data;
-
- /* version patch from buttons_object.c */
- if (data->flag == 0)
- data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
- break;
- }
- }
- }
- }
- }
- }
-
- /* copy old object level track settings to curve modifers */
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Curve) {
- CurveModifierData *cmd = (CurveModifierData *)md;
-
- if (cmd->defaxis == 0)
- cmd->defaxis = ob->trackflag + 1;
- }
- }
-
- }
-
- for (ma = bmain->materials.first; ma; ma = ma->id.next) {
- if (ma->nodetree)
- ntree_version_242(ma->nodetree);
- }
-
- for (me = bmain->meshes.first; me; me = me->id.next)
- customdata_version_242(me);
-
- for (collection = bmain->collections.first; collection; collection = collection->id.next)
- if (collection->layer == 0)
- collection->layer = (1 << 20) - 1;
-
- /* now, subversion control! */
- if (bmain->subversionfile < 3) {
- Image *ima;
- Tex *tex;
-
- /* Image refactor initialize */
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- ima->source = IMA_SRC_FILE;
- ima->type = IMA_TYPE_IMAGE;
-
- ima->gen_x = 256; ima->gen_y = 256;
- ima->gen_type = 1;
-
- if (STREQLEN(ima->id.name + 2, "Viewer Node", sizeof(ima->id.name) - 2)) {
- ima->source = IMA_SRC_VIEWER;
- ima->type = IMA_TYPE_COMPOSITE;
- }
- if (STREQLEN(ima->id.name + 2, "Render Result", sizeof(ima->id.name) - 2)) {
- ima->source = IMA_SRC_VIEWER;
- ima->type = IMA_TYPE_R_RESULT;
- }
-
- }
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- enum {
- TEX_ANIMCYCLIC = (1 << 6),
- TEX_ANIM5 = (1 << 7),
- };
-
- if (tex->type == TEX_IMAGE && tex->ima) {
- ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
- if (tex->imaflag & TEX_ANIM5) {
- ima->source = IMA_SRC_MOVIE;
- }
- }
- tex->iuser.frames = tex->frames;
- tex->iuser.offset = tex->offset;
- tex->iuser.sfra = tex->sfra;
- tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC) != 0;
- }
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
- do_version_ntree_242_2(sce->nodetree);
- }
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- do_version_ntree_242_2(ntree);
- for (ma = bmain->materials.first; ma; ma = ma->id.next)
- if (ma->nodetree)
- do_version_ntree_242_2(ma->nodetree);
- }
-
- if (bmain->subversionfile < 4) {
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->r.bake_mode = 1; /* prevent to include render stuff here */
- sce->r.bake_filter = 16;
- sce->r.bake_flag = R_BAKE_CLEAR;
- }
- }
- }
-
- if (bmain->versionfile <= 243) {
- Object *ob = bmain->objects.first;
-
- for (; ob; ob = ob->id.next) {
- bDeformGroup *curdef;
-
- for (curdef = ob->defbase.first; curdef; curdef = curdef->next) {
- /* replace an empty-string name with unique name */
- if (curdef->name[0] == '\0') {
- defgroup_unique_name(curdef, ob);
- }
- }
-
- if (bmain->versionfile < 243 || bmain->subversionfile < 1) {
- ModifierData *md;
-
- /* translate old mirror modifier axis values to new flags */
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Mirror) {
- MirrorModifierData *mmd = (MirrorModifierData *)md;
-
- switch (mmd->axis) {
- case 0:
- mmd->flag |= MOD_MIR_AXIS_X;
- break;
- case 1:
- mmd->flag |= MOD_MIR_AXIS_Y;
- break;
- case 2:
- mmd->flag |= MOD_MIR_AXIS_Z;
- break;
- }
-
- mmd->axis = 0;
- }
- }
- }
- }
-
- /* render layer added, this is not the active layer */
- if (bmain->versionfile <= 243 || bmain->subversionfile < 2) {
- Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next)
- customdata_version_243(me);
- }
-
- }
-
- if (bmain->versionfile <= 244) {
- bScreen *sc;
-
- if (bmain->versionfile != 244 || bmain->subversionfile < 2) {
- /* correct older action editors - incorrect scrolling */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
- sa = sc->areabase.first;
- while (sa) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)sl;
-
- saction->v2d.tot.ymin = -1000.0;
- saction->v2d.tot.ymax = 0.0;
-
- saction->v2d.cur.ymin = -75.0;
- saction->v2d.cur.ymax = 5.0;
- }
- }
- sa = sa->next;
- }
- }
- }
- }
-
- if (bmain->versionfile <= 245) {
- Scene *sce;
- Object *ob;
- Image *ima;
- Light *la;
- Material *ma;
- ParticleSettings *part;
- Mesh *me;
- bNodeTree *ntree;
- Tex *tex;
- ModifierData *md;
- ParticleSystem *psys;
-
- /* unless the file was created 2.44.3 but not 2.45, update the constraints */
- if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) &&
- ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0)) )
- {
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- ListBase *list;
- list = &ob->constraints;
-
- /* fix up constraints due to constraint recode changes (originally at 2.44.3) */
- if (list) {
- bConstraint *curcon;
- for (curcon = list->first; curcon; curcon = curcon->next) {
- /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
- if (curcon->flag & 0x20) {
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- }
-
- switch (curcon->type) {
- case CONSTRAINT_TYPE_LOCLIMIT:
- {
- bLocLimitConstraint *data = (bLocLimitConstraint *)curcon->data;
-
- /* old limit without parent option for objects */
- if (data->flag2)
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- break;
- }
- }
- }
- }
-
- /* correctly initialize constinv matrix */
- unit_m4(ob->constinv);
-
- if (ob->type == OB_ARMATURE) {
- if (ob->pose) {
- bConstraint *curcon;
- bPoseChannel *pchan;
-
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* make sure constraints are all up to date */
- for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
- /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
- if (curcon->flag & 0x20) {
- curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- }
-
- switch (curcon->type) {
- case CONSTRAINT_TYPE_ACTION:
- {
- bActionConstraint *data = (bActionConstraint *)curcon->data;
-
- /* 'data->local' used to mean that target was in local-space */
- if (data->local)
- curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
- break;
- }
- }
- }
-
- /* correctly initialize constinv matrix */
- unit_m4(pchan->constinv);
- }
- }
- }
- }
- }
-
- /* fix all versions before 2.45 */
- if (bmain->versionfile != 245) {
-
- /* repair preview from 242 - 244*/
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- ima->preview = NULL;
- }
- }
-
- /* add point caches */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->soft && !ob->soft->pointcache)
- ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
-
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (psys->pointcache) {
- if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE) == 0) {
- printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n");
- psys->pointcache->flag &= ~PTCACHE_BAKED;
- }
- }
- else
- psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
- }
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
- if (!clmd->point_cache) {
- clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
- clmd->point_cache->step = 1;
- }
- }
- }
- }
-
- /* Copy over old per-level multires vertex data
- * into a single vertex array in struct Multires */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- if (me->mr && !me->mr->verts) {
- MultiresLevel *lvl = me->mr->levels.last;
- if (lvl) {
- me->mr->verts = lvl->verts;
- lvl->verts = NULL;
- /* Don't need the other vert arrays */
- for (lvl = lvl->prev; lvl; lvl = lvl->prev) {
- MEM_freeN(lvl->verts);
- lvl->verts = NULL;
- }
- }
- }
- }
-
- if (bmain->versionfile != 245 || bmain->subversionfile < 1) {
- for (la = bmain->lights.first; la; la = la->id.next) {
- la->falloff_type = LA_FALLOFF_INVLINEAR;
-
- if (la->curfalloff == NULL) {
- la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- curvemapping_initialize(la->curfalloff);
- }
- }
- }
-
- for (ma = bmain->materials.first; ma; ma = ma->id.next) {
- if (ma->gloss_mir == 0.0f) {
- ma->gloss_mir = 1.0f;
- }
- }
-
- for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->ren_child_nbr == 0)
- part->ren_child_nbr = part->child_nbr;
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
- ntree_version_245(fd, lib, sce->nodetree);
-
- if (sce->r.simplify_subsurf == 0) {
- sce->r.simplify_subsurf = 6;
- sce->r.simplify_particles = 1.0f;
- }
- }
-
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
- ntree_version_245(fd, lib, ntree);
-
- /* fix for temporary flag changes during 245 cycle */
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- if (ima->flag & IMA_OLD_PREMUL) {
- ima->flag &= ~IMA_OLD_PREMUL;
- ima->alpha_mode = IMA_ALPHA_STRAIGHT;
- }
- }
-
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->iuser.flag & IMA_OLD_PREMUL) {
- tex->iuser.flag &= ~IMA_OLD_PREMUL;
- }
-
- ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
- if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) {
- ima->flag &= ~IMA_OLD_PREMUL;
- ima->alpha_mode = IMA_ALPHA_STRAIGHT;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 2)) {
- Image *ima;
-
- /* initialize 1:1 Aspect */
- for (ima = bmain->images.first; ima; ima = ima->id.next) {
- ima->aspx = ima->aspy = 1.0f;
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 4)) {
- bArmature *arm;
- ModifierData *md;
- Object *ob;
-
- for (arm = bmain->armatures.first; arm; arm = arm->id.next)
- arm->deformflag |= ARM_DEF_B_BONE_REST;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Armature)
- ((ArmatureModifierData *)md)->deformflag |= ARM_DEF_B_BONE_REST;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 5)) {
- /* foreground color needs to be something other then black */
- Scene *sce;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
- sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */
- sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */
- }
- }
-
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 6)) {
- Scene *sce;
- /* fix frs_sec_base */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->r.frs_sec_base == 0) {
- sce->r.frs_sec_base = 1;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 7)) {
- Object *ob;
- bPoseChannel *pchan;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pose) {
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- do_version_constraints_245(&pchan->constraints);
- }
- }
- do_version_constraints_245(&ob->constraints);
-
- if (ob->soft && ob->soft->keys) {
- SoftBody *sb = ob->soft;
- int k;
-
- for (k = 0; k < sb->totkey; k++) {
- if (sb->keys[k])
- MEM_freeN(sb->keys[k]);
- }
-
- MEM_freeN(sb->keys);
-
- sb->keys = NULL;
- sb->totkey = 0;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 8)) {
- Scene *sce;
- Object *ob;
- PartEff *paf = NULL;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->soft && ob->soft->keys) {
- SoftBody *sb = ob->soft;
- int k;
-
- for (k = 0; k < sb->totkey; k++) {
- if (sb->keys[k])
- MEM_freeN(sb->keys[k]);
- }
-
- MEM_freeN(sb->keys);
-
- sb->keys = NULL;
- sb->totkey = 0;
- }
-
- /* convert old particles to new system */
- if ((paf = blo_do_version_give_parteff_245(ob))) {
- ParticleSystem *psys;
- ModifierData *md;
- ParticleSystemModifierData *psmd;
- ParticleSettings *part;
-
- /* create new particle system */
- psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
- psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
-
- part = psys->part = BKE_particlesettings_add(bmain, "ParticleSettings");
-
- /* needed for proper libdata lookup */
- blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
- part->id.lib = ob->id.lib;
-
- part->id.us--;
- part->id.tag |= (ob->id.tag & LIB_TAG_NEED_LINK);
-
- psys->totpart = 0;
- psys->flag = PSYS_CURRENT;
-
- BLI_addtail(&ob->particlesystem, psys);
-
- md = modifier_new(eModifierType_ParticleSystem);
- BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_listbase_count(&ob->particlesystem));
- psmd = (ParticleSystemModifierData *)md;
- psmd->psys = psys;
- BLI_addtail(&ob->modifiers, md);
-
- /* convert settings from old particle system */
- /* general settings */
- part->totpart = MIN2(paf->totpart, 100000);
- part->sta = paf->sta;
- part->end = paf->end;
- part->lifetime = paf->lifetime;
- part->randlife = paf->randlife;
- psys->seed = paf->seed;
- part->disp = paf->disp;
- part->omat = paf->mat[0];
- part->hair_step = paf->totkey;
-
- part->eff_group = paf->group;
-
- /* old system didn't interpolate between keypoints at render time */
- part->draw_step = part->ren_step = 0;
-
- /* physics */
- part->normfac = paf->normfac * 25.0f;
- part->obfac = paf->obfac;
- part->randfac = paf->randfac * 25.0f;
- part->dampfac = paf->damp;
- copy_v3_v3(part->acc, paf->force);
-
- /* flags */
- if (paf->stype & PAF_VECT) {
- if (paf->flag & PAF_STATIC) {
- /* new hair lifetime is always 100.0f */
- float fac = paf->lifetime / 100.0f;
-
- part->draw_as = PART_DRAW_PATH;
- part->type = PART_HAIR;
- psys->recalc |= ID_RECALC_PSYS_REDO;
-
- part->normfac *= fac;
- part->randfac *= fac;
- }
- else {
- part->draw_as = PART_DRAW_LINE;
- part->draw |= PART_DRAW_VEL_LENGTH;
- part->draw_line[1] = 0.04f;
- }
- }
-
- part->rotmode = PART_ROT_VEL;
-
- part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0;
- part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0;
- part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0;
- part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0;
- part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0;
- part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0;
- part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0;
-
- psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup;
- psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v;
- psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v;
-
- /* dupliobjects */
- if (ob->transflag & OB_DUPLIVERTS) {
- Object *dup = bmain->objects.first;
-
- for (; dup; dup = dup->id.next) {
- if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) {
- part->instance_object = dup;
- ob->transflag |= OB_DUPLIPARTS;
- ob->transflag &= ~OB_DUPLIVERTS;
-
- part->draw_as = PART_DRAW_OB;
-
- /* needed for proper libdata lookup */
- blo_do_versions_oldnewmap_insert(fd->libmap, dup, dup, 0);
- }
- }
- }
-
- {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
- part->type = PART_FLUID;
- }
-
- do_version_free_effects_245(&ob->effect);
-
- printf("Old particle system converted to new system.\n");
- }
- }
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- ParticleEditSettings *pset = &sce->toolsettings->particle;
- int a;
-
- if (pset->brush[0].size == 0) {
- pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER;
- pset->emitterdist = 0.25f;
- pset->totrekey = 5;
- pset->totaddkey = 5;
-
- for (a = 0; a < ARRAY_SIZE(pset->brush); a++) {
- pset->brush[a].strength = 50;
- pset->brush[a].size = 50;
- pset->brush[a].step = 10;
- }
-
- pset->brush[PE_BRUSH_CUT].strength = 100;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 10)) {
- Object *ob;
-
- /* dupliface scale */
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
- ob->instance_faces_scale = 1.0f;
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
- Object *ob;
- bActionStrip *strip;
-
- /* nla-strips - scale */
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- float length, actlength, repeat;
-
- if (strip->flag & ACTSTRIP_USESTRIDE)
- repeat = 1.0f;
- else
- repeat = strip->repeat;
-
- length = strip->end - strip->start;
- if (length == 0.0f)
- length = 1.0f;
- actlength = strip->actend - strip->actstart;
-
- strip->scale = length / (repeat * actlength);
- if (strip->scale == 0.0f)
- strip->scale = 1.0f;
- }
- if (ob->soft) {
- ob->soft->inpush = ob->soft->inspring;
- ob->soft->shearstiff = 1.0f;
- }
- }
- }
-
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 14)) {
- Scene *sce;
- Sequence *seq;
-
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- SEQ_BEGIN (sce->ed, seq)
- {
- if (seq->blend_mode == 0)
- seq->blend_opacity = 100.0f;
- } SEQ_END;
- }
- }
-
- /* fix broken group lengths in id properties */
- if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 15)) {
- idproperties_fix_group_lengths(bmain->scenes);
- idproperties_fix_group_lengths(bmain->libraries);
- idproperties_fix_group_lengths(bmain->objects);
- idproperties_fix_group_lengths(bmain->meshes);
- idproperties_fix_group_lengths(bmain->curves);
- idproperties_fix_group_lengths(bmain->metaballs);
- idproperties_fix_group_lengths(bmain->materials);
- idproperties_fix_group_lengths(bmain->textures);
- idproperties_fix_group_lengths(bmain->images);
- idproperties_fix_group_lengths(bmain->lattices);
- idproperties_fix_group_lengths(bmain->lights);
- idproperties_fix_group_lengths(bmain->cameras);
- idproperties_fix_group_lengths(bmain->ipo);
- idproperties_fix_group_lengths(bmain->shapekeys);
- idproperties_fix_group_lengths(bmain->worlds);
- idproperties_fix_group_lengths(bmain->screens);
- idproperties_fix_group_lengths(bmain->fonts);
- idproperties_fix_group_lengths(bmain->texts);
- idproperties_fix_group_lengths(bmain->sounds);
- idproperties_fix_group_lengths(bmain->collections);
- idproperties_fix_group_lengths(bmain->armatures);
- idproperties_fix_group_lengths(bmain->actions);
- idproperties_fix_group_lengths(bmain->nodetrees);
- idproperties_fix_group_lengths(bmain->brushes);
- idproperties_fix_group_lengths(bmain->particles);
- }
-
- /* convert fluids to modifier */
- if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
- Object *ob;
-
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->fluidsimSettings) {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
- BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
-
- MEM_freeN(fluidmd->fss);
- fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings);
- fluidmd->fss->ipo = blo_do_versions_newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo);
- MEM_freeN(ob->fluidsimSettings);
-
- fluidmd->fss->lastgoodframe = INT_MAX;
- fluidmd->fss->flag = 0;
- fluidmd->fss->meshVelocities = NULL;
- }
- }
- }
-
- if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
- ob->pd->f_noise = 0.0f;
- }
- }
-
- /* set the curve radius interpolation to 2.47 default - easy */
- if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 6)) {
- Curve *cu;
- Nurb *nu;
-
- for (cu = bmain->curves.first; cu; cu = cu->id.next) {
- for (nu = cu->nurb.first; nu; nu = nu->next) {
- if (nu) {
- nu->radius_interp = 3;
-
- /* resolu and resolv are now used differently for surfaces
- * rather than using the resolution to define the entire number of divisions,
- * use it for the number of divisions per segment
- */
- if (nu->pntsv > 1) {
- nu->resolu = MAX2(1, (int)(((float)nu->resolu / (float)nu->pntsu) + 0.5f) );
- nu->resolv = MAX2(1, (int)(((float)nu->resolv / (float)nu->pntsv) + 0.5f) );
- }
- }
- }
- }
- }
-
- if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 2)) {
- Scene *sce;
-
- /* Note, these will need to be added for painting */
- for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- sce->toolsettings->imapaint.seam_bleed = 2;
- sce->toolsettings->imapaint.normal_angle = 80;
- }
- }
-
- if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) {
- bScreen *sc;
-
- /* adjust default settings for Animation Editors */
- for (sc = bmain->screens.first; sc; sc = sc->id.next) {
- ScrArea *sa;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- SpaceLink *sl;
-
- for (sl = sa->spacedata.first; sl; sl = sl->next) {
- switch (sl->spacetype) {
- case SPACE_ACTION:
- {
- SpaceAction *sact = (SpaceAction *)sl;
-
- sact->mode = SACTCONT_DOPESHEET;
- sact->autosnap = SACTSNAP_FRAME;
- break;
- }
- case SPACE_GRAPH:
- {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- sipo->autosnap = SACTSNAP_FRAME;
- break;
- }
- case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- snla->autosnap = SACTSNAP_FRAME;
- break;
- }
- }
- }
- }
- }
- }
-
- /* correct introduce of seed for wind force */
- if (bmain->versionfile < 249 && bmain->subversionfile < 1) {
- Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pd)
- ob->pd->seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
- }
-
- }
-
- if (bmain->versionfile < 249 && bmain->subversionfile < 2) {
- Scene *sce = bmain->scenes.first;
- Sequence *seq;
- Editing *ed;
-
- while (sce) {
- ed = sce->ed;
- if (ed) {
- SEQP_BEGIN (ed, seq)
- {
- if (seq->strip && seq->strip->proxy) {
- seq->strip->proxy->quality = 90;
- }
- } SEQ_END;
- }
-
- sce = sce->id.next;
- }
- }
+ /* WATCH IT!!!: pointers from libdata have not been converted */
+
+ if (bmain->versionfile == 100) {
+ /* tex->extend and tex->imageflag have changed: */
+ Tex *tex = bmain->textures.first;
+ while (tex) {
+ if (tex->id.tag & LIB_TAG_NEED_LINK) {
+
+ if (tex->extend == 0) {
+ if (tex->xrepeat || tex->yrepeat) {
+ tex->extend = TEX_REPEAT;
+ }
+ else {
+ tex->extend = TEX_EXTEND;
+ tex->xrepeat = tex->yrepeat = 1;
+ }
+ }
+ }
+ tex = tex->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 101) {
+ /* frame mapping */
+ Scene *sce = bmain->scenes.first;
+ while (sce) {
+ sce->r.framapto = 100;
+ sce->r.images = 100;
+ sce->r.framelen = 1.0;
+ sce = sce->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 103) {
+ /* new variable in object: colbits */
+ Object *ob = bmain->objects.first;
+ int a;
+ while (ob) {
+ ob->colbits = 0;
+ if (ob->totcol) {
+ for (a = 0; a < ob->totcol; a++) {
+ if (ob->mat[a])
+ ob->colbits |= (1 << a);
+ }
+ }
+ ob = ob->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 104) {
+ /* timeoffs moved */
+ Object *ob = bmain->objects.first;
+ while (ob) {
+ if (ob->transflag & 1) {
+ ob->transflag -= 1;
+ }
+ ob = ob->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 106) {
+ /* mcol changed */
+ Mesh *me = bmain->meshes.first;
+ while (me) {
+ if (me->mcol)
+ vcol_to_fcol(me);
+ me = me->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 107) {
+ Object *ob;
+ ob = bmain->objects.first;
+ while (ob) {
+ if (ob->dt == 0)
+ ob->dt = OB_SOLID;
+ ob = ob->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 109) {
+ /* new variable: gridlines */
+ bScreen *sc = bmain->screens.first;
+ while (sc) {
+ ScrArea *sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl = sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ if (v3d->gridlines == 0)
+ v3d->gridlines = 20;
+ }
+ sl = sl->next;
+ }
+ sa = sa->next;
+ }
+ sc = sc->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 134) {
+ Tex *tex = bmain->textures.first;
+ while (tex) {
+ if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && (tex->bfac == 0.0f)) {
+ tex->rfac = 1.0f;
+ tex->gfac = 1.0f;
+ tex->bfac = 1.0f;
+ tex->filtersize = 1.0f;
+ }
+ tex = tex->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 140) {
+ /* r-g-b-fac in texture */
+ Tex *tex = bmain->textures.first;
+ while (tex) {
+ if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && (tex->bfac == 0.0f)) {
+ tex->rfac = 1.0f;
+ tex->gfac = 1.0f;
+ tex->bfac = 1.0f;
+ tex->filtersize = 1.0f;
+ }
+ tex = tex->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 153) {
+ Scene *sce = bmain->scenes.first;
+ while (sce) {
+ if (sce->r.blurfac == 0.0f)
+ sce->r.blurfac = 1.0f;
+ sce = sce->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 163) {
+ Scene *sce = bmain->scenes.first;
+ while (sce) {
+ if (sce->r.frs_sec == 0)
+ sce->r.frs_sec = 25;
+ sce = sce->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 164) {
+ Mesh *me = bmain->meshes.first;
+ while (me) {
+ me->smoothresh = 30;
+ me = me->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 165) {
+ Mesh *me = bmain->meshes.first;
+ TFace *tface;
+ int nr;
+ char *cp;
+
+ while (me) {
+ if (me->tface) {
+ nr = me->totface;
+ tface = me->tface;
+ while (nr--) {
+ int j;
+ for (j = 0; j < 4; j++) {
+ int k;
+ cp = ((char *)&tface->col[j]) + 1;
+ for (k = 0; k < 3; k++) {
+ cp[k] = (cp[k] > 126) ? 255 : cp[k] * 2;
+ }
+ }
+
+ tface++;
+ }
+ }
+ me = me->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 169) {
+ Mesh *me = bmain->meshes.first;
+ while (me) {
+ if (me->subdiv == 0)
+ me->subdiv = 1;
+ me = me->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 169) {
+ bScreen *sc = bmain->screens.first;
+ while (sc) {
+ ScrArea *sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl = sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ sipo->v2d.max[0] = 15000.0;
+ }
+ sl = sl->next;
+ }
+ sa = sa->next;
+ }
+ sc = sc->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 170) {
+ Object *ob = bmain->objects.first;
+ PartEff *paf;
+ while (ob) {
+ paf = blo_do_version_give_parteff_245(ob);
+ if (paf) {
+ if (paf->staticstep == 0) {
+ paf->staticstep = 5;
+ }
+ }
+ ob = ob->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 171) {
+ bScreen *sc = bmain->screens.first;
+ while (sc) {
+ ScrArea *sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl = sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st = (SpaceText *)sl;
+ st->lheight = 12;
+ }
+ sl = sl->next;
+ }
+ sa = sa->next;
+ }
+ sc = sc->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 173) {
+ int a, b;
+ Mesh *me = bmain->meshes.first;
+ while (me) {
+ if (me->tface) {
+ TFace *tface = me->tface;
+ for (a = 0; a < me->totface; a++, tface++) {
+ for (b = 0; b < 4; b++) {
+ tface->uv[b][0] /= 32767.0f;
+ tface->uv[b][1] /= 32767.0f;
+ }
+ }
+ }
+ me = me->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 204) {
+ bSound *sound;
+
+ sound = bmain->sounds.first;
+ while (sound) {
+ if (sound->volume < 0.01f) {
+ sound->volume = 1.0f;
+ }
+ sound = sound->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 212) {
+ bSound *sound;
+ Mesh *me;
+
+ sound = bmain->sounds.first;
+ while (sound) {
+ sound->max_gain = 1.0;
+ sound->min_gain = 0.0;
+ sound->distance = 1.0;
+
+ if (sound->attenuation > 0.0f)
+ sound->flags |= SOUND_FLAGS_3D;
+ else
+ sound->flags &= ~SOUND_FLAGS_3D;
+
+ sound = sound->id.next;
+ }
+
+ /* me->subdiv changed to reflect the actual reparametization
+ * better, and smeshes were removed - if it was a smesh make
+ * it a subsurf, and reset the subdiv level because subsurf
+ * takes a lot more work to calculate.
+ */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ enum {
+ ME_SMESH = (1 << 6),
+ ME_SUBSURF = (1 << 7),
+ };
+ if (me->flag & ME_SMESH) {
+ me->flag &= ~ME_SMESH;
+ me->flag |= ME_SUBSURF;
+
+ me->subdiv = 1;
+ }
+ else {
+ if (me->subdiv < 2)
+ me->subdiv = 1;
+ else
+ me->subdiv--;
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 220) {
+ Mesh *me;
+
+ /* Began using alpha component of vertex colors, but
+ * old file vertex colors are undefined, reset them
+ * to be fully opaque. -zr
+ */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if (me->mcol) {
+ int i;
+
+ for (i = 0; i < me->totface * 4; i++) {
+ MCol *mcol = &me->mcol[i];
+ mcol->a = 255;
+ }
+ }
+ if (me->tface) {
+ int i, j;
+
+ for (i = 0; i < me->totface; i++) {
+ TFace *tf = &((TFace *)me->tface)[i];
+
+ for (j = 0; j < 4; j++) {
+ char *col = (char *)&tf->col[j];
+
+ col[0] = 255;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 223) {
+ VFont *vf;
+ for (vf = bmain->fonts.first; vf; vf = vf->id.next) {
+ if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
+ strcpy(vf->name, FO_BUILTIN_NAME);
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 224) {
+ bSound *sound;
+ Scene *sce;
+ Mesh *me;
+ bScreen *sc;
+
+ for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
+ if (sound->packedfile) {
+ if (sound->newpackedfile == NULL) {
+ sound->newpackedfile = sound->packedfile;
+ }
+ sound->packedfile = NULL;
+ }
+ }
+ /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ enum { ME_SUBSURF = (1 << 7) };
+ if ((me->flag & ME_SUBSURF) && (me->subdivr == 0)) {
+ me->subdivr = me->subdiv;
+ }
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->r.stereomode = 1; // no stereo
+ }
+
+ /* some oldfile patch, moved from set_func_space */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_GRAPH) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ sseq->v2d.keeptot = 0;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 227) {
+ Scene *sce;
+ bScreen *sc;
+ Object *ob;
+
+ /* As of now, this insures that the transition from the old Track system
+ * to the new full constraint Track is painless for everyone. - theeth
+ */
+ ob = bmain->objects.first;
+
+ while (ob) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing TrackTo constraint
+ * set their track and up flag correctly
+ */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon = curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+ }
+ }
+
+ /* Change Ob->Track in real TrackTo constraint */
+ blo_do_version_old_trackto_to_constraints(ob);
+
+ ob = ob->id.next;
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->audio.mixrate = 48000;
+ sce->audio.flag |= AUDIO_SCRUB;
+ }
+
+ /* patch for old wrong max view2d settings, allows zooming out more */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *sac = (SpaceAction *)sl;
+ sac->v2d.max[0] = 32000;
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *sla = (SpaceNla *)sl;
+ sla->v2d.max[0] = 32000;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 228) {
+ bScreen *sc;
+ Object *ob;
+
+ /* As of now, this insures that the transition from the old Track system
+ * to the new full constraint Track is painless for everyone.
+ */
+ ob = bmain->objects.first;
+
+ while (ob) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing TrackTo constraint
+ * set their track and up flag correctly */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon = curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
+ if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
+ bTrackToConstraint *data = curcon->data;
+ data->reserved1 = ob->trackflag;
+ data->reserved2 = ob->upflag;
+ }
+ }
+ }
+ }
+ }
+
+ ob = ob->id.next;
+ }
+
+ /* convert old mainb values for new button panels */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_PROPERTIES) {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+
+ sbuts->v2d.maxzoom = 1.2f;
+
+ if (sbuts->mainb == BUTS_LAMP) {
+ sbuts->mainb = CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
+ }
+ else if (sbuts->mainb == BUTS_MAT) {
+ sbuts->mainb = CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
+ }
+ else if (sbuts->mainb == BUTS_TEX) {
+ sbuts->mainb = CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
+ }
+ else if (sbuts->mainb == BUTS_ANIM) {
+ sbuts->mainb = CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb == BUTS_WORLD) {
+ sbuts->mainb = CONTEXT_SCENE;
+ //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
+ }
+ else if (sbuts->mainb == BUTS_RENDER) {
+ sbuts->mainb = CONTEXT_SCENE;
+ //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
+ }
+ else if (sbuts->mainb == BUTS_FPAINT) {
+ sbuts->mainb = CONTEXT_EDITING;
+ }
+ else if (sbuts->mainb == BUTS_RADIO) {
+ sbuts->mainb = CONTEXT_SHADING;
+ //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
+ }
+ else if (sbuts->mainb == BUTS_CONSTRAINT) {
+ sbuts->mainb = CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb == BUTS_SCRIPT) {
+ sbuts->mainb = CONTEXT_OBJECT;
+ }
+ else if (sbuts->mainb == BUTS_EDIT) {
+ sbuts->mainb = CONTEXT_EDITING;
+ }
+ else {
+ sbuts->mainb = CONTEXT_SCENE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* ton: made this 230 instead of 229,
+ * to be sure (tuho files) and this is a reliable check anyway
+ * nevertheless, we might need to think over a fitness (initialize)
+ * check apart from the do_versions()
+ */
+
+ if (bmain->versionfile <= 230) {
+ bScreen *sc;
+
+ /* new variable blockscale, for panels in any area */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ /* added: 5x better zoom in for action */
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *sac = (SpaceAction *)sl;
+ sac->v2d.maxzoom = 50;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 231) {
+ bScreen *sc = bmain->screens.first;
+
+ /* new bit flags for showing/hiding grid floor and axes */
+
+ while (sc) {
+ ScrArea *sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl = sa->spacedata.first;
+ while (sl) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ if (v3d->gridflag == 0) {
+ v3d->gridflag |= V3D_SHOW_X;
+ v3d->gridflag |= V3D_SHOW_Y;
+ v3d->gridflag |= V3D_SHOW_FLOOR;
+ v3d->gridflag &= ~V3D_SHOW_Z;
+ }
+ }
+ sl = sl->next;
+ }
+ sa = sa->next;
+ }
+ sc = sc->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 232) {
+ Tex *tex = bmain->textures.first;
+ World *wrld = bmain->worlds.first;
+ bScreen *sc;
+
+ while (tex) {
+ if ((tex->flag & (TEX_CHECKER_ODD + TEX_CHECKER_EVEN)) == 0) {
+ tex->flag |= TEX_CHECKER_ODD;
+ }
+ /* copied from kernel texture.c */
+ if (tex->ns_outscale == 0.0f) {
+ /* musgrave */
+ tex->mg_H = 1.0f;
+ tex->mg_lacunarity = 2.0f;
+ tex->mg_octaves = 2.0f;
+ tex->mg_offset = 1.0f;
+ tex->mg_gain = 1.0f;
+ tex->ns_outscale = 1.0f;
+ /* distnoise */
+ tex->dist_amount = 1.0f;
+ /* voronoi */
+ tex->vn_w1 = 1.0f;
+ tex->vn_mexp = 2.5f;
+ }
+ tex = tex->id.next;
+ }
+
+ while (wrld) {
+ if (wrld->aodist == 0.0f) {
+ wrld->aodist = 10.0f;
+ }
+ if (wrld->aoenergy == 0.0f)
+ wrld->aoenergy = 1.0f;
+ wrld = wrld->id.next;
+ }
+
+ /* new variable blockscale, for panels in any area, do again because new
+ * areas didnt initialize it to 0.7 yet
+ */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ /* added: 5x better zoom in for nla */
+ if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+ snla->v2d.maxzoom = 50;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 233) {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->flag |= V3D_SELECT_OUTLINE;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 234) {
+ bScreen *sc;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st = (SpaceText *)sl;
+ if (st->tabnumber == 0)
+ st->tabnumber = 2;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 235) {
+ Tex *tex = bmain->textures.first;
+ Scene *sce = bmain->scenes.first;
+ Sequence *seq;
+ Editing *ed;
+
+ while (tex) {
+ if (tex->nabla == 0.0f)
+ tex->nabla = 0.025f;
+ tex = tex->id.next;
+ }
+ while (sce) {
+ ed = sce->ed;
+ if (ed) {
+ SEQ_BEGIN (sce->ed, seq) {
+ if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE)
+ seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
+ }
+ SEQ_END;
+ }
+
+ sce = sce->id.next;
+ }
+ }
+
+ if (bmain->versionfile <= 236) {
+ Object *ob;
+ Camera *cam = bmain->cameras.first;
+
+ while (cam) {
+ if (cam->ortho_scale == 0.0f) {
+ cam->ortho_scale = 256.0f / cam->lens;
+ if (cam->type == CAM_ORTHO)
+ printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
+ }
+ cam = cam->id.next;
+ }
+ /* force oops draw if depgraph was set*/
+ /* set time line var */
+
+ /* softbody init new vars */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->soft) {
+ if (ob->soft->defgoal == 0.0f)
+ ob->soft->defgoal = 0.7f;
+ if (ob->soft->physics_speed == 0.0f)
+ ob->soft->physics_speed = 1.0f;
+
+ if (ob->soft->interval == 0) {
+ ob->soft->interval = 2;
+ ob->soft->sfra = 1;
+ ob->soft->efra = 100;
+ }
+ }
+ if (ob->soft && ob->soft->vertgroup == 0) {
+ bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL");
+ if (locGroup) {
+ /* retrieve index for that group */
+ ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup);
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 237) {
+ bArmature *arm;
+ bConstraint *con;
+ Object *ob;
+ Bone *bone;
+
+ /* armature recode checks */
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ BKE_armature_where_is(arm);
+
+ for (bone = arm->bonebase.first; bone; bone = bone->next)
+ do_version_bone_head_tail_237(bone);
+ }
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->parent) {
+ Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
+ if (parent && parent->type == OB_LATTICE)
+ ob->partype = PARSKEL;
+ }
+
+ /* btw. armature_rebuild_pose is further only called on leave editmode */
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose)
+ BKE_pose_tag_recalc(bmain, ob->pose);
+
+ /* cannot call stuff now (pointers!), done in setup_app_data */
+ ob->id.recalc |= ID_RECALC_ALL;
+
+ /* new generic xray option */
+ arm = blo_do_versions_newlibadr(fd, lib, ob->data);
+ enum { ARM_DRAWXRAY = (1 << 1) };
+ if (arm->flag & ARM_DRAWXRAY) {
+ ob->dtx |= OB_DRAWXRAY;
+ }
+ }
+ else if (ob->type == OB_MESH) {
+ Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
+
+ enum {
+ ME_SUBSURF = (1 << 7),
+ ME_OPT_EDGES = (1 << 8),
+ };
+
+ if ((me->flag & ME_SUBSURF)) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)modifier_new(eModifierType_Subsurf);
+
+ smd->levels = MAX2(1, me->subdiv);
+ smd->renderLevels = MAX2(1, me->subdivr);
+ smd->subdivType = me->subsurftype;
+
+ smd->modifier.mode = 0;
+ if (me->subdiv != 0)
+ smd->modifier.mode |= 1;
+ if (me->subdivr != 0)
+ smd->modifier.mode |= 2;
+
+ if (me->flag & ME_OPT_EDGES)
+ smd->flags |= eSubsurfModifierFlag_ControlEdges;
+
+ BLI_addtail(&ob->modifiers, smd);
+
+ modifier_unique_name(&ob->modifiers, (ModifierData *)smd);
+ }
+ }
+
+ /* follow path constraint needs to set the 'path' option in curves... */
+ for (con = ob->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
+ bFollowPathConstraint *data = con->data;
+ Object *obc = blo_do_versions_newlibadr(fd, lib, data->tar);
+
+ if (obc && obc->type == OB_CURVE) {
+ Curve *cu = blo_do_versions_newlibadr(fd, lib, obc->data);
+ if (cu)
+ cu->flag |= CU_PATH;
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 238) {
+ Lattice *lt;
+ Object *ob;
+ bArmature *arm;
+ Mesh *me;
+ Key *key;
+ Scene *sce = bmain->scenes.first;
+
+ while (sce) {
+ if (sce->toolsettings == NULL) {
+ sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct");
+ sce->toolsettings->doublimit = 0.001f;
+ }
+ sce = sce->id.next;
+ }
+
+ for (lt = bmain->lattices.first; lt; lt = lt->id.next) {
+ if (lt->fu == 0.0f && lt->fv == 0.0f && lt->fw == 0.0f) {
+ calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
+ calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
+ calc_lat_fudu(lt->flag, lt->pntsw, &lt->fw, &lt->dw);
+ }
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ PartEff *paf;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Subsurf) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
+
+ smd->flags &= ~(eSubsurfModifierFlag_Incremental | eSubsurfModifierFlag_DebugIncr);
+ }
+ }
+
+ if ((ob->softflag & OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) {
+ if (ob->softflag & OB_SB_POSTDEF) {
+ md = ob->modifiers.first;
+
+ while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) {
+ md = md->next;
+ }
+
+ BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody));
+ }
+ else {
+ BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody));
+ }
+
+ ob->softflag &= ~OB_SB_ENABLE;
+ }
+
+ if (ob->pose) {
+ bPoseChannel *pchan;
+ bConstraint *con;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* note, pchan->bone is also lib-link stuff */
+ if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) {
+ pchan->limitmin[0] = pchan->limitmin[1] = pchan->limitmin[2] = -180.0f;
+ pchan->limitmax[0] = pchan->limitmax[1] = pchan->limitmax[2] = 180.0f;
+
+ for (con = pchan->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = (bKinematicConstraint *)con->data;
+ data->weight = 1.0f;
+ data->orientweight = 1.0f;
+ data->flag &= ~CONSTRAINT_IK_ROT;
+
+ /* enforce conversion from old IK_TOPARENT to rootbone index */
+ data->rootbone = -1;
+
+ /* update_pose_etc handles rootbone == -1 */
+ BKE_pose_tag_recalc(bmain, ob->pose);
+ }
+ }
+ }
+ }
+ }
+
+ paf = blo_do_version_give_parteff_245(ob);
+ if (paf) {
+ if (paf->disp == 0)
+ paf->disp = 100;
+ if (paf->speedtex == 0)
+ paf->speedtex = 8;
+ if (paf->omat == 0)
+ paf->omat = 1;
+ }
+ }
+
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ bone_version_238(&arm->bonebase);
+ arm->deformflag |= ARM_DEF_VGROUP;
+ }
+
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if (!me->medge) {
+ BKE_mesh_calc_edges_legacy(me, true); /* true = use mface->edcode */
+ }
+ else {
+ BKE_mesh_strip_loose_faces(me);
+ }
+ }
+
+ for (key = bmain->shapekeys.first; key; key = key->id.next) {
+ KeyBlock *kb;
+ int index = 1;
+
+ for (kb = key->block.first; kb; kb = kb->next) {
+ if (kb == key->refkey) {
+ if (kb->name[0] == 0)
+ strcpy(kb->name, "Basis");
+ }
+ else {
+ if (kb->name[0] == 0) {
+ BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
+ }
+ index++;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 239) {
+ bArmature *arm;
+ Object *ob;
+ Scene *sce = bmain->scenes.first;
+ Camera *cam = bmain->cameras.first;
+ int set_passepartout = 0;
+
+ /* deformflag is local in modifier now */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Armature) {
+ ArmatureModifierData *amd = (ArmatureModifierData *)md;
+ if (amd->object && amd->deformflag == 0) {
+ Object *oba = blo_do_versions_newlibadr(fd, lib, amd->object);
+ arm = blo_do_versions_newlibadr(fd, lib, oba->data);
+ amd->deformflag = arm->deformflag;
+ }
+ }
+ }
+ }
+
+ /* updating stepsize for ghost drawing */
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ bone_version_239(&arm->bonebase);
+ if (arm->layer == 0)
+ arm->layer = 1;
+ }
+
+ for (; sce; sce = sce->id.next) {
+ if (sce->r.scemode & R_PASSEPARTOUT) {
+ set_passepartout = 1;
+ sce->r.scemode &= ~R_PASSEPARTOUT;
+ }
+ }
+
+ for (; cam; cam = cam->id.next) {
+ if (set_passepartout)
+ cam->flag |= CAM_SHOWPASSEPARTOUT;
+
+ /* make sure old cameras have title safe on */
+ if (!(cam->flag & CAM_SHOW_SAFE_MARGINS))
+ cam->flag |= CAM_SHOW_SAFE_MARGINS;
+
+ /* set an appropriate camera passepartout alpha */
+ if (!(cam->passepartalpha))
+ cam->passepartalpha = 0.2f;
+ }
+ }
+
+ if (bmain->versionfile <= 241) {
+ Object *ob;
+ Scene *sce;
+ Light *la;
+ bArmature *arm;
+ bNodeTree *ntree;
+
+ /* updating layers still */
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ bone_version_239(&arm->bonebase);
+ if (arm->layer == 0)
+ arm->layer = 1;
+ }
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->audio.mixrate == 0)
+ sce->audio.mixrate = 48000;
+
+ /* We don't add default layer since blender2.8 because the layers
+ * are now in Scene->view_layers and a default layer is created in
+ * the doversion later on.
+ */
+ SceneRenderLayer *srl;
+ /* new layer flag for sky, was default for solid */
+ for (srl = sce->r.layers.first; srl; srl = srl->next) {
+ if (srl->layflag & SCE_LAY_SOLID)
+ srl->layflag |= SCE_LAY_SKY;
+ srl->passflag &= (SCE_PASS_COMBINED | SCE_PASS_Z | SCE_PASS_NORMAL | SCE_PASS_VECTOR);
+ }
+
+ /* node version changes */
+ if (sce->nodetree)
+ ntree_version_241(sce->nodetree);
+
+ /* uv calculation options moved to toolsettings */
+ if (sce->toolsettings->unwrapper == 0) {
+ sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES;
+ sce->toolsettings->unwrapper = 1;
+ }
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ ntree_version_241(ntree);
+
+ for (la = bmain->lights.first; la; la = la->id.next)
+ if (la->buffers == 0)
+ la->buffers = 1;
+
+ /* for empty drawsize and drawtype */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->empty_drawsize == 0.0f) {
+ ob->empty_drawtype = OB_ARROWS;
+ ob->empty_drawsize = 1.0;
+ }
+ }
+
+ /* during 2.41 images with this name were used for viewer node output, lets fix that */
+ if (bmain->versionfile == 241) {
+ Image *ima;
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (STREQ(ima->name, "Compositor")) {
+ strcpy(ima->id.name + 2, "Viewer Node");
+ strcpy(ima->name, "Viewer Node");
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 242) {
+ Scene *sce;
+ bScreen *sc;
+ Object *ob;
+ Curve *cu;
+ Material *ma;
+ Mesh *me;
+ Collection *collection;
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ bNodeTree *ntree;
+ int a;
+
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ if (v3d->gridsubdiv == 0)
+ v3d->gridsubdiv = 10;
+ }
+ }
+ sa = sa->next;
+ }
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ enum {
+ R_THREADS = (1 << 19),
+ };
+ if (sce->toolsettings->select_thresh == 0.0f)
+ sce->toolsettings->select_thresh = 0.01f;
+ if (sce->r.threads == 0) {
+ if (sce->r.mode & R_THREADS)
+ sce->r.threads = 2;
+ else
+ sce->r.threads = 1;
+ }
+ if (sce->nodetree)
+ ntree_version_242(sce->nodetree);
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ ntree_version_242(ntree);
+
+ /* add default radius values to old curve points */
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu) {
+ if (nu->bezt) {
+ for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
+ if (!bezt->radius)
+ bezt->radius = 1.0;
+ }
+ }
+ else if (nu->bp) {
+ for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
+ if (!bp->radius)
+ bp->radius = 1.0;
+ }
+ }
+ }
+ }
+ }
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* check for already existing MinMax (floor) constraint
+ * and update the sticky flagging */
+
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon = curcon->next) {
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_MINMAX: {
+ bMinMaxConstraint *data = curcon->data;
+ if (data->sticky == 1)
+ data->flag |= MINMAX_STICKY;
+ else
+ data->flag &= ~MINMAX_STICKY;
+
+ break;
+ }
+ case CONSTRAINT_TYPE_ROTLIKE: {
+ bRotateLikeConstraint *data = curcon->data;
+
+ /* version patch from buttons_object.c */
+ if (data->flag == 0)
+ data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
+
+ break;
+ }
+ }
+ }
+ }
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_MINMAX: {
+ bMinMaxConstraint *data = curcon->data;
+ if (data->sticky == 1)
+ data->flag |= MINMAX_STICKY;
+ else
+ data->flag &= ~MINMAX_STICKY;
+ break;
+ }
+ case CONSTRAINT_TYPE_KINEMATIC: {
+ bKinematicConstraint *data = curcon->data;
+ if (!(data->flag & CONSTRAINT_IK_POS)) {
+ data->flag |= CONSTRAINT_IK_POS;
+ data->flag |= CONSTRAINT_IK_STRETCH;
+ }
+ break;
+ }
+ case CONSTRAINT_TYPE_ROTLIKE: {
+ bRotateLikeConstraint *data = curcon->data;
+
+ /* version patch from buttons_object.c */
+ if (data->flag == 0)
+ data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* copy old object level track settings to curve modifers */
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Curve) {
+ CurveModifierData *cmd = (CurveModifierData *)md;
+
+ if (cmd->defaxis == 0)
+ cmd->defaxis = ob->trackflag + 1;
+ }
+ }
+ }
+
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+ if (ma->nodetree)
+ ntree_version_242(ma->nodetree);
+ }
+
+ for (me = bmain->meshes.first; me; me = me->id.next)
+ customdata_version_242(me);
+
+ for (collection = bmain->collections.first; collection; collection = collection->id.next)
+ if (collection->layer == 0)
+ collection->layer = (1 << 20) - 1;
+
+ /* now, subversion control! */
+ if (bmain->subversionfile < 3) {
+ Image *ima;
+ Tex *tex;
+
+ /* Image refactor initialize */
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ ima->source = IMA_SRC_FILE;
+ ima->type = IMA_TYPE_IMAGE;
+
+ ima->gen_x = 256;
+ ima->gen_y = 256;
+ ima->gen_type = 1;
+
+ if (STREQLEN(ima->id.name + 2, "Viewer Node", sizeof(ima->id.name) - 2)) {
+ ima->source = IMA_SRC_VIEWER;
+ ima->type = IMA_TYPE_COMPOSITE;
+ }
+ if (STREQLEN(ima->id.name + 2, "Render Result", sizeof(ima->id.name) - 2)) {
+ ima->source = IMA_SRC_VIEWER;
+ ima->type = IMA_TYPE_R_RESULT;
+ }
+ }
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ enum {
+ TEX_ANIMCYCLIC = (1 << 6),
+ TEX_ANIM5 = (1 << 7),
+ };
+
+ if (tex->type == TEX_IMAGE && tex->ima) {
+ ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
+ if (tex->imaflag & TEX_ANIM5) {
+ ima->source = IMA_SRC_MOVIE;
+ }
+ }
+ tex->iuser.frames = tex->frames;
+ tex->iuser.offset = tex->offset;
+ tex->iuser.sfra = tex->sfra;
+ tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC) != 0;
+ }
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree)
+ do_version_ntree_242_2(sce->nodetree);
+ }
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ do_version_ntree_242_2(ntree);
+ for (ma = bmain->materials.first; ma; ma = ma->id.next)
+ if (ma->nodetree)
+ do_version_ntree_242_2(ma->nodetree);
+ }
+
+ if (bmain->subversionfile < 4) {
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->r.bake_mode = 1; /* prevent to include render stuff here */
+ sce->r.bake_filter = 16;
+ sce->r.bake_flag = R_BAKE_CLEAR;
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 243) {
+ Object *ob = bmain->objects.first;
+
+ for (; ob; ob = ob->id.next) {
+ bDeformGroup *curdef;
+
+ for (curdef = ob->defbase.first; curdef; curdef = curdef->next) {
+ /* replace an empty-string name with unique name */
+ if (curdef->name[0] == '\0') {
+ defgroup_unique_name(curdef, ob);
+ }
+ }
+
+ if (bmain->versionfile < 243 || bmain->subversionfile < 1) {
+ ModifierData *md;
+
+ /* translate old mirror modifier axis values to new flags */
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Mirror) {
+ MirrorModifierData *mmd = (MirrorModifierData *)md;
+
+ switch (mmd->axis) {
+ case 0:
+ mmd->flag |= MOD_MIR_AXIS_X;
+ break;
+ case 1:
+ mmd->flag |= MOD_MIR_AXIS_Y;
+ break;
+ case 2:
+ mmd->flag |= MOD_MIR_AXIS_Z;
+ break;
+ }
+
+ mmd->axis = 0;
+ }
+ }
+ }
+ }
+
+ /* render layer added, this is not the active layer */
+ if (bmain->versionfile <= 243 || bmain->subversionfile < 2) {
+ Mesh *me;
+ for (me = bmain->meshes.first; me; me = me->id.next)
+ customdata_version_243(me);
+ }
+ }
+
+ if (bmain->versionfile <= 244) {
+ bScreen *sc;
+
+ if (bmain->versionfile != 244 || bmain->subversionfile < 2) {
+ /* correct older action editors - incorrect scrolling */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+ sa = sc->areabase.first;
+ while (sa) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_ACTION) {
+ SpaceAction *saction = (SpaceAction *)sl;
+
+ saction->v2d.tot.ymin = -1000.0;
+ saction->v2d.tot.ymax = 0.0;
+
+ saction->v2d.cur.ymin = -75.0;
+ saction->v2d.cur.ymax = 5.0;
+ }
+ }
+ sa = sa->next;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile <= 245) {
+ Scene *sce;
+ Object *ob;
+ Image *ima;
+ Light *la;
+ Material *ma;
+ ParticleSettings *part;
+ Mesh *me;
+ bNodeTree *ntree;
+ Tex *tex;
+ ModifierData *md;
+ ParticleSystem *psys;
+
+ /* unless the file was created 2.44.3 but not 2.45, update the constraints */
+ if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) &&
+ ((bmain->versionfile < 245) ||
+ (bmain->versionfile == 245 && bmain->subversionfile == 0))) {
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ ListBase *list;
+ list = &ob->constraints;
+
+ /* fix up constraints due to constraint recode changes (originally at 2.44.3) */
+ if (list) {
+ bConstraint *curcon;
+ for (curcon = list->first; curcon; curcon = curcon->next) {
+ /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
+ if (curcon->flag & 0x20) {
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
+
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_LOCLIMIT: {
+ bLocLimitConstraint *data = (bLocLimitConstraint *)curcon->data;
+
+ /* old limit without parent option for objects */
+ if (data->flag2)
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ break;
+ }
+ }
+ }
+ }
+
+ /* correctly initialize constinv matrix */
+ unit_m4(ob->constinv);
+
+ if (ob->type == OB_ARMATURE) {
+ if (ob->pose) {
+ bConstraint *curcon;
+ bPoseChannel *pchan;
+
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* make sure constraints are all up to date */
+ for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
+ /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */
+ if (curcon->flag & 0x20) {
+ curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
+
+ switch (curcon->type) {
+ case CONSTRAINT_TYPE_ACTION: {
+ bActionConstraint *data = (bActionConstraint *)curcon->data;
+
+ /* 'data->local' used to mean that target was in local-space */
+ if (data->local)
+ curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ break;
+ }
+ }
+ }
+
+ /* correctly initialize constinv matrix */
+ unit_m4(pchan->constinv);
+ }
+ }
+ }
+ }
+ }
+
+ /* fix all versions before 2.45 */
+ if (bmain->versionfile != 245) {
+
+ /* repair preview from 242 - 244*/
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ ima->preview = NULL;
+ }
+ }
+
+ /* add point caches */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->soft && !ob->soft->pointcache)
+ ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
+
+ for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+ if (psys->pointcache) {
+ if (psys->pointcache->flag & PTCACHE_BAKED &&
+ (psys->pointcache->flag & PTCACHE_DISK_CACHE) == 0) {
+ printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n");
+ psys->pointcache->flag &= ~PTCACHE_BAKED;
+ }
+ }
+ else
+ psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
+ }
+
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+ if (!clmd->point_cache) {
+ clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
+ clmd->point_cache->step = 1;
+ }
+ }
+ }
+ }
+
+ /* Copy over old per-level multires vertex data
+ * into a single vertex array in struct Multires */
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if (me->mr && !me->mr->verts) {
+ MultiresLevel *lvl = me->mr->levels.last;
+ if (lvl) {
+ me->mr->verts = lvl->verts;
+ lvl->verts = NULL;
+ /* Don't need the other vert arrays */
+ for (lvl = lvl->prev; lvl; lvl = lvl->prev) {
+ MEM_freeN(lvl->verts);
+ lvl->verts = NULL;
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile != 245 || bmain->subversionfile < 1) {
+ for (la = bmain->lights.first; la; la = la->id.next) {
+ la->falloff_type = LA_FALLOFF_INVLINEAR;
+
+ if (la->curfalloff == NULL) {
+ la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
+ curvemapping_initialize(la->curfalloff);
+ }
+ }
+ }
+
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+ if (ma->gloss_mir == 0.0f) {
+ ma->gloss_mir = 1.0f;
+ }
+ }
+
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (part->ren_child_nbr == 0)
+ part->ren_child_nbr = part->child_nbr;
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree)
+ ntree_version_245(fd, lib, sce->nodetree);
+
+ if (sce->r.simplify_subsurf == 0) {
+ sce->r.simplify_subsurf = 6;
+ sce->r.simplify_particles = 1.0f;
+ }
+ }
+
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ ntree_version_245(fd, lib, ntree);
+
+ /* fix for temporary flag changes during 245 cycle */
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (ima->flag & IMA_OLD_PREMUL) {
+ ima->flag &= ~IMA_OLD_PREMUL;
+ ima->alpha_mode = IMA_ALPHA_STRAIGHT;
+ }
+ }
+
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->iuser.flag & IMA_OLD_PREMUL) {
+ tex->iuser.flag &= ~IMA_OLD_PREMUL;
+ }
+
+ ima = blo_do_versions_newlibadr(fd, lib, tex->ima);
+ if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) {
+ ima->flag &= ~IMA_OLD_PREMUL;
+ ima->alpha_mode = IMA_ALPHA_STRAIGHT;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 2)) {
+ Image *ima;
+
+ /* initialize 1:1 Aspect */
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ ima->aspx = ima->aspy = 1.0f;
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 4)) {
+ bArmature *arm;
+ ModifierData *md;
+ Object *ob;
+
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next)
+ arm->deformflag |= ARM_DEF_B_BONE_REST;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Armature)
+ ((ArmatureModifierData *)md)->deformflag |= ARM_DEF_B_BONE_REST;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 5)) {
+ /* foreground color needs to be something other then black */
+ Scene *sce;
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
+ sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */
+ sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 6)) {
+ Scene *sce;
+ /* fix frs_sec_base */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->r.frs_sec_base == 0) {
+ sce->r.frs_sec_base = 1;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 7)) {
+ Object *ob;
+ bPoseChannel *pchan;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pose) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ do_version_constraints_245(&pchan->constraints);
+ }
+ }
+ do_version_constraints_245(&ob->constraints);
+
+ if (ob->soft && ob->soft->keys) {
+ SoftBody *sb = ob->soft;
+ int k;
+
+ for (k = 0; k < sb->totkey; k++) {
+ if (sb->keys[k])
+ MEM_freeN(sb->keys[k]);
+ }
+
+ MEM_freeN(sb->keys);
+
+ sb->keys = NULL;
+ sb->totkey = 0;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 8)) {
+ Scene *sce;
+ Object *ob;
+ PartEff *paf = NULL;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->soft && ob->soft->keys) {
+ SoftBody *sb = ob->soft;
+ int k;
+
+ for (k = 0; k < sb->totkey; k++) {
+ if (sb->keys[k])
+ MEM_freeN(sb->keys[k]);
+ }
+
+ MEM_freeN(sb->keys);
+
+ sb->keys = NULL;
+ sb->totkey = 0;
+ }
+
+ /* convert old particles to new system */
+ if ((paf = blo_do_version_give_parteff_245(ob))) {
+ ParticleSystem *psys;
+ ModifierData *md;
+ ParticleSystemModifierData *psmd;
+ ParticleSettings *part;
+
+ /* create new particle system */
+ psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
+ psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
+
+ part = psys->part = BKE_particlesettings_add(bmain, "ParticleSettings");
+
+ /* needed for proper libdata lookup */
+ blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
+ part->id.lib = ob->id.lib;
+
+ part->id.us--;
+ part->id.tag |= (ob->id.tag & LIB_TAG_NEED_LINK);
+
+ psys->totpart = 0;
+ psys->flag = PSYS_CURRENT;
+
+ BLI_addtail(&ob->particlesystem, psys);
+
+ md = modifier_new(eModifierType_ParticleSystem);
+ BLI_snprintf(md->name,
+ sizeof(md->name),
+ "ParticleSystem %i",
+ BLI_listbase_count(&ob->particlesystem));
+ psmd = (ParticleSystemModifierData *)md;
+ psmd->psys = psys;
+ BLI_addtail(&ob->modifiers, md);
+
+ /* convert settings from old particle system */
+ /* general settings */
+ part->totpart = MIN2(paf->totpart, 100000);
+ part->sta = paf->sta;
+ part->end = paf->end;
+ part->lifetime = paf->lifetime;
+ part->randlife = paf->randlife;
+ psys->seed = paf->seed;
+ part->disp = paf->disp;
+ part->omat = paf->mat[0];
+ part->hair_step = paf->totkey;
+
+ part->eff_group = paf->group;
+
+ /* old system didn't interpolate between keypoints at render time */
+ part->draw_step = part->ren_step = 0;
+
+ /* physics */
+ part->normfac = paf->normfac * 25.0f;
+ part->obfac = paf->obfac;
+ part->randfac = paf->randfac * 25.0f;
+ part->dampfac = paf->damp;
+ copy_v3_v3(part->acc, paf->force);
+
+ /* flags */
+ if (paf->stype & PAF_VECT) {
+ if (paf->flag & PAF_STATIC) {
+ /* new hair lifetime is always 100.0f */
+ float fac = paf->lifetime / 100.0f;
+
+ part->draw_as = PART_DRAW_PATH;
+ part->type = PART_HAIR;
+ psys->recalc |= ID_RECALC_PSYS_REDO;
+
+ part->normfac *= fac;
+ part->randfac *= fac;
+ }
+ else {
+ part->draw_as = PART_DRAW_LINE;
+ part->draw |= PART_DRAW_VEL_LENGTH;
+ part->draw_line[1] = 0.04f;
+ }
+ }
+
+ part->rotmode = PART_ROT_VEL;
+
+ part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0;
+ part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0;
+ part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0;
+ part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0;
+ part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0;
+ part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0;
+ part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0;
+
+ psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup;
+ psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v;
+ psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v;
+
+ /* dupliobjects */
+ if (ob->transflag & OB_DUPLIVERTS) {
+ Object *dup = bmain->objects.first;
+
+ for (; dup; dup = dup->id.next) {
+ if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) {
+ part->instance_object = dup;
+ ob->transflag |= OB_DUPLIPARTS;
+ ob->transflag &= ~OB_DUPLIVERTS;
+
+ part->draw_as = PART_DRAW_OB;
+
+ /* needed for proper libdata lookup */
+ blo_do_versions_oldnewmap_insert(fd->libmap, dup, dup, 0);
+ }
+ }
+ }
+
+ {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
+ ob, eModifierType_Fluidsim);
+ if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
+ part->type = PART_FLUID;
+ }
+
+ do_version_free_effects_245(&ob->effect);
+
+ printf("Old particle system converted to new system.\n");
+ }
+ }
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ ParticleEditSettings *pset = &sce->toolsettings->particle;
+ int a;
+
+ if (pset->brush[0].size == 0) {
+ pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER;
+ pset->emitterdist = 0.25f;
+ pset->totrekey = 5;
+ pset->totaddkey = 5;
+
+ for (a = 0; a < ARRAY_SIZE(pset->brush); a++) {
+ pset->brush[a].strength = 50;
+ pset->brush[a].size = 50;
+ pset->brush[a].step = 10;
+ }
+
+ pset->brush[PE_BRUSH_CUT].strength = 100;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 10)) {
+ Object *ob;
+
+ /* dupliface scale */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next)
+ ob->instance_faces_scale = 1.0f;
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
+ Object *ob;
+ bActionStrip *strip;
+
+ /* nla-strips - scale */
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (strip = ob->nlastrips.first; strip; strip = strip->next) {
+ float length, actlength, repeat;
+
+ if (strip->flag & ACTSTRIP_USESTRIDE)
+ repeat = 1.0f;
+ else
+ repeat = strip->repeat;
+
+ length = strip->end - strip->start;
+ if (length == 0.0f)
+ length = 1.0f;
+ actlength = strip->actend - strip->actstart;
+
+ strip->scale = length / (repeat * actlength);
+ if (strip->scale == 0.0f)
+ strip->scale = 1.0f;
+ }
+ if (ob->soft) {
+ ob->soft->inpush = ob->soft->inspring;
+ ob->soft->shearstiff = 1.0f;
+ }
+ }
+ }
+
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 14)) {
+ Scene *sce;
+ Sequence *seq;
+
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ SEQ_BEGIN (sce->ed, seq) {
+ if (seq->blend_mode == 0)
+ seq->blend_opacity = 100.0f;
+ }
+ SEQ_END;
+ }
+ }
+
+ /* fix broken group lengths in id properties */
+ if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 15)) {
+ idproperties_fix_group_lengths(bmain->scenes);
+ idproperties_fix_group_lengths(bmain->libraries);
+ idproperties_fix_group_lengths(bmain->objects);
+ idproperties_fix_group_lengths(bmain->meshes);
+ idproperties_fix_group_lengths(bmain->curves);
+ idproperties_fix_group_lengths(bmain->metaballs);
+ idproperties_fix_group_lengths(bmain->materials);
+ idproperties_fix_group_lengths(bmain->textures);
+ idproperties_fix_group_lengths(bmain->images);
+ idproperties_fix_group_lengths(bmain->lattices);
+ idproperties_fix_group_lengths(bmain->lights);
+ idproperties_fix_group_lengths(bmain->cameras);
+ idproperties_fix_group_lengths(bmain->ipo);
+ idproperties_fix_group_lengths(bmain->shapekeys);
+ idproperties_fix_group_lengths(bmain->worlds);
+ idproperties_fix_group_lengths(bmain->screens);
+ idproperties_fix_group_lengths(bmain->fonts);
+ idproperties_fix_group_lengths(bmain->texts);
+ idproperties_fix_group_lengths(bmain->sounds);
+ idproperties_fix_group_lengths(bmain->collections);
+ idproperties_fix_group_lengths(bmain->armatures);
+ idproperties_fix_group_lengths(bmain->actions);
+ idproperties_fix_group_lengths(bmain->nodetrees);
+ idproperties_fix_group_lengths(bmain->brushes);
+ idproperties_fix_group_lengths(bmain->particles);
+ }
+
+ /* convert fluids to modifier */
+ if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
+ Object *ob;
+
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->fluidsimSettings) {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(
+ eModifierType_Fluidsim);
+ BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
+
+ MEM_freeN(fluidmd->fss);
+ fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings);
+ fluidmd->fss->ipo = blo_do_versions_newlibadr_us(
+ fd, ob->id.lib, ob->fluidsimSettings->ipo);
+ MEM_freeN(ob->fluidsimSettings);
+
+ fluidmd->fss->lastgoodframe = INT_MAX;
+ fluidmd->fss->flag = 0;
+ fluidmd->fss->meshVelocities = NULL;
+ }
+ }
+ }
+
+ if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
+ ob->pd->f_noise = 0.0f;
+ }
+ }
+
+ /* set the curve radius interpolation to 2.47 default - easy */
+ if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 6)) {
+ Curve *cu;
+ Nurb *nu;
+
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu) {
+ nu->radius_interp = 3;
+
+ /* resolu and resolv are now used differently for surfaces
+ * rather than using the resolution to define the entire number of divisions,
+ * use it for the number of divisions per segment
+ */
+ if (nu->pntsv > 1) {
+ nu->resolu = MAX2(1, (int)(((float)nu->resolu / (float)nu->pntsu) + 0.5f));
+ nu->resolv = MAX2(1, (int)(((float)nu->resolv / (float)nu->pntsv) + 0.5f));
+ }
+ }
+ }
+ }
+ }
+
+ if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 2)) {
+ Scene *sce;
+
+ /* Note, these will need to be added for painting */
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ sce->toolsettings->imapaint.seam_bleed = 2;
+ sce->toolsettings->imapaint.normal_angle = 80;
+ }
+ }
+
+ if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) {
+ bScreen *sc;
+
+ /* adjust default settings for Animation Editors */
+ for (sc = bmain->screens.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ switch (sl->spacetype) {
+ case SPACE_ACTION: {
+ SpaceAction *sact = (SpaceAction *)sl;
+
+ sact->mode = SACTCONT_DOPESHEET;
+ sact->autosnap = SACTSNAP_FRAME;
+ break;
+ }
+ case SPACE_GRAPH: {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ sipo->autosnap = SACTSNAP_FRAME;
+ break;
+ }
+ case SPACE_NLA: {
+ SpaceNla *snla = (SpaceNla *)sl;
+ snla->autosnap = SACTSNAP_FRAME;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* correct introduce of seed for wind force */
+ if (bmain->versionfile < 249 && bmain->subversionfile < 1) {
+ Object *ob;
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->pd)
+ ob->pd->seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
+ }
+ }
+
+ if (bmain->versionfile < 249 && bmain->subversionfile < 2) {
+ Scene *sce = bmain->scenes.first;
+ Sequence *seq;
+ Editing *ed;
+
+ while (sce) {
+ ed = sce->ed;
+ if (ed) {
+ SEQP_BEGIN (ed, seq) {
+ if (seq->strip && seq->strip->proxy) {
+ seq->strip->proxy->quality = 90;
+ }
+ }
+ SEQ_END;
+ }
+
+ sce = sce->id.next;
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 025bfc55569..bf88eddc145 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -35,84 +35,83 @@
#include "BKE_main.h"
#include "BKE_keyconfig.h"
-#include "BLO_readfile.h" /* Own include. */
+#include "BLO_readfile.h" /* Own include. */
#include "wm_event_types.h"
/* Disallow access to global userdef. */
#define U (_error_)
-
static void do_versions_theme(UserDef *userdef, bTheme *btheme)
{
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver)
- if (!USER_VERSION_ATLEAST(280, 20)) {
- memcpy(btheme, &U_theme_default, sizeof(*btheme));
- }
-
-#define FROM_DEFAULT_V4_UCHAR(member) \
- copy_v4_v4_char(btheme->member, U_theme_default.member)
-
- if (!USER_VERSION_ATLEAST(280, 25)) {
- copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active);
- copy_v4_v4_char(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active);
- copy_v4_v4_char(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active);
- }
-
- if (!USER_VERSION_ATLEAST(280, 26)) {
- FROM_DEFAULT_V4_UCHAR(tui.icon_collection);
- FROM_DEFAULT_V4_UCHAR(tui.icon_object);
- FROM_DEFAULT_V4_UCHAR(tui.icon_object_data);
- FROM_DEFAULT_V4_UCHAR(tui.icon_modifier);
- FROM_DEFAULT_V4_UCHAR(tui.icon_shading);
- }
-
- if (!USER_VERSION_ATLEAST(280, 27)) {
- FROM_DEFAULT_V4_UCHAR(space_action.shade2);
- FROM_DEFAULT_V4_UCHAR(space_action.hilite);
- FROM_DEFAULT_V4_UCHAR(space_action.group);
- FROM_DEFAULT_V4_UCHAR(space_action.group_active);
- FROM_DEFAULT_V4_UCHAR(space_action.strip_select);
- FROM_DEFAULT_V4_UCHAR(space_action.ds_channel);
- FROM_DEFAULT_V4_UCHAR(space_action.ds_subchannel);
- FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold);
- FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold_select);
- }
-
- if (!USER_VERSION_ATLEAST(280, 28)) {
- FROM_DEFAULT_V4_UCHAR(space_action.ds_ipoline);
- }
-
- if (!USER_VERSION_ATLEAST(280, 29)) {
- FROM_DEFAULT_V4_UCHAR(space_properties.navigation_bar);
- }
- if (!USER_VERSION_ATLEAST(280, 31)) {
- FROM_DEFAULT_V4_UCHAR(space_clip.list_text);
- }
-
- if (!USER_VERSION_ATLEAST(280, 36)) {
- FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed);
- FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed_sel);
- }
-
- if (!USER_VERSION_ATLEAST(280, 39)) {
- FROM_DEFAULT_V4_UCHAR(space_clip.metadatabg);
- FROM_DEFAULT_V4_UCHAR(space_clip.metadatatext);
- }
-
- if (!USER_VERSION_ATLEAST(280, 40)) {
- FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar);
- copy_v4_v4_char(btheme->space_preferences.execution_buts, btheme->space_preferences.navigation_bar);
- }
-
- if (!USER_VERSION_ATLEAST(280, 41)) {
- FROM_DEFAULT_V4_UCHAR(space_view3d.back);
- }
-
- if (!USER_VERSION_ATLEAST(280, 52)) {
- FROM_DEFAULT_V4_UCHAR(space_info.info_info);
- }
+ if (!USER_VERSION_ATLEAST(280, 20)) {
+ memcpy(btheme, &U_theme_default, sizeof(*btheme));
+ }
+
+#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_char(btheme->member, U_theme_default.member)
+
+ if (!USER_VERSION_ATLEAST(280, 25)) {
+ copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active);
+ copy_v4_v4_char(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active);
+ copy_v4_v4_char(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 26)) {
+ FROM_DEFAULT_V4_UCHAR(tui.icon_collection);
+ FROM_DEFAULT_V4_UCHAR(tui.icon_object);
+ FROM_DEFAULT_V4_UCHAR(tui.icon_object_data);
+ FROM_DEFAULT_V4_UCHAR(tui.icon_modifier);
+ FROM_DEFAULT_V4_UCHAR(tui.icon_shading);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 27)) {
+ FROM_DEFAULT_V4_UCHAR(space_action.shade2);
+ FROM_DEFAULT_V4_UCHAR(space_action.hilite);
+ FROM_DEFAULT_V4_UCHAR(space_action.group);
+ FROM_DEFAULT_V4_UCHAR(space_action.group_active);
+ FROM_DEFAULT_V4_UCHAR(space_action.strip_select);
+ FROM_DEFAULT_V4_UCHAR(space_action.ds_channel);
+ FROM_DEFAULT_V4_UCHAR(space_action.ds_subchannel);
+ FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold);
+ FROM_DEFAULT_V4_UCHAR(space_action.keytype_movehold_select);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 28)) {
+ FROM_DEFAULT_V4_UCHAR(space_action.ds_ipoline);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 29)) {
+ FROM_DEFAULT_V4_UCHAR(space_properties.navigation_bar);
+ }
+ if (!USER_VERSION_ATLEAST(280, 31)) {
+ FROM_DEFAULT_V4_UCHAR(space_clip.list_text);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 36)) {
+ FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed);
+ FROM_DEFAULT_V4_UCHAR(tui.wcol_state.inner_changed_sel);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 39)) {
+ FROM_DEFAULT_V4_UCHAR(space_clip.metadatabg);
+ FROM_DEFAULT_V4_UCHAR(space_clip.metadatatext);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 40)) {
+ FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar);
+ copy_v4_v4_char(btheme->space_preferences.execution_buts,
+ btheme->space_preferences.navigation_bar);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 41)) {
+ FROM_DEFAULT_V4_UCHAR(space_view3d.back);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 52)) {
+ FROM_DEFAULT_V4_UCHAR(space_info.info_info);
+ }
#undef FROM_DEFAULT_V4_UCHAR
@@ -120,26 +119,35 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
}
/* UserDef.flag */
-#define USER_LMOUSESELECT (1 << 14) /* deprecated */
+#define USER_LMOUSESELECT (1 << 14) /* deprecated */
static void do_version_select_mouse(UserDef *userdef, wmKeyMapItem *kmi)
{
- /* Remove select/action mouse from user defined keymaps. */
- enum {
- ACTIONMOUSE = 0x0005,
- SELECTMOUSE = 0x0006,
- EVT_TWEAK_A = 0x5005,
- EVT_TWEAK_S = 0x5006,
- };
- const bool left = (userdef->flag & USER_LMOUSESELECT) != 0;
-
- switch (kmi->type) {
- case SELECTMOUSE: kmi->type = (left) ? LEFTMOUSE : RIGHTMOUSE; break;
- case ACTIONMOUSE: kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE; break;
- case EVT_TWEAK_S: kmi->type = (left) ? EVT_TWEAK_L : EVT_TWEAK_R; break;
- case EVT_TWEAK_A: kmi->type = (left) ? EVT_TWEAK_R : EVT_TWEAK_L; break;
- default: break;
- }
+ /* Remove select/action mouse from user defined keymaps. */
+ enum {
+ ACTIONMOUSE = 0x0005,
+ SELECTMOUSE = 0x0006,
+ EVT_TWEAK_A = 0x5005,
+ EVT_TWEAK_S = 0x5006,
+ };
+ const bool left = (userdef->flag & USER_LMOUSESELECT) != 0;
+
+ switch (kmi->type) {
+ case SELECTMOUSE:
+ kmi->type = (left) ? LEFTMOUSE : RIGHTMOUSE;
+ break;
+ case ACTIONMOUSE:
+ kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE;
+ break;
+ case EVT_TWEAK_S:
+ kmi->type = (left) ? EVT_TWEAK_L : EVT_TWEAK_R;
+ break;
+ case EVT_TWEAK_A:
+ kmi->type = (left) ? EVT_TWEAK_R : EVT_TWEAK_L;
+ break;
+ default:
+ break;
+ }
}
/* patching UserDef struct and Themes */
@@ -148,365 +156,358 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
- /* the UserDef struct is not corrected with do_versions() .... ugh! */
- if (userdef->wheellinescroll == 0) userdef->wheellinescroll = 3;
- if (userdef->menuthreshold1 == 0) {
- userdef->menuthreshold1 = 5;
- userdef->menuthreshold2 = 2;
- }
- if (userdef->mixbufsize == 0) userdef->mixbufsize = 2048;
- if (userdef->autokey_mode == 0) {
- /* 'add/replace' but not on */
- userdef->autokey_mode = 2;
- }
- if (userdef->savetime <= 0) {
- userdef->savetime = 1;
-// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
- }
- if (userdef->gizmo_size == 0) {
- userdef->gizmo_size = 75;
- userdef->gizmo_flag |= USER_GIZMO_DRAW;
- }
- if (userdef->pad_rot_angle == 0.0f)
- userdef->pad_rot_angle = 15.0f;
-
- /* graph editor - unselected F-Curve visibility */
- if (userdef->fcu_inactive_alpha == 0) {
- userdef->fcu_inactive_alpha = 0.25f;
- }
-
- if (!USER_VERSION_ATLEAST(192, 0)) {
- strcpy(userdef->sounddir, "/");
- }
-
- /* patch to set Dupli Armature */
- if (!USER_VERSION_ATLEAST(220, 0)) {
- userdef->dupflag |= USER_DUP_ARM;
- }
-
- /* added seam, normal color, undo */
- if (!USER_VERSION_ATLEAST(235, 0)) {
- userdef->uiflag |= USER_GLOBALUNDO;
- if (userdef->undosteps == 0) userdef->undosteps = 32;
- }
- if (!USER_VERSION_ATLEAST(236, 0)) {
- /* illegal combo... */
- if (userdef->flag & USER_LMOUSESELECT)
- userdef->flag &= ~USER_TWOBUTTONMOUSE;
- }
- if (!USER_VERSION_ATLEAST(240, 0)) {
- userdef->uiflag |= USER_PLAINMENUS;
- if (userdef->obcenter_dia == 0) userdef->obcenter_dia = 6;
- }
- if (!USER_VERSION_ATLEAST(242, 0)) {
- /* set defaults for 3D View rotating axis indicator */
- /* since size can't be set to 0, this indicates it's not saved in startup.blend */
- if (userdef->rvisize == 0) {
- userdef->rvisize = 15;
- userdef->rvibright = 8;
- userdef->uiflag |= USER_SHOW_GIZMO_AXIS;
- }
-
- }
- if (!USER_VERSION_ATLEAST(244, 0)) {
- /* set default number of recently-used files (if not set) */
- if (userdef->recent_files == 0) userdef->recent_files = 10;
- }
- if (!USER_VERSION_ATLEAST(245, 3)) {
- if (userdef->coba_weight.tot == 0)
- BKE_colorband_init(&userdef->coba_weight, true);
- }
- if (!USER_VERSION_ATLEAST(245, 3)) {
- userdef->flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
- }
- if (!USER_VERSION_ATLEAST(250, 0)) {
- /* adjust grease-pencil distances */
- userdef->gp_manhattendist = 1;
- userdef->gp_euclideandist = 2;
-
- /* adjust default interpolation for new IPO-curves */
- userdef->ipo_new = BEZT_IPO_BEZ;
- }
-
- if (!USER_VERSION_ATLEAST(250, 3)) {
- /* new audio system */
- if (userdef->audiochannels == 0)
- userdef->audiochannels = 2;
- if (userdef->audioformat == 0)
- userdef->audioformat = 0x24;
- if (userdef->audiorate == 0)
- userdef->audiorate = 48000;
- }
-
- if (!USER_VERSION_ATLEAST(250, 8)) {
- wmKeyMap *km;
-
- for (km = userdef->user_keymaps.first; km; km = km->next) {
- if (STREQ(km->idname, "Armature_Sketch"))
- strcpy(km->idname, "Armature Sketch");
- else if (STREQ(km->idname, "View3D"))
- strcpy(km->idname, "3D View");
- else if (STREQ(km->idname, "View3D Generic"))
- strcpy(km->idname, "3D View Generic");
- else if (STREQ(km->idname, "EditMesh"))
- strcpy(km->idname, "Mesh");
- else if (STREQ(km->idname, "UVEdit"))
- strcpy(km->idname, "UV Editor");
- else if (STREQ(km->idname, "Animation_Channels"))
- strcpy(km->idname, "Animation Channels");
- else if (STREQ(km->idname, "GraphEdit Keys"))
- strcpy(km->idname, "Graph Editor");
- else if (STREQ(km->idname, "GraphEdit Generic"))
- strcpy(km->idname, "Graph Editor Generic");
- else if (STREQ(km->idname, "Action_Keys"))
- strcpy(km->idname, "Dopesheet");
- else if (STREQ(km->idname, "NLA Data"))
- strcpy(km->idname, "NLA Editor");
- else if (STREQ(km->idname, "Node Generic"))
- strcpy(km->idname, "Node Editor");
- else if (STREQ(km->idname, "Logic Generic"))
- strcpy(km->idname, "Logic Editor");
- else if (STREQ(km->idname, "File"))
- strcpy(km->idname, "File Browser");
- else if (STREQ(km->idname, "FileMain"))
- strcpy(km->idname, "File Browser Main");
- else if (STREQ(km->idname, "FileButtons"))
- strcpy(km->idname, "File Browser Buttons");
- else if (STREQ(km->idname, "Buttons Generic"))
- strcpy(km->idname, "Property Editor");
- }
- }
-
- if (!USER_VERSION_ATLEAST(252, 3)) {
- if (userdef->flag & USER_LMOUSESELECT)
- userdef->flag &= ~USER_TWOBUTTONMOUSE;
- }
- if (!USER_VERSION_ATLEAST(252, 4)) {
- /* default new handle type is auto handles */
- userdef->keyhandles_new = HD_AUTO;
- }
-
- if (!USER_VERSION_ATLEAST(257, 0)) {
- /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs,
- * so that it doesn't linger around from old configs like a ghost */
- userdef->autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
- }
-
- if (!USER_VERSION_ATLEAST(260, 3)) {
- /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
- * was changed in 260 as part of GSoC11, but version patch was wrong
- */
- if (userdef->keyhandles_new == HD_AUTO)
- userdef->keyhandles_new = HD_AUTO_ANIM;
-
- /* enable (Cycles) addon by default */
- BKE_addon_ensure(&userdef->addons, "cycles");
- }
-
- if (!USER_VERSION_ATLEAST(267, 0)) {
-
- /* GL Texture Garbage Collection */
- if (userdef->textimeout == 0) {
- userdef->texcollectrate = 60;
- userdef->textimeout = 120;
- }
- if (userdef->memcachelimit <= 0) {
- userdef->memcachelimit = 32;
- }
- if (userdef->dbl_click_time == 0) {
- userdef->dbl_click_time = 350;
- }
- if (userdef->v2d_min_gridsize == 0) {
- userdef->v2d_min_gridsize = 35;
- }
- if (userdef->widget_unit == 0)
- userdef->widget_unit = 20;
- if (userdef->anisotropic_filter <= 0)
- userdef->anisotropic_filter = 1;
-
- if (userdef->ndof_sensitivity == 0.0f) {
- userdef->ndof_sensitivity = 1.0f;
- userdef->ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE);
- }
-
- if (userdef->ndof_orbit_sensitivity == 0.0f) {
- userdef->ndof_orbit_sensitivity = userdef->ndof_sensitivity;
-
- if (!(userdef->flag & USER_TRACKBALL))
- userdef->ndof_flag |= NDOF_TURNTABLE;
- }
- if (userdef->tweak_threshold == 0)
- userdef->tweak_threshold = 10;
- }
-
- /* NOTE!! from now on use userdef->versionfile and userdef->subversionfile */
+ /* the UserDef struct is not corrected with do_versions() .... ugh! */
+ if (userdef->wheellinescroll == 0)
+ userdef->wheellinescroll = 3;
+ if (userdef->menuthreshold1 == 0) {
+ userdef->menuthreshold1 = 5;
+ userdef->menuthreshold2 = 2;
+ }
+ if (userdef->mixbufsize == 0)
+ userdef->mixbufsize = 2048;
+ if (userdef->autokey_mode == 0) {
+ /* 'add/replace' but not on */
+ userdef->autokey_mode = 2;
+ }
+ if (userdef->savetime <= 0) {
+ userdef->savetime = 1;
+ // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
+ }
+ if (userdef->gizmo_size == 0) {
+ userdef->gizmo_size = 75;
+ userdef->gizmo_flag |= USER_GIZMO_DRAW;
+ }
+ if (userdef->pad_rot_angle == 0.0f)
+ userdef->pad_rot_angle = 15.0f;
+
+ /* graph editor - unselected F-Curve visibility */
+ if (userdef->fcu_inactive_alpha == 0) {
+ userdef->fcu_inactive_alpha = 0.25f;
+ }
+
+ if (!USER_VERSION_ATLEAST(192, 0)) {
+ strcpy(userdef->sounddir, "/");
+ }
+
+ /* patch to set Dupli Armature */
+ if (!USER_VERSION_ATLEAST(220, 0)) {
+ userdef->dupflag |= USER_DUP_ARM;
+ }
+
+ /* added seam, normal color, undo */
+ if (!USER_VERSION_ATLEAST(235, 0)) {
+ userdef->uiflag |= USER_GLOBALUNDO;
+ if (userdef->undosteps == 0)
+ userdef->undosteps = 32;
+ }
+ if (!USER_VERSION_ATLEAST(236, 0)) {
+ /* illegal combo... */
+ if (userdef->flag & USER_LMOUSESELECT)
+ userdef->flag &= ~USER_TWOBUTTONMOUSE;
+ }
+ if (!USER_VERSION_ATLEAST(240, 0)) {
+ userdef->uiflag |= USER_PLAINMENUS;
+ if (userdef->obcenter_dia == 0)
+ userdef->obcenter_dia = 6;
+ }
+ if (!USER_VERSION_ATLEAST(242, 0)) {
+ /* set defaults for 3D View rotating axis indicator */
+ /* since size can't be set to 0, this indicates it's not saved in startup.blend */
+ if (userdef->rvisize == 0) {
+ userdef->rvisize = 15;
+ userdef->rvibright = 8;
+ userdef->uiflag |= USER_SHOW_GIZMO_AXIS;
+ }
+ }
+ if (!USER_VERSION_ATLEAST(244, 0)) {
+ /* set default number of recently-used files (if not set) */
+ if (userdef->recent_files == 0)
+ userdef->recent_files = 10;
+ }
+ if (!USER_VERSION_ATLEAST(245, 3)) {
+ if (userdef->coba_weight.tot == 0)
+ BKE_colorband_init(&userdef->coba_weight, true);
+ }
+ if (!USER_VERSION_ATLEAST(245, 3)) {
+ userdef->flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
+ }
+ if (!USER_VERSION_ATLEAST(250, 0)) {
+ /* adjust grease-pencil distances */
+ userdef->gp_manhattendist = 1;
+ userdef->gp_euclideandist = 2;
+
+ /* adjust default interpolation for new IPO-curves */
+ userdef->ipo_new = BEZT_IPO_BEZ;
+ }
+
+ if (!USER_VERSION_ATLEAST(250, 3)) {
+ /* new audio system */
+ if (userdef->audiochannels == 0)
+ userdef->audiochannels = 2;
+ if (userdef->audioformat == 0)
+ userdef->audioformat = 0x24;
+ if (userdef->audiorate == 0)
+ userdef->audiorate = 48000;
+ }
+
+ if (!USER_VERSION_ATLEAST(250, 8)) {
+ wmKeyMap *km;
+
+ for (km = userdef->user_keymaps.first; km; km = km->next) {
+ if (STREQ(km->idname, "Armature_Sketch"))
+ strcpy(km->idname, "Armature Sketch");
+ else if (STREQ(km->idname, "View3D"))
+ strcpy(km->idname, "3D View");
+ else if (STREQ(km->idname, "View3D Generic"))
+ strcpy(km->idname, "3D View Generic");
+ else if (STREQ(km->idname, "EditMesh"))
+ strcpy(km->idname, "Mesh");
+ else if (STREQ(km->idname, "UVEdit"))
+ strcpy(km->idname, "UV Editor");
+ else if (STREQ(km->idname, "Animation_Channels"))
+ strcpy(km->idname, "Animation Channels");
+ else if (STREQ(km->idname, "GraphEdit Keys"))
+ strcpy(km->idname, "Graph Editor");
+ else if (STREQ(km->idname, "GraphEdit Generic"))
+ strcpy(km->idname, "Graph Editor Generic");
+ else if (STREQ(km->idname, "Action_Keys"))
+ strcpy(km->idname, "Dopesheet");
+ else if (STREQ(km->idname, "NLA Data"))
+ strcpy(km->idname, "NLA Editor");
+ else if (STREQ(km->idname, "Node Generic"))
+ strcpy(km->idname, "Node Editor");
+ else if (STREQ(km->idname, "Logic Generic"))
+ strcpy(km->idname, "Logic Editor");
+ else if (STREQ(km->idname, "File"))
+ strcpy(km->idname, "File Browser");
+ else if (STREQ(km->idname, "FileMain"))
+ strcpy(km->idname, "File Browser Main");
+ else if (STREQ(km->idname, "FileButtons"))
+ strcpy(km->idname, "File Browser Buttons");
+ else if (STREQ(km->idname, "Buttons Generic"))
+ strcpy(km->idname, "Property Editor");
+ }
+ }
+
+ if (!USER_VERSION_ATLEAST(252, 3)) {
+ if (userdef->flag & USER_LMOUSESELECT)
+ userdef->flag &= ~USER_TWOBUTTONMOUSE;
+ }
+ if (!USER_VERSION_ATLEAST(252, 4)) {
+ /* default new handle type is auto handles */
+ userdef->keyhandles_new = HD_AUTO;
+ }
+
+ if (!USER_VERSION_ATLEAST(257, 0)) {
+ /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs,
+ * so that it doesn't linger around from old configs like a ghost */
+ userdef->autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
+ }
+
+ if (!USER_VERSION_ATLEAST(260, 3)) {
+ /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
+ * was changed in 260 as part of GSoC11, but version patch was wrong
+ */
+ if (userdef->keyhandles_new == HD_AUTO)
+ userdef->keyhandles_new = HD_AUTO_ANIM;
+
+ /* enable (Cycles) addon by default */
+ BKE_addon_ensure(&userdef->addons, "cycles");
+ }
+
+ if (!USER_VERSION_ATLEAST(267, 0)) {
+
+ /* GL Texture Garbage Collection */
+ if (userdef->textimeout == 0) {
+ userdef->texcollectrate = 60;
+ userdef->textimeout = 120;
+ }
+ if (userdef->memcachelimit <= 0) {
+ userdef->memcachelimit = 32;
+ }
+ if (userdef->dbl_click_time == 0) {
+ userdef->dbl_click_time = 350;
+ }
+ if (userdef->v2d_min_gridsize == 0) {
+ userdef->v2d_min_gridsize = 35;
+ }
+ if (userdef->widget_unit == 0)
+ userdef->widget_unit = 20;
+ if (userdef->anisotropic_filter <= 0)
+ userdef->anisotropic_filter = 1;
+
+ if (userdef->ndof_sensitivity == 0.0f) {
+ userdef->ndof_sensitivity = 1.0f;
+ userdef->ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM |
+ NDOF_SHOULD_ROTATE);
+ }
+
+ if (userdef->ndof_orbit_sensitivity == 0.0f) {
+ userdef->ndof_orbit_sensitivity = userdef->ndof_sensitivity;
+
+ if (!(userdef->flag & USER_TRACKBALL))
+ userdef->ndof_flag |= NDOF_TURNTABLE;
+ }
+ if (userdef->tweak_threshold == 0)
+ userdef->tweak_threshold = 10;
+ }
+
+ /* NOTE!! from now on use userdef->versionfile and userdef->subversionfile */
#undef USER_VERSION_ATLEAST
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver)
- if (!USER_VERSION_ATLEAST(271, 5)) {
- userdef->pie_menu_radius = 100;
- userdef->pie_menu_threshold = 12;
- userdef->pie_animation_timeout = 6;
- }
-
- if (!USER_VERSION_ATLEAST(275, 2)) {
- userdef->ndof_deadzone = 0.1;
- }
-
- if (!USER_VERSION_ATLEAST(275, 4)) {
- userdef->node_margin = 80;
- }
-
- if (!USER_VERSION_ATLEAST(278, 6)) {
- /* Clear preference flags for re-use. */
- userdef->flag &= ~(
- USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_UNUSED_2 | USER_FLAG_UNUSED_3 |
- USER_FLAG_UNUSED_6 | USER_FLAG_UNUSED_7 |
- USER_FLAG_UNUSED_9 | USER_DEVELOPER_UI);
- userdef->uiflag &= ~(
- USER_HEADER_BOTTOM);
- userdef->transopts &= ~(
- USER_TR_UNUSED_2 | USER_TR_UNUSED_3 | USER_TR_UNUSED_4 |
- USER_TR_UNUSED_6 | USER_TR_UNUSED_7);
-
- userdef->uiflag |= USER_LOCK_CURSOR_ADJUST;
- }
-
-
- if (!USER_VERSION_ATLEAST(280, 20)) {
- userdef->gpu_viewport_quality = 0.6f;
-
- /* Reset theme, old themes will not be compatible with minor version updates from now on. */
- for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
- memcpy(btheme, &U_theme_default, sizeof(*btheme));
- }
-
- /* Annotations - new layer color
- * Replace anything that used to be set if it looks like was left
- * on the old default (i.e. black), which most users used
- */
- if ((userdef->gpencil_new_layer_col[3] < 0.1f) || (userdef->gpencil_new_layer_col[0] < 0.1f)) {
- /* - New color matches the annotation pencil icon
- * - Non-full alpha looks better!
- */
- ARRAY_SET_ITEMS(userdef->gpencil_new_layer_col, 0.38f, 0.61f, 0.78f, 0.9f);
- }
- }
-
- if (!USER_VERSION_ATLEAST(280, 31)) {
- /* Remove select/action mouse from user defined keymaps. */
- for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
- for (wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
- if (kmdi->remove_item) {
- do_version_select_mouse(userdef, kmdi->remove_item);
- }
- if (kmdi->add_item) {
- do_version_select_mouse(userdef, kmdi->add_item);
- }
- }
-
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
- do_version_select_mouse(userdef, kmi);
- }
- }
- }
-
- if (!USER_VERSION_ATLEAST(280, 33)) {
- /* Enable GLTF addon by default. */
- BKE_addon_ensure(&userdef->addons, "io_scene_gltf2");
- }
-
- if (!USER_VERSION_ATLEAST(280, 35)) {
- /* Preserve RMB select setting after moving to Python and changing default value. */
- if (USER_VERSION_ATLEAST(280, 32) || !(userdef->flag & USER_LMOUSESELECT)) {
- BKE_keyconfig_pref_set_select_mouse(userdef, 1, false);
- }
-
- userdef->flag &= ~USER_LMOUSESELECT;
- }
-
- if (!USER_VERSION_ATLEAST(280, 38)) {
-
- /* (keep this block even if it becomes empty). */
- copy_v4_fl4(userdef->light_param[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
- copy_v4_fl4(userdef->light_param[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
- copy_v4_fl4(userdef->light_param[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
- userdef->light_param[0].flag = 1;
- userdef->light_param[0].smooth = 0.1;
-
- copy_v4_fl4(userdef->light_param[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
- copy_v4_fl4(userdef->light_param[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
- copy_v4_fl4(userdef->light_param[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
- userdef->light_param[1].flag = 1;
- userdef->light_param[1].smooth = 0.25;
-
- copy_v4_fl4(userdef->light_param[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
- copy_v4_fl4(userdef->light_param[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
- copy_v4_fl4(userdef->light_param[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
- userdef->light_param[2].flag = 1;
- userdef->light_param[2].smooth = 0.4;
-
- copy_v4_fl4(userdef->light_param[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
- copy_v4_fl4(userdef->light_param[3].col, 0.0, 0.0, 0.0, 1.0);
- copy_v4_fl4(userdef->light_param[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
- userdef->light_param[3].flag = 1;
- userdef->light_param[3].smooth = 0.7;
-
- copy_v3_fl3(userdef->light_ambient, 0.025000, 0.025000, 0.025000);
-
- userdef->flag &= ~(
- USER_FLAG_UNUSED_4);
-
- userdef->uiflag &= ~(
- USER_HEADER_FROM_PREF |
- USER_UIFLAG_UNUSED_12 |
- USER_UIFLAG_UNUSED_22);
- }
-
- if (!USER_VERSION_ATLEAST(280, 41)) {
- /* (keep this block even if it becomes empty). */
-
- if (userdef->pie_tap_timeout == 0) {
- userdef->pie_tap_timeout = 20;
- }
- }
-
- if (!USER_VERSION_ATLEAST(280, 44)) {
- userdef->uiflag &= ~(
- USER_UIFLAG_UNUSED_0 | USER_UIFLAG_UNUSED_1);
- userdef->uiflag2 &= ~(
- USER_UIFLAG2_UNUSED_0);
- userdef->gp_settings &= ~(
- GP_PAINT_UNUSED_0);
- }
-
- if (!USER_VERSION_ATLEAST(280, 50)) {
- /* 3ds is no longer enabled by default and not ported yet. */
- BKE_addon_remove_safe(&userdef->addons, "io_scene_3ds");
- }
-
- if (!USER_VERSION_ATLEAST(280, 51)) {
- userdef->move_threshold = 2;
- }
-
- /**
- * Include next version bump.
- */
- {
- /* (keep this block even if it becomes empty). */
- }
-
- if (userdef->pixelsize == 0.0f)
- userdef->pixelsize = 1.0f;
-
- if (userdef->image_draw_method == 0)
- userdef->image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
-
- for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
- do_versions_theme(userdef, btheme);
- }
+ if (!USER_VERSION_ATLEAST(271, 5)) {
+ userdef->pie_menu_radius = 100;
+ userdef->pie_menu_threshold = 12;
+ userdef->pie_animation_timeout = 6;
+ }
+
+ if (!USER_VERSION_ATLEAST(275, 2)) {
+ userdef->ndof_deadzone = 0.1;
+ }
+
+ if (!USER_VERSION_ATLEAST(275, 4)) {
+ userdef->node_margin = 80;
+ }
+
+ if (!USER_VERSION_ATLEAST(278, 6)) {
+ /* Clear preference flags for re-use. */
+ userdef->flag &= ~(USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_UNUSED_2 | USER_FLAG_UNUSED_3 |
+ USER_FLAG_UNUSED_6 | USER_FLAG_UNUSED_7 | USER_FLAG_UNUSED_9 |
+ USER_DEVELOPER_UI);
+ userdef->uiflag &= ~(USER_HEADER_BOTTOM);
+ userdef->transopts &= ~(USER_TR_UNUSED_2 | USER_TR_UNUSED_3 | USER_TR_UNUSED_4 |
+ USER_TR_UNUSED_6 | USER_TR_UNUSED_7);
+
+ userdef->uiflag |= USER_LOCK_CURSOR_ADJUST;
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 20)) {
+ userdef->gpu_viewport_quality = 0.6f;
+
+ /* Reset theme, old themes will not be compatible with minor version updates from now on. */
+ for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ memcpy(btheme, &U_theme_default, sizeof(*btheme));
+ }
+
+ /* Annotations - new layer color
+ * Replace anything that used to be set if it looks like was left
+ * on the old default (i.e. black), which most users used
+ */
+ if ((userdef->gpencil_new_layer_col[3] < 0.1f) || (userdef->gpencil_new_layer_col[0] < 0.1f)) {
+ /* - New color matches the annotation pencil icon
+ * - Non-full alpha looks better!
+ */
+ ARRAY_SET_ITEMS(userdef->gpencil_new_layer_col, 0.38f, 0.61f, 0.78f, 0.9f);
+ }
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 31)) {
+ /* Remove select/action mouse from user defined keymaps. */
+ for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
+ for (wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ if (kmdi->remove_item) {
+ do_version_select_mouse(userdef, kmdi->remove_item);
+ }
+ if (kmdi->add_item) {
+ do_version_select_mouse(userdef, kmdi->add_item);
+ }
+ }
+
+ for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ do_version_select_mouse(userdef, kmi);
+ }
+ }
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 33)) {
+ /* Enable GLTF addon by default. */
+ BKE_addon_ensure(&userdef->addons, "io_scene_gltf2");
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 35)) {
+ /* Preserve RMB select setting after moving to Python and changing default value. */
+ if (USER_VERSION_ATLEAST(280, 32) || !(userdef->flag & USER_LMOUSESELECT)) {
+ BKE_keyconfig_pref_set_select_mouse(userdef, 1, false);
+ }
+
+ userdef->flag &= ~USER_LMOUSESELECT;
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 38)) {
+
+ /* (keep this block even if it becomes empty). */
+ copy_v4_fl4(userdef->light_param[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
+ copy_v4_fl4(userdef->light_param[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
+ copy_v4_fl4(userdef->light_param[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
+ userdef->light_param[0].flag = 1;
+ userdef->light_param[0].smooth = 0.1;
+
+ copy_v4_fl4(userdef->light_param[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
+ copy_v4_fl4(userdef->light_param[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
+ copy_v4_fl4(userdef->light_param[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
+ userdef->light_param[1].flag = 1;
+ userdef->light_param[1].smooth = 0.25;
+
+ copy_v4_fl4(userdef->light_param[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
+ copy_v4_fl4(userdef->light_param[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
+ copy_v4_fl4(userdef->light_param[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
+ userdef->light_param[2].flag = 1;
+ userdef->light_param[2].smooth = 0.4;
+
+ copy_v4_fl4(userdef->light_param[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
+ copy_v4_fl4(userdef->light_param[3].col, 0.0, 0.0, 0.0, 1.0);
+ copy_v4_fl4(userdef->light_param[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
+ userdef->light_param[3].flag = 1;
+ userdef->light_param[3].smooth = 0.7;
+
+ copy_v3_fl3(userdef->light_ambient, 0.025000, 0.025000, 0.025000);
+
+ userdef->flag &= ~(USER_FLAG_UNUSED_4);
+
+ userdef->uiflag &= ~(USER_HEADER_FROM_PREF | USER_UIFLAG_UNUSED_12 | USER_UIFLAG_UNUSED_22);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 41)) {
+ /* (keep this block even if it becomes empty). */
+
+ if (userdef->pie_tap_timeout == 0) {
+ userdef->pie_tap_timeout = 20;
+ }
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 44)) {
+ userdef->uiflag &= ~(USER_UIFLAG_UNUSED_0 | USER_UIFLAG_UNUSED_1);
+ userdef->uiflag2 &= ~(USER_UIFLAG2_UNUSED_0);
+ userdef->gp_settings &= ~(GP_PAINT_UNUSED_0);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 50)) {
+ /* 3ds is no longer enabled by default and not ported yet. */
+ BKE_addon_remove_safe(&userdef->addons, "io_scene_3ds");
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 51)) {
+ userdef->move_threshold = 2;
+ }
+
+ /**
+ * Include next version bump.
+ */
+ {
+ /* (keep this block even if it becomes empty). */
+ }
+
+ if (userdef->pixelsize == 0.0f)
+ userdef->pixelsize = 1.0f;
+
+ if (userdef->image_draw_method == 0)
+ userdef->image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
+
+ for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ do_versions_theme(userdef, btheme);
+ }
#undef USER_VERSION_ATLEAST
-
}
#undef USER_LMOUSESELECT
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e0746c7c3dd..79cd7678f90 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -21,7 +21,6 @@
* \ingroup blenloader
*/
-
/**
*
* FILE FORMAT
@@ -72,7 +71,6 @@
* - write #USER (#UserDef struct) if filename is ``~/.config/blender/X.XX/config/startup.blend``.
*/
-
#include <math.h>
#include <fcntl.h>
#include <limits.h>
@@ -81,12 +79,12 @@
#include <stdlib.h>
#ifdef WIN32
-# include <zlib.h> /* odd include order-issue */
+# include <zlib.h> /* odd include order-issue */
# include "winsock2.h"
# include <io.h>
# include "BLI_winstuff.h"
#else
-# include <unistd.h> /* FreeBSD, for write() and close(). */
+# include <unistd.h> /* FreeBSD, for write() and close(). */
#endif
#include "BLI_utildefines.h"
@@ -141,7 +139,7 @@
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
-#include "MEM_guardedalloc.h" // MEM_freeN
+#include "MEM_guardedalloc.h" // MEM_freeN
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_mempool.h"
@@ -153,7 +151,7 @@
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
-#include "BKE_global.h" // for G
+#include "BKE_global.h" // for G
#include "BKE_gpencil_modifier.h"
#include "BKE_idcode.h"
#include "BKE_layer.h"
@@ -170,10 +168,9 @@
#include "BKE_workspace.h"
#ifdef USE_NODE_COMPAT_CUSTOMNODES
-#include "NOD_socket.h" /* for sock->default_value data */
+# include "NOD_socket.h" /* for sock->default_value data */
#endif
-
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_readfile.h"
@@ -190,8 +187,8 @@
/* ********* my write, buffered writing with minimum size chunks ************ */
/* Use optimal allocation since blocks of this size are kept in memory for undo. */
-#define MYWRITE_BUFFER_SIZE (MEM_SIZE_OPTIMAL(1 << 17)) /* 128kb */
-#define MYWRITE_MAX_CHUNK (MEM_SIZE_OPTIMAL(1 << 15)) /* ~32kb */
+#define MYWRITE_BUFFER_SIZE (MEM_SIZE_OPTIMAL(1 << 17)) /* 128kb */
+#define MYWRITE_MAX_CHUNK (MEM_SIZE_OPTIMAL(1 << 15)) /* ~32kb */
/** Use if we want to store how many bytes have been written to the file. */
// #define USE_WRITE_DATA_LEN
@@ -201,80 +198,78 @@
* \{ */
typedef enum {
- WW_WRAP_NONE = 1,
- WW_WRAP_ZLIB,
+ WW_WRAP_NONE = 1,
+ WW_WRAP_ZLIB,
} eWriteWrapType;
typedef struct WriteWrap WriteWrap;
struct WriteWrap {
- /* callbacks */
- bool (*open)(WriteWrap *ww, const char *filepath);
- bool (*close)(WriteWrap *ww);
- size_t (*write)(WriteWrap *ww, const char *data, size_t data_len);
-
- /* Buffer output (we only want when output isn't already buffered). */
- bool use_buf;
-
- /* internal */
- union {
- int file_handle;
- gzFile gz_handle;
- } _user_data;
+ /* callbacks */
+ bool (*open)(WriteWrap *ww, const char *filepath);
+ bool (*close)(WriteWrap *ww);
+ size_t (*write)(WriteWrap *ww, const char *data, size_t data_len);
+
+ /* Buffer output (we only want when output isn't already buffered). */
+ bool use_buf;
+
+ /* internal */
+ union {
+ int file_handle;
+ gzFile gz_handle;
+ } _user_data;
};
/* none */
-#define FILE_HANDLE(ww) \
- (ww)->_user_data.file_handle
+#define FILE_HANDLE(ww) (ww)->_user_data.file_handle
static bool ww_open_none(WriteWrap *ww, const char *filepath)
{
- int file;
+ int file;
- file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
+ file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
- if (file != -1) {
- FILE_HANDLE(ww) = file;
- return true;
- }
- else {
- return false;
- }
+ if (file != -1) {
+ FILE_HANDLE(ww) = file;
+ return true;
+ }
+ else {
+ return false;
+ }
}
static bool ww_close_none(WriteWrap *ww)
{
- return (close(FILE_HANDLE(ww)) != -1);
+ return (close(FILE_HANDLE(ww)) != -1);
}
static size_t ww_write_none(WriteWrap *ww, const char *buf, size_t buf_len)
{
- return write(FILE_HANDLE(ww), buf, buf_len);
+ return write(FILE_HANDLE(ww), buf, buf_len);
}
#undef FILE_HANDLE
/* zlib */
-#define FILE_HANDLE(ww) \
- (ww)->_user_data.gz_handle
+#define FILE_HANDLE(ww) (ww)->_user_data.gz_handle
static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
{
- gzFile file;
+ gzFile file;
- file = BLI_gzopen(filepath, "wb1");
+ file = BLI_gzopen(filepath, "wb1");
- if (file != Z_NULL) {
- FILE_HANDLE(ww) = file;
- return true;
- }
- else {
- return false;
- }
+ if (file != Z_NULL) {
+ FILE_HANDLE(ww) = file;
+ return true;
+ }
+ else {
+ return false;
+ }
}
static bool ww_close_zlib(WriteWrap *ww)
{
- return (gzclose(FILE_HANDLE(ww)) == Z_OK);
+ return (gzclose(FILE_HANDLE(ww)) == Z_OK);
}
static size_t ww_write_zlib(WriteWrap *ww, const char *buf, size_t buf_len)
{
- return gzwrite(FILE_HANDLE(ww), buf, buf_len);
+ return gzwrite(FILE_HANDLE(ww), buf, buf_len);
}
#undef FILE_HANDLE
@@ -282,26 +277,24 @@ static size_t ww_write_zlib(WriteWrap *ww, const char *buf, size_t buf_len)
static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
{
- memset(r_ww, 0, sizeof(*r_ww));
-
- switch (ww_type) {
- case WW_WRAP_ZLIB:
- {
- r_ww->open = ww_open_zlib;
- r_ww->close = ww_close_zlib;
- r_ww->write = ww_write_zlib;
- r_ww->use_buf = false;
- break;
- }
- default:
- {
- r_ww->open = ww_open_none;
- r_ww->close = ww_close_none;
- r_ww->write = ww_write_none;
- r_ww->use_buf = true;
- break;
- }
- }
+ memset(r_ww, 0, sizeof(*r_ww));
+
+ switch (ww_type) {
+ case WW_WRAP_ZLIB: {
+ r_ww->open = ww_open_zlib;
+ r_ww->close = ww_close_zlib;
+ r_ww->write = ww_write_zlib;
+ r_ww->use_buf = false;
+ break;
+ }
+ default: {
+ r_ww->open = ww_open_none;
+ r_ww->close = ww_close_none;
+ r_ww->write = ww_write_none;
+ r_ww->use_buf = true;
+ break;
+ }
+ }
}
/** \} */
@@ -311,81 +304,81 @@ static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
* \{ */
typedef struct {
- const struct SDNA *sdna;
+ const struct SDNA *sdna;
- /** Use for file and memory writing (fixed size of #MYWRITE_BUFFER_SIZE). */
- uchar *buf;
- /** Number of bytes used in #WriteData.buf (flushed when exceeded). */
- int buf_used_len;
+ /** Use for file and memory writing (fixed size of #MYWRITE_BUFFER_SIZE). */
+ uchar *buf;
+ /** Number of bytes used in #WriteData.buf (flushed when exceeded). */
+ int buf_used_len;
#ifdef USE_WRITE_DATA_LEN
- /** Total number of bytes written. */
- size_t write_len;
+ /** Total number of bytes written. */
+ size_t write_len;
#endif
- /** Set on unlikely case of an error (ignores further file writing). */
- bool error;
-
- /** #MemFile writing (used for undo). */
- struct {
- MemFile *current;
- MemFile *compare;
- /** Use to de-duplicate chunks when writing. */
- MemFileChunk *compare_chunk;
- } mem;
- /** When true, write to #WriteData.current, could also call 'is_undo'. */
- bool use_memfile;
-
- /**
- * Wrap writing, so we can use zlib or
- * other compression types later, see: G_FILE_COMPRESS
- * Will be NULL for UNDO.
- */
- WriteWrap *ww;
+ /** Set on unlikely case of an error (ignores further file writing). */
+ bool error;
+
+ /** #MemFile writing (used for undo). */
+ struct {
+ MemFile *current;
+ MemFile *compare;
+ /** Use to de-duplicate chunks when writing. */
+ MemFileChunk *compare_chunk;
+ } mem;
+ /** When true, write to #WriteData.current, could also call 'is_undo'. */
+ bool use_memfile;
+
+ /**
+ * Wrap writing, so we can use zlib or
+ * other compression types later, see: G_FILE_COMPRESS
+ * Will be NULL for UNDO.
+ */
+ WriteWrap *ww;
} WriteData;
static WriteData *writedata_new(WriteWrap *ww)
{
- WriteData *wd = MEM_callocN(sizeof(*wd), "writedata");
+ WriteData *wd = MEM_callocN(sizeof(*wd), "writedata");
- wd->sdna = DNA_sdna_current_get();
+ wd->sdna = DNA_sdna_current_get();
- wd->ww = ww;
+ wd->ww = ww;
- if ((ww == NULL) || (ww->use_buf)) {
- wd->buf = MEM_mallocN(MYWRITE_BUFFER_SIZE, "wd->buf");
- }
+ if ((ww == NULL) || (ww->use_buf)) {
+ wd->buf = MEM_mallocN(MYWRITE_BUFFER_SIZE, "wd->buf");
+ }
- return wd;
+ return wd;
}
static void writedata_do_write(WriteData *wd, const void *mem, int memlen)
{
- if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) {
- return;
- }
-
- if (UNLIKELY(wd->error)) {
- return;
- }
-
- /* memory based save */
- if (wd->use_memfile) {
- memfile_chunk_add(wd->mem.current, mem, memlen, &wd->mem.compare_chunk);
- }
- else {
- if (wd->ww->write(wd->ww, mem, memlen) != memlen) {
- wd->error = true;
- }
- }
+ if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) {
+ return;
+ }
+
+ if (UNLIKELY(wd->error)) {
+ return;
+ }
+
+ /* memory based save */
+ if (wd->use_memfile) {
+ memfile_chunk_add(wd->mem.current, mem, memlen, &wd->mem.compare_chunk);
+ }
+ else {
+ if (wd->ww->write(wd->ww, mem, memlen) != memlen) {
+ wd->error = true;
+ }
+ }
}
static void writedata_free(WriteData *wd)
{
- if (wd->buf) {
- MEM_freeN(wd->buf);
- }
- MEM_freeN(wd);
+ if (wd->buf) {
+ MEM_freeN(wd->buf);
+ }
+ MEM_freeN(wd);
}
/** \} */
@@ -400,10 +393,10 @@ static void writedata_free(WriteData *wd)
*/
static void mywrite_flush(WriteData *wd)
{
- if (wd->buf_used_len) {
- writedata_do_write(wd, wd->buf, wd->buf_used_len);
- wd->buf_used_len = 0;
- }
+ if (wd->buf_used_len) {
+ writedata_do_write(wd, wd->buf, wd->buf_used_len);
+ wd->buf_used_len = 0;
+ }
}
/**
@@ -413,51 +406,51 @@ static void mywrite_flush(WriteData *wd)
*/
static void mywrite(WriteData *wd, const void *adr, int len)
{
- if (UNLIKELY(wd->error)) {
- return;
- }
+ if (UNLIKELY(wd->error)) {
+ return;
+ }
- if (UNLIKELY(adr == NULL)) {
- BLI_assert(0);
- return;
- }
+ if (UNLIKELY(adr == NULL)) {
+ BLI_assert(0);
+ return;
+ }
#ifdef USE_WRITE_DATA_LEN
- wd->write_len += len;
+ wd->write_len += len;
#endif
- if (wd->buf == NULL) {
- writedata_do_write(wd, adr, len);
- }
- else {
- /* if we have a single big chunk, write existing data in
- * buffer and write out big chunk in smaller pieces */
- if (len > MYWRITE_MAX_CHUNK) {
- if (wd->buf_used_len) {
- writedata_do_write(wd, wd->buf, wd->buf_used_len);
- wd->buf_used_len = 0;
- }
-
- do {
- int writelen = MIN2(len, MYWRITE_MAX_CHUNK);
- writedata_do_write(wd, adr, writelen);
- adr = (const char *)adr + writelen;
- len -= writelen;
- } while (len > 0);
-
- return;
- }
-
- /* if data would overflow buffer, write out the buffer */
- if (len + wd->buf_used_len > MYWRITE_BUFFER_SIZE - 1) {
- writedata_do_write(wd, wd->buf, wd->buf_used_len);
- wd->buf_used_len = 0;
- }
-
- /* append data at end of buffer */
- memcpy(&wd->buf[wd->buf_used_len], adr, len);
- wd->buf_used_len += len;
- }
+ if (wd->buf == NULL) {
+ writedata_do_write(wd, adr, len);
+ }
+ else {
+ /* if we have a single big chunk, write existing data in
+ * buffer and write out big chunk in smaller pieces */
+ if (len > MYWRITE_MAX_CHUNK) {
+ if (wd->buf_used_len) {
+ writedata_do_write(wd, wd->buf, wd->buf_used_len);
+ wd->buf_used_len = 0;
+ }
+
+ do {
+ int writelen = MIN2(len, MYWRITE_MAX_CHUNK);
+ writedata_do_write(wd, adr, writelen);
+ adr = (const char *)adr + writelen;
+ len -= writelen;
+ } while (len > 0);
+
+ return;
+ }
+
+ /* if data would overflow buffer, write out the buffer */
+ if (len + wd->buf_used_len > MYWRITE_BUFFER_SIZE - 1) {
+ writedata_do_write(wd, wd->buf, wd->buf_used_len);
+ wd->buf_used_len = 0;
+ }
+
+ /* append data at end of buffer */
+ memcpy(&wd->buf[wd->buf_used_len], adr, len);
+ wd->buf_used_len += len;
+ }
}
/**
@@ -469,16 +462,16 @@ static void mywrite(WriteData *wd, const void *adr, int len)
*/
static WriteData *mywrite_begin(WriteWrap *ww, MemFile *compare, MemFile *current)
{
- WriteData *wd = writedata_new(ww);
+ WriteData *wd = writedata_new(ww);
- if (current != NULL) {
- wd->mem.current = current;
- wd->mem.compare = compare;
- wd->mem.compare_chunk = compare ? compare->chunks.first : NULL;
- wd->use_memfile = true;
- }
+ if (current != NULL) {
+ wd->mem.current = current;
+ wd->mem.compare = compare;
+ wd->mem.compare_chunk = compare ? compare->chunks.first : NULL;
+ wd->use_memfile = true;
+ }
- return wd;
+ return wd;
}
/**
@@ -489,15 +482,15 @@ static WriteData *mywrite_begin(WriteWrap *ww, MemFile *compare, MemFile *curren
*/
static bool mywrite_end(WriteData *wd)
{
- if (wd->buf_used_len) {
- writedata_do_write(wd, wd->buf, wd->buf_used_len);
- wd->buf_used_len = 0;
- }
+ if (wd->buf_used_len) {
+ writedata_do_write(wd, wd->buf, wd->buf_used_len);
+ wd->buf_used_len = 0;
+ }
- const bool err = wd->error;
- writedata_free(wd);
+ const bool err = wd->error;
+ writedata_free(wd);
- return err;
+ return err;
}
/** \} */
@@ -507,128 +500,127 @@ static bool mywrite_end(WriteData *wd)
* \{ */
static void writestruct_at_address_nr(
- WriteData *wd, int filecode, const int struct_nr, int nr,
- const void *adr, const void *data)
+ WriteData *wd, int filecode, const int struct_nr, int nr, const void *adr, const void *data)
{
- BHead bh;
- const short *sp;
+ BHead bh;
+ const short *sp;
- BLI_assert(struct_nr > 0 && struct_nr < SDNA_TYPE_MAX);
+ BLI_assert(struct_nr > 0 && struct_nr < SDNA_TYPE_MAX);
- if (adr == NULL || data == NULL || nr == 0) {
- return;
- }
+ if (adr == NULL || data == NULL || nr == 0) {
+ return;
+ }
- /* init BHead */
- bh.code = filecode;
- bh.old = adr;
- bh.nr = nr;
+ /* init BHead */
+ bh.code = filecode;
+ bh.old = adr;
+ bh.nr = nr;
- bh.SDNAnr = struct_nr;
- sp = wd->sdna->structs[bh.SDNAnr];
+ bh.SDNAnr = struct_nr;
+ sp = wd->sdna->structs[bh.SDNAnr];
- bh.len = nr * wd->sdna->types_size[sp[0]];
+ bh.len = nr * wd->sdna->types_size[sp[0]];
- if (bh.len == 0) {
- return;
- }
+ if (bh.len == 0) {
+ return;
+ }
- mywrite(wd, &bh, sizeof(BHead));
- mywrite(wd, data, bh.len);
+ mywrite(wd, &bh, sizeof(BHead));
+ mywrite(wd, data, bh.len);
}
static void writestruct_at_address_id(
- WriteData *wd, int filecode, const char *structname, int nr,
- const void *adr, const void *data)
+ WriteData *wd, int filecode, const char *structname, int nr, const void *adr, const void *data)
{
- if (adr == NULL || data == NULL || nr == 0) {
- return;
- }
+ if (adr == NULL || data == NULL || nr == 0) {
+ return;
+ }
- const int SDNAnr = DNA_struct_find_nr(wd->sdna, structname);
- if (UNLIKELY(SDNAnr == -1)) {
- printf("error: can't find SDNA code <%s>\n", structname);
- return;
- }
+ const int SDNAnr = DNA_struct_find_nr(wd->sdna, structname);
+ if (UNLIKELY(SDNAnr == -1)) {
+ printf("error: can't find SDNA code <%s>\n", structname);
+ return;
+ }
- writestruct_at_address_nr(wd, filecode, SDNAnr, nr, adr, data);
+ writestruct_at_address_nr(wd, filecode, SDNAnr, nr, adr, data);
}
static void writestruct_nr(
- WriteData *wd, int filecode, const int struct_nr, int nr,
- const void *adr)
+ WriteData *wd, int filecode, const int struct_nr, int nr, const void *adr)
{
- writestruct_at_address_nr(wd, filecode, struct_nr, nr, adr, adr);
+ writestruct_at_address_nr(wd, filecode, struct_nr, nr, adr, adr);
}
static void writestruct_id(
- WriteData *wd, int filecode, const char *structname, int nr,
- const void *adr)
+ WriteData *wd, int filecode, const char *structname, int nr, const void *adr)
{
- writestruct_at_address_id(wd, filecode, structname, nr, adr, adr);
+ writestruct_at_address_id(wd, filecode, structname, nr, adr, adr);
}
-static void writedata(WriteData *wd, int filecode, int len, const void *adr) /* do not use for structs */
+static void writedata(WriteData *wd,
+ int filecode,
+ int len,
+ const void *adr) /* do not use for structs */
{
- BHead bh;
+ BHead bh;
- if (adr == NULL || len == 0) {
- return;
- }
+ if (adr == NULL || len == 0) {
+ return;
+ }
- /* align to 4 (writes uninitialized bytes in some cases) */
- len = (len + 3) & ~3;
+ /* align to 4 (writes uninitialized bytes in some cases) */
+ len = (len + 3) & ~3;
- /* init BHead */
- bh.code = filecode;
- bh.old = adr;
- bh.nr = 1;
- bh.SDNAnr = 0;
- bh.len = len;
+ /* init BHead */
+ bh.code = filecode;
+ bh.old = adr;
+ bh.nr = 1;
+ bh.SDNAnr = 0;
+ bh.len = len;
- mywrite(wd, &bh, sizeof(BHead));
- mywrite(wd, adr, len);
+ mywrite(wd, &bh, sizeof(BHead));
+ mywrite(wd, adr, len);
}
/* use this to force writing of lists in same order as reading (using link_list) */
static void writelist_nr(WriteData *wd, int filecode, const int struct_nr, const ListBase *lb)
{
- const Link *link = lb->first;
+ const Link *link = lb->first;
- while (link) {
- writestruct_nr(wd, filecode, struct_nr, 1, link);
- link = link->next;
- }
+ while (link) {
+ writestruct_nr(wd, filecode, struct_nr, 1, link);
+ link = link->next;
+ }
}
#if 0
static void writelist_id(WriteData *wd, int filecode, const char *structname, const ListBase *lb)
{
- const Link *link = lb->first;
- if (link) {
-
- const int struct_nr = DNA_struct_find_nr(wd->sdna, structname);
- if (struct_nr == -1) {
- printf("error: can't find SDNA code <%s>\n", structname);
- return;
- }
-
- while (link) {
- writestruct_nr(wd, filecode, struct_nr, 1, link);
- link = link->next;
- }
- }
+ const Link *link = lb->first;
+ if (link) {
+
+ const int struct_nr = DNA_struct_find_nr(wd->sdna, structname);
+ if (struct_nr == -1) {
+ printf("error: can't find SDNA code <%s>\n", structname);
+ return;
+ }
+
+ while (link) {
+ writestruct_nr(wd, filecode, struct_nr, 1, link);
+ link = link->next;
+ }
+ }
}
#endif
#define writestruct_at_address(wd, filecode, struct_id, nr, adr, data) \
- writestruct_at_address_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr, data)
+ writestruct_at_address_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr, data)
#define writestruct(wd, filecode, struct_id, nr, adr) \
- writestruct_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr)
+ writestruct_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr)
#define writelist(wd, filecode, struct_id, lb) \
- writelist_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), lb)
+ writelist_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), lb)
/** \} */
@@ -643,550 +635,550 @@ void IDP_WriteProperty(const IDProperty *prop, void *wd);
static void IDP_WriteArray(const IDProperty *prop, void *wd)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
- if (prop->data.pointer) {
- writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
-
- if (prop->subtype == IDP_GROUP) {
- IDProperty **array = prop->data.pointer;
- int a;
-
- for (a = 0; a < prop->len; a++) {
- IDP_WriteProperty(array[a], wd);
- }
- }
- }
+ /*REMEMBER to set totalen to len in the linking code!!*/
+ if (prop->data.pointer) {
+ writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
+
+ if (prop->subtype == IDP_GROUP) {
+ IDProperty **array = prop->data.pointer;
+ int a;
+
+ for (a = 0; a < prop->len; a++) {
+ IDP_WriteProperty(array[a], wd);
+ }
+ }
+ }
}
static void IDP_WriteIDPArray(const IDProperty *prop, void *wd)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
- if (prop->data.pointer) {
- const IDProperty *array = prop->data.pointer;
- int a;
+ /*REMEMBER to set totalen to len in the linking code!!*/
+ if (prop->data.pointer) {
+ const IDProperty *array = prop->data.pointer;
+ int a;
- writestruct(wd, DATA, IDProperty, prop->len, array);
+ writestruct(wd, DATA, IDProperty, prop->len, array);
- for (a = 0; a < prop->len; a++) {
- IDP_WriteProperty_OnlyData(&array[a], wd);
- }
- }
+ for (a = 0; a < prop->len; a++) {
+ IDP_WriteProperty_OnlyData(&array[a], wd);
+ }
+ }
}
static void IDP_WriteString(const IDProperty *prop, void *wd)
{
- /*REMEMBER to set totalen to len in the linking code!!*/
- writedata(wd, DATA, prop->len, prop->data.pointer);
+ /*REMEMBER to set totalen to len in the linking code!!*/
+ writedata(wd, DATA, prop->len, prop->data.pointer);
}
static void IDP_WriteGroup(const IDProperty *prop, void *wd)
{
- IDProperty *loop;
+ IDProperty *loop;
- for (loop = prop->data.group.first; loop; loop = loop->next) {
- IDP_WriteProperty(loop, wd);
- }
+ for (loop = prop->data.group.first; loop; loop = loop->next) {
+ IDP_WriteProperty(loop, wd);
+ }
}
/* Functions to read/write ID Properties */
void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd)
{
- switch (prop->type) {
- case IDP_GROUP:
- IDP_WriteGroup(prop, wd);
- break;
- case IDP_STRING:
- IDP_WriteString(prop, wd);
- break;
- case IDP_ARRAY:
- IDP_WriteArray(prop, wd);
- break;
- case IDP_IDPARRAY:
- IDP_WriteIDPArray(prop, wd);
- break;
- }
+ switch (prop->type) {
+ case IDP_GROUP:
+ IDP_WriteGroup(prop, wd);
+ break;
+ case IDP_STRING:
+ IDP_WriteString(prop, wd);
+ break;
+ case IDP_ARRAY:
+ IDP_WriteArray(prop, wd);
+ break;
+ case IDP_IDPARRAY:
+ IDP_WriteIDPArray(prop, wd);
+ break;
+ }
}
void IDP_WriteProperty(const IDProperty *prop, void *wd)
{
- writestruct(wd, DATA, IDProperty, 1, prop);
- IDP_WriteProperty_OnlyData(prop, wd);
+ writestruct(wd, DATA, IDProperty, 1, prop);
+ IDP_WriteProperty_OnlyData(prop, wd);
}
static void write_iddata(void *wd, const ID *id)
{
- /* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
- if (id->properties && !ELEM(GS(id->name), ID_WM)) {
- IDP_WriteProperty(id->properties, wd);
- }
-
- if (id->override_static) {
- writestruct(wd, DATA, IDOverrideStatic, 1, id->override_static);
-
- writelist(wd, DATA, IDOverrideStaticProperty, &id->override_static->properties);
- for (IDOverrideStaticProperty *op = id->override_static->properties.first; op; op = op->next) {
- writedata(wd, DATA, strlen(op->rna_path) + 1, op->rna_path);
-
- writelist(wd, DATA, IDOverrideStaticPropertyOperation, &op->operations);
- for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop; opop = opop->next) {
- if (opop->subitem_reference_name) {
- writedata(wd, DATA, strlen(opop->subitem_reference_name) + 1, opop->subitem_reference_name);
- }
- if (opop->subitem_local_name) {
- writedata(wd, DATA, strlen(opop->subitem_local_name) + 1, opop->subitem_local_name);
- }
- }
- }
- }
+ /* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
+ if (id->properties && !ELEM(GS(id->name), ID_WM)) {
+ IDP_WriteProperty(id->properties, wd);
+ }
+
+ if (id->override_static) {
+ writestruct(wd, DATA, IDOverrideStatic, 1, id->override_static);
+
+ writelist(wd, DATA, IDOverrideStaticProperty, &id->override_static->properties);
+ for (IDOverrideStaticProperty *op = id->override_static->properties.first; op; op = op->next) {
+ writedata(wd, DATA, strlen(op->rna_path) + 1, op->rna_path);
+
+ writelist(wd, DATA, IDOverrideStaticPropertyOperation, &op->operations);
+ for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop;
+ opop = opop->next) {
+ if (opop->subitem_reference_name) {
+ writedata(
+ wd, DATA, strlen(opop->subitem_reference_name) + 1, opop->subitem_reference_name);
+ }
+ if (opop->subitem_local_name) {
+ writedata(wd, DATA, strlen(opop->subitem_local_name) + 1, opop->subitem_local_name);
+ }
+ }
+ }
+ }
}
static void write_previews(WriteData *wd, const PreviewImage *prv_orig)
{
- /* Note we write previews also for undo steps. It takes up some memory,
- * but not doing so would causes all previews to be re-rendered after
- * undo which is too expensive. */
- if (prv_orig) {
- PreviewImage prv = *prv_orig;
-
- /* don't write out large previews if not requested */
- if (!(U.flag & USER_SAVE_PREVIEWS)) {
- prv.w[1] = 0;
- prv.h[1] = 0;
- prv.rect[1] = NULL;
- }
- writestruct_at_address(wd, DATA, PreviewImage, 1, prv_orig, &prv);
- if (prv.rect[0]) {
- writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(uint), prv.rect[0]);
- }
- if (prv.rect[1]) {
- writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(uint), prv.rect[1]);
- }
- }
+ /* Note we write previews also for undo steps. It takes up some memory,
+ * but not doing so would causes all previews to be re-rendered after
+ * undo which is too expensive. */
+ if (prv_orig) {
+ PreviewImage prv = *prv_orig;
+
+ /* don't write out large previews if not requested */
+ if (!(U.flag & USER_SAVE_PREVIEWS)) {
+ prv.w[1] = 0;
+ prv.h[1] = 0;
+ prv.rect[1] = NULL;
+ }
+ writestruct_at_address(wd, DATA, PreviewImage, 1, prv_orig, &prv);
+ if (prv.rect[0]) {
+ writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(uint), prv.rect[0]);
+ }
+ if (prv.rect[1]) {
+ writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(uint), prv.rect[1]);
+ }
+ }
}
static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
{
- FModifier *fcm;
-
- /* Write all modifiers first (for faster reloading) */
- writelist(wd, DATA, FModifier, fmodifiers);
-
- /* Modifiers */
- for (fcm = fmodifiers->first; fcm; fcm = fcm->next) {
- const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
-
- /* Write the specific data */
- if (fmi && fcm->data) {
- /* firstly, just write the plain fmi->data struct */
- writestruct_id(wd, DATA, fmi->structName, 1, fcm->data);
-
- /* do any modifier specific stuff */
- switch (fcm->type) {
- case FMODIFIER_TYPE_GENERATOR:
- {
- FMod_Generator *data = fcm->data;
-
- /* write coefficients array */
- if (data->coefficients) {
- writedata(wd, DATA, sizeof(float) * (data->arraysize), data->coefficients);
- }
-
- break;
- }
- case FMODIFIER_TYPE_ENVELOPE:
- {
- FMod_Envelope *data = fcm->data;
-
- /* write envelope data */
- if (data->data) {
- writestruct(wd, DATA, FCM_EnvelopeData, data->totvert, data->data);
- }
-
- break;
- }
- case FMODIFIER_TYPE_PYTHON:
- {
- FMod_Python *data = fcm->data;
-
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_WriteProperty(data->prop, wd);
-
- break;
- }
- }
- }
- }
+ FModifier *fcm;
+
+ /* Write all modifiers first (for faster reloading) */
+ writelist(wd, DATA, FModifier, fmodifiers);
+
+ /* Modifiers */
+ for (fcm = fmodifiers->first; fcm; fcm = fcm->next) {
+ const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
+
+ /* Write the specific data */
+ if (fmi && fcm->data) {
+ /* firstly, just write the plain fmi->data struct */
+ writestruct_id(wd, DATA, fmi->structName, 1, fcm->data);
+
+ /* do any modifier specific stuff */
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_GENERATOR: {
+ FMod_Generator *data = fcm->data;
+
+ /* write coefficients array */
+ if (data->coefficients) {
+ writedata(wd, DATA, sizeof(float) * (data->arraysize), data->coefficients);
+ }
+
+ break;
+ }
+ case FMODIFIER_TYPE_ENVELOPE: {
+ FMod_Envelope *data = fcm->data;
+
+ /* write envelope data */
+ if (data->data) {
+ writestruct(wd, DATA, FCM_EnvelopeData, data->totvert, data->data);
+ }
+
+ break;
+ }
+ case FMODIFIER_TYPE_PYTHON: {
+ FMod_Python *data = fcm->data;
+
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_WriteProperty(data->prop, wd);
+
+ break;
+ }
+ }
+ }
+ }
}
static void write_fcurves(WriteData *wd, ListBase *fcurves)
{
- FCurve *fcu;
-
- writelist(wd, DATA, FCurve, fcurves);
- for (fcu = fcurves->first; fcu; fcu = fcu->next) {
- /* curve data */
- if (fcu->bezt) {
- writestruct(wd, DATA, BezTriple, fcu->totvert, fcu->bezt);
- }
- if (fcu->fpt) {
- writestruct(wd, DATA, FPoint, fcu->totvert, fcu->fpt);
- }
-
- if (fcu->rna_path) {
- writedata(wd, DATA, strlen(fcu->rna_path) + 1, fcu->rna_path);
- }
-
- /* driver data */
- if (fcu->driver) {
- ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
-
- writestruct(wd, DATA, ChannelDriver, 1, driver);
-
- /* variables */
- writelist(wd, DATA, DriverVar, &driver->variables);
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
- {
- if (dtar->rna_path) {
- writedata(wd, DATA, strlen(dtar->rna_path) + 1, dtar->rna_path);
- }
- }
- DRIVER_TARGETS_LOOPER_END;
- }
- }
-
- /* write F-Modifiers */
- write_fmodifiers(wd, &fcu->modifiers);
- }
+ FCurve *fcu;
+
+ writelist(wd, DATA, FCurve, fcurves);
+ for (fcu = fcurves->first; fcu; fcu = fcu->next) {
+ /* curve data */
+ if (fcu->bezt) {
+ writestruct(wd, DATA, BezTriple, fcu->totvert, fcu->bezt);
+ }
+ if (fcu->fpt) {
+ writestruct(wd, DATA, FPoint, fcu->totvert, fcu->fpt);
+ }
+
+ if (fcu->rna_path) {
+ writedata(wd, DATA, strlen(fcu->rna_path) + 1, fcu->rna_path);
+ }
+
+ /* driver data */
+ if (fcu->driver) {
+ ChannelDriver *driver = fcu->driver;
+ DriverVar *dvar;
+
+ writestruct(wd, DATA, ChannelDriver, 1, driver);
+
+ /* variables */
+ writelist(wd, DATA, DriverVar, &driver->variables);
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
+ if (dtar->rna_path) {
+ writedata(wd, DATA, strlen(dtar->rna_path) + 1, dtar->rna_path);
+ }
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* write F-Modifiers */
+ write_fmodifiers(wd, &fcu->modifiers);
+ }
}
static void write_action(WriteData *wd, bAction *act)
{
- if (act->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_AC, bAction, 1, act);
- write_iddata(wd, &act->id);
+ if (act->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_AC, bAction, 1, act);
+ write_iddata(wd, &act->id);
- write_fcurves(wd, &act->curves);
+ write_fcurves(wd, &act->curves);
- for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) {
- writestruct(wd, DATA, bActionGroup, 1, grp);
- }
+ for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) {
+ writestruct(wd, DATA, bActionGroup, 1, grp);
+ }
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
- writestruct(wd, DATA, TimeMarker, 1, marker);
- }
- }
+ for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ writestruct(wd, DATA, TimeMarker, 1, marker);
+ }
+ }
}
static void write_keyingsets(WriteData *wd, ListBase *list)
{
- KeyingSet *ks;
- KS_Path *ksp;
-
- for (ks = list->first; ks; ks = ks->next) {
- /* KeyingSet */
- writestruct(wd, DATA, KeyingSet, 1, ks);
-
- /* Paths */
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- /* Path */
- writestruct(wd, DATA, KS_Path, 1, ksp);
-
- if (ksp->rna_path) {
- writedata(wd, DATA, strlen(ksp->rna_path) + 1, ksp->rna_path);
- }
- }
- }
+ KeyingSet *ks;
+ KS_Path *ksp;
+
+ for (ks = list->first; ks; ks = ks->next) {
+ /* KeyingSet */
+ writestruct(wd, DATA, KeyingSet, 1, ks);
+
+ /* Paths */
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ /* Path */
+ writestruct(wd, DATA, KS_Path, 1, ksp);
+
+ if (ksp->rna_path) {
+ writedata(wd, DATA, strlen(ksp->rna_path) + 1, ksp->rna_path);
+ }
+ }
+ }
}
static void write_nlastrips(WriteData *wd, ListBase *strips)
{
- NlaStrip *strip;
+ NlaStrip *strip;
- writelist(wd, DATA, NlaStrip, strips);
- for (strip = strips->first; strip; strip = strip->next) {
- /* write the strip's F-Curves and modifiers */
- write_fcurves(wd, &strip->fcurves);
- write_fmodifiers(wd, &strip->modifiers);
+ writelist(wd, DATA, NlaStrip, strips);
+ for (strip = strips->first; strip; strip = strip->next) {
+ /* write the strip's F-Curves and modifiers */
+ write_fcurves(wd, &strip->fcurves);
+ write_fmodifiers(wd, &strip->modifiers);
- /* write the strip's children */
- write_nlastrips(wd, &strip->strips);
- }
+ /* write the strip's children */
+ write_nlastrips(wd, &strip->strips);
+ }
}
static void write_nladata(WriteData *wd, ListBase *nlabase)
{
- NlaTrack *nlt;
+ NlaTrack *nlt;
- /* write all the tracks */
- for (nlt = nlabase->first; nlt; nlt = nlt->next) {
- /* write the track first */
- writestruct(wd, DATA, NlaTrack, 1, nlt);
+ /* write all the tracks */
+ for (nlt = nlabase->first; nlt; nlt = nlt->next) {
+ /* write the track first */
+ writestruct(wd, DATA, NlaTrack, 1, nlt);
- /* write the track's strips */
- write_nlastrips(wd, &nlt->strips);
- }
+ /* write the track's strips */
+ write_nlastrips(wd, &nlt->strips);
+ }
}
static void write_animdata(WriteData *wd, AnimData *adt)
{
- AnimOverride *aor;
+ AnimOverride *aor;
- /* firstly, just write the AnimData block */
- writestruct(wd, DATA, AnimData, 1, adt);
+ /* firstly, just write the AnimData block */
+ writestruct(wd, DATA, AnimData, 1, adt);
- /* write drivers */
- write_fcurves(wd, &adt->drivers);
+ /* write drivers */
+ write_fcurves(wd, &adt->drivers);
- /* write overrides */
- // FIXME: are these needed?
- for (aor = adt->overrides.first; aor; aor = aor->next) {
- /* overrides consist of base data + rna_path */
- writestruct(wd, DATA, AnimOverride, 1, aor);
- writedata(wd, DATA, strlen(aor->rna_path) + 1, aor->rna_path);
- }
+ /* write overrides */
+ // FIXME: are these needed?
+ for (aor = adt->overrides.first; aor; aor = aor->next) {
+ /* overrides consist of base data + rna_path */
+ writestruct(wd, DATA, AnimOverride, 1, aor);
+ writedata(wd, DATA, strlen(aor->rna_path) + 1, aor->rna_path);
+ }
- // TODO write the remaps (if they are needed)
+ // TODO write the remaps (if they are needed)
- /* write NLA data */
- write_nladata(wd, &adt->nla_tracks);
+ /* write NLA data */
+ write_nladata(wd, &adt->nla_tracks);
}
static void write_curvemapping_curves(WriteData *wd, CurveMapping *cumap)
{
- for (int a = 0; a < CM_TOT; a++) {
- writestruct(wd, DATA, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
- }
+ for (int a = 0; a < CM_TOT; a++) {
+ writestruct(wd, DATA, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
+ }
}
static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
{
- writestruct(wd, DATA, CurveMapping, 1, cumap);
+ writestruct(wd, DATA, CurveMapping, 1, cumap);
- write_curvemapping_curves(wd, cumap);
+ write_curvemapping_curves(wd, cumap);
}
-static void write_node_socket(WriteData *wd, bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock)
+static void write_node_socket(WriteData *wd,
+ bNodeTree *UNUSED(ntree),
+ bNode *node,
+ bNodeSocket *sock)
{
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open (not for undo) */
- if (wd->use_memfile == false) {
- sock->stack_type = 1;
-
- if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup) {
- /* for node groups: look up the deprecated groupsock pointer */
- sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
- BLI_assert(sock->groupsock != NULL);
-
- /* node group sockets now use the generic identifier string to verify group nodes,
- * old blender uses the own_index.
- */
- sock->own_index = sock->groupsock->own_index;
- }
- }
- }
+ /* forward compatibility code, so older blenders still open (not for undo) */
+ if (wd->use_memfile == false) {
+ sock->stack_type = 1;
+
+ if (node->type == NODE_GROUP) {
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ if (ngroup) {
+ /* for node groups: look up the deprecated groupsock pointer */
+ sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
+ BLI_assert(sock->groupsock != NULL);
+
+ /* node group sockets now use the generic identifier string to verify group nodes,
+ * old blender uses the own_index.
+ */
+ sock->own_index = sock->groupsock->own_index;
+ }
+ }
+ }
#endif
- /* actual socket writing */
- writestruct(wd, DATA, bNodeSocket, 1, sock);
+ /* actual socket writing */
+ writestruct(wd, DATA, bNodeSocket, 1, sock);
- if (sock->prop) {
- IDP_WriteProperty(sock->prop, wd);
- }
+ if (sock->prop) {
+ IDP_WriteProperty(sock->prop, wd);
+ }
- if (sock->default_value) {
- writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
- }
+ if (sock->default_value) {
+ writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
+ }
}
static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), bNodeSocket *sock)
{
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open */
- sock->stack_type = 1;
+ /* forward compatibility code, so older blenders still open */
+ sock->stack_type = 1;
- /* Reconstruct the deprecated default_value structs in socket interface DNA. */
- if (sock->default_value == NULL && sock->typeinfo) {
- node_socket_init_default_value(sock);
- }
+ /* Reconstruct the deprecated default_value structs in socket interface DNA. */
+ if (sock->default_value == NULL && sock->typeinfo) {
+ node_socket_init_default_value(sock);
+ }
#endif
- /* actual socket writing */
- writestruct(wd, DATA, bNodeSocket, 1, sock);
+ /* actual socket writing */
+ writestruct(wd, DATA, bNodeSocket, 1, sock);
- if (sock->prop) {
- IDP_WriteProperty(sock->prop, wd);
- }
+ if (sock->prop) {
+ IDP_WriteProperty(sock->prop, wd);
+ }
- if (sock->default_value) {
- writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
- }
+ if (sock->default_value) {
+ writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
+ }
}
/* this is only direct data, tree itself should have been written */
static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
- bNodeLink *link;
-
- /* for link_list() speed, we write per list */
-
- if (ntree->adt) {
- write_animdata(wd, ntree->adt);
- }
-
- for (node = ntree->nodes.first; node; node = node->next) {
- writestruct(wd, DATA, bNode, 1, node);
-
- if (node->prop) {
- IDP_WriteProperty(node->prop, wd);
- }
-
- for (sock = node->inputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
- }
- for (sock = node->outputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
- }
-
- for (link = node->internal_links.first; link; link = link->next) {
- writestruct(wd, DATA, bNodeLink, 1, link);
- }
-
- if (node->storage) {
- /* could be handlerized at some point, now only 1 exception still */
- if ((ntree->type == NTREE_SHADER) &&
- ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB))
- {
- write_curvemapping(wd, node->storage);
- }
- else if (ntree->type == NTREE_SHADER &&
- (node->type == SH_NODE_SCRIPT))
- {
- NodeShaderScript *nss = (NodeShaderScript *)node->storage;
- if (nss->bytecode) {
- writedata(wd, DATA, strlen(nss->bytecode) + 1, nss->bytecode);
- }
- writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
- }
- else if ((ntree->type == NTREE_COMPOSIT) &&
- ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
- {
- write_curvemapping(wd, node->storage);
- }
- else if ((ntree->type == NTREE_TEXTURE) &&
- (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME))
- {
- write_curvemapping(wd, node->storage);
- }
- else if ((ntree->type == NTREE_COMPOSIT) &&
- (node->type == CMP_NODE_MOVIEDISTORTION))
- {
- /* pass */
- }
- else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_GLARE)) {
- /* Simple forward compat for fix for T50736.
- * Not ideal (there is no ideal solution here), but should do for now. */
- NodeGlare *ndg = node->storage;
- /* Not in undo case. */
- if (wd->use_memfile == false) {
- switch (ndg->type) {
- case 2: /* Grrrr! magic numbers :( */
- ndg->angle = ndg->streaks;
- break;
- case 0:
- ndg->angle = ndg->star_45;
- break;
- default:
- break;
- }
- }
- writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
- }
- else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
- NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
- if (nc->matte_id) {
- writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id);
- }
- writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
- }
- else {
- writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
- }
- }
-
- if (node->type == CMP_NODE_OUTPUT_FILE) {
- /* inputs have own storage data */
- for (sock = node->inputs.first; sock; sock = sock->next) {
- writestruct(wd, DATA, NodeImageMultiFileSocket, 1, sock->storage);
- }
- }
- if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
- /* write extra socket info */
- for (sock = node->outputs.first; sock; sock = sock->next) {
- writestruct(wd, DATA, NodeImageLayer, 1, sock->storage);
- }
- }
- }
-
- for (link = ntree->links.first; link; link = link->next) {
- writestruct(wd, DATA, bNodeLink, 1, link);
- }
-
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
- }
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
- }
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ /* for link_list() speed, we write per list */
+
+ if (ntree->adt) {
+ write_animdata(wd, ntree->adt);
+ }
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ writestruct(wd, DATA, bNode, 1, node);
+
+ if (node->prop) {
+ IDP_WriteProperty(node->prop, wd);
+ }
+
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ write_node_socket(wd, ntree, node, sock);
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ write_node_socket(wd, ntree, node, sock);
+ }
+
+ for (link = node->internal_links.first; link; link = link->next) {
+ writestruct(wd, DATA, bNodeLink, 1, link);
+ }
+
+ if (node->storage) {
+ /* could be handlerized at some point, now only 1 exception still */
+ if ((ntree->type == NTREE_SHADER) &&
+ ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB)) {
+ write_curvemapping(wd, node->storage);
+ }
+ else if (ntree->type == NTREE_SHADER && (node->type == SH_NODE_SCRIPT)) {
+ NodeShaderScript *nss = (NodeShaderScript *)node->storage;
+ if (nss->bytecode) {
+ writedata(wd, DATA, strlen(nss->bytecode) + 1, nss->bytecode);
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
+ else if ((ntree->type == NTREE_COMPOSIT) && ELEM(node->type,
+ CMP_NODE_TIME,
+ CMP_NODE_CURVE_VEC,
+ CMP_NODE_CURVE_RGB,
+ CMP_NODE_HUECORRECT)) {
+ write_curvemapping(wd, node->storage);
+ }
+ else if ((ntree->type == NTREE_TEXTURE) &&
+ (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME)) {
+ write_curvemapping(wd, node->storage);
+ }
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_MOVIEDISTORTION)) {
+ /* pass */
+ }
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_GLARE)) {
+ /* Simple forward compat for fix for T50736.
+ * Not ideal (there is no ideal solution here), but should do for now. */
+ NodeGlare *ndg = node->storage;
+ /* Not in undo case. */
+ if (wd->use_memfile == false) {
+ switch (ndg->type) {
+ case 2: /* Grrrr! magic numbers :( */
+ ndg->angle = ndg->streaks;
+ break;
+ case 0:
+ ndg->angle = ndg->star_45;
+ break;
+ default:
+ break;
+ }
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
+ else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+ if (nc->matte_id) {
+ writedata(wd, DATA, strlen(nc->matte_id) + 1, nc->matte_id);
+ }
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
+ else {
+ writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
+ }
+ }
+
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
+ /* inputs have own storage data */
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ writestruct(wd, DATA, NodeImageMultiFileSocket, 1, sock->storage);
+ }
+ }
+ if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
+ /* write extra socket info */
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ writestruct(wd, DATA, NodeImageLayer, 1, sock->storage);
+ }
+ }
+ }
+
+ for (link = ntree->links.first; link; link = link->next) {
+ writestruct(wd, DATA, bNodeLink, 1, link);
+ }
+
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ write_node_socket_interface(wd, ntree, sock);
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ write_node_socket_interface(wd, ntree, sock);
+ }
}
/**
* Take care using 'use_active_win', since we wont want the currently active window
* to change which scene renders (currently only used for undo).
*/
-static void current_screen_compat(
- Main *mainvar, bool use_active_win,
- bScreen **r_screen, Scene **r_scene, ViewLayer **r_view_layer)
+static void current_screen_compat(Main *mainvar,
+ bool use_active_win,
+ bScreen **r_screen,
+ Scene **r_scene,
+ ViewLayer **r_view_layer)
{
- wmWindowManager *wm;
- wmWindow *window = NULL;
-
- /* find a global current screen in the first open window, to have
- * a reasonable default for reading in older versions */
- wm = mainvar->wm.first;
-
- if (wm) {
- if (use_active_win) {
- /* write the active window into the file, needed for multi-window undo T43424 */
- for (window = wm->windows.first; window; window = window->next) {
- if (window->active) {
- break;
- }
- }
-
- /* fallback */
- if (window == NULL) {
- window = wm->windows.first;
- }
- }
- else {
- window = wm->windows.first;
- }
- }
-
- *r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
- *r_scene = (window) ? window->scene : NULL;
- *r_view_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
+ wmWindowManager *wm;
+ wmWindow *window = NULL;
+
+ /* find a global current screen in the first open window, to have
+ * a reasonable default for reading in older versions */
+ wm = mainvar->wm.first;
+
+ if (wm) {
+ if (use_active_win) {
+ /* write the active window into the file, needed for multi-window undo T43424 */
+ for (window = wm->windows.first; window; window = window->next) {
+ if (window->active) {
+ break;
+ }
+ }
+
+ /* fallback */
+ if (window == NULL) {
+ window = wm->windows.first;
+ }
+ }
+ else {
+ window = wm->windows.first;
+ }
+ }
+
+ *r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
+ *r_scene = (window) ? window->scene : NULL;
+ *r_view_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) :
+ NULL;
}
typedef struct RenderInfo {
- int sfra;
- int efra;
- char scene_name[MAX_ID_NAME - 2];
+ int sfra;
+ int efra;
+ char scene_name[MAX_ID_NAME - 2];
} RenderInfo;
/* was for historic render-deamon feature,
@@ -1194,2579 +1186,2598 @@ typedef struct RenderInfo {
* reading the whole blend file */
static void write_renderinfo(WriteData *wd, Main *mainvar)
{
- bScreen *curscreen;
- Scene *sce, *curscene = NULL;
- ViewLayer *view_layer;
- RenderInfo data;
+ bScreen *curscreen;
+ Scene *sce, *curscene = NULL;
+ ViewLayer *view_layer;
+ RenderInfo data;
- /* XXX in future, handle multiple windows with multiple screens? */
- current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
+ /* XXX in future, handle multiple windows with multiple screens? */
+ current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
- for (sce = mainvar->scenes.first; sce; sce = sce->id.next) {
- if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
- data.sfra = sce->r.sfra;
- data.efra = sce->r.efra;
- memset(data.scene_name, 0, sizeof(data.scene_name));
+ for (sce = mainvar->scenes.first; sce; sce = sce->id.next) {
+ if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
+ data.sfra = sce->r.sfra;
+ data.efra = sce->r.efra;
+ memset(data.scene_name, 0, sizeof(data.scene_name));
- BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name));
+ BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name));
- writedata(wd, REND, sizeof(data), &data);
- }
- }
+ writedata(wd, REND, sizeof(data), &data);
+ }
+ }
}
static void write_keymapitem(WriteData *wd, const wmKeyMapItem *kmi)
{
- writestruct(wd, DATA, wmKeyMapItem, 1, kmi);
- if (kmi->properties) {
- IDP_WriteProperty(kmi->properties, wd);
- }
+ writestruct(wd, DATA, wmKeyMapItem, 1, kmi);
+ if (kmi->properties) {
+ IDP_WriteProperty(kmi->properties, wd);
+ }
}
static void write_userdef(WriteData *wd, const UserDef *userdef)
{
- writestruct(wd, USER, UserDef, 1, userdef);
-
- for (const bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
- writestruct(wd, DATA, bTheme, 1, btheme);
- }
-
- for (const wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
- writestruct(wd, DATA, wmKeyMap, 1, keymap);
-
- for (const wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
- writestruct(wd, DATA, wmKeyMapDiffItem, 1, kmdi);
- if (kmdi->remove_item) {
- write_keymapitem(wd, kmdi->remove_item);
- }
- if (kmdi->add_item) {
- write_keymapitem(wd, kmdi->add_item);
- }
- }
-
- for (const wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
- write_keymapitem(wd, kmi);
- }
- }
-
- for (const wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
- writestruct(wd, DATA, wmKeyConfigPref, 1, kpt);
- if (kpt->prop) {
- IDP_WriteProperty(kpt->prop, wd);
- }
- }
-
- for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) {
- writestruct(wd, DATA, bUserMenu, 1, um);
- for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
- if (umi->type == USER_MENU_TYPE_OPERATOR) {
- const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi;
- writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op);
- if (umi_op->prop) {
- IDP_WriteProperty(umi_op->prop, wd);
- }
- }
- else if (umi->type == USER_MENU_TYPE_MENU) {
- const bUserMenuItem_Menu *umi_mt = (const bUserMenuItem_Menu *)umi;
- writestruct(wd, DATA, bUserMenuItem_Menu, 1, umi_mt);
- }
- else if (umi->type == USER_MENU_TYPE_PROP) {
- const bUserMenuItem_Prop *umi_pr = (const bUserMenuItem_Prop *)umi;
- writestruct(wd, DATA, bUserMenuItem_Prop, 1, umi_pr);
- }
- else {
- writestruct(wd, DATA, bUserMenuItem, 1, umi);
- }
- }
- }
-
- for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) {
- writestruct(wd, DATA, bAddon, 1, bext);
- if (bext->prop) {
- IDP_WriteProperty(bext->prop, wd);
- }
- }
-
- for (const bPathCompare *path_cmp = userdef->autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) {
- writestruct(wd, DATA, bPathCompare, 1, path_cmp);
- }
-
- for (const uiStyle *style = userdef->uistyles.first; style; style = style->next) {
- writestruct(wd, DATA, uiStyle, 1, style);
- }
+ writestruct(wd, USER, UserDef, 1, userdef);
+
+ for (const bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ writestruct(wd, DATA, bTheme, 1, btheme);
+ }
+
+ for (const wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
+ writestruct(wd, DATA, wmKeyMap, 1, keymap);
+
+ for (const wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ writestruct(wd, DATA, wmKeyMapDiffItem, 1, kmdi);
+ if (kmdi->remove_item) {
+ write_keymapitem(wd, kmdi->remove_item);
+ }
+ if (kmdi->add_item) {
+ write_keymapitem(wd, kmdi->add_item);
+ }
+ }
+
+ for (const wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ write_keymapitem(wd, kmi);
+ }
+ }
+
+ for (const wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
+ writestruct(wd, DATA, wmKeyConfigPref, 1, kpt);
+ if (kpt->prop) {
+ IDP_WriteProperty(kpt->prop, wd);
+ }
+ }
+
+ for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) {
+ writestruct(wd, DATA, bUserMenu, 1, um);
+ for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ if (umi->type == USER_MENU_TYPE_OPERATOR) {
+ const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi;
+ writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op);
+ if (umi_op->prop) {
+ IDP_WriteProperty(umi_op->prop, wd);
+ }
+ }
+ else if (umi->type == USER_MENU_TYPE_MENU) {
+ const bUserMenuItem_Menu *umi_mt = (const bUserMenuItem_Menu *)umi;
+ writestruct(wd, DATA, bUserMenuItem_Menu, 1, umi_mt);
+ }
+ else if (umi->type == USER_MENU_TYPE_PROP) {
+ const bUserMenuItem_Prop *umi_pr = (const bUserMenuItem_Prop *)umi;
+ writestruct(wd, DATA, bUserMenuItem_Prop, 1, umi_pr);
+ }
+ else {
+ writestruct(wd, DATA, bUserMenuItem, 1, umi);
+ }
+ }
+ }
+
+ for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) {
+ writestruct(wd, DATA, bAddon, 1, bext);
+ if (bext->prop) {
+ IDP_WriteProperty(bext->prop, wd);
+ }
+ }
+
+ for (const bPathCompare *path_cmp = userdef->autoexec_paths.first; path_cmp;
+ path_cmp = path_cmp->next) {
+ writestruct(wd, DATA, bPathCompare, 1, path_cmp);
+ }
+
+ for (const uiStyle *style = userdef->uistyles.first; style; style = style->next) {
+ writestruct(wd, DATA, uiStyle, 1, style);
+ }
}
static void write_boid_state(WriteData *wd, BoidState *state)
{
- BoidRule *rule = state->rules.first;
-
- writestruct(wd, DATA, BoidState, 1, state);
-
- for (; rule; rule = rule->next) {
- switch (rule->type) {
- case eBoidRuleType_Goal:
- case eBoidRuleType_Avoid:
- writestruct(wd, DATA, BoidRuleGoalAvoid, 1, rule);
- break;
- case eBoidRuleType_AvoidCollision:
- writestruct(wd, DATA, BoidRuleAvoidCollision, 1, rule);
- break;
- case eBoidRuleType_FollowLeader:
- writestruct(wd, DATA, BoidRuleFollowLeader, 1, rule);
- break;
- case eBoidRuleType_AverageSpeed:
- writestruct(wd, DATA, BoidRuleAverageSpeed, 1, rule);
- break;
- case eBoidRuleType_Fight:
- writestruct(wd, DATA, BoidRuleFight, 1, rule);
- break;
- default:
- writestruct(wd, DATA, BoidRule, 1, rule);
- break;
- }
- }
+ BoidRule *rule = state->rules.first;
+
+ writestruct(wd, DATA, BoidState, 1, state);
+
+ for (; rule; rule = rule->next) {
+ switch (rule->type) {
+ case eBoidRuleType_Goal:
+ case eBoidRuleType_Avoid:
+ writestruct(wd, DATA, BoidRuleGoalAvoid, 1, rule);
+ break;
+ case eBoidRuleType_AvoidCollision:
+ writestruct(wd, DATA, BoidRuleAvoidCollision, 1, rule);
+ break;
+ case eBoidRuleType_FollowLeader:
+ writestruct(wd, DATA, BoidRuleFollowLeader, 1, rule);
+ break;
+ case eBoidRuleType_AverageSpeed:
+ writestruct(wd, DATA, BoidRuleAverageSpeed, 1, rule);
+ break;
+ case eBoidRuleType_Fight:
+ writestruct(wd, DATA, BoidRuleFight, 1, rule);
+ break;
+ default:
+ writestruct(wd, DATA, BoidRule, 1, rule);
+ break;
+ }
+ }
#if 0
- BoidCondition *cond = state->conditions.first;
- for (; cond; cond = cond->next) {
- writestruct(wd, DATA, BoidCondition, 1, cond);
- }
+ BoidCondition *cond = state->conditions.first;
+ for (; cond; cond = cond->next) {
+ writestruct(wd, DATA, BoidCondition, 1, cond);
+ }
#endif
}
/* update this also to readfile.c */
static const char *ptcache_data_struct[] = {
- "", // BPHYS_DATA_INDEX
- "", // BPHYS_DATA_LOCATION
- "", // BPHYS_DATA_VELOCITY
- "", // BPHYS_DATA_ROTATION
- "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
- "", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
- "BoidData", // case BPHYS_DATA_BOIDS:
+ "", // BPHYS_DATA_INDEX
+ "", // BPHYS_DATA_LOCATION
+ "", // BPHYS_DATA_VELOCITY
+ "", // BPHYS_DATA_ROTATION
+ "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
+ "", // BPHYS_DATA_SIZE:
+ "", // BPHYS_DATA_TIMES:
+ "BoidData", // case BPHYS_DATA_BOIDS:
};
static const char *ptcache_extra_struct[] = {
- "",
- "ParticleSpring",
+ "",
+ "ParticleSpring",
};
static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
{
- PointCache *cache = ptcaches->first;
- int i;
-
- for (; cache; cache = cache->next) {
- writestruct(wd, DATA, PointCache, 1, cache);
-
- if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- PTCacheMem *pm = cache->mem_cache.first;
-
- for (; pm; pm = pm->next) {
- PTCacheExtra *extra = pm->extradata.first;
-
- writestruct(wd, DATA, PTCacheMem, 1, pm);
-
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (pm->data[i] && pm->data_types & (1 << i)) {
- if (ptcache_data_struct[i][0] == '\0') {
- writedata(wd, DATA, MEM_allocN_len(pm->data[i]), pm->data[i]);
- }
- else {
- writestruct_id(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
- }
- }
- }
-
- for (; extra; extra = extra->next) {
- if (ptcache_extra_struct[extra->type][0] == '\0') {
- continue;
- }
- writestruct(wd, DATA, PTCacheExtra, 1, extra);
- writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
- }
- }
- }
- }
+ PointCache *cache = ptcaches->first;
+ int i;
+
+ for (; cache; cache = cache->next) {
+ writestruct(wd, DATA, PointCache, 1, cache);
+
+ if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
+ PTCacheMem *pm = cache->mem_cache.first;
+
+ for (; pm; pm = pm->next) {
+ PTCacheExtra *extra = pm->extradata.first;
+
+ writestruct(wd, DATA, PTCacheMem, 1, pm);
+
+ for (i = 0; i < BPHYS_TOT_DATA; i++) {
+ if (pm->data[i] && pm->data_types & (1 << i)) {
+ if (ptcache_data_struct[i][0] == '\0') {
+ writedata(wd, DATA, MEM_allocN_len(pm->data[i]), pm->data[i]);
+ }
+ else {
+ writestruct_id(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
+ }
+ }
+ }
+
+ for (; extra; extra = extra->next) {
+ if (ptcache_extra_struct[extra->type][0] == '\0') {
+ continue;
+ }
+ writestruct(wd, DATA, PTCacheExtra, 1, extra);
+ writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
+ }
+ }
+ }
+ }
}
static void write_particlesettings(WriteData *wd, ParticleSettings *part)
{
- if (part->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_PA, ParticleSettings, 1, part);
- write_iddata(wd, &part->id);
-
- if (part->adt) {
- write_animdata(wd, part->adt);
- }
- writestruct(wd, DATA, PartDeflect, 1, part->pd);
- writestruct(wd, DATA, PartDeflect, 1, part->pd2);
- writestruct(wd, DATA, EffectorWeights, 1, part->effector_weights);
-
- if (part->clumpcurve) {
- write_curvemapping(wd, part->clumpcurve);
- }
- if (part->roughcurve) {
- write_curvemapping(wd, part->roughcurve);
- }
- if (part->twistcurve) {
- write_curvemapping(wd, part->twistcurve);
- }
-
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
- /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
- if (dw->ob != NULL) {
- dw->index = 0;
- if (part->instance_collection) { /* can be NULL if lining fails or set to None */
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->instance_collection, object)
- {
- if (object == dw->ob) {
- break;
- }
- dw->index++;
- }
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- }
- }
- writestruct(wd, DATA, ParticleDupliWeight, 1, dw);
- }
-
- if (part->boids && part->phystype == PART_PHYS_BOIDS) {
- writestruct(wd, DATA, BoidSettings, 1, part->boids);
-
- for (BoidState *state = part->boids->states.first; state; state = state->next) {
- write_boid_state(wd, state);
- }
- }
- if (part->fluid && part->phystype == PART_PHYS_FLUID) {
- writestruct(wd, DATA, SPHFluidSettings, 1, part->fluid);
- }
-
- for (int a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- writestruct(wd, DATA, MTex, 1, part->mtex[a]);
- }
- }
- }
+ if (part->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_PA, ParticleSettings, 1, part);
+ write_iddata(wd, &part->id);
+
+ if (part->adt) {
+ write_animdata(wd, part->adt);
+ }
+ writestruct(wd, DATA, PartDeflect, 1, part->pd);
+ writestruct(wd, DATA, PartDeflect, 1, part->pd2);
+ writestruct(wd, DATA, EffectorWeights, 1, part->effector_weights);
+
+ if (part->clumpcurve) {
+ write_curvemapping(wd, part->clumpcurve);
+ }
+ if (part->roughcurve) {
+ write_curvemapping(wd, part->roughcurve);
+ }
+ if (part->twistcurve) {
+ write_curvemapping(wd, part->twistcurve);
+ }
+
+ for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
+ if (dw->ob != NULL) {
+ dw->index = 0;
+ if (part->instance_collection) { /* can be NULL if lining fails or set to None */
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
+ if (object == dw->ob) {
+ break;
+ }
+ dw->index++;
+ }
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+ }
+ }
+ writestruct(wd, DATA, ParticleDupliWeight, 1, dw);
+ }
+
+ if (part->boids && part->phystype == PART_PHYS_BOIDS) {
+ writestruct(wd, DATA, BoidSettings, 1, part->boids);
+
+ for (BoidState *state = part->boids->states.first; state; state = state->next) {
+ write_boid_state(wd, state);
+ }
+ }
+ if (part->fluid && part->phystype == PART_PHYS_FLUID) {
+ writestruct(wd, DATA, SPHFluidSettings, 1, part->fluid);
+ }
+
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (part->mtex[a]) {
+ writestruct(wd, DATA, MTex, 1, part->mtex[a]);
+ }
+ }
+ }
}
static void write_particlesystems(WriteData *wd, ListBase *particles)
{
- ParticleSystem *psys = particles->first;
- ParticleTarget *pt;
- int a;
-
- for (; psys; psys = psys->next) {
- writestruct(wd, DATA, ParticleSystem, 1, psys);
-
- if (psys->particles) {
- writestruct(wd, DATA, ParticleData, psys->totpart, psys->particles);
-
- if (psys->particles->hair) {
- ParticleData *pa = psys->particles;
-
- for (a = 0; a < psys->totpart; a++, pa++) {
- writestruct(wd, DATA, HairKey, pa->totkey, pa->hair);
- }
- }
-
- if (psys->particles->boid &&
- (psys->part->phystype == PART_PHYS_BOIDS))
- {
- writestruct(wd, DATA, BoidParticle, psys->totpart, psys->particles->boid);
- }
-
- if (psys->part->fluid &&
- (psys->part->phystype == PART_PHYS_FLUID) &&
- (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS))
- {
- writestruct(wd, DATA, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
- }
- }
- pt = psys->targets.first;
- for (; pt; pt = pt->next) {
- writestruct(wd, DATA, ParticleTarget, 1, pt);
- }
-
- if (psys->child) {
- writestruct(wd, DATA, ChildParticle, psys->totchild, psys->child);
- }
-
- if (psys->clmd) {
- writestruct(wd, DATA, ClothModifierData, 1, psys->clmd);
- writestruct(wd, DATA, ClothSimSettings, 1, psys->clmd->sim_parms);
- writestruct(wd, DATA, ClothCollSettings, 1, psys->clmd->coll_parms);
- }
-
- write_pointcaches(wd, &psys->ptcaches);
- }
+ ParticleSystem *psys = particles->first;
+ ParticleTarget *pt;
+ int a;
+
+ for (; psys; psys = psys->next) {
+ writestruct(wd, DATA, ParticleSystem, 1, psys);
+
+ if (psys->particles) {
+ writestruct(wd, DATA, ParticleData, psys->totpart, psys->particles);
+
+ if (psys->particles->hair) {
+ ParticleData *pa = psys->particles;
+
+ for (a = 0; a < psys->totpart; a++, pa++) {
+ writestruct(wd, DATA, HairKey, pa->totkey, pa->hair);
+ }
+ }
+
+ if (psys->particles->boid && (psys->part->phystype == PART_PHYS_BOIDS)) {
+ writestruct(wd, DATA, BoidParticle, psys->totpart, psys->particles->boid);
+ }
+
+ if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) &&
+ (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) {
+ writestruct(wd, DATA, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
+ }
+ }
+ pt = psys->targets.first;
+ for (; pt; pt = pt->next) {
+ writestruct(wd, DATA, ParticleTarget, 1, pt);
+ }
+
+ if (psys->child) {
+ writestruct(wd, DATA, ChildParticle, psys->totchild, psys->child);
+ }
+
+ if (psys->clmd) {
+ writestruct(wd, DATA, ClothModifierData, 1, psys->clmd);
+ writestruct(wd, DATA, ClothSimSettings, 1, psys->clmd->sim_parms);
+ writestruct(wd, DATA, ClothCollSettings, 1, psys->clmd->coll_parms);
+ }
+
+ write_pointcaches(wd, &psys->ptcaches);
+ }
}
static void write_motionpath(WriteData *wd, bMotionPath *mpath)
{
- /* sanity checks */
- if (mpath == NULL) {
- return;
- }
+ /* sanity checks */
+ if (mpath == NULL) {
+ return;
+ }
- /* firstly, just write the motionpath struct */
- writestruct(wd, DATA, bMotionPath, 1, mpath);
+ /* firstly, just write the motionpath struct */
+ writestruct(wd, DATA, bMotionPath, 1, mpath);
- /* now write the array of data */
- writestruct(wd, DATA, bMotionPathVert, mpath->length, mpath->points);
+ /* now write the array of data */
+ writestruct(wd, DATA, bMotionPathVert, mpath->length, mpath->points);
}
static void write_constraints(WriteData *wd, ListBase *conlist)
{
- bConstraint *con;
-
- for (con = conlist->first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
-
- /* Write the specific data */
- if (cti && con->data) {
- /* firstly, just write the plain con->data struct */
- writestruct_id(wd, DATA, cti->structName, 1, con->data);
-
- /* do any constraint specific stuff */
- switch (con->type) {
- case CONSTRAINT_TYPE_PYTHON:
- {
- bPythonConstraint *data = con->data;
- bConstraintTarget *ct;
-
- /* write targets */
- for (ct = data->targets.first; ct; ct = ct->next) {
- writestruct(wd, DATA, bConstraintTarget, 1, ct);
- }
-
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_WriteProperty(data->prop, wd);
-
- break;
- }
- case CONSTRAINT_TYPE_ARMATURE:
- {
- bArmatureConstraint *data = con->data;
- bConstraintTarget *ct;
-
- /* write targets */
- for (ct = data->targets.first; ct; ct = ct->next) {
- writestruct(wd, DATA, bConstraintTarget, 1, ct);
- }
-
- break;
- }
- case CONSTRAINT_TYPE_SPLINEIK:
- {
- bSplineIKConstraint *data = con->data;
-
- /* write points array */
- writedata(wd, DATA, sizeof(float) * (data->numpoints), data->points);
-
- break;
- }
- }
- }
-
- /* Write the constraint */
- writestruct(wd, DATA, bConstraint, 1, con);
- }
+ bConstraint *con;
+
+ for (con = conlist->first; con; con = con->next) {
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+
+ /* Write the specific data */
+ if (cti && con->data) {
+ /* firstly, just write the plain con->data struct */
+ writestruct_id(wd, DATA, cti->structName, 1, con->data);
+
+ /* do any constraint specific stuff */
+ switch (con->type) {
+ case CONSTRAINT_TYPE_PYTHON: {
+ bPythonConstraint *data = con->data;
+ bConstraintTarget *ct;
+
+ /* write targets */
+ for (ct = data->targets.first; ct; ct = ct->next) {
+ writestruct(wd, DATA, bConstraintTarget, 1, ct);
+ }
+
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_WriteProperty(data->prop, wd);
+
+ break;
+ }
+ case CONSTRAINT_TYPE_ARMATURE: {
+ bArmatureConstraint *data = con->data;
+ bConstraintTarget *ct;
+
+ /* write targets */
+ for (ct = data->targets.first; ct; ct = ct->next) {
+ writestruct(wd, DATA, bConstraintTarget, 1, ct);
+ }
+
+ break;
+ }
+ case CONSTRAINT_TYPE_SPLINEIK: {
+ bSplineIKConstraint *data = con->data;
+
+ /* write points array */
+ writedata(wd, DATA, sizeof(float) * (data->numpoints), data->points);
+
+ break;
+ }
+ }
+ }
+
+ /* Write the constraint */
+ writestruct(wd, DATA, bConstraint, 1, con);
+ }
}
static void write_pose(WriteData *wd, bPose *pose)
{
- bPoseChannel *chan;
- bActionGroup *grp;
-
- /* Write each channel */
- if (pose == NULL) {
- return;
- }
-
- /* Write channels */
- for (chan = pose->chanbase.first; chan; chan = chan->next) {
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- if (chan->prop) {
- IDP_WriteProperty(chan->prop, wd);
- }
-
- write_constraints(wd, &chan->constraints);
-
- write_motionpath(wd, chan->mpath);
-
- /* prevent crashes with autosave,
- * when a bone duplicated in editmode has not yet been assigned to its posechannel */
- if (chan->bone) {
- /* gets restored on read, for library armatures */
- chan->selectflag = chan->bone->flag & BONE_SELECTED;
- }
-
- writestruct(wd, DATA, bPoseChannel, 1, chan);
- }
-
- /* Write groups */
- for (grp = pose->agroups.first; grp; grp = grp->next) {
- writestruct(wd, DATA, bActionGroup, 1, grp);
- }
-
- /* write IK param */
- if (pose->ikparam) {
- const char *structname = BKE_pose_ikparam_get_name(pose);
- if (structname) {
- writestruct_id(wd, DATA, structname, 1, pose->ikparam);
- }
- }
-
- /* Write this pose */
- writestruct(wd, DATA, bPose, 1, pose);
-
+ bPoseChannel *chan;
+ bActionGroup *grp;
+
+ /* Write each channel */
+ if (pose == NULL) {
+ return;
+ }
+
+ /* Write channels */
+ for (chan = pose->chanbase.first; chan; chan = chan->next) {
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ if (chan->prop) {
+ IDP_WriteProperty(chan->prop, wd);
+ }
+
+ write_constraints(wd, &chan->constraints);
+
+ write_motionpath(wd, chan->mpath);
+
+ /* prevent crashes with autosave,
+ * when a bone duplicated in editmode has not yet been assigned to its posechannel */
+ if (chan->bone) {
+ /* gets restored on read, for library armatures */
+ chan->selectflag = chan->bone->flag & BONE_SELECTED;
+ }
+
+ writestruct(wd, DATA, bPoseChannel, 1, chan);
+ }
+
+ /* Write groups */
+ for (grp = pose->agroups.first; grp; grp = grp->next) {
+ writestruct(wd, DATA, bActionGroup, 1, grp);
+ }
+
+ /* write IK param */
+ if (pose->ikparam) {
+ const char *structname = BKE_pose_ikparam_get_name(pose);
+ if (structname) {
+ writestruct_id(wd, DATA, structname, 1, pose->ikparam);
+ }
+ }
+
+ /* Write this pose */
+ writestruct(wd, DATA, bPose, 1, pose);
}
static void write_defgroups(WriteData *wd, ListBase *defbase)
{
- for (bDeformGroup *defgroup = defbase->first; defgroup; defgroup = defgroup->next) {
- writestruct(wd, DATA, bDeformGroup, 1, defgroup);
- }
+ for (bDeformGroup *defgroup = defbase->first; defgroup; defgroup = defgroup->next) {
+ writestruct(wd, DATA, bDeformGroup, 1, defgroup);
+ }
}
static void write_fmaps(WriteData *wd, ListBase *fbase)
{
- for (bFaceMap *fmap = fbase->first; fmap; fmap = fmap->next) {
- writestruct(wd, DATA, bFaceMap, 1, fmap);
- }
+ for (bFaceMap *fmap = fbase->first; fmap; fmap = fmap->next) {
+ writestruct(wd, DATA, bFaceMap, 1, fmap);
+ }
}
static void write_modifiers(WriteData *wd, ListBase *modbase)
{
- ModifierData *md;
-
- if (modbase == NULL) {
- return;
- }
-
- for (md = modbase->first; md; md = md->next) {
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (mti == NULL) {
- return;
- }
-
- writestruct_id(wd, DATA, mti->structName, 1, md);
-
- if (md->type == eModifierType_Hook) {
- HookModifierData *hmd = (HookModifierData *)md;
-
- if (hmd->curfalloff) {
- write_curvemapping(wd, hmd->curfalloff);
- }
-
- writedata(wd, DATA, sizeof(int) * hmd->totindex, hmd->indexar);
- }
- else if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- writestruct(wd, DATA, ClothSimSettings, 1, clmd->sim_parms);
- writestruct(wd, DATA, ClothCollSettings, 1, clmd->coll_parms);
- writestruct(wd, DATA, EffectorWeights, 1, clmd->sim_parms->effector_weights);
- write_pointcaches(wd, &clmd->ptcaches);
- }
- else if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
-
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- writestruct(wd, DATA, SmokeDomainSettings, 1, smd->domain);
-
- if (smd->domain) {
- write_pointcaches(wd, &(smd->domain->ptcaches[0]));
-
- /* create fake pointcache so that old blender versions can read it */
- smd->domain->point_cache[1] = BKE_ptcache_add(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
- smd->domain->point_cache[1]->step = 1;
-
- write_pointcaches(wd, &(smd->domain->ptcaches[1]));
-
- if (smd->domain->coba) {
- writestruct(wd, DATA, ColorBand, 1, smd->domain->coba);
- }
-
-
- /* cleanup the fake pointcache */
- BKE_ptcache_free_list(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1] = NULL;
-
- writestruct(wd, DATA, EffectorWeights, 1, smd->domain->effector_weights);
- }
- }
- else if (smd->type & MOD_SMOKE_TYPE_FLOW) {
- writestruct(wd, DATA, SmokeFlowSettings, 1, smd->flow);
- }
- else if (smd->type & MOD_SMOKE_TYPE_COLL) {
- writestruct(wd, DATA, SmokeCollSettings, 1, smd->coll);
- }
- }
- else if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
-
- writestruct(wd, DATA, FluidsimSettings, 1, fluidmd->fss);
- }
- else if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-
- if (pmd->canvas) {
- DynamicPaintSurface *surface;
- writestruct(wd, DATA, DynamicPaintCanvasSettings, 1, pmd->canvas);
-
- /* write surfaces */
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
- writestruct(wd, DATA, DynamicPaintSurface, 1, surface);
- }
- /* write caches and effector weights */
- for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
- write_pointcaches(wd, &(surface->ptcaches));
-
- writestruct(wd, DATA, EffectorWeights, 1, surface->effector_weights);
- }
- }
- if (pmd->brush) {
- writestruct(wd, DATA, DynamicPaintBrushSettings, 1, pmd->brush);
- writestruct(wd, DATA, ColorBand, 1, pmd->brush->paint_ramp);
- writestruct(wd, DATA, ColorBand, 1, pmd->brush->vel_ramp);
- }
- }
- else if (md->type == eModifierType_Collision) {
+ ModifierData *md;
+
+ if (modbase == NULL) {
+ return;
+ }
+
+ for (md = modbase->first; md; md = md->next) {
+ const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ if (mti == NULL) {
+ return;
+ }
+
+ writestruct_id(wd, DATA, mti->structName, 1, md);
+
+ if (md->type == eModifierType_Hook) {
+ HookModifierData *hmd = (HookModifierData *)md;
+
+ if (hmd->curfalloff) {
+ write_curvemapping(wd, hmd->curfalloff);
+ }
+
+ writedata(wd, DATA, sizeof(int) * hmd->totindex, hmd->indexar);
+ }
+ else if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ writestruct(wd, DATA, ClothSimSettings, 1, clmd->sim_parms);
+ writestruct(wd, DATA, ClothCollSettings, 1, clmd->coll_parms);
+ writestruct(wd, DATA, EffectorWeights, 1, clmd->sim_parms->effector_weights);
+ write_pointcaches(wd, &clmd->ptcaches);
+ }
+ else if (md->type == eModifierType_Smoke) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+ writestruct(wd, DATA, SmokeDomainSettings, 1, smd->domain);
+
+ if (smd->domain) {
+ write_pointcaches(wd, &(smd->domain->ptcaches[0]));
+
+ /* create fake pointcache so that old blender versions can read it */
+ smd->domain->point_cache[1] = BKE_ptcache_add(&smd->domain->ptcaches[1]);
+ smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
+ smd->domain->point_cache[1]->step = 1;
+
+ write_pointcaches(wd, &(smd->domain->ptcaches[1]));
+
+ if (smd->domain->coba) {
+ writestruct(wd, DATA, ColorBand, 1, smd->domain->coba);
+ }
+
+ /* cleanup the fake pointcache */
+ BKE_ptcache_free_list(&smd->domain->ptcaches[1]);
+ smd->domain->point_cache[1] = NULL;
+
+ writestruct(wd, DATA, EffectorWeights, 1, smd->domain->effector_weights);
+ }
+ }
+ else if (smd->type & MOD_SMOKE_TYPE_FLOW) {
+ writestruct(wd, DATA, SmokeFlowSettings, 1, smd->flow);
+ }
+ else if (smd->type & MOD_SMOKE_TYPE_COLL) {
+ writestruct(wd, DATA, SmokeCollSettings, 1, smd->coll);
+ }
+ }
+ else if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
+
+ writestruct(wd, DATA, FluidsimSettings, 1, fluidmd->fss);
+ }
+ else if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+
+ if (pmd->canvas) {
+ DynamicPaintSurface *surface;
+ writestruct(wd, DATA, DynamicPaintCanvasSettings, 1, pmd->canvas);
+
+ /* write surfaces */
+ for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ writestruct(wd, DATA, DynamicPaintSurface, 1, surface);
+ }
+ /* write caches and effector weights */
+ for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
+ write_pointcaches(wd, &(surface->ptcaches));
+
+ writestruct(wd, DATA, EffectorWeights, 1, surface->effector_weights);
+ }
+ }
+ if (pmd->brush) {
+ writestruct(wd, DATA, DynamicPaintBrushSettings, 1, pmd->brush);
+ writestruct(wd, DATA, ColorBand, 1, pmd->brush->paint_ramp);
+ writestruct(wd, DATA, ColorBand, 1, pmd->brush->vel_ramp);
+ }
+ }
+ else if (md->type == eModifierType_Collision) {
#if 0
- CollisionModifierData *collmd = (CollisionModifierData *)md;
- // TODO: CollisionModifier should use pointcache
- // + have proper reset events before enabling this
- writestruct(wd, DATA, MVert, collmd->numverts, collmd->x);
- writestruct(wd, DATA, MVert, collmd->numverts, collmd->xnew);
- writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
+ CollisionModifierData *collmd = (CollisionModifierData *)md;
+ // TODO: CollisionModifier should use pointcache
+ // + have proper reset events before enabling this
+ writestruct(wd, DATA, MVert, collmd->numverts, collmd->x);
+ writestruct(wd, DATA, MVert, collmd->numverts, collmd->xnew);
+ writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
#endif
- }
- else if (md->type == eModifierType_MeshDeform) {
- MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
- int size = mmd->dyngridsize;
-
- writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->bindinfluences);
- writedata(wd, DATA, sizeof(int) * (mmd->totvert + 1), mmd->bindoffsets);
- writedata(wd, DATA, sizeof(float) * 3 * mmd->totcagevert,
- mmd->bindcagecos);
- writestruct(wd, DATA, MDefCell, size * size * size, mmd->dyngrid);
- writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->dyninfluences);
- writedata(wd, DATA, sizeof(int) * mmd->totvert, mmd->dynverts);
- }
- else if (md->type == eModifierType_Warp) {
- WarpModifierData *tmd = (WarpModifierData *)md;
- if (tmd->curfalloff) {
- write_curvemapping(wd, tmd->curfalloff);
- }
- }
- else if (md->type == eModifierType_WeightVGEdit) {
- WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
-
- if (wmd->cmap_curve) {
- write_curvemapping(wd, wmd->cmap_curve);
- }
- }
- else if (md->type == eModifierType_LaplacianDeform) {
- LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
-
- writedata(wd, DATA, sizeof(float) * lmd->total_verts * 3, lmd->vertexco);
- }
- else if (md->type == eModifierType_CorrectiveSmooth) {
- CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
-
- if (csmd->bind_coords) {
- writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords);
- }
- }
- else if (md->type == eModifierType_SurfaceDeform) {
- SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
-
- writestruct(wd, DATA, SDefVert, smd->numverts, smd->verts);
-
- if (smd->verts) {
- for (int i = 0; i < smd->numverts; i++) {
- writestruct(wd, DATA, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds);
-
- if (smd->verts[i].binds) {
- for (int j = 0; j < smd->verts[i].numbinds; j++) {
- writedata(wd, DATA, sizeof(int) * smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_inds);
-
- if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
- smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI)
- {
- writedata(wd, DATA, sizeof(float) * 3, smd->verts[i].binds[j].vert_weights);
- }
- else {
- writedata(wd, DATA, sizeof(float) * smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_weights);
- }
- }
- }
- }
- }
- }
- }
+ }
+ else if (md->type == eModifierType_MeshDeform) {
+ MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
+ int size = mmd->dyngridsize;
+
+ writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->bindinfluences);
+ writedata(wd, DATA, sizeof(int) * (mmd->totvert + 1), mmd->bindoffsets);
+ writedata(wd, DATA, sizeof(float) * 3 * mmd->totcagevert, mmd->bindcagecos);
+ writestruct(wd, DATA, MDefCell, size * size * size, mmd->dyngrid);
+ writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->dyninfluences);
+ writedata(wd, DATA, sizeof(int) * mmd->totvert, mmd->dynverts);
+ }
+ else if (md->type == eModifierType_Warp) {
+ WarpModifierData *tmd = (WarpModifierData *)md;
+ if (tmd->curfalloff) {
+ write_curvemapping(wd, tmd->curfalloff);
+ }
+ }
+ else if (md->type == eModifierType_WeightVGEdit) {
+ WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
+
+ if (wmd->cmap_curve) {
+ write_curvemapping(wd, wmd->cmap_curve);
+ }
+ }
+ else if (md->type == eModifierType_LaplacianDeform) {
+ LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
+
+ writedata(wd, DATA, sizeof(float) * lmd->total_verts * 3, lmd->vertexco);
+ }
+ else if (md->type == eModifierType_CorrectiveSmooth) {
+ CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
+
+ if (csmd->bind_coords) {
+ writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords);
+ }
+ }
+ else if (md->type == eModifierType_SurfaceDeform) {
+ SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
+
+ writestruct(wd, DATA, SDefVert, smd->numverts, smd->verts);
+
+ if (smd->verts) {
+ for (int i = 0; i < smd->numverts; i++) {
+ writestruct(wd, DATA, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds);
+
+ if (smd->verts[i].binds) {
+ for (int j = 0; j < smd->verts[i].numbinds; j++) {
+ writedata(wd,
+ DATA,
+ sizeof(int) * smd->verts[i].binds[j].numverts,
+ smd->verts[i].binds[j].vert_inds);
+
+ if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
+ smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
+ writedata(wd, DATA, sizeof(float) * 3, smd->verts[i].binds[j].vert_weights);
+ }
+ else {
+ writedata(wd,
+ DATA,
+ sizeof(float) * smd->verts[i].binds[j].numverts,
+ smd->verts[i].binds[j].vert_weights);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
{
- GpencilModifierData *md;
-
- if (modbase == NULL) {
- return;
- }
-
- for (md = modbase->first; md; md = md->next) {
- const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
- if (mti == NULL) {
- return;
- }
-
- writestruct_id(wd, DATA, mti->struct_name, 1, md);
-
- if (md->type == eGpencilModifierType_Thick) {
- ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
-
- if (gpmd->curve_thickness) {
- write_curvemapping(wd, gpmd->curve_thickness);
- }
- }
- else if (md->type == eGpencilModifierType_Hook) {
- HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
-
- if (gpmd->curfalloff) {
- write_curvemapping(wd, gpmd->curfalloff);
- }
- }
- }
+ GpencilModifierData *md;
+
+ if (modbase == NULL) {
+ return;
+ }
+
+ for (md = modbase->first; md; md = md->next) {
+ const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
+ if (mti == NULL) {
+ return;
+ }
+
+ writestruct_id(wd, DATA, mti->struct_name, 1, md);
+
+ if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+
+ if (gpmd->curve_thickness) {
+ write_curvemapping(wd, gpmd->curve_thickness);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
+
+ if (gpmd->curfalloff) {
+ write_curvemapping(wd, gpmd->curfalloff);
+ }
+ }
+ }
}
static void write_shaderfxs(WriteData *wd, ListBase *fxbase)
{
- ShaderFxData *fx;
+ ShaderFxData *fx;
- if (fxbase == NULL) {
- return;
- }
+ if (fxbase == NULL) {
+ return;
+ }
- for (fx = fxbase->first; fx; fx = fx->next) {
- const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
- if (fxi == NULL) {
- return;
- }
+ for (fx = fxbase->first; fx; fx = fx->next) {
+ const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
+ if (fxi == NULL) {
+ return;
+ }
- writestruct_id(wd, DATA, fxi->struct_name, 1, fx);
- }
+ writestruct_id(wd, DATA, fxi->struct_name, 1, fx);
+ }
}
static void write_object(WriteData *wd, Object *ob)
{
- if (ob->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_OB, Object, 1, ob);
- write_iddata(wd, &ob->id);
-
- if (ob->adt) {
- write_animdata(wd, ob->adt);
- }
-
- /* direct data */
- writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat);
- writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits);
- /* write_effects(wd, &ob->effect); */ /* not used anymore */
-
- if (ob->type == OB_ARMATURE) {
- bArmature *arm = ob->data;
- if (arm && ob->pose && arm->act_bone) {
- BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
- }
- }
-
- write_pose(wd, ob->pose);
- write_defgroups(wd, &ob->defbase);
- write_fmaps(wd, &ob->fmaps);
- write_constraints(wd, &ob->constraints);
- write_motionpath(wd, ob->mpath);
-
- writestruct(wd, DATA, PartDeflect, 1, ob->pd);
- if (ob->soft) {
- /* Set deprecated pointers to prevent crashes of older Blenders */
- ob->soft->pointcache = ob->soft->shared->pointcache;
- ob->soft->ptcaches = ob->soft->shared->ptcaches;
- writestruct(wd, DATA, SoftBody, 1, ob->soft);
- writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared);
- write_pointcaches(wd, &(ob->soft->shared->ptcaches));
- writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
- }
-
- if (ob->rigidbody_object) {
- /* TODO: if any extra data is added to handle duplis, will need separate function then */
- writestruct(wd, DATA, RigidBodyOb, 1, ob->rigidbody_object);
- }
- if (ob->rigidbody_constraint) {
- writestruct(wd, DATA, RigidBodyCon, 1, ob->rigidbody_constraint);
- }
-
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
- writestruct(wd, DATA, ImageUser, 1, ob->iuser);
- }
-
- write_particlesystems(wd, &ob->particlesystem);
- write_modifiers(wd, &ob->modifiers);
- write_gpencil_modifiers(wd, &ob->greasepencil_modifiers);
- write_shaderfxs(wd, &ob->shader_fx);
-
- writelist(wd, DATA, LinkData, &ob->pc_ids);
- writelist(wd, DATA, LodLevel, &ob->lodlevels);
-
- write_previews(wd, ob->preview);
- }
+ if (ob->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_OB, Object, 1, ob);
+ write_iddata(wd, &ob->id);
+
+ if (ob->adt) {
+ write_animdata(wd, ob->adt);
+ }
+
+ /* direct data */
+ writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat);
+ writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits);
+ /* write_effects(wd, &ob->effect); */ /* not used anymore */
+
+ if (ob->type == OB_ARMATURE) {
+ bArmature *arm = ob->data;
+ if (arm && ob->pose && arm->act_bone) {
+ BLI_strncpy(
+ ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
+ }
+ }
+
+ write_pose(wd, ob->pose);
+ write_defgroups(wd, &ob->defbase);
+ write_fmaps(wd, &ob->fmaps);
+ write_constraints(wd, &ob->constraints);
+ write_motionpath(wd, ob->mpath);
+
+ writestruct(wd, DATA, PartDeflect, 1, ob->pd);
+ if (ob->soft) {
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ ob->soft->pointcache = ob->soft->shared->pointcache;
+ ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ writestruct(wd, DATA, SoftBody, 1, ob->soft);
+ writestruct(wd, DATA, SoftBody_Shared, 1, ob->soft->shared);
+ write_pointcaches(wd, &(ob->soft->shared->ptcaches));
+ writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
+ }
+
+ if (ob->rigidbody_object) {
+ /* TODO: if any extra data is added to handle duplis, will need separate function then */
+ writestruct(wd, DATA, RigidBodyOb, 1, ob->rigidbody_object);
+ }
+ if (ob->rigidbody_constraint) {
+ writestruct(wd, DATA, RigidBodyCon, 1, ob->rigidbody_constraint);
+ }
+
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
+ writestruct(wd, DATA, ImageUser, 1, ob->iuser);
+ }
+
+ write_particlesystems(wd, &ob->particlesystem);
+ write_modifiers(wd, &ob->modifiers);
+ write_gpencil_modifiers(wd, &ob->greasepencil_modifiers);
+ write_shaderfxs(wd, &ob->shader_fx);
+
+ writelist(wd, DATA, LinkData, &ob->pc_ids);
+ writelist(wd, DATA, LodLevel, &ob->lodlevels);
+
+ write_previews(wd, ob->preview);
+ }
}
-
static void write_vfont(WriteData *wd, VFont *vf)
{
- if (vf->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_VF, VFont, 1, vf);
- write_iddata(wd, &vf->id);
-
- /* direct data */
- if (vf->packedfile) {
- PackedFile *pf = vf->packedfile;
- writestruct(wd, DATA, PackedFile, 1, pf);
- writedata(wd, DATA, pf->size, pf->data);
- }
- }
+ if (vf->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_VF, VFont, 1, vf);
+ write_iddata(wd, &vf->id);
+
+ /* direct data */
+ if (vf->packedfile) {
+ PackedFile *pf = vf->packedfile;
+ writestruct(wd, DATA, PackedFile, 1, pf);
+ writedata(wd, DATA, pf->size, pf->data);
+ }
+ }
}
-
static void write_key(WriteData *wd, Key *key)
{
- if (key->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_KE, Key, 1, key);
- write_iddata(wd, &key->id);
-
- if (key->adt) {
- write_animdata(wd, key->adt);
- }
-
- /* direct data */
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
- writestruct(wd, DATA, KeyBlock, 1, kb);
- if (kb->data) {
- writedata(wd, DATA, kb->totelem * key->elemsize, kb->data);
- }
- }
- }
+ if (key->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_KE, Key, 1, key);
+ write_iddata(wd, &key->id);
+
+ if (key->adt) {
+ write_animdata(wd, key->adt);
+ }
+
+ /* direct data */
+ for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ writestruct(wd, DATA, KeyBlock, 1, kb);
+ if (kb->data) {
+ writedata(wd, DATA, kb->totelem * key->elemsize, kb->data);
+ }
+ }
+ }
}
static void write_camera(WriteData *wd, Camera *cam)
{
- if (cam->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_CA, Camera, 1, cam);
- write_iddata(wd, &cam->id);
-
- if (cam->adt) {
- write_animdata(wd, cam->adt);
- }
-
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
- writestruct(wd, DATA, CameraBGImage, 1, bgpic);
- }
- }
+ if (cam->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_CA, Camera, 1, cam);
+ write_iddata(wd, &cam->id);
+
+ if (cam->adt) {
+ write_animdata(wd, cam->adt);
+ }
+
+ for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ writestruct(wd, DATA, CameraBGImage, 1, bgpic);
+ }
+ }
}
static void write_mball(WriteData *wd, MetaBall *mb)
{
- if (mb->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_MB, MetaBall, 1, mb);
- write_iddata(wd, &mb->id);
-
- /* direct data */
- writedata(wd, DATA, sizeof(void *) * mb->totcol, mb->mat);
- if (mb->adt) {
- write_animdata(wd, mb->adt);
- }
-
- for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
- writestruct(wd, DATA, MetaElem, 1, ml);
- }
- }
+ if (mb->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_MB, MetaBall, 1, mb);
+ write_iddata(wd, &mb->id);
+
+ /* direct data */
+ writedata(wd, DATA, sizeof(void *) * mb->totcol, mb->mat);
+ if (mb->adt) {
+ write_animdata(wd, mb->adt);
+ }
+
+ for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ writestruct(wd, DATA, MetaElem, 1, ml);
+ }
+ }
}
static void write_curve(WriteData *wd, Curve *cu)
{
- if (cu->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_CU, Curve, 1, cu);
- write_iddata(wd, &cu->id);
-
- /* direct data */
- writedata(wd, DATA, sizeof(void *) * cu->totcol, cu->mat);
- if (cu->adt) {
- write_animdata(wd, cu->adt);
- }
-
- if (cu->vfont) {
- writedata(wd, DATA, cu->len + 1, cu->str);
- writestruct(wd, DATA, CharInfo, cu->len_wchar + 1, cu->strinfo);
- writestruct(wd, DATA, TextBox, cu->totbox, cu->tb);
- }
- else {
- /* is also the order of reading */
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
- writestruct(wd, DATA, Nurb, 1, nu);
- }
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt);
- }
- else {
- writestruct(wd, DATA, BPoint, nu->pntsu * nu->pntsv, nu->bp);
- if (nu->knotsu) {
- writedata(wd, DATA, KNOTSU(nu) * sizeof(float), nu->knotsu);
- }
- if (nu->knotsv) {
- writedata(wd, DATA, KNOTSV(nu) * sizeof(float), nu->knotsv);
- }
- }
- }
- }
- }
+ if (cu->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_CU, Curve, 1, cu);
+ write_iddata(wd, &cu->id);
+
+ /* direct data */
+ writedata(wd, DATA, sizeof(void *) * cu->totcol, cu->mat);
+ if (cu->adt) {
+ write_animdata(wd, cu->adt);
+ }
+
+ if (cu->vfont) {
+ writedata(wd, DATA, cu->len + 1, cu->str);
+ writestruct(wd, DATA, CharInfo, cu->len_wchar + 1, cu->strinfo);
+ writestruct(wd, DATA, TextBox, cu->totbox, cu->tb);
+ }
+ else {
+ /* is also the order of reading */
+ for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ writestruct(wd, DATA, Nurb, 1, nu);
+ }
+ for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ if (nu->type == CU_BEZIER) {
+ writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt);
+ }
+ else {
+ writestruct(wd, DATA, BPoint, nu->pntsu * nu->pntsv, nu->bp);
+ if (nu->knotsu) {
+ writedata(wd, DATA, KNOTSU(nu) * sizeof(float), nu->knotsu);
+ }
+ if (nu->knotsv) {
+ writedata(wd, DATA, KNOTSV(nu) * sizeof(float), nu->knotsv);
+ }
+ }
+ }
+ }
+ }
}
static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
{
- if (dvlist) {
-
- /* Write the dvert list */
- writestruct(wd, DATA, MDeformVert, count, dvlist);
-
- /* Write deformation data for each dvert */
- for (int i = 0; i < count; i++) {
- if (dvlist[i].dw) {
- writestruct(wd, DATA, MDeformWeight, dvlist[i].totweight, dvlist[i].dw);
- }
- }
- }
+ if (dvlist) {
+
+ /* Write the dvert list */
+ writestruct(wd, DATA, MDeformVert, count, dvlist);
+
+ /* Write deformation data for each dvert */
+ for (int i = 0; i < count; i++) {
+ if (dvlist[i].dw) {
+ writestruct(wd, DATA, MDeformWeight, dvlist[i].totweight, dvlist[i].dw);
+ }
+ }
+ }
}
static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external)
{
- if (mdlist) {
- int i;
-
- writestruct(wd, DATA, MDisps, count, mdlist);
- for (i = 0; i < count; ++i) {
- MDisps *md = &mdlist[i];
- if (md->disps) {
- if (!external) {
- writedata(wd, DATA, sizeof(float) * 3 * md->totdisp, md->disps);
- }
- }
-
- if (md->hidden) {
- writedata(wd, DATA, BLI_BITMAP_SIZE(md->totdisp), md->hidden);
- }
- }
- }
+ if (mdlist) {
+ int i;
+
+ writestruct(wd, DATA, MDisps, count, mdlist);
+ for (i = 0; i < count; ++i) {
+ MDisps *md = &mdlist[i];
+ if (md->disps) {
+ if (!external) {
+ writedata(wd, DATA, sizeof(float) * 3 * md->totdisp, md->disps);
+ }
+ }
+
+ if (md->hidden) {
+ writedata(wd, DATA, BLI_BITMAP_SIZE(md->totdisp), md->hidden);
+ }
+ }
+ }
}
static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_paint_mask)
{
- if (grid_paint_mask) {
- int i;
-
- writestruct(wd, DATA, GridPaintMask, count, grid_paint_mask);
- for (i = 0; i < count; ++i) {
- GridPaintMask *gpm = &grid_paint_mask[i];
- if (gpm->data) {
- const int gridsize = BKE_ccg_gridsize(gpm->level);
- writedata(wd, DATA,
- sizeof(*gpm->data) * gridsize * gridsize,
- gpm->data);
- }
- }
- }
+ if (grid_paint_mask) {
+ int i;
+
+ writestruct(wd, DATA, GridPaintMask, count, grid_paint_mask);
+ for (i = 0; i < count; ++i) {
+ GridPaintMask *gpm = &grid_paint_mask[i];
+ if (gpm->data) {
+ const int gridsize = BKE_ccg_gridsize(gpm->level);
+ writedata(wd, DATA, sizeof(*gpm->data) * gridsize * gridsize, gpm->data);
+ }
+ }
+ }
}
-static void write_customdata(
- WriteData *wd, ID *id,
- int count, CustomData *data, CustomDataLayer *layers, CustomDataMask cddata_mask,
- int partial_type, int partial_count)
+static void write_customdata(WriteData *wd,
+ ID *id,
+ int count,
+ CustomData *data,
+ CustomDataLayer *layers,
+ CustomDataMask cddata_mask,
+ int partial_type,
+ int partial_count)
{
- int i;
-
- /* write external customdata (not for undo) */
- if (data->external && (wd->use_memfile == false)) {
- CustomData_external_write(data, id, cddata_mask, count, 0);
- }
-
- writestruct_at_address(wd, DATA, CustomDataLayer, data->totlayer, data->layers, layers);
-
- for (i = 0; i < data->totlayer; i++) {
- CustomDataLayer *layer = &layers[i];
- const char *structname;
- int structnum, datasize;
-
- if (layer->type == CD_MDEFORMVERT) {
- /* layer types that allocate own memory need special handling */
- write_dverts(wd, count, layer->data);
- }
- else if (layer->type == CD_MDISPS) {
- write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
- }
- else if (layer->type == CD_PAINT_MASK) {
- const float *layer_data = layer->data;
- writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
- }
- else if (layer->type == CD_GRID_PAINT_MASK) {
- write_grid_paint_mask(wd, count, layer->data);
- }
- else if (layer->type == CD_FACEMAP) {
- const int *layer_data = layer->data;
- writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
- }
- else {
- CustomData_file_write_info(layer->type, &structname, &structnum);
- if (structnum) {
- /* when using partial visibility, the MEdge and MFace layers
- * are smaller than the original, so their type and count is
- * passed to make this work */
- if (layer->type != partial_type) {
- datasize = structnum * count;
- }
- else {
- datasize = structnum * partial_count;
- }
-
- writestruct_id(wd, DATA, structname, datasize, layer->data);
- }
- else {
- printf("%s error: layer '%s':%d - can't be written to file\n",
- __func__, structname, layer->type);
- }
- }
- }
-
- if (data->external) {
- writestruct(wd, DATA, CustomDataExternal, 1, data->external);
- }
+ int i;
+
+ /* write external customdata (not for undo) */
+ if (data->external && (wd->use_memfile == false)) {
+ CustomData_external_write(data, id, cddata_mask, count, 0);
+ }
+
+ writestruct_at_address(wd, DATA, CustomDataLayer, data->totlayer, data->layers, layers);
+
+ for (i = 0; i < data->totlayer; i++) {
+ CustomDataLayer *layer = &layers[i];
+ const char *structname;
+ int structnum, datasize;
+
+ if (layer->type == CD_MDEFORMVERT) {
+ /* layer types that allocate own memory need special handling */
+ write_dverts(wd, count, layer->data);
+ }
+ else if (layer->type == CD_MDISPS) {
+ write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
+ }
+ else if (layer->type == CD_PAINT_MASK) {
+ const float *layer_data = layer->data;
+ writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
+ }
+ else if (layer->type == CD_GRID_PAINT_MASK) {
+ write_grid_paint_mask(wd, count, layer->data);
+ }
+ else if (layer->type == CD_FACEMAP) {
+ const int *layer_data = layer->data;
+ writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
+ }
+ else {
+ CustomData_file_write_info(layer->type, &structname, &structnum);
+ if (structnum) {
+ /* when using partial visibility, the MEdge and MFace layers
+ * are smaller than the original, so their type and count is
+ * passed to make this work */
+ if (layer->type != partial_type) {
+ datasize = structnum * count;
+ }
+ else {
+ datasize = structnum * partial_count;
+ }
+
+ writestruct_id(wd, DATA, structname, datasize, layer->data);
+ }
+ else {
+ printf("%s error: layer '%s':%d - can't be written to file\n",
+ __func__,
+ structname,
+ layer->type);
+ }
+ }
+ }
+
+ if (data->external) {
+ writestruct(wd, DATA, CustomDataExternal, 1, data->external);
+ }
}
static void write_mesh(WriteData *wd, Mesh *mesh)
{
- CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
-
- if (mesh->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- {
- /* write a copy of the mesh, don't modify in place because it is
- * not thread safe for threaded renders that are reading this */
- Mesh *old_mesh = mesh;
- Mesh copy_mesh = *mesh;
- mesh = &copy_mesh;
-
- /* cache only - don't write */
- mesh->mface = NULL;
- mesh->totface = 0;
- memset(&mesh->fdata, 0, sizeof(mesh->fdata));
-
- /**
- * Those calls:
- * - Reduce mesh->xdata.totlayer to number of layers to write.
- * - Fill xlayers with those layers to be written.
- * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is
- * a temp local copy!
- */
- CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
- CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
- flayers = flayers_buff;
- CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
- CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
-
- writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
- write_iddata(wd, &mesh->id);
-
- /* direct data */
- if (mesh->adt) {
- write_animdata(wd, mesh->adt);
- }
-
- writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
- writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect);
-
- write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, CD_MASK_MESH.vmask, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, CD_MASK_MESH.emask, -1, 0);
- /* fdata is really a dummy - written so slots align */
- write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, CD_MASK_MESH.fmask, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask, -1, 0);
-
- /* restore pointer */
- mesh = old_mesh;
- }
- }
-
- if (vlayers && vlayers != vlayers_buff) {
- MEM_freeN(vlayers);
- }
- if (elayers && elayers != elayers_buff) {
- MEM_freeN(elayers);
- }
- if (flayers && flayers != flayers_buff) {
- MEM_freeN(flayers);
- }
- if (llayers && llayers != llayers_buff) {
- MEM_freeN(llayers);
- }
- if (players && players != players_buff) {
- MEM_freeN(players);
- }
+ CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+
+ if (mesh->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ {
+ /* write a copy of the mesh, don't modify in place because it is
+ * not thread safe for threaded renders that are reading this */
+ Mesh *old_mesh = mesh;
+ Mesh copy_mesh = *mesh;
+ mesh = &copy_mesh;
+
+ /* cache only - don't write */
+ mesh->mface = NULL;
+ mesh->totface = 0;
+ memset(&mesh->fdata, 0, sizeof(mesh->fdata));
+
+ /**
+ * Those calls:
+ * - Reduce mesh->xdata.totlayer to number of layers to write.
+ * - Fill xlayers with those layers to be written.
+ * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is
+ * a temp local copy!
+ */
+ CustomData_file_write_prepare(
+ &mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
+ CustomData_file_write_prepare(
+ &mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
+ flayers = flayers_buff;
+ CustomData_file_write_prepare(
+ &mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
+ CustomData_file_write_prepare(
+ &mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+
+ writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
+ write_iddata(wd, &mesh->id);
+
+ /* direct data */
+ if (mesh->adt) {
+ write_animdata(wd, mesh->adt);
+ }
+
+ writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
+ writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect);
+
+ write_customdata(
+ wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, CD_MASK_MESH.vmask, -1, 0);
+ write_customdata(
+ wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, CD_MASK_MESH.emask, -1, 0);
+ /* fdata is really a dummy - written so slots align */
+ write_customdata(
+ wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, CD_MASK_MESH.fmask, -1, 0);
+ write_customdata(
+ wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask, -1, 0);
+ write_customdata(
+ wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask, -1, 0);
+
+ /* restore pointer */
+ mesh = old_mesh;
+ }
+ }
+
+ if (vlayers && vlayers != vlayers_buff) {
+ MEM_freeN(vlayers);
+ }
+ if (elayers && elayers != elayers_buff) {
+ MEM_freeN(elayers);
+ }
+ if (flayers && flayers != flayers_buff) {
+ MEM_freeN(flayers);
+ }
+ if (llayers && llayers != llayers_buff) {
+ MEM_freeN(llayers);
+ }
+ if (players && players != players_buff) {
+ MEM_freeN(players);
+ }
}
static void write_lattice(WriteData *wd, Lattice *lt)
{
- if (lt->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_LT, Lattice, 1, lt);
- write_iddata(wd, &lt->id);
+ if (lt->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_LT, Lattice, 1, lt);
+ write_iddata(wd, &lt->id);
- /* write animdata */
- if (lt->adt) {
- write_animdata(wd, lt->adt);
- }
+ /* write animdata */
+ if (lt->adt) {
+ write_animdata(wd, lt->adt);
+ }
- /* direct data */
- writestruct(wd, DATA, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
+ /* direct data */
+ writestruct(wd, DATA, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
- write_dverts(wd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
- }
+ write_dverts(wd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
+ }
}
static void write_image(WriteData *wd, Image *ima)
{
- if (ima->id.us > 0 || wd->use_memfile) {
- ImagePackedFile *imapf;
-
- /* Some trickery to keep forward compatibility of packed images. */
- BLI_assert(ima->packedfile == NULL);
- if (ima->packedfiles.first != NULL) {
- imapf = ima->packedfiles.first;
- ima->packedfile = imapf->packedfile;
- }
-
- /* write LibData */
- writestruct(wd, ID_IM, Image, 1, ima);
- write_iddata(wd, &ima->id);
-
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
- writestruct(wd, DATA, ImagePackedFile, 1, imapf);
- if (imapf->packedfile) {
- PackedFile *pf = imapf->packedfile;
- writestruct(wd, DATA, PackedFile, 1, pf);
- writedata(wd, DATA, pf->size, pf->data);
- }
- }
-
- write_previews(wd, ima->preview);
-
- for (ImageView *iv = ima->views.first; iv; iv = iv->next) {
- writestruct(wd, DATA, ImageView, 1, iv);
- }
- writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format);
-
- ima->packedfile = NULL;
-
- writelist(wd, DATA, RenderSlot, &ima->renderslots);
- }
+ if (ima->id.us > 0 || wd->use_memfile) {
+ ImagePackedFile *imapf;
+
+ /* Some trickery to keep forward compatibility of packed images. */
+ BLI_assert(ima->packedfile == NULL);
+ if (ima->packedfiles.first != NULL) {
+ imapf = ima->packedfiles.first;
+ ima->packedfile = imapf->packedfile;
+ }
+
+ /* write LibData */
+ writestruct(wd, ID_IM, Image, 1, ima);
+ write_iddata(wd, &ima->id);
+
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ writestruct(wd, DATA, ImagePackedFile, 1, imapf);
+ if (imapf->packedfile) {
+ PackedFile *pf = imapf->packedfile;
+ writestruct(wd, DATA, PackedFile, 1, pf);
+ writedata(wd, DATA, pf->size, pf->data);
+ }
+ }
+
+ write_previews(wd, ima->preview);
+
+ for (ImageView *iv = ima->views.first; iv; iv = iv->next) {
+ writestruct(wd, DATA, ImageView, 1, iv);
+ }
+ writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format);
+
+ ima->packedfile = NULL;
+
+ writelist(wd, DATA, RenderSlot, &ima->renderslots);
+ }
}
static void write_texture(WriteData *wd, Tex *tex)
{
- if (tex->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_TE, Tex, 1, tex);
- write_iddata(wd, &tex->id);
-
- if (tex->adt) {
- write_animdata(wd, tex->adt);
- }
-
- /* direct data */
- if (tex->coba) {
- writestruct(wd, DATA, ColorBand, 1, tex->coba);
- }
-
- /* nodetree is integral part of texture, no libdata */
- if (tex->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, tex->nodetree);
- write_nodetree_nolib(wd, tex->nodetree);
- }
-
- write_previews(wd, tex->preview);
- }
+ if (tex->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_TE, Tex, 1, tex);
+ write_iddata(wd, &tex->id);
+
+ if (tex->adt) {
+ write_animdata(wd, tex->adt);
+ }
+
+ /* direct data */
+ if (tex->coba) {
+ writestruct(wd, DATA, ColorBand, 1, tex->coba);
+ }
+
+ /* nodetree is integral part of texture, no libdata */
+ if (tex->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, tex->nodetree);
+ write_nodetree_nolib(wd, tex->nodetree);
+ }
+
+ write_previews(wd, tex->preview);
+ }
}
static void write_material(WriteData *wd, Material *ma)
{
- if (ma->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_MA, Material, 1, ma);
- write_iddata(wd, &ma->id);
-
- if (ma->adt) {
- write_animdata(wd, ma->adt);
- }
-
- /* nodetree is integral part of material, no libdata */
- if (ma->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, ma->nodetree);
- write_nodetree_nolib(wd, ma->nodetree);
- }
-
- write_previews(wd, ma->preview);
-
- /* grease pencil settings */
- if (ma->gp_style) {
- writestruct(wd, DATA, MaterialGPencilStyle, 1, ma->gp_style);
- }
- }
+ if (ma->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_MA, Material, 1, ma);
+ write_iddata(wd, &ma->id);
+
+ if (ma->adt) {
+ write_animdata(wd, ma->adt);
+ }
+
+ /* nodetree is integral part of material, no libdata */
+ if (ma->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, ma->nodetree);
+ write_nodetree_nolib(wd, ma->nodetree);
+ }
+
+ write_previews(wd, ma->preview);
+
+ /* grease pencil settings */
+ if (ma->gp_style) {
+ writestruct(wd, DATA, MaterialGPencilStyle, 1, ma->gp_style);
+ }
+ }
}
static void write_world(WriteData *wd, World *wrld)
{
- if (wrld->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_WO, World, 1, wrld);
- write_iddata(wd, &wrld->id);
-
- if (wrld->adt) {
- write_animdata(wd, wrld->adt);
- }
-
- /* nodetree is integral part of world, no libdata */
- if (wrld->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree);
- write_nodetree_nolib(wd, wrld->nodetree);
- }
-
- write_previews(wd, wrld->preview);
- }
+ if (wrld->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_WO, World, 1, wrld);
+ write_iddata(wd, &wrld->id);
+
+ if (wrld->adt) {
+ write_animdata(wd, wrld->adt);
+ }
+
+ /* nodetree is integral part of world, no libdata */
+ if (wrld->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree);
+ write_nodetree_nolib(wd, wrld->nodetree);
+ }
+
+ write_previews(wd, wrld->preview);
+ }
}
static void write_light(WriteData *wd, Light *la)
{
- if (la->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_LA, Light, 1, la);
- write_iddata(wd, &la->id);
-
- if (la->adt) {
- write_animdata(wd, la->adt);
- }
-
- if (la->curfalloff) {
- write_curvemapping(wd, la->curfalloff);
- }
-
- /* Node-tree is integral part of lights, no libdata. */
- if (la->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, la->nodetree);
- write_nodetree_nolib(wd, la->nodetree);
- }
-
- write_previews(wd, la->preview);
- }
+ if (la->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_LA, Light, 1, la);
+ write_iddata(wd, &la->id);
+
+ if (la->adt) {
+ write_animdata(wd, la->adt);
+ }
+
+ if (la->curfalloff) {
+ write_curvemapping(wd, la->curfalloff);
+ }
+
+ /* Node-tree is integral part of lights, no libdata. */
+ if (la->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, la->nodetree);
+ write_nodetree_nolib(wd, la->nodetree);
+ }
+
+ write_previews(wd, la->preview);
+ }
}
static void write_collection_nolib(WriteData *wd, Collection *collection)
{
- /* Shared function for collection datablocks and scene master collection. */
- write_previews(wd, collection->preview);
+ /* Shared function for collection datablocks and scene master collection. */
+ write_previews(wd, collection->preview);
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
- writestruct(wd, DATA, CollectionObject, 1, cob);
- }
+ for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ writestruct(wd, DATA, CollectionObject, 1, cob);
+ }
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
- writestruct(wd, DATA, CollectionChild, 1, child);
- }
+ for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ writestruct(wd, DATA, CollectionChild, 1, child);
+ }
}
static void write_collection(WriteData *wd, Collection *collection)
{
- if (collection->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_GR, Collection, 1, collection);
- write_iddata(wd, &collection->id);
+ if (collection->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_GR, Collection, 1, collection);
+ write_iddata(wd, &collection->id);
- write_collection_nolib(wd, collection);
- }
+ write_collection_nolib(wd, collection);
+ }
}
static void write_sequence_modifiers(WriteData *wd, ListBase *modbase)
{
- SequenceModifierData *smd;
+ SequenceModifierData *smd;
- for (smd = modbase->first; smd; smd = smd->next) {
- const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
+ for (smd = modbase->first; smd; smd = smd->next) {
+ const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
- if (smti) {
- writestruct_id(wd, DATA, smti->struct_name, 1, smd);
+ if (smti) {
+ writestruct_id(wd, DATA, smti->struct_name, 1, smd);
- if (smd->type == seqModifierType_Curves) {
- CurvesModifierData *cmd = (CurvesModifierData *)smd;
+ if (smd->type == seqModifierType_Curves) {
+ CurvesModifierData *cmd = (CurvesModifierData *)smd;
- write_curvemapping(wd, &cmd->curve_mapping);
- }
- else if (smd->type == seqModifierType_HueCorrect) {
- HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
+ write_curvemapping(wd, &cmd->curve_mapping);
+ }
+ else if (smd->type == seqModifierType_HueCorrect) {
+ HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
- write_curvemapping(wd, &hcmd->curve_mapping);
- }
- }
- else {
- writestruct(wd, DATA, SequenceModifierData, 1, smd);
- }
- }
+ write_curvemapping(wd, &hcmd->curve_mapping);
+ }
+ }
+ else {
+ writestruct(wd, DATA, SequenceModifierData, 1, smd);
+ }
+ }
}
static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_settings)
{
- if (view_settings->curve_mapping) {
- write_curvemapping(wd, view_settings->curve_mapping);
- }
+ if (view_settings->curve_mapping) {
+ write_curvemapping(wd, view_settings->curve_mapping);
+ }
}
static void write_paint(WriteData *wd, Paint *p)
{
- if (p->cavity_curve) {
- write_curvemapping(wd, p->cavity_curve);
- }
- writedata(wd, DATA, sizeof(PaintToolSlot) * p->tool_slots_len, p->tool_slots);
+ if (p->cavity_curve) {
+ write_curvemapping(wd, p->cavity_curve);
+ }
+ writedata(wd, DATA, sizeof(PaintToolSlot) * p->tool_slots_len, p->tool_slots);
}
static void write_layer_collections(WriteData *wd, ListBase *lb)
{
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
- writestruct(wd, DATA, LayerCollection, 1, lc);
+ for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ writestruct(wd, DATA, LayerCollection, 1, lc);
- write_layer_collections(wd, &lc->layer_collections);
- }
+ write_layer_collections(wd, &lc->layer_collections);
+ }
}
static void write_view_layer(WriteData *wd, ViewLayer *view_layer)
{
- writestruct(wd, DATA, ViewLayer, 1, view_layer);
- writelist(wd, DATA, Base, &view_layer->object_bases);
-
- if (view_layer->id_properties) {
- IDP_WriteProperty(view_layer->id_properties, wd);
- }
-
- for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; fmc = fmc->next) {
- writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc);
- }
-
- for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
- writestruct(wd, DATA, FreestyleLineSet, 1, fls);
- }
- write_layer_collections(wd, &view_layer->layer_collections);
+ writestruct(wd, DATA, ViewLayer, 1, view_layer);
+ writelist(wd, DATA, Base, &view_layer->object_bases);
+
+ if (view_layer->id_properties) {
+ IDP_WriteProperty(view_layer->id_properties, wd);
+ }
+
+ for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc;
+ fmc = fmc->next) {
+ writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc);
+ }
+
+ for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
+ writestruct(wd, DATA, FreestyleLineSet, 1, fls);
+ }
+ write_layer_collections(wd, &view_layer->layer_collections);
}
static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex)
{
- if (tex->data) {
- size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
- if (tex->data_type == LIGHTCACHETEX_FLOAT) {
- data_size *= sizeof(float);
- }
- else if (tex->data_type == LIGHTCACHETEX_UINT) {
- data_size *= sizeof(uint);
- }
- writedata(wd, DATA, data_size, tex->data);
- }
+ if (tex->data) {
+ size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
+ if (tex->data_type == LIGHTCACHETEX_FLOAT) {
+ data_size *= sizeof(float);
+ }
+ else if (tex->data_type == LIGHTCACHETEX_UINT) {
+ data_size *= sizeof(uint);
+ }
+ writedata(wd, DATA, data_size, tex->data);
+ }
}
static void write_lightcache(WriteData *wd, LightCache *cache)
{
- write_lightcache_texture(wd, &cache->grid_tx);
- write_lightcache_texture(wd, &cache->cube_tx);
-
- if (cache->cube_mips) {
- writestruct(wd, DATA, LightCacheTexture, cache->mips_len, cache->cube_mips);
- for (int i = 0; i < cache->mips_len; ++i) {
- write_lightcache_texture(wd, &cache->cube_mips[i]);
- }
- }
-
- writestruct(wd, DATA, LightGridCache, cache->grid_len, cache->grid_data);
- writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data);
+ write_lightcache_texture(wd, &cache->grid_tx);
+ write_lightcache_texture(wd, &cache->cube_tx);
+
+ if (cache->cube_mips) {
+ writestruct(wd, DATA, LightCacheTexture, cache->mips_len, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; ++i) {
+ write_lightcache_texture(wd, &cache->cube_mips[i]);
+ }
+ }
+
+ writestruct(wd, DATA, LightGridCache, cache->grid_len, cache->grid_data);
+ writestruct(wd, DATA, LightProbeCache, cache->cube_len, cache->cube_data);
}
static void write_scene(WriteData *wd, Scene *sce)
{
- /* write LibData */
- writestruct(wd, ID_SCE, Scene, 1, sce);
- write_iddata(wd, &sce->id);
-
- if (sce->adt) {
- write_animdata(wd, sce->adt);
- }
- write_keyingsets(wd, &sce->keyingsets);
-
- /* direct data */
- ToolSettings *tos = sce->toolsettings;
- writestruct(wd, DATA, ToolSettings, 1, tos);
- if (tos->vpaint) {
- writestruct(wd, DATA, VPaint, 1, tos->vpaint);
- write_paint(wd, &tos->vpaint->paint);
- }
- if (tos->wpaint) {
- writestruct(wd, DATA, VPaint, 1, tos->wpaint);
- write_paint(wd, &tos->wpaint->paint);
- }
- if (tos->sculpt) {
- writestruct(wd, DATA, Sculpt, 1, tos->sculpt);
- write_paint(wd, &tos->sculpt->paint);
- }
- if (tos->uvsculpt) {
- writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt);
- write_paint(wd, &tos->uvsculpt->paint);
- }
- if (tos->gp_paint) {
- writestruct(wd, DATA, GpPaint, 1, tos->gp_paint);
- write_paint(wd, &tos->gp_paint->paint);
- }
- /* write grease-pencil custom ipo curve to file */
- if (tos->gp_interpolate.custom_ipo) {
- write_curvemapping(wd, tos->gp_interpolate.custom_ipo);
- }
- /* write grease-pencil multiframe falloff curve to file */
- if (tos->gp_sculpt.cur_falloff) {
- write_curvemapping(wd, tos->gp_sculpt.cur_falloff);
- }
- /* write grease-pencil primitive curve to file */
- if (tos->gp_sculpt.cur_primitive) {
- write_curvemapping(wd, tos->gp_sculpt.cur_primitive);
- }
-
- write_paint(wd, &tos->imapaint.paint);
-
- Editing *ed = sce->ed;
- if (ed) {
- Sequence *seq;
-
- writestruct(wd, DATA, Editing, 1, ed);
-
- /* reset write flags too */
-
- SEQ_BEGIN(ed, seq)
- {
- if (seq->strip) {
- seq->strip->done = false;
- }
- writestruct(wd, DATA, Sequence, 1, seq);
- } SEQ_END;
-
- SEQ_BEGIN(ed, seq)
- {
- if (seq->strip && seq->strip->done == 0) {
- /* write strip with 'done' at 0 because readfile */
-
- if (seq->effectdata) {
- switch (seq->type) {
- case SEQ_TYPE_COLOR:
- writestruct(wd, DATA, SolidColorVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_SPEED:
- writestruct(wd, DATA, SpeedControlVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_WIPE:
- writestruct(wd, DATA, WipeVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_GLOW:
- writestruct(wd, DATA, GlowVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_TRANSFORM:
- writestruct(wd, DATA, TransformVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_GAUSSIAN_BLUR:
- writestruct(wd, DATA, GaussianBlurVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_TEXT:
- writestruct(wd, DATA, TextVars, 1, seq->effectdata);
- break;
- case SEQ_TYPE_COLORMIX:
- writestruct(wd, DATA, ColorMixVars, 1, seq->effectdata);
- break;
- }
- }
-
- writestruct(wd, DATA, Stereo3dFormat, 1, seq->stereo3d_format);
-
- Strip *strip = seq->strip;
- writestruct(wd, DATA, Strip, 1, strip);
- if (seq->flag & SEQ_USE_CROP && strip->crop) {
- writestruct(wd, DATA, StripCrop, 1, strip->crop);
- }
- if (seq->flag & SEQ_USE_TRANSFORM && strip->transform) {
- writestruct(wd, DATA, StripTransform, 1, strip->transform);
- }
- if (seq->flag & SEQ_USE_PROXY && strip->proxy) {
- writestruct(wd, DATA, StripProxy, 1, strip->proxy);
- }
- if (seq->type == SEQ_TYPE_IMAGE) {
- writestruct(wd, DATA, StripElem,
- MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
- strip->stripdata);
- }
- else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- writestruct(wd, DATA, StripElem, 1, strip->stripdata);
- }
-
- strip->done = true;
- }
-
- if (seq->prop) {
- IDP_WriteProperty(seq->prop, wd);
- }
-
- write_sequence_modifiers(wd, &seq->modifiers);
- } SEQ_END;
-
- /* new; meta stack too, even when its nasty restore code */
- for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) {
- writestruct(wd, DATA, MetaStack, 1, ms);
- }
- }
-
- if (sce->r.avicodecdata) {
- writestruct(wd, DATA, AviCodecData, 1, sce->r.avicodecdata);
- if (sce->r.avicodecdata->lpFormat) {
- writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
- }
- if (sce->r.avicodecdata->lpParms) {
- writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
- }
- }
- if (sce->r.ffcodecdata.properties) {
- IDP_WriteProperty(sce->r.ffcodecdata.properties, wd);
- }
-
- /* writing dynamic list of TimeMarkers to the blend file */
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
- writestruct(wd, DATA, TimeMarker, 1, marker);
- }
-
- /* writing dynamic list of TransformOrientations to the blend file */
- for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) {
- writestruct(wd, DATA, TransformOrientation, 1, ts);
- }
-
- /* writing MultiView to the blend file */
- for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) {
- writestruct(wd, DATA, SceneRenderView, 1, srv);
- }
-
- if (sce->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, sce->nodetree);
- write_nodetree_nolib(wd, sce->nodetree);
- }
-
- write_view_settings(wd, &sce->view_settings);
-
- /* writing RigidBodyWorld data to the blend file */
- if (sce->rigidbody_world) {
- /* Set deprecated pointers to prevent crashes of older Blenders */
- sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
- sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
- writestruct(wd, DATA, RigidBodyWorld, 1, sce->rigidbody_world);
-
- writestruct(wd, DATA, RigidBodyWorld_Shared, 1, sce->rigidbody_world->shared);
- writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights);
- write_pointcaches(wd, &(sce->rigidbody_world->shared->ptcaches));
- }
-
- write_previews(wd, sce->preview);
- write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve);
-
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- write_view_layer(wd, view_layer);
- }
-
- if (sce->master_collection) {
- writestruct(wd, DATA, Collection, 1, sce->master_collection);
- write_collection_nolib(wd, sce->master_collection);
- }
-
- /* Eevee Lightcache */
- if (sce->eevee.light_cache && !wd->use_memfile) {
- writestruct(wd, DATA, LightCache, 1, sce->eevee.light_cache);
- write_lightcache(wd, sce->eevee.light_cache);
- }
-
- /* Freed on doversion. */
- BLI_assert(sce->layer_properties == NULL);
+ /* write LibData */
+ writestruct(wd, ID_SCE, Scene, 1, sce);
+ write_iddata(wd, &sce->id);
+
+ if (sce->adt) {
+ write_animdata(wd, sce->adt);
+ }
+ write_keyingsets(wd, &sce->keyingsets);
+
+ /* direct data */
+ ToolSettings *tos = sce->toolsettings;
+ writestruct(wd, DATA, ToolSettings, 1, tos);
+ if (tos->vpaint) {
+ writestruct(wd, DATA, VPaint, 1, tos->vpaint);
+ write_paint(wd, &tos->vpaint->paint);
+ }
+ if (tos->wpaint) {
+ writestruct(wd, DATA, VPaint, 1, tos->wpaint);
+ write_paint(wd, &tos->wpaint->paint);
+ }
+ if (tos->sculpt) {
+ writestruct(wd, DATA, Sculpt, 1, tos->sculpt);
+ write_paint(wd, &tos->sculpt->paint);
+ }
+ if (tos->uvsculpt) {
+ writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt);
+ write_paint(wd, &tos->uvsculpt->paint);
+ }
+ if (tos->gp_paint) {
+ writestruct(wd, DATA, GpPaint, 1, tos->gp_paint);
+ write_paint(wd, &tos->gp_paint->paint);
+ }
+ /* write grease-pencil custom ipo curve to file */
+ if (tos->gp_interpolate.custom_ipo) {
+ write_curvemapping(wd, tos->gp_interpolate.custom_ipo);
+ }
+ /* write grease-pencil multiframe falloff curve to file */
+ if (tos->gp_sculpt.cur_falloff) {
+ write_curvemapping(wd, tos->gp_sculpt.cur_falloff);
+ }
+ /* write grease-pencil primitive curve to file */
+ if (tos->gp_sculpt.cur_primitive) {
+ write_curvemapping(wd, tos->gp_sculpt.cur_primitive);
+ }
+
+ write_paint(wd, &tos->imapaint.paint);
+
+ Editing *ed = sce->ed;
+ if (ed) {
+ Sequence *seq;
+
+ writestruct(wd, DATA, Editing, 1, ed);
+
+ /* reset write flags too */
+
+ SEQ_BEGIN (ed, seq) {
+ if (seq->strip) {
+ seq->strip->done = false;
+ }
+ writestruct(wd, DATA, Sequence, 1, seq);
+ }
+ SEQ_END;
+
+ SEQ_BEGIN (ed, seq) {
+ if (seq->strip && seq->strip->done == 0) {
+ /* write strip with 'done' at 0 because readfile */
+
+ if (seq->effectdata) {
+ switch (seq->type) {
+ case SEQ_TYPE_COLOR:
+ writestruct(wd, DATA, SolidColorVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_SPEED:
+ writestruct(wd, DATA, SpeedControlVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_WIPE:
+ writestruct(wd, DATA, WipeVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_GLOW:
+ writestruct(wd, DATA, GlowVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_TRANSFORM:
+ writestruct(wd, DATA, TransformVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_GAUSSIAN_BLUR:
+ writestruct(wd, DATA, GaussianBlurVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_TEXT:
+ writestruct(wd, DATA, TextVars, 1, seq->effectdata);
+ break;
+ case SEQ_TYPE_COLORMIX:
+ writestruct(wd, DATA, ColorMixVars, 1, seq->effectdata);
+ break;
+ }
+ }
+
+ writestruct(wd, DATA, Stereo3dFormat, 1, seq->stereo3d_format);
+
+ Strip *strip = seq->strip;
+ writestruct(wd, DATA, Strip, 1, strip);
+ if (seq->flag & SEQ_USE_CROP && strip->crop) {
+ writestruct(wd, DATA, StripCrop, 1, strip->crop);
+ }
+ if (seq->flag & SEQ_USE_TRANSFORM && strip->transform) {
+ writestruct(wd, DATA, StripTransform, 1, strip->transform);
+ }
+ if (seq->flag & SEQ_USE_PROXY && strip->proxy) {
+ writestruct(wd, DATA, StripProxy, 1, strip->proxy);
+ }
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ writestruct(wd,
+ DATA,
+ StripElem,
+ MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
+ strip->stripdata);
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
+ writestruct(wd, DATA, StripElem, 1, strip->stripdata);
+ }
+
+ strip->done = true;
+ }
+
+ if (seq->prop) {
+ IDP_WriteProperty(seq->prop, wd);
+ }
+
+ write_sequence_modifiers(wd, &seq->modifiers);
+ }
+ SEQ_END;
+
+ /* new; meta stack too, even when its nasty restore code */
+ for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) {
+ writestruct(wd, DATA, MetaStack, 1, ms);
+ }
+ }
+
+ if (sce->r.avicodecdata) {
+ writestruct(wd, DATA, AviCodecData, 1, sce->r.avicodecdata);
+ if (sce->r.avicodecdata->lpFormat) {
+ writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
+ }
+ if (sce->r.avicodecdata->lpParms) {
+ writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
+ }
+ }
+ if (sce->r.ffcodecdata.properties) {
+ IDP_WriteProperty(sce->r.ffcodecdata.properties, wd);
+ }
+
+ /* writing dynamic list of TimeMarkers to the blend file */
+ for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ writestruct(wd, DATA, TimeMarker, 1, marker);
+ }
+
+ /* writing dynamic list of TransformOrientations to the blend file */
+ for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) {
+ writestruct(wd, DATA, TransformOrientation, 1, ts);
+ }
+
+ /* writing MultiView to the blend file */
+ for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) {
+ writestruct(wd, DATA, SceneRenderView, 1, srv);
+ }
+
+ if (sce->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, sce->nodetree);
+ write_nodetree_nolib(wd, sce->nodetree);
+ }
+
+ write_view_settings(wd, &sce->view_settings);
+
+ /* writing RigidBodyWorld data to the blend file */
+ if (sce->rigidbody_world) {
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
+ sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
+ writestruct(wd, DATA, RigidBodyWorld, 1, sce->rigidbody_world);
+
+ writestruct(wd, DATA, RigidBodyWorld_Shared, 1, sce->rigidbody_world->shared);
+ writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights);
+ write_pointcaches(wd, &(sce->rigidbody_world->shared->ptcaches));
+ }
+
+ write_previews(wd, sce->preview);
+ write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve);
+
+ for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ write_view_layer(wd, view_layer);
+ }
+
+ if (sce->master_collection) {
+ writestruct(wd, DATA, Collection, 1, sce->master_collection);
+ write_collection_nolib(wd, sce->master_collection);
+ }
+
+ /* Eevee Lightcache */
+ if (sce->eevee.light_cache && !wd->use_memfile) {
+ writestruct(wd, DATA, LightCache, 1, sce->eevee.light_cache);
+ write_lightcache(wd, sce->eevee.light_cache);
+ }
+
+ /* Freed on doversion. */
+ BLI_assert(sce->layer_properties == NULL);
}
static void write_gpencil(WriteData *wd, bGPdata *gpd)
{
- if (gpd->id.us > 0 || wd->use_memfile) {
- /* write gpd data block to file */
- writestruct(wd, ID_GD, bGPdata, 1, gpd);
- write_iddata(wd, &gpd->id);
-
- if (gpd->adt) {
- write_animdata(wd, gpd->adt);
- }
-
- writedata(wd, DATA, sizeof(void *) * gpd->totcol, gpd->mat);
-
- /* write grease-pencil layers to file */
- writelist(wd, DATA, bGPDlayer, &gpd->layers);
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* write this layer's frames to file */
- writelist(wd, DATA, bGPDframe, &gpl->frames);
- for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- /* write strokes */
- writelist(wd, DATA, bGPDstroke, &gpf->strokes);
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points);
- write_dverts(wd, gps->totpoints, gps->dvert);
- }
- }
- }
- }
+ if (gpd->id.us > 0 || wd->use_memfile) {
+ /* write gpd data block to file */
+ writestruct(wd, ID_GD, bGPdata, 1, gpd);
+ write_iddata(wd, &gpd->id);
+
+ if (gpd->adt) {
+ write_animdata(wd, gpd->adt);
+ }
+
+ writedata(wd, DATA, sizeof(void *) * gpd->totcol, gpd->mat);
+
+ /* write grease-pencil layers to file */
+ writelist(wd, DATA, bGPDlayer, &gpd->layers);
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* write this layer's frames to file */
+ writelist(wd, DATA, bGPDframe, &gpl->frames);
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ /* write strokes */
+ writelist(wd, DATA, bGPDstroke, &gpf->strokes);
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points);
+ write_dverts(wd, gps->totpoints, gps->dvert);
+ }
+ }
+ }
+ }
}
static void write_region(WriteData *wd, ARegion *ar, int spacetype)
{
- writestruct(wd, DATA, ARegion, 1, ar);
-
- if (ar->regiondata) {
- if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
- return;
- }
-
- switch (spacetype) {
- case SPACE_VIEW3D:
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d = ar->regiondata;
- writestruct(wd, DATA, RegionView3D, 1, rv3d);
-
- if (rv3d->localvd) {
- writestruct(wd, DATA, RegionView3D, 1, rv3d->localvd);
- }
- if (rv3d->clipbb) {
- writestruct(wd, DATA, BoundBox, 1, rv3d->clipbb);
- }
-
- }
- else
- printf("regiondata write missing!\n");
- break;
- default:
- printf("regiondata write missing!\n");
- }
- }
+ writestruct(wd, DATA, ARegion, 1, ar);
+
+ if (ar->regiondata) {
+ if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+ return;
+ }
+
+ switch (spacetype) {
+ case SPACE_VIEW3D:
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ writestruct(wd, DATA, RegionView3D, 1, rv3d);
+
+ if (rv3d->localvd) {
+ writestruct(wd, DATA, RegionView3D, 1, rv3d->localvd);
+ }
+ if (rv3d->clipbb) {
+ writestruct(wd, DATA, BoundBox, 1, rv3d->clipbb);
+ }
+ }
+ else
+ printf("regiondata write missing!\n");
+ break;
+ default:
+ printf("regiondata write missing!\n");
+ }
+ }
}
static void write_uilist(WriteData *wd, uiList *ui_list)
{
- writestruct(wd, DATA, uiList, 1, ui_list);
+ writestruct(wd, DATA, uiList, 1, ui_list);
- if (ui_list->properties) {
- IDP_WriteProperty(ui_list->properties, wd);
- }
+ if (ui_list->properties) {
+ IDP_WriteProperty(ui_list->properties, wd);
+ }
}
static void write_soops(WriteData *wd, SpaceOutliner *so)
{
- BLI_mempool *ts = so->treestore;
-
- if (ts) {
- SpaceOutliner so_flat = *so;
-
- int elems = BLI_mempool_len(ts);
- /* linearize mempool to array */
- TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
-
- if (data) {
- /* In this block we use the memory location of the treestore
- * but _not_ its data, the addresses in this case are UUID's,
- * since we can't rely on malloc giving us different values each time.
- */
- TreeStore ts_flat = {0};
-
- /* we know the treestore is at least as big as a pointer,
- * so offsetting works to give us a UUID. */
- void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
-
- ts_flat.usedelem = elems;
- ts_flat.totelem = elems;
- ts_flat.data = data_addr;
-
- writestruct(wd, DATA, SpaceOutliner, 1, so);
-
- writestruct_at_address(wd, DATA, TreeStore, 1, ts, &ts_flat);
- writestruct_at_address(wd, DATA, TreeStoreElem, elems, data_addr, data);
-
- MEM_freeN(data);
- }
- else {
- so_flat.treestore = NULL;
- writestruct_at_address(wd, DATA, SpaceOutliner, 1, so, &so_flat);
- }
- }
- else {
- writestruct(wd, DATA, SpaceOutliner, 1, so);
- }
+ BLI_mempool *ts = so->treestore;
+
+ if (ts) {
+ SpaceOutliner so_flat = *so;
+
+ int elems = BLI_mempool_len(ts);
+ /* linearize mempool to array */
+ TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
+
+ if (data) {
+ /* In this block we use the memory location of the treestore
+ * but _not_ its data, the addresses in this case are UUID's,
+ * since we can't rely on malloc giving us different values each time.
+ */
+ TreeStore ts_flat = {0};
+
+ /* we know the treestore is at least as big as a pointer,
+ * so offsetting works to give us a UUID. */
+ void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
+
+ ts_flat.usedelem = elems;
+ ts_flat.totelem = elems;
+ ts_flat.data = data_addr;
+
+ writestruct(wd, DATA, SpaceOutliner, 1, so);
+
+ writestruct_at_address(wd, DATA, TreeStore, 1, ts, &ts_flat);
+ writestruct_at_address(wd, DATA, TreeStoreElem, elems, data_addr, data);
+
+ MEM_freeN(data);
+ }
+ else {
+ so_flat.treestore = NULL;
+ writestruct_at_address(wd, DATA, SpaceOutliner, 1, so, &so_flat);
+ }
+ }
+ else {
+ writestruct(wd, DATA, SpaceOutliner, 1, so);
+ }
}
static void write_panel_list(WriteData *wd, ListBase *lb)
{
- for (Panel *pa = lb->first; pa; pa = pa->next) {
- writestruct(wd, DATA, Panel, 1, pa);
- write_panel_list(wd, &pa->children);
- }
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ writestruct(wd, DATA, Panel, 1, pa);
+ write_panel_list(wd, &pa->children);
+ }
}
static void write_area_regions(WriteData *wd, ScrArea *area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
- write_region(wd, region, area->spacetype);
- write_panel_list(wd, &region->panels);
-
- for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act; pc_act = pc_act->next) {
- writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
- }
-
- for (uiList *ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
- write_uilist(wd, ui_list);
- }
-
- for (uiPreview *ui_preview = region->ui_previews.first; ui_preview; ui_preview = ui_preview->next) {
- writestruct(wd, DATA, uiPreview, 1, ui_preview);
- }
- }
-
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- for (ARegion *region = sl->regionbase.first; region; region = region->next) {
- write_region(wd, region, sl->spacetype);
- }
-
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- writestruct(wd, DATA, View3D, 1, v3d);
-
- if (v3d->localvd) {
- writestruct(wd, DATA, View3D, 1, v3d->localvd);
- }
-
- if (v3d->fx_settings.ssao) {
- writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao);
- }
- if (v3d->fx_settings.dof) {
- writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
- }
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- ListBase tmpGhosts = sipo->runtime.ghost_curves;
-
- /* temporarily disable ghost curves when saving */
- BLI_listbase_clear(&sipo->runtime.ghost_curves);
-
- writestruct(wd, DATA, SpaceGraph, 1, sl);
- if (sipo->ads) {
- writestruct(wd, DATA, bDopeSheet, 1, sipo->ads);
- }
-
- /* reenable ghost curves */
- sipo->runtime.ghost_curves = tmpGhosts;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- writestruct(wd, DATA, SpaceProperties, 1, sl);
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- writestruct(wd, DATA, SpaceFile, 1, sl);
- if (sfile->params) {
- writestruct(wd, DATA, FileSelectParams, 1, sfile->params);
- }
- }
- else if (sl->spacetype == SPACE_SEQ) {
- writestruct(wd, DATA, SpaceSeq, 1, sl);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- write_soops(wd, so);
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- writestruct(wd, DATA, SpaceImage, 1, sl);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- writestruct(wd, DATA, SpaceText, 1, sl);
- }
- else if (sl->spacetype == SPACE_SCRIPT) {
- SpaceScript *scr = (SpaceScript *)sl;
- scr->but_refs = NULL;
- writestruct(wd, DATA, SpaceScript, 1, sl);
- }
- else if (sl->spacetype == SPACE_ACTION) {
- writestruct(wd, DATA, SpaceAction, 1, sl);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
-
- writestruct(wd, DATA, SpaceNla, 1, snla);
- if (snla->ads) {
- writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
- }
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- bNodeTreePath *path;
- writestruct(wd, DATA, SpaceNode, 1, snode);
-
- for (path = snode->treepath.first; path; path = path->next) {
- writestruct(wd, DATA, bNodeTreePath, 1, path);
- }
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *con = (SpaceConsole *)sl;
- ConsoleLine *cl;
-
- for (cl = con->history.first; cl; cl = cl->next) {
- /* 'len_alloc' is invalid on write, set from 'len' on read */
- writestruct(wd, DATA, ConsoleLine, 1, cl);
- writedata(wd, DATA, cl->len + 1, cl->line);
- }
- writestruct(wd, DATA, SpaceConsole, 1, sl);
- }
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ write_region(wd, region, area->spacetype);
+ write_panel_list(wd, &region->panels);
+
+ for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act;
+ pc_act = pc_act->next) {
+ writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
+ }
+
+ for (uiList *ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ write_uilist(wd, ui_list);
+ }
+
+ for (uiPreview *ui_preview = region->ui_previews.first; ui_preview;
+ ui_preview = ui_preview->next) {
+ writestruct(wd, DATA, uiPreview, 1, ui_preview);
+ }
+ }
+
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ for (ARegion *region = sl->regionbase.first; region; region = region->next) {
+ write_region(wd, region, sl->spacetype);
+ }
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ writestruct(wd, DATA, View3D, 1, v3d);
+
+ if (v3d->localvd) {
+ writestruct(wd, DATA, View3D, 1, v3d->localvd);
+ }
+
+ if (v3d->fx_settings.ssao) {
+ writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao);
+ }
+ if (v3d->fx_settings.dof) {
+ writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
+ }
+ }
+ else if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ ListBase tmpGhosts = sipo->runtime.ghost_curves;
+
+ /* temporarily disable ghost curves when saving */
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
+
+ writestruct(wd, DATA, SpaceGraph, 1, sl);
+ if (sipo->ads) {
+ writestruct(wd, DATA, bDopeSheet, 1, sipo->ads);
+ }
+
+ /* reenable ghost curves */
+ sipo->runtime.ghost_curves = tmpGhosts;
+ }
+ else if (sl->spacetype == SPACE_PROPERTIES) {
+ writestruct(wd, DATA, SpaceProperties, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ writestruct(wd, DATA, SpaceFile, 1, sl);
+ if (sfile->params) {
+ writestruct(wd, DATA, FileSelectParams, 1, sfile->params);
+ }
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ writestruct(wd, DATA, SpaceSeq, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *so = (SpaceOutliner *)sl;
+ write_soops(wd, so);
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ writestruct(wd, DATA, SpaceImage, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ writestruct(wd, DATA, SpaceText, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_SCRIPT) {
+ SpaceScript *scr = (SpaceScript *)sl;
+ scr->but_refs = NULL;
+ writestruct(wd, DATA, SpaceScript, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_ACTION) {
+ writestruct(wd, DATA, SpaceAction, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ writestruct(wd, DATA, SpaceNla, 1, snla);
+ if (snla->ads) {
+ writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
+ }
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ bNodeTreePath *path;
+ writestruct(wd, DATA, SpaceNode, 1, snode);
+
+ for (path = snode->treepath.first; path; path = path->next) {
+ writestruct(wd, DATA, bNodeTreePath, 1, path);
+ }
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *con = (SpaceConsole *)sl;
+ ConsoleLine *cl;
+
+ for (cl = con->history.first; cl; cl = cl->next) {
+ /* 'len_alloc' is invalid on write, set from 'len' on read */
+ writestruct(wd, DATA, ConsoleLine, 1, cl);
+ writedata(wd, DATA, cl->len + 1, cl->line);
+ }
+ writestruct(wd, DATA, SpaceConsole, 1, sl);
+ }
#ifdef WITH_GLOBAL_AREA_WRITING
- else if (sl->spacetype == SPACE_TOPBAR) {
- writestruct(wd, DATA, SpaceTopBar, 1, sl);
- }
- else if (sl->spacetype == SPACE_STATUSBAR) {
- writestruct(wd, DATA, SpaceStatusBar, 1, sl);
- }
+ else if (sl->spacetype == SPACE_TOPBAR) {
+ writestruct(wd, DATA, SpaceTopBar, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_STATUSBAR) {
+ writestruct(wd, DATA, SpaceStatusBar, 1, sl);
+ }
#endif
- else if (sl->spacetype == SPACE_USERPREF) {
- writestruct(wd, DATA, SpaceUserPref, 1, sl);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- writestruct(wd, DATA, SpaceClip, 1, sl);
- }
- else if (sl->spacetype == SPACE_INFO) {
- writestruct(wd, DATA, SpaceInfo, 1, sl);
- }
- }
+ else if (sl->spacetype == SPACE_USERPREF) {
+ writestruct(wd, DATA, SpaceUserPref, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ writestruct(wd, DATA, SpaceClip, 1, sl);
+ }
+ else if (sl->spacetype == SPACE_INFO) {
+ writestruct(wd, DATA, SpaceInfo, 1, sl);
+ }
+ }
}
static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
{
- writelist(wd, DATA, ScrVert, &area_map->vertbase);
- writelist(wd, DATA, ScrEdge, &area_map->edgebase);
- for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
- area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
+ writelist(wd, DATA, ScrVert, &area_map->vertbase);
+ writelist(wd, DATA, ScrEdge, &area_map->edgebase);
+ for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
- writestruct(wd, DATA, ScrArea, 1, area);
+ writestruct(wd, DATA, ScrArea, 1, area);
#ifdef WITH_GLOBAL_AREA_WRITING
- writestruct(wd, DATA, ScrGlobalAreaData, 1, area->global);
+ writestruct(wd, DATA, ScrGlobalAreaData, 1, area->global);
#endif
- write_area_regions(wd, area);
+ write_area_regions(wd, area);
- area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
- }
+ area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
+ }
}
static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
{
- writestruct(wd, ID_WM, wmWindowManager, 1, wm);
- write_iddata(wd, &wm->id);
+ writestruct(wd, ID_WM, wmWindowManager, 1, wm);
+ write_iddata(wd, &wm->id);
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
#ifndef WITH_GLOBAL_AREA_WRITING
- /* Don't write global areas yet, while we make changes to them. */
- ScrAreaMap global_areas = win->global_areas;
- memset(&win->global_areas, 0, sizeof(win->global_areas));
+ /* Don't write global areas yet, while we make changes to them. */
+ ScrAreaMap global_areas = win->global_areas;
+ memset(&win->global_areas, 0, sizeof(win->global_areas));
#endif
- /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
- win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
+ win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
- writestruct(wd, DATA, wmWindow, 1, win);
- writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook);
- writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
+ writestruct(wd, DATA, wmWindow, 1, win);
+ writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook);
+ writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
#ifdef WITH_GLOBAL_AREA_WRITING
- write_area_map(wd, &win->global_areas);
+ write_area_map(wd, &win->global_areas);
#else
- win->global_areas = global_areas;
+ win->global_areas = global_areas;
#endif
- /* data is written, clear deprecated data again */
- win->screen = NULL;
- }
+ /* data is written, clear deprecated data again */
+ win->screen = NULL;
+ }
}
static void write_screen(WriteData *wd, bScreen *sc)
{
- /* Screens are reference counted, only saved if used by a workspace. */
- if (sc->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
- writestruct(wd, ID_SCRN, bScreen, 1, sc);
- write_iddata(wd, &sc->id);
-
- write_previews(wd, sc->preview);
-
- /* direct data */
- write_area_map(wd, AREAMAP_FROM_SCREEN(sc));
- }
+ /* Screens are reference counted, only saved if used by a workspace. */
+ if (sc->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ writestruct(wd, ID_SCRN, bScreen, 1, sc);
+ write_iddata(wd, &sc->id);
+
+ write_previews(wd, sc->preview);
+
+ /* direct data */
+ write_area_map(wd, AREAMAP_FROM_SCREEN(sc));
+ }
}
static void write_bone(WriteData *wd, Bone *bone)
{
- /* PATCH for upward compatibility after 2.37+ armature recode */
- bone->size[0] = bone->size[1] = bone->size[2] = 1.0f;
-
- /* Write this bone */
- writestruct(wd, DATA, Bone, 1, bone);
-
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- if (bone->prop) {
- IDP_WriteProperty(bone->prop, wd);
- }
-
- /* Write Children */
- for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) {
- write_bone(wd, cbone);
- }
+ /* PATCH for upward compatibility after 2.37+ armature recode */
+ bone->size[0] = bone->size[1] = bone->size[2] = 1.0f;
+
+ /* Write this bone */
+ writestruct(wd, DATA, Bone, 1, bone);
+
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ if (bone->prop) {
+ IDP_WriteProperty(bone->prop, wd);
+ }
+
+ /* Write Children */
+ for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) {
+ write_bone(wd, cbone);
+ }
}
static void write_armature(WriteData *wd, bArmature *arm)
{
- if (arm->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_AR, bArmature, 1, arm);
- write_iddata(wd, &arm->id);
-
- if (arm->adt) {
- write_animdata(wd, arm->adt);
- }
-
- /* Direct data */
- for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
- write_bone(wd, bone);
- }
- }
+ if (arm->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_AR, bArmature, 1, arm);
+ write_iddata(wd, &arm->id);
+
+ if (arm->adt) {
+ write_animdata(wd, arm->adt);
+ }
+
+ /* Direct data */
+ for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
+ write_bone(wd, bone);
+ }
+ }
}
static void write_text(WriteData *wd, Text *text)
{
- if ((text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) {
- text->flags &= ~TXT_ISEXT;
- }
-
- /* write LibData */
- writestruct(wd, ID_TXT, Text, 1, text);
- write_iddata(wd, &text->id);
-
- if (text->name) {
- writedata(wd, DATA, strlen(text->name) + 1, text->name);
- }
-
- if (!(text->flags & TXT_ISEXT)) {
- /* now write the text data, in two steps for optimization in the readfunction */
- for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
- writestruct(wd, DATA, TextLine, 1, tmp);
- }
-
- for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
- writedata(wd, DATA, tmp->len + 1, tmp->line);
- }
- }
+ if ((text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) {
+ text->flags &= ~TXT_ISEXT;
+ }
+
+ /* write LibData */
+ writestruct(wd, ID_TXT, Text, 1, text);
+ write_iddata(wd, &text->id);
+
+ if (text->name) {
+ writedata(wd, DATA, strlen(text->name) + 1, text->name);
+ }
+
+ if (!(text->flags & TXT_ISEXT)) {
+ /* now write the text data, in two steps for optimization in the readfunction */
+ for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
+ writestruct(wd, DATA, TextLine, 1, tmp);
+ }
+
+ for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
+ writedata(wd, DATA, tmp->len + 1, tmp->line);
+ }
+ }
}
static void write_speaker(WriteData *wd, Speaker *spk)
{
- if (spk->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_SPK, Speaker, 1, spk);
- write_iddata(wd, &spk->id);
-
- if (spk->adt) {
- write_animdata(wd, spk->adt);
- }
- }
+ if (spk->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_SPK, Speaker, 1, spk);
+ write_iddata(wd, &spk->id);
+
+ if (spk->adt) {
+ write_animdata(wd, spk->adt);
+ }
+ }
}
static void write_sound(WriteData *wd, bSound *sound)
{
- if (sound->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_SO, bSound, 1, sound);
- write_iddata(wd, &sound->id);
-
- if (sound->packedfile) {
- PackedFile *pf = sound->packedfile;
- writestruct(wd, DATA, PackedFile, 1, pf);
- writedata(wd, DATA, pf->size, pf->data);
- }
- }
+ if (sound->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_SO, bSound, 1, sound);
+ write_iddata(wd, &sound->id);
+
+ if (sound->packedfile) {
+ PackedFile *pf = sound->packedfile;
+ writestruct(wd, DATA, PackedFile, 1, pf);
+ writedata(wd, DATA, pf->size, pf->data);
+ }
+ }
}
static void write_probe(WriteData *wd, LightProbe *prb)
{
- if (prb->id.us > 0 || wd->use_memfile) {
- /* write LibData */
- writestruct(wd, ID_LP, LightProbe, 1, prb);
- write_iddata(wd, &prb->id);
-
- if (prb->adt) {
- write_animdata(wd, prb->adt);
- }
- }
+ if (prb->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_LP, LightProbe, 1, prb);
+ write_iddata(wd, &prb->id);
+
+ if (prb->adt) {
+ write_animdata(wd, prb->adt);
+ }
+ }
}
static void write_nodetree(WriteData *wd, bNodeTree *ntree)
{
- if (ntree->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_NT, bNodeTree, 1, ntree);
- /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot
- * be linked, etc., so we write actual id data here only, for 'real' ID trees. */
- write_iddata(wd, &ntree->id);
-
- write_nodetree_nolib(wd, ntree);
- }
+ if (ntree->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_NT, bNodeTree, 1, ntree);
+ /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot
+ * be linked, etc., so we write actual id data here only, for 'real' ID trees. */
+ write_iddata(wd, &ntree->id);
+
+ write_nodetree_nolib(wd, ntree);
+ }
}
#ifdef USE_NODE_COMPAT_CUSTOMNODES
static void customnodes_add_deprecated_data(Main *mainvar)
{
- FOREACH_NODETREE_BEGIN(mainvar, ntree, id) {
- bNodeLink *link, *last_link = ntree->links.last;
-
- /* only do this for node groups */
- if (id != &ntree->id) {
- continue;
- }
-
- /* Forward compatibility for group nodes: add links to node tree interface sockets.
- * These links are invalid by new rules (missing node pointer)!
- * They will be removed again in customnodes_free_deprecated_data,
- * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
- * When loading files with such links in a new Blender version
- * they will be removed as well.
- */
- for (link = ntree->links.first; link; link = link->next) {
- bNode *fromnode = link->fromnode, *tonode = link->tonode;
- bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
-
- /* check both sides of the link, to handle direct input-to-output links */
- if (fromnode->type == NODE_GROUP_INPUT) {
- fromnode = NULL;
- fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
- }
- /* only the active output node defines links */
- if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
- tonode = NULL;
- tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
- }
-
- if (!fromnode || !tonode) {
- /* Note: not using nodeAddLink here, it asserts existing node pointers */
- bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
- tlink->fromnode = fromnode;
- tlink->fromsock = fromsock;
- tlink->tonode = tonode;
- tlink->tosock = tosock;
- tosock->link = tlink;
- tlink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ntree->links, tlink);
- }
-
- /* don't check newly created compatibility links */
- if (link == last_link) {
- break;
- }
- }
- } FOREACH_NODETREE_END;
+ FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
+ bNodeLink *link, *last_link = ntree->links.last;
+
+ /* only do this for node groups */
+ if (id != &ntree->id) {
+ continue;
+ }
+
+ /* Forward compatibility for group nodes: add links to node tree interface sockets.
+ * These links are invalid by new rules (missing node pointer)!
+ * They will be removed again in customnodes_free_deprecated_data,
+ * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
+ * When loading files with such links in a new Blender version
+ * they will be removed as well.
+ */
+ for (link = ntree->links.first; link; link = link->next) {
+ bNode *fromnode = link->fromnode, *tonode = link->tonode;
+ bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
+
+ /* check both sides of the link, to handle direct input-to-output links */
+ if (fromnode->type == NODE_GROUP_INPUT) {
+ fromnode = NULL;
+ fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
+ }
+ /* only the active output node defines links */
+ if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
+ tonode = NULL;
+ tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
+ }
+
+ if (!fromnode || !tonode) {
+ /* Note: not using nodeAddLink here, it asserts existing node pointers */
+ bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
+ tlink->fromnode = fromnode;
+ tlink->fromsock = fromsock;
+ tlink->tonode = tonode;
+ tlink->tosock = tosock;
+ tosock->link = tlink;
+ tlink->flag |= NODE_LINK_VALID;
+ BLI_addtail(&ntree->links, tlink);
+ }
+
+ /* don't check newly created compatibility links */
+ if (link == last_link) {
+ break;
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
}
static void customnodes_free_deprecated_data(Main *mainvar)
{
- FOREACH_NODETREE_BEGIN(mainvar, ntree, id) {
- bNodeLink *link, *next_link;
-
- for (link = ntree->links.first; link; link = next_link) {
- next_link = link->next;
- if (link->fromnode == NULL || link->tonode == NULL) {
- nodeRemLink(ntree, link);
- }
- }
- } FOREACH_NODETREE_END;
+ FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
+ bNodeLink *link, *next_link;
+
+ for (link = ntree->links.first; link; link = next_link) {
+ next_link = link->next;
+ if (link->fromnode == NULL || link->tonode == NULL) {
+ nodeRemLink(ntree, link);
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
}
#endif
static void write_brush(WriteData *wd, Brush *brush)
{
- if (brush->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_BR, Brush, 1, brush);
- write_iddata(wd, &brush->id);
-
- if (brush->curve) {
- write_curvemapping(wd, brush->curve);
- }
-
- if (brush->gpencil_settings) {
- writestruct(wd, DATA, BrushGpencilSettings, 1, brush->gpencil_settings);
-
- if (brush->gpencil_settings->curve_sensitivity) {
- write_curvemapping(wd, brush->gpencil_settings->curve_sensitivity);
- }
- if (brush->gpencil_settings->curve_strength) {
- write_curvemapping(wd, brush->gpencil_settings->curve_strength);
- }
- if (brush->gpencil_settings->curve_jitter) {
- write_curvemapping(wd, brush->gpencil_settings->curve_jitter);
- }
- }
- if (brush->gradient) {
- writestruct(wd, DATA, ColorBand, 1, brush->gradient);
- }
- }
+ if (brush->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_BR, Brush, 1, brush);
+ write_iddata(wd, &brush->id);
+
+ if (brush->curve) {
+ write_curvemapping(wd, brush->curve);
+ }
+
+ if (brush->gpencil_settings) {
+ writestruct(wd, DATA, BrushGpencilSettings, 1, brush->gpencil_settings);
+
+ if (brush->gpencil_settings->curve_sensitivity) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_sensitivity);
+ }
+ if (brush->gpencil_settings->curve_strength) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_strength);
+ }
+ if (brush->gpencil_settings->curve_jitter) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_jitter);
+ }
+ }
+ if (brush->gradient) {
+ writestruct(wd, DATA, ColorBand, 1, brush->gradient);
+ }
+ }
}
static void write_palette(WriteData *wd, Palette *palette)
{
- if (palette->id.us > 0 || wd->use_memfile) {
- PaletteColor *color;
- writestruct(wd, ID_PAL, Palette, 1, palette);
- write_iddata(wd, &palette->id);
-
- for (color = palette->colors.first; color; color = color->next) {
- writestruct(wd, DATA, PaletteColor, 1, color);
- }
- }
+ if (palette->id.us > 0 || wd->use_memfile) {
+ PaletteColor *color;
+ writestruct(wd, ID_PAL, Palette, 1, palette);
+ write_iddata(wd, &palette->id);
+
+ for (color = palette->colors.first; color; color = color->next) {
+ writestruct(wd, DATA, PaletteColor, 1, color);
+ }
+ }
}
static void write_paintcurve(WriteData *wd, PaintCurve *pc)
{
- if (pc->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_PC, PaintCurve, 1, pc);
- write_iddata(wd, &pc->id);
+ if (pc->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_PC, PaintCurve, 1, pc);
+ write_iddata(wd, &pc->id);
- writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points);
- }
+ writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points);
+ }
}
static void write_movieTracks(WriteData *wd, ListBase *tracks)
{
- MovieTrackingTrack *track;
+ MovieTrackingTrack *track;
- track = tracks->first;
- while (track) {
- writestruct(wd, DATA, MovieTrackingTrack, 1, track);
+ track = tracks->first;
+ while (track) {
+ writestruct(wd, DATA, MovieTrackingTrack, 1, track);
- if (track->markers) {
- writestruct(wd, DATA, MovieTrackingMarker, track->markersnr, track->markers);
- }
+ if (track->markers) {
+ writestruct(wd, DATA, MovieTrackingMarker, track->markersnr, track->markers);
+ }
- track = track->next;
- }
+ track = track->next;
+ }
}
static void write_moviePlaneTracks(WriteData *wd, ListBase *plane_tracks_base)
{
- MovieTrackingPlaneTrack *plane_track;
+ MovieTrackingPlaneTrack *plane_track;
- for (plane_track = plane_tracks_base->first;
- plane_track;
- plane_track = plane_track->next)
- {
- writestruct(wd, DATA, MovieTrackingPlaneTrack, 1, plane_track);
+ for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
+ writestruct(wd, DATA, MovieTrackingPlaneTrack, 1, plane_track);
- writedata(wd, DATA, sizeof(MovieTrackingTrack *) * plane_track->point_tracksnr, plane_track->point_tracks);
- writestruct(wd, DATA, MovieTrackingPlaneMarker, plane_track->markersnr, plane_track->markers);
- }
+ writedata(wd,
+ DATA,
+ sizeof(MovieTrackingTrack *) * plane_track->point_tracksnr,
+ plane_track->point_tracks);
+ writestruct(wd, DATA, MovieTrackingPlaneMarker, plane_track->markersnr, plane_track->markers);
+ }
}
static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction)
{
- if (reconstruction->camnr) {
- writestruct(wd, DATA, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras);
- }
+ if (reconstruction->camnr) {
+ writestruct(
+ wd, DATA, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras);
+ }
}
static void write_movieclip(WriteData *wd, MovieClip *clip)
{
- if (clip->id.us > 0 || wd->use_memfile) {
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object;
+ if (clip->id.us > 0 || wd->use_memfile) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *object;
- writestruct(wd, ID_MC, MovieClip, 1, clip);
- write_iddata(wd, &clip->id);
+ writestruct(wd, ID_MC, MovieClip, 1, clip);
+ write_iddata(wd, &clip->id);
- if (clip->adt) {
- write_animdata(wd, clip->adt);
- }
+ if (clip->adt) {
+ write_animdata(wd, clip->adt);
+ }
- write_movieTracks(wd, &tracking->tracks);
- write_moviePlaneTracks(wd, &tracking->plane_tracks);
- write_movieReconstruction(wd, &tracking->reconstruction);
+ write_movieTracks(wd, &tracking->tracks);
+ write_moviePlaneTracks(wd, &tracking->plane_tracks);
+ write_movieReconstruction(wd, &tracking->reconstruction);
- object = tracking->objects.first;
- while (object) {
- writestruct(wd, DATA, MovieTrackingObject, 1, object);
+ object = tracking->objects.first;
+ while (object) {
+ writestruct(wd, DATA, MovieTrackingObject, 1, object);
- write_movieTracks(wd, &object->tracks);
- write_moviePlaneTracks(wd, &object->plane_tracks);
- write_movieReconstruction(wd, &object->reconstruction);
+ write_movieTracks(wd, &object->tracks);
+ write_moviePlaneTracks(wd, &object->plane_tracks);
+ write_movieReconstruction(wd, &object->reconstruction);
- object = object->next;
- }
- }
+ object = object->next;
+ }
+ }
}
static void write_mask(WriteData *wd, Mask *mask)
{
- if (mask->id.us > 0 || wd->use_memfile) {
- MaskLayer *masklay;
+ if (mask->id.us > 0 || wd->use_memfile) {
+ MaskLayer *masklay;
- writestruct(wd, ID_MSK, Mask, 1, mask);
- write_iddata(wd, &mask->id);
+ writestruct(wd, ID_MSK, Mask, 1, mask);
+ write_iddata(wd, &mask->id);
- if (mask->adt) {
- write_animdata(wd, mask->adt);
- }
+ if (mask->adt) {
+ write_animdata(wd, mask->adt);
+ }
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- MaskLayerShape *masklay_shape;
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+ MaskLayerShape *masklay_shape;
- writestruct(wd, DATA, MaskLayer, 1, masklay);
+ writestruct(wd, DATA, MaskLayer, 1, masklay);
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- int i;
+ for (spline = masklay->splines.first; spline; spline = spline->next) {
+ int i;
- void *points_deform = spline->points_deform;
- spline->points_deform = NULL;
+ void *points_deform = spline->points_deform;
+ spline->points_deform = NULL;
- writestruct(wd, DATA, MaskSpline, 1, spline);
- writestruct(wd, DATA, MaskSplinePoint, spline->tot_point, spline->points);
+ writestruct(wd, DATA, MaskSpline, 1, spline);
+ writestruct(wd, DATA, MaskSplinePoint, spline->tot_point, spline->points);
- spline->points_deform = points_deform;
+ spline->points_deform = points_deform;
- for (i = 0; i < spline->tot_point; i++) {
- MaskSplinePoint *point = &spline->points[i];
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
- if (point->tot_uw) {
- writestruct(wd, DATA, MaskSplinePointUW, point->tot_uw, point->uw);
- }
- }
- }
+ if (point->tot_uw) {
+ writestruct(wd, DATA, MaskSplinePointUW, point->tot_uw, point->uw);
+ }
+ }
+ }
- for (masklay_shape = masklay->splines_shapes.first;
- masklay_shape;
- masklay_shape = masklay_shape->next)
- {
- writestruct(wd, DATA, MaskLayerShape, 1, masklay_shape);
- writedata(wd, DATA,
- masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE,
- masklay_shape->data);
- }
- }
- }
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
+ masklay_shape = masklay_shape->next) {
+ writestruct(wd, DATA, MaskLayerShape, 1, masklay_shape);
+ writedata(wd,
+ DATA,
+ masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE,
+ masklay_shape->data);
+ }
+ }
+ }
}
static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
{
- LineStyleModifier *m;
-
- for (m = modifiers->first; m; m = m->next) {
- int struct_nr;
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Material);
- break;
- case LS_MODIFIER_TANGENT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Tangent);
- break;
- case LS_MODIFIER_NOISE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Noise);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_CreaseAngle);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Curvature_3D);
- break;
- default:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
- }
- writestruct_nr(wd, DATA, struct_nr, 1, m);
- }
- for (m = modifiers->first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
- break;
- case LS_MODIFIER_MATERIAL:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Material *)m)->color_ramp);
- break;
- case LS_MODIFIER_TANGENT:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Tangent *)m)->color_ramp);
- break;
- case LS_MODIFIER_NOISE:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Noise *)m)->color_ramp);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp);
- break;
- }
- }
+ LineStyleModifier *m;
+
+ for (m = modifiers->first; m; m = m->next) {
+ int struct_nr;
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Material);
+ break;
+ case LS_MODIFIER_TANGENT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Tangent);
+ break;
+ case LS_MODIFIER_NOISE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Noise);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_CreaseAngle);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Curvature_3D);
+ break;
+ default:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
+ }
+ writestruct_nr(wd, DATA, struct_nr, 1, m);
+ }
+ for (m = modifiers->first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ writestruct(
+ wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ writestruct(
+ wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Material *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_TANGENT:
+ writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Tangent *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_NOISE:
+ writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Noise *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ writestruct(
+ wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp);
+ break;
+ }
+ }
}
static void write_linestyle_alpha_modifiers(WriteData *wd, ListBase *modifiers)
{
- LineStyleModifier *m;
-
- for (m = modifiers->first; m; m = m->next) {
- int struct_nr;
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Material);
- break;
- case LS_MODIFIER_TANGENT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Tangent);
- break;
- case LS_MODIFIER_NOISE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Noise);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_CreaseAngle);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Curvature_3D);
- break;
- default:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
- }
- writestruct_nr(wd, DATA, struct_nr, 1, m);
- }
- for (m = modifiers->first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
- break;
- case LS_MODIFIER_MATERIAL:
- write_curvemapping(wd, ((LineStyleAlphaModifier_Material *)m)->curve);
- break;
- case LS_MODIFIER_TANGENT:
- write_curvemapping(wd, ((LineStyleAlphaModifier_Tangent *)m)->curve);
- break;
- case LS_MODIFIER_NOISE:
- write_curvemapping(wd, ((LineStyleAlphaModifier_Noise *)m)->curve);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- write_curvemapping(wd, ((LineStyleAlphaModifier_CreaseAngle *)m)->curve);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- write_curvemapping(wd, ((LineStyleAlphaModifier_Curvature_3D *)m)->curve);
- break;
- }
- }
+ LineStyleModifier *m;
+
+ for (m = modifiers->first; m; m = m->next) {
+ int struct_nr;
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Material);
+ break;
+ case LS_MODIFIER_TANGENT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Tangent);
+ break;
+ case LS_MODIFIER_NOISE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Noise);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_CreaseAngle);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Curvature_3D);
+ break;
+ default:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
+ }
+ writestruct_nr(wd, DATA, struct_nr, 1, m);
+ }
+ for (m = modifiers->first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_Material *)m)->curve);
+ break;
+ case LS_MODIFIER_TANGENT:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_Tangent *)m)->curve);
+ break;
+ case LS_MODIFIER_NOISE:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_Noise *)m)->curve);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_CreaseAngle *)m)->curve);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ write_curvemapping(wd, ((LineStyleAlphaModifier_Curvature_3D *)m)->curve);
+ break;
+ }
+ }
}
static void write_linestyle_thickness_modifiers(WriteData *wd, ListBase *modifiers)
{
- LineStyleModifier *m;
-
- for (m = modifiers->first; m; m = m->next) {
- int struct_nr;
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Material);
- break;
- case LS_MODIFIER_CALLIGRAPHY:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Calligraphy);
- break;
- case LS_MODIFIER_TANGENT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Tangent);
- break;
- case LS_MODIFIER_NOISE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Noise);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_CreaseAngle);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Curvature_3D);
- break;
- default:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
- }
- writestruct_nr(wd, DATA, struct_nr, 1, m);
- }
- for (m = modifiers->first; m; m = m->next) {
- switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
- break;
- case LS_MODIFIER_MATERIAL:
- write_curvemapping(wd, ((LineStyleThicknessModifier_Material *)m)->curve);
- break;
- case LS_MODIFIER_TANGENT:
- write_curvemapping(wd, ((LineStyleThicknessModifier_Tangent *)m)->curve);
- break;
- case LS_MODIFIER_CREASE_ANGLE:
- write_curvemapping(wd, ((LineStyleThicknessModifier_CreaseAngle *)m)->curve);
- break;
- case LS_MODIFIER_CURVATURE_3D:
- write_curvemapping(wd, ((LineStyleThicknessModifier_Curvature_3D *)m)->curve);
- break;
- }
- }
+ LineStyleModifier *m;
+
+ for (m = modifiers->first; m; m = m->next) {
+ int struct_nr;
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Material);
+ break;
+ case LS_MODIFIER_CALLIGRAPHY:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Calligraphy);
+ break;
+ case LS_MODIFIER_TANGENT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Tangent);
+ break;
+ case LS_MODIFIER_NOISE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Noise);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_CreaseAngle);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Curvature_3D);
+ break;
+ default:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
+ }
+ writestruct_nr(wd, DATA, struct_nr, 1, m);
+ }
+ for (m = modifiers->first; m; m = m->next) {
+ switch (m->type) {
+ case LS_MODIFIER_ALONG_STROKE:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_Material *)m)->curve);
+ break;
+ case LS_MODIFIER_TANGENT:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_Tangent *)m)->curve);
+ break;
+ case LS_MODIFIER_CREASE_ANGLE:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_CreaseAngle *)m)->curve);
+ break;
+ case LS_MODIFIER_CURVATURE_3D:
+ write_curvemapping(wd, ((LineStyleThicknessModifier_Curvature_3D *)m)->curve);
+ break;
+ }
+ }
}
static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifiers)
{
- LineStyleModifier *m;
-
- for (m = modifiers->first; m; m = m->next) {
- int struct_nr;
- switch (m->type) {
- case LS_MODIFIER_SAMPLING:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Sampling);
- break;
- case LS_MODIFIER_BEZIER_CURVE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BezierCurve);
- break;
- case LS_MODIFIER_SINUS_DISPLACEMENT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SinusDisplacement);
- break;
- case LS_MODIFIER_SPATIAL_NOISE:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SpatialNoise);
- break;
- case LS_MODIFIER_PERLIN_NOISE_1D:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise1D);
- break;
- case LS_MODIFIER_PERLIN_NOISE_2D:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise2D);
- break;
- case LS_MODIFIER_BACKBONE_STRETCHER:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BackboneStretcher);
- break;
- case LS_MODIFIER_TIP_REMOVER:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_TipRemover);
- break;
- case LS_MODIFIER_POLYGONIZATION:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Polygonalization);
- break;
- case LS_MODIFIER_GUIDING_LINES:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_GuidingLines);
- break;
- case LS_MODIFIER_BLUEPRINT:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Blueprint);
- break;
- case LS_MODIFIER_2D_OFFSET:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DOffset);
- break;
- case LS_MODIFIER_2D_TRANSFORM:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DTransform);
- break;
- case LS_MODIFIER_SIMPLIFICATION:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Simplification);
- break;
- default:
- struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
- }
- writestruct_nr(wd, DATA, struct_nr, 1, m);
- }
+ LineStyleModifier *m;
+
+ for (m = modifiers->first; m; m = m->next) {
+ int struct_nr;
+ switch (m->type) {
+ case LS_MODIFIER_SAMPLING:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Sampling);
+ break;
+ case LS_MODIFIER_BEZIER_CURVE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BezierCurve);
+ break;
+ case LS_MODIFIER_SINUS_DISPLACEMENT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SinusDisplacement);
+ break;
+ case LS_MODIFIER_SPATIAL_NOISE:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SpatialNoise);
+ break;
+ case LS_MODIFIER_PERLIN_NOISE_1D:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise1D);
+ break;
+ case LS_MODIFIER_PERLIN_NOISE_2D:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise2D);
+ break;
+ case LS_MODIFIER_BACKBONE_STRETCHER:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BackboneStretcher);
+ break;
+ case LS_MODIFIER_TIP_REMOVER:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_TipRemover);
+ break;
+ case LS_MODIFIER_POLYGONIZATION:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Polygonalization);
+ break;
+ case LS_MODIFIER_GUIDING_LINES:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_GuidingLines);
+ break;
+ case LS_MODIFIER_BLUEPRINT:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Blueprint);
+ break;
+ case LS_MODIFIER_2D_OFFSET:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DOffset);
+ break;
+ case LS_MODIFIER_2D_TRANSFORM:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DTransform);
+ break;
+ case LS_MODIFIER_SIMPLIFICATION:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Simplification);
+ break;
+ default:
+ struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
+ }
+ writestruct_nr(wd, DATA, struct_nr, 1, m);
+ }
}
static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle)
{
- if (linestyle->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle);
- write_iddata(wd, &linestyle->id);
-
- if (linestyle->adt) {
- write_animdata(wd, linestyle->adt);
- }
-
- write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
- write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
- write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
- write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
- for (int a = 0; a < MAX_MTEX; a++) {
- if (linestyle->mtex[a]) {
- writestruct(wd, DATA, MTex, 1, linestyle->mtex[a]);
- }
- }
- if (linestyle->nodetree) {
- writestruct(wd, DATA, bNodeTree, 1, linestyle->nodetree);
- write_nodetree_nolib(wd, linestyle->nodetree);
- }
- }
+ if (linestyle->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle);
+ write_iddata(wd, &linestyle->id);
+
+ if (linestyle->adt) {
+ write_animdata(wd, linestyle->adt);
+ }
+
+ write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
+ write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
+ write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
+ write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ writestruct(wd, DATA, MTex, 1, linestyle->mtex[a]);
+ }
+ }
+ if (linestyle->nodetree) {
+ writestruct(wd, DATA, bNodeTree, 1, linestyle->nodetree);
+ write_nodetree_nolib(wd, linestyle->nodetree);
+ }
+ }
}
static void write_cachefile(WriteData *wd, CacheFile *cache_file)
{
- if (cache_file->id.us > 0 || wd->use_memfile) {
- writestruct(wd, ID_CF, CacheFile, 1, cache_file);
+ if (cache_file->id.us > 0 || wd->use_memfile) {
+ writestruct(wd, ID_CF, CacheFile, 1, cache_file);
- if (cache_file->adt) {
- write_animdata(wd, cache_file->adt);
- }
- }
+ if (cache_file->adt) {
+ write_animdata(wd, cache_file->adt);
+ }
+ }
}
static void write_workspace(WriteData *wd, WorkSpace *workspace)
{
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
-
- writestruct(wd, ID_WS, WorkSpace, 1, workspace);
- writelist(wd, DATA, WorkSpaceLayout, layouts);
- writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
- writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
- writelist(wd, DATA, bToolRef, &workspace->tools);
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
- if (tref->properties) {
- IDP_WriteProperty(tref->properties, wd);
- }
- }
+ ListBase *layouts = BKE_workspace_layouts_get(workspace);
+
+ writestruct(wd, ID_WS, WorkSpace, 1, workspace);
+ writelist(wd, DATA, WorkSpaceLayout, layouts);
+ writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
+ writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
+ writelist(wd, DATA, bToolRef, &workspace->tools);
+ for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ if (tref->properties) {
+ IDP_WriteProperty(tref->properties, wd);
+ }
+ }
}
/* Keep it last of write_foodata functions. */
static void write_libraries(WriteData *wd, Main *main)
{
- ListBase *lbarray[MAX_LIBARRAY];
- ID *id;
- int a, tot;
- bool found_one;
-
- for (; main; main = main->next) {
- a = tot = set_listbasepointers(main, lbarray);
-
- /* test: is lib being used */
- if (main->curlib && main->curlib->packedfile) {
- found_one = true;
- }
- else {
- found_one = false;
- while (!found_one && tot--) {
- for (id = lbarray[tot]->first; id; id = id->next) {
- if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
- found_one = true;
- break;
- }
- }
- }
- }
-
- /* to be able to restore quit.blend and temp saves, the packed blend has to be in undo buffers... */
- /* XXX needs rethink, just like save UI in undo files now - would be nice to append things only for the]
- * quit.blend and temp saves */
- if (found_one) {
- /* Not overridable. */
-
- writestruct(wd, ID_LI, Library, 1, main->curlib);
- write_iddata(wd, &main->curlib->id);
-
- if (main->curlib->packedfile) {
- PackedFile *pf = main->curlib->packedfile;
- writestruct(wd, DATA, PackedFile, 1, pf);
- writedata(wd, DATA, pf->size, pf->data);
- if (wd->use_memfile == false) {
- printf("write packed .blend: %s\n", main->curlib->name);
- }
- }
-
- /* Write link placeholders for all direct linked IDs. */
- while (a--) {
- for (id = lbarray[a]->first; id; id = id->next) {
- if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
- if (!BKE_idcode_is_linkable(GS(id->name))) {
- printf("ERROR: write file: data-block '%s' from lib '%s' is not linkable "
- "but is flagged as directly linked", id->name, main->curlib->filepath);
- BLI_assert(0);
- }
- writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id);
- }
- }
- }
- }
- }
-
- mywrite_flush(wd);
+ ListBase *lbarray[MAX_LIBARRAY];
+ ID *id;
+ int a, tot;
+ bool found_one;
+
+ for (; main; main = main->next) {
+ a = tot = set_listbasepointers(main, lbarray);
+
+ /* test: is lib being used */
+ if (main->curlib && main->curlib->packedfile) {
+ found_one = true;
+ }
+ else {
+ found_one = false;
+ while (!found_one && tot--) {
+ for (id = lbarray[tot]->first; id; id = id->next) {
+ if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
+ found_one = true;
+ break;
+ }
+ }
+ }
+ }
+
+ /* to be able to restore quit.blend and temp saves, the packed blend has to be in undo buffers... */
+ /* XXX needs rethink, just like save UI in undo files now - would be nice to append things only for the]
+ * quit.blend and temp saves */
+ if (found_one) {
+ /* Not overridable. */
+
+ writestruct(wd, ID_LI, Library, 1, main->curlib);
+ write_iddata(wd, &main->curlib->id);
+
+ if (main->curlib->packedfile) {
+ PackedFile *pf = main->curlib->packedfile;
+ writestruct(wd, DATA, PackedFile, 1, pf);
+ writedata(wd, DATA, pf->size, pf->data);
+ if (wd->use_memfile == false) {
+ printf("write packed .blend: %s\n", main->curlib->name);
+ }
+ }
+
+ /* Write link placeholders for all direct linked IDs. */
+ while (a--) {
+ for (id = lbarray[a]->first; id; id = id->next) {
+ if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
+ if (!BKE_idcode_is_linkable(GS(id->name))) {
+ printf(
+ "ERROR: write file: data-block '%s' from lib '%s' is not linkable "
+ "but is flagged as directly linked",
+ id->name,
+ main->curlib->filepath);
+ BLI_assert(0);
+ }
+ writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id);
+ }
+ }
+ }
+ }
+ }
+
+ mywrite_flush(wd);
}
/* context is usually defined by WM, two cases where no WM is available:
@@ -3774,50 +3785,50 @@ static void write_libraries(WriteData *wd, Main *main)
* - for undofile, curscene needs to be saved */
static void write_global(WriteData *wd, int fileflags, Main *mainvar)
{
- const bool is_undo = wd->use_memfile;
- FileGlobal fg;
- bScreen *screen;
- Scene *scene;
- ViewLayer *view_layer;
- char subvstr[8];
-
- /* prevent mem checkers from complaining */
- memset(fg._pad, 0, sizeof(fg._pad));
- memset(fg.filename, 0, sizeof(fg.filename));
- memset(fg.build_hash, 0, sizeof(fg.build_hash));
- fg._pad1 = NULL;
-
- current_screen_compat(mainvar, is_undo, &screen, &scene, &view_layer);
-
- /* XXX still remap G */
- fg.curscreen = screen;
- fg.curscene = scene;
- fg.cur_view_layer = view_layer;
-
- /* prevent to save this, is not good convention, and feature with concerns... */
- fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
-
- fg.globalf = G.f;
- BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
- sprintf(subvstr, "%4d", BLENDER_SUBVERSION);
- memcpy(fg.subvstr, subvstr, 4);
-
- fg.subversion = BLENDER_SUBVERSION;
- fg.minversion = BLENDER_MINVERSION;
- fg.minsubversion = BLENDER_MINSUBVERSION;
+ const bool is_undo = wd->use_memfile;
+ FileGlobal fg;
+ bScreen *screen;
+ Scene *scene;
+ ViewLayer *view_layer;
+ char subvstr[8];
+
+ /* prevent mem checkers from complaining */
+ memset(fg._pad, 0, sizeof(fg._pad));
+ memset(fg.filename, 0, sizeof(fg.filename));
+ memset(fg.build_hash, 0, sizeof(fg.build_hash));
+ fg._pad1 = NULL;
+
+ current_screen_compat(mainvar, is_undo, &screen, &scene, &view_layer);
+
+ /* XXX still remap G */
+ fg.curscreen = screen;
+ fg.curscene = scene;
+ fg.cur_view_layer = view_layer;
+
+ /* prevent to save this, is not good convention, and feature with concerns... */
+ fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
+
+ fg.globalf = G.f;
+ BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
+ sprintf(subvstr, "%4d", BLENDER_SUBVERSION);
+ memcpy(fg.subvstr, subvstr, 4);
+
+ fg.subversion = BLENDER_SUBVERSION;
+ fg.minversion = BLENDER_MINVERSION;
+ fg.minsubversion = BLENDER_MINSUBVERSION;
#ifdef WITH_BUILDINFO
- {
- extern unsigned long build_commit_timestamp;
- extern char build_hash[];
- /* TODO(sergey): Add branch name to file as well? */
- fg.build_commit_timestamp = build_commit_timestamp;
- BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
- }
+ {
+ extern unsigned long build_commit_timestamp;
+ extern char build_hash[];
+ /* TODO(sergey): Add branch name to file as well? */
+ fg.build_commit_timestamp = build_commit_timestamp;
+ BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
+ }
#else
- fg.build_commit_timestamp = 0;
- BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash));
+ fg.build_commit_timestamp = 0;
+ BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash));
#endif
- writestruct(wd, GLOB, FileGlobal, 1, &fg);
+ writestruct(wd, GLOB, FileGlobal, 1, &fg);
}
/* preview image, first 2 values are width and height
@@ -3826,9 +3837,9 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
*/
static void write_thumb(WriteData *wd, const BlendThumbnail *thumb)
{
- if (thumb) {
- writedata(wd, TEST, BLEN_THUMB_MEMSIZE_FILE(thumb->width, thumb->height), thumb);
- }
+ if (thumb) {
+ writedata(wd, TEST, BLEN_THUMB_MEMSIZE_FILE(thumb->width, thumb->height), thumb);
+ }
}
/** \} */
@@ -3838,276 +3849,281 @@ static void write_thumb(WriteData *wd, const BlendThumbnail *thumb)
* \{ */
/* if MemFile * there's filesave to memory */
-static bool write_file_handle(
- Main *mainvar,
- WriteWrap *ww,
- MemFile *compare, MemFile *current,
- int write_flags, const BlendThumbnail *thumb)
+static bool write_file_handle(Main *mainvar,
+ WriteWrap *ww,
+ MemFile *compare,
+ MemFile *current,
+ int write_flags,
+ const BlendThumbnail *thumb)
{
- BHead bhead;
- ListBase mainlist;
- char buf[16];
- WriteData *wd;
+ BHead bhead;
+ ListBase mainlist;
+ char buf[16];
+ WriteData *wd;
- blo_split_main(&mainlist, mainvar);
+ blo_split_main(&mainlist, mainvar);
- wd = mywrite_begin(ww, compare, current);
+ wd = mywrite_begin(ww, compare, current);
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* don't write compatibility data on undo */
- if (!current) {
- /* deprecated forward compat data is freed again below */
- customnodes_add_deprecated_data(mainvar);
- }
+ /* don't write compatibility data on undo */
+ if (!current) {
+ /* deprecated forward compat data is freed again below */
+ customnodes_add_deprecated_data(mainvar);
+ }
#endif
- sprintf(buf, "BLENDER%c%c%.3d",
- (sizeof(void *) == 8) ? '-' : '_',
- (ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v',
- BLENDER_VERSION);
-
- mywrite(wd, buf, 12);
-
- write_renderinfo(wd, mainvar);
- write_thumb(wd, thumb);
- write_global(wd, write_flags, mainvar);
-
- /* The windowmanager and screen often change,
- * avoid thumbnail detecting changes because of this. */
- mywrite_flush(wd);
-
- OverrideStaticStorage *override_storage = wd->use_memfile ? NULL : BKE_override_static_operations_store_initialize();
-
- /* This outer loop allows to save first datablocks from real mainvar, then the temp ones from override process,
- * if needed, without duplicating whole code. */
- Main *bmain = mainvar;
- do {
- ListBase *lbarray[MAX_LIBARRAY];
- int a = set_listbasepointers(bmain, lbarray);
- while (a--) {
- ID *id = lbarray[a]->first;
-
- if (id && GS(id->name) == ID_LI) {
- continue; /* Libraries are handled separately below. */
- }
-
- for (; id; id = id->next) {
- /* We should never attempt to write non-regular IDs (i.e. all kind of temp/runtime ones). */
- BLI_assert((id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
-
- const bool do_override = !ELEM(override_storage, NULL, bmain) && id->override_static;
-
- if (do_override) {
- BKE_override_static_operations_store_start(bmain, override_storage, id);
- }
-
- switch ((ID_Type)GS(id->name)) {
- case ID_WM:
- write_windowmanager(wd, (wmWindowManager *)id);
- break;
- case ID_WS:
- write_workspace(wd, (WorkSpace *)id);
- break;
- case ID_SCR:
- write_screen(wd, (bScreen *)id);
- break;
- case ID_MC:
- write_movieclip(wd, (MovieClip *)id);
- break;
- case ID_MSK:
- write_mask(wd, (Mask *)id);
- break;
- case ID_SCE:
- write_scene(wd, (Scene *)id);
- break;
- case ID_CU:
- write_curve(wd, (Curve *)id);
- break;
- case ID_MB:
- write_mball(wd, (MetaBall *)id);
- break;
- case ID_IM:
- write_image(wd, (Image *)id);
- break;
- case ID_CA:
- write_camera(wd, (Camera *)id);
- break;
- case ID_LA:
- write_light(wd, (Light *)id);
- break;
- case ID_LT:
- write_lattice(wd, (Lattice *)id);
- break;
- case ID_VF:
- write_vfont(wd, (VFont *)id);
- break;
- case ID_KE:
- write_key(wd, (Key *)id);
- break;
- case ID_WO:
- write_world(wd, (World *)id);
- break;
- case ID_TXT:
- write_text(wd, (Text *)id);
- break;
- case ID_SPK:
- write_speaker(wd, (Speaker *)id);
- break;
- case ID_LP:
- write_probe(wd, (LightProbe *)id);
- break;
- case ID_SO:
- write_sound(wd, (bSound *)id);
- break;
- case ID_GR:
- write_collection(wd, (Collection *)id);
- break;
- case ID_AR:
- write_armature(wd, (bArmature *)id);
- break;
- case ID_AC:
- write_action(wd, (bAction *)id);
- break;
- case ID_OB:
- write_object(wd, (Object *)id);
- break;
- case ID_MA:
- write_material(wd, (Material *)id);
- break;
- case ID_TE:
- write_texture(wd, (Tex *)id);
- break;
- case ID_ME:
- write_mesh(wd, (Mesh *)id);
- break;
- case ID_PA:
- write_particlesettings(wd, (ParticleSettings *)id);
- break;
- case ID_NT:
- write_nodetree(wd, (bNodeTree *)id);
- break;
- case ID_BR:
- write_brush(wd, (Brush *)id);
- break;
- case ID_PAL:
- write_palette(wd, (Palette *)id);
- break;
- case ID_PC:
- write_paintcurve(wd, (PaintCurve *)id);
- break;
- case ID_GD:
- write_gpencil(wd, (bGPdata *)id);
- break;
- case ID_LS:
- write_linestyle(wd, (FreestyleLineStyle *)id);
- break;
- case ID_CF:
- write_cachefile(wd, (CacheFile *)id);
- break;
- case ID_LI:
- /* Do nothing, handled below - and should never be reached. */
- BLI_assert(0);
- break;
- case ID_IP:
- /* Do nothing, deprecated. */
- break;
- default:
- /* Should never be reached. */
- BLI_assert(0);
- break;
- }
-
- if (do_override) {
- BKE_override_static_operations_store_end(override_storage, id);
- }
- }
-
- mywrite_flush(wd);
- }
- } while ((bmain != override_storage) && (bmain = override_storage));
-
- if (override_storage) {
- BKE_override_static_operations_store_finalize(override_storage);
- override_storage = NULL;
- }
-
- /* Special handling, operating over split Mains... */
- write_libraries(wd, mainvar->next);
-
- /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */
- mywrite_flush(wd);
-
- if (write_flags & G_FILE_USERPREFS) {
- write_userdef(wd, &U);
- }
-
- /* Write DNA last, because (to be implemented) test for which structs are written.
- *
- * Note that we *borrow* the pointer to 'DNAstr',
- * so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
- writedata(wd, DNA1, wd->sdna->data_len, wd->sdna->data);
+ sprintf(buf,
+ "BLENDER%c%c%.3d",
+ (sizeof(void *) == 8) ? '-' : '_',
+ (ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v',
+ BLENDER_VERSION);
+
+ mywrite(wd, buf, 12);
+
+ write_renderinfo(wd, mainvar);
+ write_thumb(wd, thumb);
+ write_global(wd, write_flags, mainvar);
+
+ /* The windowmanager and screen often change,
+ * avoid thumbnail detecting changes because of this. */
+ mywrite_flush(wd);
+
+ OverrideStaticStorage *override_storage = wd->use_memfile ?
+ NULL :
+ BKE_override_static_operations_store_initialize();
+
+ /* This outer loop allows to save first datablocks from real mainvar, then the temp ones from override process,
+ * if needed, without duplicating whole code. */
+ Main *bmain = mainvar;
+ do {
+ ListBase *lbarray[MAX_LIBARRAY];
+ int a = set_listbasepointers(bmain, lbarray);
+ while (a--) {
+ ID *id = lbarray[a]->first;
+
+ if (id && GS(id->name) == ID_LI) {
+ continue; /* Libraries are handled separately below. */
+ }
+
+ for (; id; id = id->next) {
+ /* We should never attempt to write non-regular IDs (i.e. all kind of temp/runtime ones). */
+ BLI_assert(
+ (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
+
+ const bool do_override = !ELEM(override_storage, NULL, bmain) && id->override_static;
+
+ if (do_override) {
+ BKE_override_static_operations_store_start(bmain, override_storage, id);
+ }
+
+ switch ((ID_Type)GS(id->name)) {
+ case ID_WM:
+ write_windowmanager(wd, (wmWindowManager *)id);
+ break;
+ case ID_WS:
+ write_workspace(wd, (WorkSpace *)id);
+ break;
+ case ID_SCR:
+ write_screen(wd, (bScreen *)id);
+ break;
+ case ID_MC:
+ write_movieclip(wd, (MovieClip *)id);
+ break;
+ case ID_MSK:
+ write_mask(wd, (Mask *)id);
+ break;
+ case ID_SCE:
+ write_scene(wd, (Scene *)id);
+ break;
+ case ID_CU:
+ write_curve(wd, (Curve *)id);
+ break;
+ case ID_MB:
+ write_mball(wd, (MetaBall *)id);
+ break;
+ case ID_IM:
+ write_image(wd, (Image *)id);
+ break;
+ case ID_CA:
+ write_camera(wd, (Camera *)id);
+ break;
+ case ID_LA:
+ write_light(wd, (Light *)id);
+ break;
+ case ID_LT:
+ write_lattice(wd, (Lattice *)id);
+ break;
+ case ID_VF:
+ write_vfont(wd, (VFont *)id);
+ break;
+ case ID_KE:
+ write_key(wd, (Key *)id);
+ break;
+ case ID_WO:
+ write_world(wd, (World *)id);
+ break;
+ case ID_TXT:
+ write_text(wd, (Text *)id);
+ break;
+ case ID_SPK:
+ write_speaker(wd, (Speaker *)id);
+ break;
+ case ID_LP:
+ write_probe(wd, (LightProbe *)id);
+ break;
+ case ID_SO:
+ write_sound(wd, (bSound *)id);
+ break;
+ case ID_GR:
+ write_collection(wd, (Collection *)id);
+ break;
+ case ID_AR:
+ write_armature(wd, (bArmature *)id);
+ break;
+ case ID_AC:
+ write_action(wd, (bAction *)id);
+ break;
+ case ID_OB:
+ write_object(wd, (Object *)id);
+ break;
+ case ID_MA:
+ write_material(wd, (Material *)id);
+ break;
+ case ID_TE:
+ write_texture(wd, (Tex *)id);
+ break;
+ case ID_ME:
+ write_mesh(wd, (Mesh *)id);
+ break;
+ case ID_PA:
+ write_particlesettings(wd, (ParticleSettings *)id);
+ break;
+ case ID_NT:
+ write_nodetree(wd, (bNodeTree *)id);
+ break;
+ case ID_BR:
+ write_brush(wd, (Brush *)id);
+ break;
+ case ID_PAL:
+ write_palette(wd, (Palette *)id);
+ break;
+ case ID_PC:
+ write_paintcurve(wd, (PaintCurve *)id);
+ break;
+ case ID_GD:
+ write_gpencil(wd, (bGPdata *)id);
+ break;
+ case ID_LS:
+ write_linestyle(wd, (FreestyleLineStyle *)id);
+ break;
+ case ID_CF:
+ write_cachefile(wd, (CacheFile *)id);
+ break;
+ case ID_LI:
+ /* Do nothing, handled below - and should never be reached. */
+ BLI_assert(0);
+ break;
+ case ID_IP:
+ /* Do nothing, deprecated. */
+ break;
+ default:
+ /* Should never be reached. */
+ BLI_assert(0);
+ break;
+ }
+
+ if (do_override) {
+ BKE_override_static_operations_store_end(override_storage, id);
+ }
+ }
+
+ mywrite_flush(wd);
+ }
+ } while ((bmain != override_storage) && (bmain = override_storage));
+
+ if (override_storage) {
+ BKE_override_static_operations_store_finalize(override_storage);
+ override_storage = NULL;
+ }
+
+ /* Special handling, operating over split Mains... */
+ write_libraries(wd, mainvar->next);
+
+ /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */
+ mywrite_flush(wd);
+
+ if (write_flags & G_FILE_USERPREFS) {
+ write_userdef(wd, &U);
+ }
+
+ /* Write DNA last, because (to be implemented) test for which structs are written.
+ *
+ * Note that we *borrow* the pointer to 'DNAstr',
+ * so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
+ writedata(wd, DNA1, wd->sdna->data_len, wd->sdna->data);
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* compatibility data not created on undo */
- if (!current) {
- /* Ugly, forward compatibility code generates deprecated data during writing,
- * this has to be freed again. Can not be done directly after writing, otherwise
- * the data pointers could be reused and not be mapped correctly.
- */
- customnodes_free_deprecated_data(mainvar);
- }
+ /* compatibility data not created on undo */
+ if (!current) {
+ /* Ugly, forward compatibility code generates deprecated data during writing,
+ * this has to be freed again. Can not be done directly after writing, otherwise
+ * the data pointers could be reused and not be mapped correctly.
+ */
+ customnodes_free_deprecated_data(mainvar);
+ }
#endif
- /* end of file */
- memset(&bhead, 0, sizeof(BHead));
- bhead.code = ENDB;
- mywrite(wd, &bhead, sizeof(BHead));
+ /* end of file */
+ memset(&bhead, 0, sizeof(BHead));
+ bhead.code = ENDB;
+ mywrite(wd, &bhead, sizeof(BHead));
- blo_join_main(&mainlist);
+ blo_join_main(&mainlist);
- return mywrite_end(wd);
+ return mywrite_end(wd);
}
/* do reverse file history: .blend1 -> .blend2, .blend -> .blend1 */
/* return: success(0), failure(1) */
static bool do_history(const char *name, ReportList *reports)
{
- char tempname1[FILE_MAX], tempname2[FILE_MAX];
- int hisnr = U.versions;
-
- if (U.versions == 0) {
- return 0;
- }
-
- if (strlen(name) < 2) {
- BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
- return 1;
- }
-
- while (hisnr > 1) {
- BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr - 1);
- if (BLI_exists(tempname1)) {
- BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr);
-
- if (BLI_rename(tempname1, tempname2)) {
- BKE_report(reports, RPT_ERROR, "Unable to make version backup");
- return true;
- }
- }
- hisnr--;
- }
-
- /* is needed when hisnr==1 */
- if (BLI_exists(name)) {
- BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
-
- if (BLI_rename(name, tempname1)) {
- BKE_report(reports, RPT_ERROR, "Unable to make version backup");
- return true;
- }
- }
-
- return 0;
+ char tempname1[FILE_MAX], tempname2[FILE_MAX];
+ int hisnr = U.versions;
+
+ if (U.versions == 0) {
+ return 0;
+ }
+
+ if (strlen(name) < 2) {
+ BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
+ return 1;
+ }
+
+ while (hisnr > 1) {
+ BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr - 1);
+ if (BLI_exists(tempname1)) {
+ BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr);
+
+ if (BLI_rename(tempname1, tempname2)) {
+ BKE_report(reports, RPT_ERROR, "Unable to make version backup");
+ return true;
+ }
+ }
+ hisnr--;
+ }
+
+ /* is needed when hisnr==1 */
+ if (BLI_exists(name)) {
+ BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
+
+ if (BLI_rename(name, tempname1)) {
+ BKE_report(reports, RPT_ERROR, "Unable to make version backup");
+ return true;
+ }
+ }
+
+ return 0;
}
/** \} */
@@ -4119,114 +4135,117 @@ static bool do_history(const char *name, ReportList *reports)
/**
* \return Success.
*/
-bool BLO_write_file(
- Main *mainvar, const char *filepath, int write_flags,
- ReportList *reports, const BlendThumbnail *thumb)
+bool BLO_write_file(Main *mainvar,
+ const char *filepath,
+ int write_flags,
+ ReportList *reports,
+ const BlendThumbnail *thumb)
{
- char tempname[FILE_MAX + 1];
- eWriteWrapType ww_type;
- WriteWrap ww;
-
- /* path backup/restore */
- void *path_list_backup = NULL;
- const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
-
- if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
- BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* save to disk");
- BLO_main_validate_libraries(mainvar, reports);
- BLO_main_validate_shapekeys(mainvar, reports);
- }
-
- /* open temporary file, so we preserve the original in case we crash */
- BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
-
- if (write_flags & G_FILE_COMPRESS) {
- ww_type = WW_WRAP_ZLIB;
- }
- else {
- ww_type = WW_WRAP_NONE;
- }
-
- ww_handle_init(ww_type, &ww);
-
- if (ww.open(&ww, tempname) == false) {
- BKE_reportf(reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
- return 0;
- }
-
- /* check if we need to backup and restore paths */
- if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) {
- path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag);
- }
-
- /* remapping of relative paths to new file location */
- if (write_flags & G_FILE_RELATIVE_REMAP) {
- char dir1[FILE_MAX];
- char dir2[FILE_MAX];
- BLI_split_dir_part(filepath, dir1, sizeof(dir1));
- BLI_split_dir_part(mainvar->name, dir2, sizeof(dir2));
-
- /* just in case there is some subtle difference */
- BLI_cleanup_dir(mainvar->name, dir1);
- BLI_cleanup_dir(mainvar->name, dir2);
-
- if (G.relbase_valid && (BLI_path_cmp(dir1, dir2) == 0)) {
- write_flags &= ~G_FILE_RELATIVE_REMAP;
- }
- else {
- if (G.relbase_valid) {
- /* blend may not have been saved before. Tn this case
- * we should not have any relative paths, but if there
- * is somehow, an invalid or empty G_MAIN->name it will
- * print an error, don't try make the absolute in this case. */
- BKE_bpath_absolute_convert(mainvar, BKE_main_blendfile_path_from_global(), NULL);
- }
- }
- }
-
- if (write_flags & G_FILE_RELATIVE_REMAP) {
- /* note, making relative to something OTHER then G_MAIN->name */
- BKE_bpath_relative_convert(mainvar, filepath, NULL);
- }
-
- /* actual file writing */
- const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, thumb);
-
- ww.close(&ww);
-
- if (UNLIKELY(path_list_backup)) {
- BKE_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
- BKE_bpath_list_free(path_list_backup);
- }
-
- if (err) {
- BKE_report(reports, RPT_ERROR, strerror(errno));
- remove(tempname);
-
- return 0;
- }
-
- /* file save to temporary file was successful */
- /* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
- if (write_flags & G_FILE_HISTORY) {
- const bool err_hist = do_history(filepath, reports);
- if (err_hist) {
- BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
- return 0;
- }
- }
-
- if (BLI_rename(tempname, filepath) != 0) {
- BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
- return 0;
- }
-
- if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
- BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* save to disk");
- BLO_main_validate_libraries(mainvar, reports);
- }
-
- return 1;
+ char tempname[FILE_MAX + 1];
+ eWriteWrapType ww_type;
+ WriteWrap ww;
+
+ /* path backup/restore */
+ void *path_list_backup = NULL;
+ const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
+
+ if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* save to disk");
+ BLO_main_validate_libraries(mainvar, reports);
+ BLO_main_validate_shapekeys(mainvar, reports);
+ }
+
+ /* open temporary file, so we preserve the original in case we crash */
+ BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
+
+ if (write_flags & G_FILE_COMPRESS) {
+ ww_type = WW_WRAP_ZLIB;
+ }
+ else {
+ ww_type = WW_WRAP_NONE;
+ }
+
+ ww_handle_init(ww_type, &ww);
+
+ if (ww.open(&ww, tempname) == false) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
+ return 0;
+ }
+
+ /* check if we need to backup and restore paths */
+ if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) {
+ path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag);
+ }
+
+ /* remapping of relative paths to new file location */
+ if (write_flags & G_FILE_RELATIVE_REMAP) {
+ char dir1[FILE_MAX];
+ char dir2[FILE_MAX];
+ BLI_split_dir_part(filepath, dir1, sizeof(dir1));
+ BLI_split_dir_part(mainvar->name, dir2, sizeof(dir2));
+
+ /* just in case there is some subtle difference */
+ BLI_cleanup_dir(mainvar->name, dir1);
+ BLI_cleanup_dir(mainvar->name, dir2);
+
+ if (G.relbase_valid && (BLI_path_cmp(dir1, dir2) == 0)) {
+ write_flags &= ~G_FILE_RELATIVE_REMAP;
+ }
+ else {
+ if (G.relbase_valid) {
+ /* blend may not have been saved before. Tn this case
+ * we should not have any relative paths, but if there
+ * is somehow, an invalid or empty G_MAIN->name it will
+ * print an error, don't try make the absolute in this case. */
+ BKE_bpath_absolute_convert(mainvar, BKE_main_blendfile_path_from_global(), NULL);
+ }
+ }
+ }
+
+ if (write_flags & G_FILE_RELATIVE_REMAP) {
+ /* note, making relative to something OTHER then G_MAIN->name */
+ BKE_bpath_relative_convert(mainvar, filepath, NULL);
+ }
+
+ /* actual file writing */
+ const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, thumb);
+
+ ww.close(&ww);
+
+ if (UNLIKELY(path_list_backup)) {
+ BKE_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
+ BKE_bpath_list_free(path_list_backup);
+ }
+
+ if (err) {
+ BKE_report(reports, RPT_ERROR, strerror(errno));
+ remove(tempname);
+
+ return 0;
+ }
+
+ /* file save to temporary file was successful */
+ /* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
+ if (write_flags & G_FILE_HISTORY) {
+ const bool err_hist = do_history(filepath, reports);
+ if (err_hist) {
+ BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
+ return 0;
+ }
+ }
+
+ if (BLI_rename(tempname, filepath) != 0) {
+ BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
+ return 0;
+ }
+
+ if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
+ BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* save to disk");
+ BLO_main_validate_libraries(mainvar, reports);
+ }
+
+ return 1;
}
/**
@@ -4234,11 +4253,11 @@ bool BLO_write_file(
*/
bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags)
{
- write_flags &= ~G_FILE_USERPREFS;
+ write_flags &= ~G_FILE_USERPREFS;
- const bool err = write_file_handle(mainvar, NULL, compare, current, write_flags, NULL);
+ const bool err = write_file_handle(mainvar, NULL, compare, current, write_flags, NULL);
- return (err == 0);
+ return (err == 0);
}
/** \} */