From 1d97e948d2c4867306e7fb5ce5fccf8b72c13391 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 5 Jun 2018 15:08:28 +0200 Subject: Cleanup: add hleper functions to get filepath from Main. This helps making things clearer and cleaner. Func returning filepath of G.main is separate, so that we can easily track its usages, and hopefully deprecate it at some point. Though that usage of G.main is likely the less evil one, you nearly always want current blendfile path in those cases anyway. --- source/blender/blenkernel/BKE_library.h | 3 +++ source/blender/blenkernel/intern/library.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index ad97eb62773..1c64aa63917 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -174,6 +174,9 @@ struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct BlendThumbnail *data); void BKE_main_thumbnail_create(struct Main *bmain); +const char *BKE_main_blendfile_path(struct Main *bmain) ATTR_NONNULL(); +const char *BKE_main_blendfile_path_from_global(void); + void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value); void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value); void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 70ee3cbe5f3..1caa0f381c5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -152,7 +152,7 @@ * also note that the id _must_ have a library - campbell */ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id) { - const char *bpath_user_data[2] = {bmain->name, lib->filepath}; + const char *bpath_user_data[2] = {BKE_main_blendfile_path(bmain), lib->filepath}; BKE_bpath_traverse_id(bmain, id, BKE_bpath_relocate_visitor, @@ -1593,6 +1593,24 @@ void BKE_main_thumbnail_create(struct Main *bmain) bmain->blen_thumb->height = BLEN_THUMB_SIZE; } +/** + * Return filepath of given \a main. + */ +const char *BKE_main_blendfile_path(Main *bmain) +{ + return bmain->name; +} + +/** + * Return filepath of global main (G.main). + * + * \warning Usage is not recommended, you should always try to get a velid Main pointer from context... + */ +const char *BKE_main_blendfile_path_from_global(void) +{ + return BKE_main_blendfile_path(G.main); +} + /* ***************** ID ************************ */ ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) { @@ -2381,7 +2399,7 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) */ /* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to * current main, not to their parent for indirectly linked ones. */ - const char *basepath = bmain->name; + const char *basepath = BKE_main_blendfile_path(bmain); BLI_path_abs(lib->filepath, basepath); } } -- cgit v1.2.3 From 481cdb08ed6f33a09d0e6843d1024db93c301178 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 5 Jun 2018 15:10:33 +0200 Subject: Cleanup: use new accessors to blendfile path (Main.name). --- source/blender/blenkernel/BKE_library.h | 2 +- source/blender/blenkernel/BKE_movieclip.h | 2 +- source/blender/blenkernel/intern/blender_undo.c | 7 +- source/blender/blenkernel/intern/blendfile.c | 42 +- source/blender/blenkernel/intern/bpath.c | 2 +- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/font.c | 6 +- source/blender/blenkernel/intern/image.c | 9 +- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/movieclip.c | 18 +- source/blender/blenkernel/intern/packedFile.c | 14 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 4 +- source/blender/blenkernel/intern/sequencer.c | 21 +- source/blender/blenkernel/intern/sound.c | 4 +- source/blender/blenkernel/intern/text.c | 6 +- source/blender/blenkernel/intern/writeavi.c | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- source/blender/blenloader/intern/readfile.c | 14 +- source/blender/blenloader/intern/readfile.h | 10 +- source/blender/blenloader/intern/undofile.c | 2 +- source/blender/blenloader/intern/versioning_250.c | 298 +++++------ source/blender/blenloader/intern/versioning_260.c | 418 +++++++-------- source/blender/blenloader/intern/versioning_270.c | 288 +++++----- .../blender/blenloader/intern/versioning_legacy.c | 590 ++++++++++----------- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/collada/ImageExporter.cpp | 2 +- .../COM_OutputFileMultiViewOperation.cpp | 10 +- .../operations/COM_OutputFileOperation.cpp | 7 +- source/blender/editors/interface/interface_ops.c | 2 +- source/blender/editors/io/io_alembic.c | 8 +- source/blender/editors/io/io_cache.c | 2 +- source/blender/editors/io/io_collada.c | 7 +- source/blender/editors/object/object_bake_api.c | 3 +- source/blender/editors/object/object_modifier.c | 2 +- source/blender/editors/render/render_opengl.c | 6 +- source/blender/editors/render/render_preview.c | 6 +- source/blender/editors/render/render_shading.c | 3 +- source/blender/editors/screen/screendump.c | 6 +- source/blender/editors/sound/sound_ops.c | 2 +- source/blender/editors/space_buttons/buttons_ops.c | 5 +- source/blender/editors/space_clip/clip_ops.c | 4 +- source/blender/editors/space_file/file_draw.c | 6 +- source/blender/editors/space_file/file_intern.h | 6 +- source/blender/editors/space_file/file_ops.c | 48 +- source/blender/editors/space_file/filelist.c | 5 +- source/blender/editors/space_file/filesel.c | 12 +- source/blender/editors/space_image/image_ops.c | 16 +- source/blender/editors/space_info/info_ops.c | 4 +- .../blender/editors/space_outliner/outliner_draw.c | 2 +- .../editors/space_sequencer/sequencer_add.c | 4 +- .../editors/space_sequencer/sequencer_edit.c | 6 +- source/blender/editors/space_text/text_ops.c | 8 +- source/blender/editors/util/ed_util.c | 4 +- source/blender/makesdna/DNA_ID.h | 2 +- source/blender/makesrna/intern/rna_color.c | 4 +- source/blender/makesrna/intern/rna_image_api.c | 2 +- source/blender/makesrna/intern/rna_main_api.c | 2 +- source/blender/makesrna/intern/rna_movieclip.c | 4 +- source/blender/makesrna/intern/rna_nodetree.c | 4 +- source/blender/makesrna/intern/rna_scene_api.c | 2 +- source/blender/python/intern/bpy_interface.c | 2 +- source/blender/python/intern/bpy_library_load.c | 2 +- source/blender/python/intern/bpy_library_write.c | 2 +- source/blender/render/intern/source/pipeline.c | 8 +- .../blender/render/intern/source/render_result.c | 9 +- source/blender/render/intern/source/voxeldata.c | 4 +- source/blender/windowmanager/intern/wm_files.c | 63 ++- .../blender/windowmanager/intern/wm_files_link.c | 4 +- source/blender/windowmanager/intern/wm_init_exit.c | 4 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- source/blender/windowmanager/intern/wm_window.c | 12 +- 72 files changed, 1067 insertions(+), 1030 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 1c64aa63917..935e90d7ed0 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -174,7 +174,7 @@ struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct BlendThumbnail *data); void BKE_main_thumbnail_create(struct Main *bmain); -const char *BKE_main_blendfile_path(struct Main *bmain) ATTR_NONNULL(); +const char *BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL(); const char *BKE_main_blendfile_path_from_global(void); void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value); diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 818f79ad8ac..b79f37fd040 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -49,7 +49,7 @@ void BKE_movieclip_make_local(struct Main *bmain, struct MovieClip *clip, const struct MovieClip *BKE_movieclip_file_add(struct Main *bmain, const char *name); struct MovieClip *BKE_movieclip_file_add_exists_ex(struct Main *bmain, const char *name, bool *r_exists); struct MovieClip *BKE_movieclip_file_add_exists(struct Main *bmain, const char *name); -void BKE_movieclip_reload(struct MovieClip *clip); +void BKE_movieclip_reload(struct Main *bmain, struct MovieClip *clip); void BKE_movieclip_clear_cache(struct MovieClip *clip); void BKE_movieclip_clear_proxy_cache(struct MovieClip *clip); diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 6b31c8c96f9..c3306b16041 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -66,10 +66,11 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) { - char mainstr[sizeof(G.main->name)]; + Main *bmain = CTX_data_main(C); + char mainstr[sizeof(bmain->name)]; int success = 0, fileflags; - BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ + BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */ fileflags = G.fileflags; G.fileflags |= G_FILE_NO_UI; @@ -82,7 +83,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, bContext *C) } /* restore */ - BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ + BLI_strncpy(bmain->name, mainstr, sizeof(bmain->name)); /* restore */ G.fileflags = fileflags; if (success) { diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index cc992a4a520..935000e3b8e 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -113,6 +113,7 @@ static void setup_app_data( bContext *C, BlendFileData *bfd, const char *filepath, ReportList *reports) { + Main *bmain = G.main; /* Valid usage */ Scene *curscene = NULL; const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; @@ -167,8 +168,8 @@ static void setup_app_data( bool track_undo_scene; /* comes from readfile.c */ - SWAP(ListBase, G.main->wm, bfd->main->wm); - SWAP(ListBase, G.main->screen, bfd->main->screen); + SWAP(ListBase, bmain->wm, bfd->main->wm); + SWAP(ListBase, bmain->screen, bfd->main->screen); /* we re-use current screen */ curscreen = CTX_wm_screen(C); @@ -221,9 +222,9 @@ static void setup_app_data( /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - G.main = bfd->main; + bmain = G.main = bfd->main; - CTX_data_main_set(C, G.main); + CTX_data_main_set(C, bmain); if (bfd->user) { /* only here free userdef themes... */ @@ -250,7 +251,7 @@ static void setup_app_data( /* Keep state from preferences. */ const int fileflags_skip = G_FILE_FLAGS_RUNTIME; G.fileflags = (G.fileflags & fileflags_skip) | (bfd->fileflags & ~fileflags_skip); - CTX_wm_manager_set(C, G.main->wm.first); + CTX_wm_manager_set(C, bmain->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscene); CTX_wm_area_set(C, NULL); @@ -262,10 +263,10 @@ static void setup_app_data( /* this can happen when active scene was lib-linked, and doesn't exist anymore */ if (CTX_data_scene(C) == NULL) { /* in case we don't even have a local scene, add one */ - if (!G.main->scene.first) - BKE_scene_add(G.main, "Empty"); + if (!bmain->scene.first) + BKE_scene_add(bmain, "Empty"); - CTX_data_scene_set(C, G.main->scene.first); + CTX_data_scene_set(C, bmain->scene.first); CTX_wm_screen(C)->scene = CTX_data_scene(C); curscene = CTX_data_scene(C); } @@ -289,30 +290,30 @@ static void setup_app_data( /* FIXME: this version patching should really be part of the file-reading code, * but we still get too many unrelated data-corruption crashes otherwise... */ - if (G.main->versionfile < 250) - do_versions_ipos_to_animato(G.main); + if (bmain->versionfile < 250) + do_versions_ipos_to_animato(bmain); - G.main->recovered = 0; + bmain->recovered = 0; /* startup.blend or recovered startup */ if (bfd->filename[0] == 0) { - G.main->name[0] = 0; + bmain->name[0] = '\0'; } else if (recover && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ filepath = bfd->filename; - G.main->recovered = 1; + bmain->recovered = 1; /* these are the same at times, should never copy to the same location */ - if (G.main->name != filepath) - BLI_strncpy(G.main->name, filepath, FILE_MAX); + if (bmain->name != filepath) + BLI_strncpy(bmain->name, filepath, FILE_MAX); } /* baseflags, groups, make depsgraph, etc */ /* first handle case if other windows have different scenes visible */ if (mode == LOAD_UI) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = bmain->wm.first; if (wm) { wmWindow *win; @@ -320,15 +321,15 @@ static void setup_app_data( for (win = wm->windows.first; win; win = win->next) { if (win->screen && win->screen->scene) /* zealous check... */ if (win->screen->scene != curscene) - BKE_scene_set_background(G.main, win->screen->scene); + BKE_scene_set_background(bmain, win->screen->scene); } } } - BKE_scene_set_background(G.main, curscene); + BKE_scene_set_background(bmain, curscene); if (mode != LOAD_UNDO) { RE_FreeAllPersistentData(); - IMB_colormanagement_check_file_config(G.main); + IMB_colormanagement_check_file_config(bmain); } MEM_freeN(bfd); @@ -406,9 +407,10 @@ bool BKE_blendfile_read_from_memfile( bContext *C, struct MemFile *memfile, ReportList *reports, int skip_flags) { + Main *bmain = CTX_data_main(C); BlendFileData *bfd; - bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports, skip_flags); + bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags); if (bfd) { /* remove the unused screens and wm */ while (bfd->main->wm.first) diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 2e8c369451b..e6be42088db 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -325,7 +325,7 @@ void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportLis struct BPathFind_Data data = {NULL}; const int flag = BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_RELOAD_EDITED; - data.basedir = bmain->name; + data.basedir = BKE_main_blendfile_path(bmain); data.reports = reports; data.searchdir = searchpath; data.find_all = find_all; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 954bfc90eda..87fd10c7e7d 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3232,7 +3232,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam BKE_image_path_ensure_ext_from_imtype(output_file, format); /* Validate output file path */ - BLI_path_abs(output_file, G.main->name); + BLI_path_abs(output_file, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(output_file); /* Init image buffer */ diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5545eba8764..39be0f67c93 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -255,8 +255,8 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) } else { BLI_split_file_part(filepath, filename, sizeof(filename)); - pf = newPackedFile(NULL, filepath, bmain->name); - temp_pf = newPackedFile(NULL, filepath, bmain->name); + pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); + temp_pf = newPackedFile(NULL, filepath, BKE_main_blendfile_path(bmain)); is_builtin = false; } @@ -301,7 +301,7 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool * char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8fd672963c7..1d909ba1a76 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -594,7 +594,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath) char str[FILE_MAX]; STRNCPY(str, filepath); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); @@ -623,7 +623,7 @@ Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists) char str[FILE_MAX], strtest[FILE_MAX]; STRNCPY(str, filepath); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, BKE_main_blendfile_path_from_global()); /* first search an identical filepath */ for (ima = G.main->image.first; ima; ima = ima->id.next) { @@ -1652,7 +1652,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d time_t t; if (scene->r.stamp & R_STAMP_FILENAME) { - SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : ""); + SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s", + G.relbase_valid ? BKE_main_blendfile_path_from_global() : ""); } else { stamp_data->file[0] = '\0'; @@ -4702,7 +4703,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) char str[FILE_MAX]; STRNCPY(str, iv->filepath); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, BKE_main_blendfile_path_from_global()); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1caa0f381c5..4982c9a2f61 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1596,7 +1596,7 @@ void BKE_main_thumbnail_create(struct Main *bmain) /** * Return filepath of given \a main. */ -const char *BKE_main_blendfile_path(Main *bmain) +const char *BKE_main_blendfile_path(const Main *bmain) { return bmain->name; } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 9ed715d7591..65768372a28 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -199,7 +199,7 @@ static void get_proxy_fname(const MovieClip *clip, else BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); BLI_path_frame(name, 1, 0); strcat(name, ".jpg"); @@ -270,7 +270,7 @@ static void movieclip_open_anim_file(MovieClip *clip) if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { char dir[FILE_MAX]; BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); - BLI_path_abs(dir, G.main->name); + BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); IMB_anim_set_index_dir(clip->anim, dir); } } @@ -627,13 +627,13 @@ static void movieclip_load_get_size(MovieClip *clip) } } -static void detect_clip_source(MovieClip *clip) +static void detect_clip_source(Main *bmain, MovieClip *clip) { ImBuf *ibuf; char name[FILE_MAX]; BLI_strncpy(name, clip->name, sizeof(name)); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path(bmain)); ibuf = IMB_testiffname(name, IB_rect | IB_multilayer); if (ibuf) { @@ -656,7 +656,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) char str[FILE_MAX]; BLI_strncpy(str, name, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* exists? */ file = BLI_open(str, O_BINARY | O_RDONLY, 0); @@ -670,7 +670,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) clip = movieclip_alloc(bmain, BLI_path_basename(name)); BLI_strncpy(clip->name, name, sizeof(clip->name)); - detect_clip_source(clip); + detect_clip_source(bmain, clip); movieclip_load_get_size(clip); if (clip->lastsize[0]) { @@ -690,7 +690,7 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { @@ -1282,13 +1282,13 @@ void BKE_movieclip_clear_proxy_cache(MovieClip *clip) } } -void BKE_movieclip_reload(MovieClip *clip) +void BKE_movieclip_reload(Main *bmain, MovieClip *clip) { /* clear cache */ free_buffers(clip); /* update clip source */ - detect_clip_source(clip); + detect_clip_source(bmain, clip); clip->lastsize[0] = clip->lastsize[1] = 0; movieclip_load_get_size(clip); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index afb155f7646..baa88f00985 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -246,14 +246,14 @@ void packAll(Main *bmain, ReportList *reports, bool verbose) for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) { if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && BKE_vfont_is_builtin(vfont) == false) { - vfont->packedfile = newPackedFile(reports, vfont->name, bmain->name); + vfont->packedfile = newPackedFile(reports, vfont->name, BKE_main_blendfile_path(bmain)); tot ++; } } for (sound = bmain->sound.first; sound; sound = sound->id.next) { if (sound->packedfile == NULL && !ID_IS_LINKED(sound)) { - sound->packedfile = newPackedFile(reports, sound->name, bmain->name); + sound->packedfile = newPackedFile(reports, sound->name, BKE_main_blendfile_path(bmain)); tot++; } } @@ -542,7 +542,7 @@ int unpackVFont(Main *bmain, ReportList *reports, VFont *vfont, int how) if (vfont != NULL) { unpack_generate_paths(vfont->name, (ID *)vfont, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, vfont->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; freePackedFile(vfont->packedfile); @@ -563,7 +563,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) if (sound != NULL) { unpack_generate_paths(sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, sound->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, sound->packedfile, how); if (newname != NULL) { BLI_strncpy(sound->name, newname, sizeof(sound->name)); MEM_freeN(newname); @@ -591,7 +591,7 @@ int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) ImagePackedFile *imapf = ima->packedfiles.last; unpack_generate_paths(imapf->filepath, (ID *)ima, absname, localname, sizeof(absname), sizeof(localname)); - newname = unpackFile(reports, bmain->name, absname, localname, imapf->packedfile, how); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), absname, localname, imapf->packedfile, how); if (newname != NULL) { ImageView *iv; @@ -637,7 +637,7 @@ int unpackLibraries(Main *bmain, ReportList *reports) for (lib = bmain->library.first; lib; lib = lib->id.next) { if (lib->packedfile && lib->name[0]) { - newname = unpackFile(reports, bmain->name, lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL); + newname = unpackFile(reports, BKE_main_blendfile_path(bmain), lib->filepath, lib->filepath, lib->packedfile, PF_WRITE_ORIGINAL); if (newname != NULL) { ret_value = RET_OK; @@ -670,7 +670,7 @@ void packLibraries(Main *bmain, ReportList *reports) for (lib = bmain->library.first; lib; lib = lib->id.next) if (lib->packedfile == NULL) - lib->packedfile = newPackedFile(reports, lib->name, bmain->name); + lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain)); } void unpackAll(Main *bmain, ReportList *reports, int how) diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b6d9ba71c2c..c7dacf97624 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1782,7 +1782,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext) static int ptcache_path(PTCacheID *pid, char *filename) { Library *lib = (pid->ob) ? pid->ob->id.lib : NULL; - const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name; + const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: BKE_main_blendfile_path_from_global(); size_t i; if (pid->cache->flag & PTCACHE_EXTERNAL) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 15ba5079ab5..8fd88b12974 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -963,11 +963,11 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name) Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name); if (sce) { BKE_scene_set_background(bmain, sce); - printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name); + printf("Scene switch for render: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain)); return sce; } - printf("Can't find scene: '%s' in file: '%s'\n", name, bmain->name); + printf("Can't find scene: '%s' in file: '%s'\n", name, BKE_main_blendfile_path(bmain)); return NULL; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1b747c4a24f..f817ba7fc37 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -893,7 +893,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); BKE_sequence_free_anim(seq); @@ -1540,7 +1540,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); proxy = seq->strip->proxy; @@ -1557,7 +1557,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) else { BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); } - BLI_path_abs(dir, G.main->name); + BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); } if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) { @@ -1685,7 +1685,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render return false; } BLI_path_append(dir, sizeof(dir), fname); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); } else if ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) && (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE)) { BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); @@ -1717,7 +1717,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render { char fname[FILE_MAXFILE]; BLI_join_dirfile(fname, PROXY_MAXFILE, dir, proxy->file); - BLI_path_abs(fname, G.main->name); + BLI_path_abs(fname, BKE_main_blendfile_path_from_global()); if (suffix[0] != '\0') { /* TODO(sergey): This will actually append suffix after extension * which is weird but how was originally coded in multiview branch. @@ -1743,7 +1743,7 @@ static bool seq_proxy_get_fname(Editing *ed, Sequence *seq, int cfra, int render BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####%s", dir, render_size, suffix); } - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); BLI_path_frame(name, frameno, 0); strcat(name, ".jpg"); @@ -1888,7 +1888,7 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con char path[FILE_MAX]; BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext); } else { @@ -2841,7 +2841,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, Sequence *seq if (s_elem) { BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); } flag = IB_rect | IB_metadata; @@ -5138,7 +5138,7 @@ void BKE_sequence_init_colorspace(Sequence *seq) ImBuf *ibuf; BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, BKE_main_blendfile_path_from_global()); /* initialize input color space */ if (seq->type == SEQ_TYPE_IMAGE) { @@ -5306,6 +5306,7 @@ static void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); /* only for sound */ char path[sizeof(seq_load->path)]; @@ -5320,7 +5321,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad int i; BLI_strncpy(path, seq_load->path, sizeof(path)); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path(bmain)); anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files"); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 45d1f969d64..7ad8f03dfee 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -79,7 +79,7 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath) BLI_strncpy(str, filepath, sizeof(str)); - path = /*bmain ? bmain->name :*/ G.main->name; + path = BKE_main_blendfile_path(bmain); BLI_path_abs(str, path); @@ -98,7 +98,7 @@ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, b char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, filepath, sizeof(str)); - BLI_path_abs(str, bmain->name); + BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (sound = bmain->sound.first; sound; sound = sound->id.next) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b650b6e9fb8..bd2afd0c512 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -391,7 +391,7 @@ bool BKE_text_reload(Text *text) } BLI_strncpy(filepath_abs, text->name, FILE_MAX); - BLI_path_abs(filepath_abs, G.main->name); + BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global()); buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len); if (buffer == NULL) { @@ -560,7 +560,7 @@ int BKE_text_file_modified_check(Text *text) return 0; BLI_strncpy(file, text->name, FILE_MAX); - BLI_path_abs(file, G.main->name); + BLI_path_abs(file, BKE_main_blendfile_path_from_global()); if (!BLI_exists(file)) return 2; @@ -588,7 +588,7 @@ void BKE_text_file_modified_ignore(Text *text) if (!text->name) return; BLI_strncpy(file, text->name, FILE_MAX); - BLI_path_abs(file, G.main->name); + BLI_path_abs(file, BKE_main_blendfile_path_from_global()); if (!BLI_exists(file)) return; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 2fb4ed03603..02940723520 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -159,7 +159,7 @@ static void filepath_avi(char *string, RenderData *rd, bool preview, const char } strcpy(string, rd->pic); - BLI_path_abs(string, G.main->name); + BLI_path_abs(string, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(string); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index eb7ad38c456..bf702aa95b9 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1138,7 +1138,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData } strcpy(string, rd->pic); - BLI_path_abs(string, G.main->name); + BLI_path_abs(string, BKE_main_blendfile_path_from_global()); BLI_make_existing_file(string); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5a7151a7477..4df79250125 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8409,11 +8409,11 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) 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, bfd->main->name, sizeof(bfd->filename)); + 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, bfd->main->name, sizeof(bfd->filename)); + BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename)); } if (G.fileflags & G_FILE_RECOVER) @@ -10309,7 +10309,7 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa blo_split_main((*fd)->mainlist, mainvar); /* which one do we need? */ - mainl = blo_find_main(*fd, filepath, G.main->name); + mainl = blo_find_main(*fd, filepath, BKE_main_blendfile_path(mainvar)); /* needed for do_version */ mainl->versionfile = (*fd)->fileversion; @@ -10384,7 +10384,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Scene BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name)); /* uses current .blend file as reference */ - BLI_path_rel(curlib->name, G.main->name); + BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global()); } blo_join_main((*fd)->mainlist); @@ -10412,7 +10412,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Scene BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false); lib_verify_nodetree(mainvar, false); - fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */ + 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. If group append, do it for objects too. * Only directly linked objects & groups are instantiated by `BLO_library_link_named_part_ex()` & co, @@ -10535,7 +10535,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) while (fd == NULL) { char newlib_path[FILE_MAX] = {0}; printf("Missing library...'\n"); - printf(" current file: %s\n", G.main->name); + printf(" current file: %s\n", BKE_main_blendfile_path_from_global()); printf(" absolute lib: %s\n", mainptr->curlib->filepath); printf(" relative lib: %s\n", mainptr->curlib->name); printf(" enter a new path:\n"); @@ -10543,7 +10543,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) if (scanf("%1023s", newlib_path) > 0) { /* Warning, keep length in sync with FILE_MAX! */ BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name)); BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath)); - BLI_cleanup_path(G.main->name, mainptr->curlib->filepath); + BLI_cleanup_path(BKE_main_blendfile_path_from_global(), mainptr->curlib->filepath); fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports); diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 62ce15a640e..ebb29b640e7 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -167,12 +167,12 @@ void blo_do_version_old_trackto_to_constraints(struct Object *ob); void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions); void blo_do_versions_key_uidgen(struct Key *key); -void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *main); -void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main); -void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *main); -void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *main); +void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *bmain); +void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *bmain); +void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain); +void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain); -void do_versions_after_linking_270(struct Main *main); +void do_versions_after_linking_270(struct Main *bmain); #endif diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index 7133dee0e82..e1ae267ea11 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -130,7 +130,7 @@ void memfile_chunk_add( 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, oldmain->name, memfile, NULL, BLO_READ_SKIP_NONE); + BlendFileData *bfd = BLO_read_from_memfile(oldmain, BKE_main_blendfile_path(oldmain), memfile, NULL, BLO_READ_SKIP_NONE); if (bfd) { bmain_undo = bfd->main; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index d308bd54da3..39c47c90b89 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -729,11 +729,11 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock) } } -void blo_do_versions_250(FileData *fd, Library *lib, Main *main) +void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (main->versionfile < 250) { + if (bmain->versionfile < 250) { bScreen *screen; Scene *scene; Base *base; @@ -753,14 +753,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bActuator *act; int a; - for (sound = main->sound.first; sound; sound = sound->id.next) { + for (sound = bmain->sound.first; sound; sound = sound->id.next) { if (sound->newpackedfile) { sound->packedfile = sound->newpackedfile; sound->newpackedfile = NULL; } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_SOUND) { bSoundActuator *sAct = (bSoundActuator*) act->data; @@ -787,15 +787,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.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, main->name); - seq->sound = BKE_sound_new_file(main, str); + 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) @@ -812,15 +812,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { do_versions_windowmanager_2_50(screen); - do_versions_gpencil_2_50(main, 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 = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->nodetree && ma->nodetree->id.name[0] == '\0') strcpy(ma->nodetree->id.name, "NTShader Nodetree"); @@ -835,7 +835,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* and composite trees */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree && sce->nodetree->id.name[0] == '\0') strcpy(sce->nodetree->id.name, "NTCompositing Nodetree"); @@ -855,7 +855,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* and texture trees */ - for (tx = main->tex.first; tx; tx = tx->id.next) { + for (tx = bmain->tex.first; tx; tx = tx->id.next) { bNode *node; if (tx->nodetree) { @@ -870,12 +870,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* copy standard draw flag to meshes(used to be global, is not available here) */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { me->drawflag = ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; } /* particle draw and render types */ - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (part->draw_as) { if (part->draw_as == PART_DRAW_DOT) { part->ren_as = PART_DRAW_HALO; @@ -894,7 +894,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* set old pointcaches to have disk cache flag */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { //BKE_ptcache_ids_from_object(&pidlist, ob); @@ -905,7 +905,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* type was a mixed flag & enum. move the 2d flag elsewhere */ - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { Nurb *nu; for (nu = cu->nurb.first; nu; nu = nu->next) { @@ -915,7 +915,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) { Object *ob; Material *ma; Tex *tex; @@ -924,7 +924,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) //PTCacheID *pid; //ListBase pidlist; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { //BKE_ptcache_ids_from_object(&pidlist, ob); //for (pid = pidlist.first; pid; pid = pid->next) { @@ -958,12 +958,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* texture filter */ - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->afmax == 0) tex->afmax = 8; } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { int a; if (ma->mode & MA_WIRE) { @@ -1018,7 +1018,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { ts = sce->toolsettings; if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) { ts->normalsize = 0.1f; @@ -1085,11 +1085,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 2)) { Scene *sce; Object *ob; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) sce->gm.flag |= GAME_ENABLE_ALL_FRAMES; if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS) @@ -1123,13 +1123,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.flag |= GAME_DISPLAY_LISTS; } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->flag & 8192) // OB_POSEMODE = 8192 ob->mode |= OB_MODE_POSE; } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 4)) { Scene *sce; Object *ob; Material *ma; @@ -1139,11 +1139,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ParticleSettings *part; bool do_gravity = false; - for (sce = main->scene.first; sce; sce = sce->id.next) + for (sce = bmain->scene.first; sce; sce = sce->id.next) if (sce->unit.scale_length == 0.0f) sce->unit.scale_length = 1.0f; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* fluid-sim stuff */ FluidsimModifierData *fluidmd = (FluidsimModifierData *) modifiers_findByType(ob, eModifierType_Fluidsim); if (fluidmd) @@ -1153,7 +1153,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ob->rotmode = ROT_MODE_EUL; } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->vol.reflection == 0.f) { ma->vol.reflection = 1.f; ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f; @@ -1163,18 +1163,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) do_version_mtex_factor_2_50(ma->mtex, ID_MA); } - for (la = main->lamp.first; la; la = la->id.next) + for (la = bmain->lamp.first; la; la = la->id.next) do_version_mtex_factor_2_50(la->mtex, ID_LA); - for (wo = main->world.first; wo; wo = wo->id.next) + for (wo = bmain->world.first; wo; wo = wo->id.next) do_version_mtex_factor_2_50(wo->mtex, ID_WO); - for (tex = main->tex.first; tex; tex = tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->vd) if (tex->vd->extend == 0) tex->vd->extend = TEX_CLIP; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->audio.main == 0.0f) sce->audio.main = 1.0f; @@ -1186,7 +1186,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* Add default gravity to scenes */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && is_zero_v3(sce->physics_settings.gravity)) { @@ -1199,11 +1199,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */ if (do_gravity) { - for (part = main->particle.first; part; part = part->id.next) + for (part = bmain->particle.first; part; part = part->id.next) part->effector_weights->global_gravity = part->acc[2]/-9.81f; } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; if (do_gravity) { @@ -1232,12 +1232,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) { Object *ob; Lamp *la; /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* new variables for all objects */ ob->quat[0] = 1.0f; ob->rotAxis[1] = 1.0f; @@ -1253,11 +1253,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (la = main->lamp.first; la; la = la->id.next) + for (la = bmain->lamp.first; la; la = la->id.next) la->compressthresh = 0.05f; } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 7)) { Mesh *me; Nurb *nu; Lattice *lt; @@ -1269,7 +1269,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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 = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.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); @@ -1279,7 +1279,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (lt = main->latt.first; lt; lt = lt->id.next) { + for (lt = bmain->latt.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); @@ -1289,7 +1289,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) { data = key->refkey->data; @@ -1317,9 +1317,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) { { - Scene *sce = main->scene.first; + Scene *sce = bmain->scene.first; while (sce) { if (sce->r.frame_step == 0) sce->r.frame_step = 1; @@ -1336,7 +1336,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* ensure all nodes have unique names */ - bNodeTree *ntree = main->nodetree.first; + bNodeTree *ntree = bmain->nodetree.first; while (ntree) { bNode *node = ntree->nodes.first; @@ -1350,7 +1350,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } { - Object *ob = main->object.first; + Object *ob = bmain->object.first; while (ob) { /* shaded mode disabled for now */ if (ob->dt == OB_MATERIAL) @@ -1364,7 +1364,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ScrArea *sa; SpaceLink *sl; - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.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) { @@ -1378,11 +1378,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* only convert old 2.50 files with color management */ - if (main->versionfile == 250) { - Scene *sce = main->scene.first; - Material *ma = main->mat.first; - World *wo = main->world.first; - Tex *tex = main->tex.first; + if (bmain->versionfile == 250) { + Scene *sce = bmain->scene.first; + Material *ma = bmain->mat.first; + World *wo = bmain->world.first; + Tex *tex = bmain->tex.first; int i, convert = 0; /* convert to new color management system: @@ -1443,20 +1443,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 9)) { Scene *sce; Mesh *me; Object *ob; - for (sce = main->scene.first; sce; sce = sce->id.next) + for (sce = bmain->scene.first; sce; sce = sce->id.next) if (!sce->toolsettings->particle.selectmode) sce->toolsettings->particle.selectmode = SCE_SELECT_PATH; - if (main->versionfile == 250 && main->subversionfile > 1) { - for (me = main->mesh.first; me; me = me->id.next) + if (bmain->versionfile == 250 && bmain->subversionfile > 1) { + for (me = bmain->mesh.first; me; me = me->id.next) multires_load_old_250(me); - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { MultiresModifierData *mmd = (MultiresModifierData *) modifiers_findByType(ob, eModifierType_Multires); if (mmd) { @@ -1469,11 +1469,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 10)) { Object *ob; /* properly initialize hair clothsim data on old files */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Cloth) { @@ -1486,14 +1486,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* fix bad area setup in subversion 10 */ - if (main->versionfile == 250 && main->subversionfile == 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 = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.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) { @@ -1523,14 +1523,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) { + 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 = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.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) { @@ -1566,19 +1566,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 12)) { Scene *sce; Object *ob; Brush *brush; Material *ma; /* game engine changes */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->gm.eyeseparation = 0.10f; } /* anim viz changes */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* initialize object defaults */ animviz_settings_init(&ob->avs); @@ -1653,12 +1653,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* brush texture changes */ - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { BKE_texture_mtex_default(&brush->mtex); BKE_texture_mtex_default(&brush->mask_mtex); } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->vol.ms_spread < 0.0001f) { ma->vol.ms_spread = 0.2f; ma->vol.ms_diff = 1.f; @@ -1667,13 +1667,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) { + 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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bPoseChannel *pchan; do_version_constraints_radians_degrees_250(&ob->constraints); @@ -1693,13 +1693,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) { + 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 = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.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; @@ -1723,15 +1723,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 15)) { World *wo; Material *ma; /* ambient default from 0.5f to 1.0f */ - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) ma->amb *= 2.0f; - for (wo = main->world.first; wo; wo = wo->id.next) { + for (wo = bmain->world.first; wo; wo = wo->id.next) { /* ao splitting into ao/env/indirect */ wo->ao_env_energy = wo->aoenergy; wo->aoenergy = 1.0f; @@ -1754,13 +1754,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 17)) { Scene *sce; Sequence *seq; Material *ma; /* initialize to sane default so toggling on border shows something */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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) { @@ -1781,7 +1781,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* particle brush strength factor was changed from int to float */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { ParticleEditSettings *pset = &sce->toolsettings->particle; int a; @@ -1789,7 +1789,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) pset->brush[a].strength /= 100.0f; } - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->mode & MA_TRACEBLE) ma->shade_flag |= MA_APPROX_OCCLUSION; @@ -1799,7 +1799,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ScrArea *sa; SpaceLink *sl; - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.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) { @@ -1828,14 +1828,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* sequencer changes */ } - if (main->versionfile <= 251) { /* 2.5.1 had no subversions */ + if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */ bScreen *sc; /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE. * 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_RENDER_OVERRIDE set, * which would cause cameras, lamps, etc to become invisible */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1849,19 +1849,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 1)) { Brush *brush; Object *ob; Scene *scene; bNodeTree *ntree; - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH; } /* properly initialize active flag for fluidsim modifiers */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Fluidsim) { @@ -1873,7 +1873,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* adjustment to color balance node values */ - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { bNode *node = scene->nodetree->nodes.first; @@ -1889,7 +1889,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } /* check inside node groups too */ - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) { bNode *node = ntree->nodes.first; while (node) { @@ -1906,18 +1906,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* old-track -> constraints (this time we're really doing it!) */ - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) + for (ob = bmain->object.first; ob; ob = ob->id.next) blo_do_version_old_trackto_to_constraints(ob); } - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) { bScreen *sc; /* Image editor scopes */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1933,14 +1933,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 253) { + if (bmain->versionfile < 253) { Object *ob; Scene *scene; bScreen *sc; Tex *tex; Brush *brush; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1982,10 +1982,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - do_version_mdef_250(main); + do_version_mdef_250(bmain); /* parent type to modifier */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.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 */ @@ -2020,7 +2020,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* initialize scene active layer */ - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { int i; for (i = 0; i < 20; i++) { if (scene->lay & (1<tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.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) @@ -2039,12 +2039,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { Curve *cu; - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { cu->smallcaps_scale = 0.75f; } } - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene) { Sequence *seq; SEQ_BEGIN (scene->ed, seq) @@ -2059,7 +2059,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* GSOC 2010 Sculpt - New settings for Brush */ - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { /* Sanity Check */ /* infinite number of dabs */ @@ -2103,7 +2103,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) brush->rate = 0.1f; /* New Settings */ - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { + 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 @@ -2133,9 +2133,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */ - if (main->versionfile < 253) { + if (bmain->versionfile < 253) { Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->sculpt_paint_unified_alpha == 0) sce->toolsettings->sculpt_paint_unified_alpha = 0.5f; @@ -2147,10 +2147,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) { + if (bmain->versionfile < 253 || (bmain->versionfile == 253 && bmain->subversionfile < 1)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { @@ -2170,7 +2170,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* for now just add it to all flow objects in the scene */ { Object *ob2; - for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) { + for (ob2 = bmain->object.first; ob2; ob2 = ob2->id.next) { ModifierData *md2; for (md2 = ob2->modifiers.first; md2; md2 = md2->next) { if (md2->type == eModifierType_Smoke) { @@ -2193,18 +2193,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) { + if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 1)) { Brush *br; ParticleSettings *part; bScreen *sc; Object *ob; - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.first; br; br = br->id.next) { if (br->ob_mode == 0) br->ob_mode = OB_MODE_ALL_PAINT; } - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (part->boids) part->boids->pitch = 1.0f; @@ -2212,7 +2212,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) part->kink_amp_clump = 1.f; /* keep old files looking similar */ } - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -2240,7 +2240,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* fix rotation actuators for objects so they use real angles (radians) * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bActuator *act = ob->actuators.first; while (act) { if (act->type == ACT_OBJECT) { @@ -2256,7 +2256,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* init facing axis property of steering actuators */ { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bActuator *act; for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_STEERING) { @@ -2274,11 +2274,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) { + 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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Ocean) { @@ -2290,13 +2290,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256) { + if (bmain->versionfile < 256) { bScreen *sc; ScrArea *sa; Key *key; /* Fix for sample line scope initializing with no height */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { sa = sc->areabase.first; while (sa) { SpaceLink *sl; @@ -2315,7 +2315,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) * 2.4x would never reveal this to users as a dummy value always ended up getting used * instead */ - for (key = main->key.first; key; key = key->id.next) { + for (key = bmain->key.first; key; key = key->id.next) { KeyBlock *kb; for (kb = key->block.first; kb; kb = kb->next) { @@ -2325,19 +2325,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) { + 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 = main->armature.first; arm; arm = arm->id.next) + for (arm = bmain->armature.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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (is_zero_v4(ob->dquat)) { unit_qt(ob->dquat); } @@ -2347,7 +2347,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { + if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) { bNodeTree *ntree; bNode *node; bNodeSocket *sock, *gsock; @@ -2356,7 +2356,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* node sockets are not exposed automatically any more, * this mimics the old behavior by adding all unlinked sockets to groups. */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + for (ntree=bmain->nodetree.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 */ @@ -2425,7 +2425,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 3)) { + if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 3)) { bScreen *sc; Brush *brush; Object *ob; @@ -2433,7 +2433,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Material *mat; int tex_nr, transp_tex; - for (mat = main->mat.first; mat; mat = mat->id.next) { + for (mat = bmain->mat.first; mat; mat = mat->id.next) { if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) { transp_tex = 0; @@ -2453,7 +2453,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* redraws flag in SpaceTime has been moved to Screen level */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.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... */ @@ -2461,13 +2461,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->height == 0) brush->height = 0.4f; } /* replace 'rim material' option for in offset*/ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Solidify) { @@ -2481,24 +2481,24 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* particle draw color from material */ - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (part->draw & PART_DRAW_MAT_COL) part->draw_col = PART_DRAW_COL_MAT; } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) { + if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) + for (me = bmain->mesh.first; me; me = me->id.next) BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { + 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 = main->scene.first; scene; scene = scene->id.next) + for (scene = bmain->scene.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) { @@ -2508,13 +2508,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) { + 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 = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; /* add regions */ for (sa = screen->areabase.first; sa; sa = sa->next) { @@ -2546,7 +2546,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* Initialize texture point density curve falloff */ Tex *tex; - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->pd) { if (tex->pd->falloff_speed_scale == 0.0f) tex->pd->falloff_speed_scale = 100.0f; @@ -2567,7 +2567,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* add default value for behind strength of camera actuator */ Object *ob; bActuator *act; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_CAMERA) { bCameraActuator *ba = act->data; @@ -2580,19 +2580,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { /* Initialize particle billboard scale */ part->bb_size[0] = part->bb_size[1] = 1.0f; } } } - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) { + if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) { { Scene *scene; Sequence *seq; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { scene->r.ffcodecdata.audio_channels = 2; scene->audio.volume = 1.0f; SEQ_BEGIN (scene->ed, seq) @@ -2605,7 +2605,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { bScreen *screen; - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; /* add regions */ @@ -2646,7 +2646,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bAction *act; FCurve *fcu; - for (act = main->action.first; act; act = act->id.next) { + for (act = bmain->action.first; act; act = act->id.next) { for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i = 0; @@ -2677,7 +2677,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bIpoActuator *ia; bActionActuator *aa; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_IPO) { /* Create the new actuator */ @@ -2715,10 +2715,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) { + if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) { { /* Convert default socket values from bNodeStack */ - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { bNode *node; bNodeSocket *sock; @@ -2745,17 +2745,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) * associate them with specific node types for polling. */ bNodeTree *ntree; - /* all node trees in main->nodetree are considered groups */ - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + /* all node trees in bmain->nodetree are considered groups */ + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) ntree->nodetype = NODE_GROUP; } } - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) { + if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 4)) { { /* Adaptive time step for particle systems */ ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { part->courant_target = 0.2f; part->time_flag &= ~PART_TIME_AUTOSF; } @@ -2764,7 +2764,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* set defaults for obstacle avoidance, recast data */ Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->gm.levelHeight == 0.f) sce->gm.levelHeight = 2.f; diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 79dfd572dbb..133db4aac40 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -631,15 +631,15 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro } } -void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) +void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) { - if (main->versionfile < 260) { + 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 = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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) @@ -649,7 +649,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) do_versions_nodetree_image_default_alpha_output(sce->nodetree); } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) do_versions_nodetree_image_default_alpha_output(ntree); } @@ -657,7 +657,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* support old particle dupliobject rotation settings */ ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { part->draw |= PART_DRAW_ROTATE_OB; @@ -668,16 +668,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)) { + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->collision_boundtype = ob->boundtype; } { Camera *cam; - for (cam = main->camera.first; cam; cam = cam->id.next) { + for (cam = bmain->camera.first; cam; cam = cam->id.next) { if (cam->sensor_x < 0.01f) cam->sensor_x = DEFAULT_SENSOR_WIDTH; @@ -687,8 +687,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 2)) { - FOREACH_NODETREE(main, ntree, id) { + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -705,24 +705,24 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 4)) { + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) { { /* Convert node angles to radians! */ Scene *sce; Material *mat; bNodeTree *ntree; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) do_versions_nodetree_convert_angle(sce->nodetree); } - for (mat = main->mat.first; mat; mat = mat->id.next) { + for (mat = bmain->mat.first; mat; mat = mat->id.next) { if (mat->nodetree) do_versions_nodetree_convert_angle(mat->nodetree); } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) do_versions_nodetree_convert_angle(ntree); } @@ -731,7 +731,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) bScreen *sc; MovieClip *clip; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -755,7 +755,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTrackingTrack *track; if (clip->aspx < 1.0f) { @@ -787,16 +787,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) { + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) { Scene *sce; MovieClip *clip; bScreen *sc; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { do_versions_image_settings_2_60(sce); } - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTrackingSettings *settings = &clip->tracking.settings; if (settings->default_pattern_size == 0.0f) { @@ -807,7 +807,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -822,7 +822,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* convert delta addition into delta scale */ int i; for (i = 0; i < 3; i++) { @@ -842,25 +842,25 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* 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 (main->versionfile == 260 && main->subversionfile == 6) { + else if (bmain->versionfile == 260 && bmain->subversionfile == 6) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (is_zero_v3(ob->dscale)) { copy_vn_fl(ob->dscale, 3, 1.0f); } } } - if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) { + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) { Brush *brush; - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) brush->alpha = 1.0f; } } - if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 1)) { + if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) { { /* update use flags for node sockets (was only temporary before) */ Scene *sce; @@ -870,39 +870,39 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) World *world; bNodeTree *ntree; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) do_versions_nodetree_socket_use_flags_2_62(sce->nodetree); } - for (mat = main->mat.first; mat; mat = mat->id.next) { + for (mat = bmain->mat.first; mat; mat = mat->id.next) { if (mat->nodetree) do_versions_nodetree_socket_use_flags_2_62(mat->nodetree); } - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->nodetree) do_versions_nodetree_socket_use_flags_2_62(tex->nodetree); } - for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) { + for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) { if (lamp->nodetree) do_versions_nodetree_socket_use_flags_2_62(lamp->nodetree); } - for (world = main->world.first; world; world = world->id.next) { + for (world = bmain->world.first; world; world = world->id.next) { if (world->nodetree) do_versions_nodetree_socket_use_flags_2_62(world->nodetree); } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) { do_versions_nodetree_socket_use_flags_2_62(ntree); } } { /* Initialize BGE exit key to esc key */ Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (!scene->gm.exitkey) scene->gm.exitkey = 218; // Blender key code for ESC } @@ -911,7 +911,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) MovieClip *clip; Object *ob; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = tracking->objects.first; @@ -931,7 +931,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bConstraint *con; for (con = ob->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) { @@ -948,7 +948,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) Object *ob; bProperty *prop; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->type == OB_FONT) { prop = BKE_bproperty_object_get(ob, "Text"); if (prop) { @@ -962,12 +962,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2)) { + if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) { { /* convert Camera Actuator values to defines */ Object *ob; bActuator *act; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_CAMERA) { bCameraActuator *ba = act->data; @@ -985,7 +985,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* convert deprecated sculpt_paint_unified_* fields to * UnifiedPaintSettings */ Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; UnifiedPaintSettings *ups = &ts->unified_paint_settings; ups->size = ts->sculpt_paint_unified_size; @@ -996,11 +996,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 3)) { + if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) { { /* convert extended ascii to utf-8 for text editor */ Text *text; - for (text = main->text.first; text; text = text->id.next) { + for (text = bmain->text.first; text; text = text->id.next) { if (!(text->flags & TXT_ISEXT)) { TextLine *tl; @@ -1018,7 +1018,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { /* set new dynamic paint values */ Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_DynamicPaint) { @@ -1038,9 +1038,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 262) { + if (bmain->versionfile < 262) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { @@ -1053,12 +1053,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263) { + 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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Fluidsim) { @@ -1070,35 +1070,35 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1)) { + 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 = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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 = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.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 (main->versionfile == 262 && main->subversionfile == 1) { + if (bmain->versionfile == 262 && bmain->subversionfile == 1) { { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { do_versions_mesh_mloopcol_swap_2_62_1(me); } } } - if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2)) { + 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 = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { KeyingSet *ks; for (ks = scene->keyingsets.first; ks; ks = ks->next) { if (!ks->idname[0]) @@ -1107,11 +1107,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3)) { + if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) { Object *ob; ModifierData *md; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData *)md; @@ -1121,11 +1121,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4)) { + if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) { /* Read Viscosity presets from older files */ Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Fluidsim) { @@ -1145,27 +1145,27 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) - if (main->versionfile < 263) { + if (bmain->versionfile < 263) { /* Default for old files is to save particle rotations to pointcache */ ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { part->flag |= PART_ROTATIONS; } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 1)) { + 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 = main->scene.first; sce; sce = sce->id.next) + for (sce = bmain->scene.first; sce; sce = sce->id.next) if (sce->nodetree) do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree); - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) do_versions_nodetree_multi_file_output_path_2_63_1(ntree); } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 3)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) { Scene *scene; Brush *brush; @@ -1173,7 +1173,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) * unified paint settings also have weight. Update unified * paint settings and brushes with a default weight value. */ - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; if (ts) { ts->unified_paint_settings.weight = ts->vgroup_weight; @@ -1181,15 +1181,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { brush->weight = 0.5; } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 2)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1221,24 +1221,24 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) { Lamp *la; Camera *cam; Curve *cu; - for (la = main->lamp.first; la; la = la->id.next) { + for (la = bmain->lamp.first; la; la = la->id.next) { if (la->shadow_frustum_size == 0.0f) la->shadow_frustum_size = 10.0f; } - for (cam = main->camera.first; cam; cam = cam->id.next) { + for (cam = bmain->camera.first; cam; cam = cam->id.next) { if (cam->flag & CAM_PANORAMA) { cam->type = CAM_PANO; cam->flag &= ~CAM_PANORAMA; } } - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { if (cu->bevfac2 == 0.0f) { cu->bevfac1 = 0.0f; cu->bevfac2 = 1.0f; @@ -1246,26 +1246,26 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 5)) { + 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 = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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 = main->nodetree.first; ntree; ntree = ntree->id.next) { + for (ntree = bmain->nodetree.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 (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 6)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) { /* update use flags for node sockets (was only temporary before) */ Scene *sce; Material *mat; @@ -1274,34 +1274,34 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) World *world; bNodeTree *ntree; - for (sce = main->scene.first; sce; sce = sce->id.next) + for (sce = bmain->scene.first; sce; sce = sce->id.next) if (sce->nodetree) do_versions_nodetree_frame_2_64_6(sce->nodetree); - for (mat = main->mat.first; mat; mat = mat->id.next) + for (mat = bmain->mat.first; mat; mat = mat->id.next) if (mat->nodetree) do_versions_nodetree_frame_2_64_6(mat->nodetree); - for (tex = main->tex.first; tex; tex = tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->nodetree) do_versions_nodetree_frame_2_64_6(tex->nodetree); - for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) + for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) if (lamp->nodetree) do_versions_nodetree_frame_2_64_6(lamp->nodetree); - for (world = main->world.first; world; world = world->id.next) + for (world = bmain->world.first; world; world = world->id.next) if (world->nodetree) do_versions_nodetree_frame_2_64_6(world->nodetree); - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) do_versions_nodetree_frame_2_64_6(ntree); } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 7)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { @@ -1317,11 +1317,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 8)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 8)) { /* set new deactivation values for game settings */ Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { /* Game Settings */ sce->gm.lineardeactthreshold = 0.8f; sce->gm.angulardeactthreshold = 1.0f; @@ -1329,8 +1329,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) { - FOREACH_NODETREE(main, ntree, id) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1347,11 +1347,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) { { Scene *scene; // composite redesign - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { if (scene->nodetree->chunksize == 0) { scene->nodetree->chunksize = 256; @@ -1359,7 +1359,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1377,7 +1377,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1399,16 +1399,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { clip->start_frame = 1; } } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 11)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTrackingTrack *track; track = clip->tracking.tracks.first; @@ -1420,16 +1420,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 12)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 12)) { Material *ma; - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->strand_widthfade == 2.0f) ma->strand_widthfade = 0.0f; } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) { - FOREACH_NODETREE(main, ntree, id) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1445,10 +1445,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 14)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) { ParticleSettings *part; - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1464,14 +1464,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END /* keep compatibility for dupliobject particle size */ - for (part = main->particle.first; part; part = part->id.next) + for (part = bmain->particle.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 (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) { - FOREACH_NODETREE(main, ntree, id) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1490,10 +1490,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 18)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->ed) { Sequence *seq; @@ -1527,7 +1527,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } /* color management pipeline changes compatibility code */ - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 19)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) { Scene *scene; Image *ima; bool colormanagement_disabled = false; @@ -1535,7 +1535,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* 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 = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) { ColorManagedDisplaySettings *display_settings = &scene->display_settings; @@ -1548,7 +1548,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { if (ima->source == IMA_SRC_VIEWER) { ima->flag |= IMA_VIEW_AS_RENDER; } @@ -1567,17 +1567,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 20)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) { Key *key; - for (key = main->key.first; key; key = key->id.next) { + for (key = bmain->key.first; key; key = key->id.next) { blo_do_versions_key_uidgen(key); } } /* remove texco */ - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 21)) { + if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) { Material *ma; - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { int a; for (a = 0; a < MAX_MTEX; a++) { if (ma->mtex[a]) { @@ -1590,7 +1590,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { CustomData_update_typemap(&me->vdata); CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert); } @@ -1601,10 +1601,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) * didn't copy animation visualization, which lead to deadlocks on motion * path calculation for proxied armatures, see [#32742] */ - if (main->versionfile < 264) { + if (bmain->versionfile < 264) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->pose) { if (ob->pose->avs.path_step == 0) { animviz_settings_init(&ob->pose->avs); @@ -1613,8 +1613,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 1)) { - FOREACH_NODETREE(main, ntree, id) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) @@ -1624,10 +1624,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 2)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; @@ -1643,12 +1643,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 3)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) { /* smoke branch */ { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { @@ -1687,7 +1687,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1707,11 +1707,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 5)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) { /* set a unwrapping margin and ABF by default */ Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->toolsettings->uvcalc_margin == 0.0f) { scene->toolsettings->uvcalc_margin = 0.001f; scene->toolsettings->unwrapper = 0; @@ -1719,11 +1719,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) { + 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(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { bNode *node; bNodeLink *link, *nextlink; @@ -1738,10 +1738,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1756,12 +1756,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) { /* convert tiles size from resolution and number of tiles */ { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->r.tilex == 0 || scene->r.tiley == 1) { if (scene->r.xparts && scene->r.yparts) { /* scene could be set for panoramic rendering, so clamp with the @@ -1781,7 +1781,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* collision masks */ { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->col_group == 0) { ob->col_group = 0x01; ob->col_mask = 0xff; @@ -1790,10 +1790,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) { + if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTrackingTrack *track; MovieTrackingObject *object; @@ -1809,9 +1809,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 265) { + if (bmain->versionfile < 265) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->step_height == 0.0f) { ob->step_height = 0.15f; ob->jump_speed = 10.0f; @@ -1820,9 +1820,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 3)) { + if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1864,11 +1864,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 5)) { + if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) { Scene *scene; Tex *tex; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { Sequence *seq; bool set_premul = false; @@ -1905,7 +1905,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Image *image = main->image.first; image; image = image->id.next) { + for (Image *image = bmain->image.first; image; image = image->id.next) { if (image->flag & IMA_DO_PREMUL) { image->alpha_mode = IMA_ALPHA_STRAIGHT; } @@ -1914,7 +1914,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.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); @@ -1923,7 +1923,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -1939,20 +1939,20 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } FOREACH_NODETREE_END } - else if (main->versionfile < 266 || (main->versionfile == 266 && main->subversionfile < 1)) { + 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 = main->tex.first; tex; tex = tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->type == TEX_IMAGE) tex->imaflag |= TEX_USEALPHA; } - if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) { + if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) { Curve *cu; - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { if (cu->flag & (CU_FRONT | CU_BACK)) { if ( cu->ext1 != 0.0f || cu->ext2 != 0.0f) { Nurb *nu; @@ -1984,16 +1984,16 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (MAIN_VERSION_OLDER(main, 265, 9)) { + if (MAIN_VERSION_OLDER(bmain, 265, 9)) { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { BKE_mesh_do_versions_cd_flag_init(me); } } - if (MAIN_VERSION_OLDER(main, 265, 10)) { + if (MAIN_VERSION_OLDER(bmain, 265, 10)) { Brush *br; - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.first; br; br = br->id.next) { if (br->ob_mode & OB_MODE_TEXTURE_PAINT) { br->mtex.brush_map_mode = MTEX_MAP_MODE_TILED; } @@ -2001,8 +2001,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } // add storage for compositor translate nodes when not existing - if (MAIN_VERSION_OLDER(main, 265, 11)) { - FOREACH_NODETREE(main, ntree, id) { + if (MAIN_VERSION_OLDER(bmain, 265, 11)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -2014,15 +2014,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (MAIN_VERSION_OLDER(main, 266, 2)) { - FOREACH_NODETREE(main, ntree, id) { + if (MAIN_VERSION_OLDER(bmain, 266, 2)) { + FOREACH_NODETREE(bmain, ntree, id) { do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id)); } FOREACH_NODETREE_END } - if (MAIN_VERSION_OLDER(main, 266, 2)) { + if (MAIN_VERSION_OLDER(bmain, 266, 2)) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -2056,7 +2056,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */ { - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(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 @@ -2068,22 +2068,22 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) /* Only add interface nodes once. * In old Blender versions they will be removed automatically due to undefined type */ - if (MAIN_VERSION_OLDER(main, 266, 2)) + if (MAIN_VERSION_OLDER(bmain, 266, 2)) ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE; } FOREACH_NODETREE_END } - if (MAIN_VERSION_OLDER(main, 266, 3)) { + 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 main->nodetree (i.e. group nodes). + * 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(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (id == &ntree->id) continue; /* already fixed for node groups */ @@ -2094,9 +2094,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 266, 4)) { + if (!MAIN_VERSION_ATLEAST(bmain, 266, 4)) { Brush *brush; - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { BKE_texture_mtex_default(&brush->mask_mtex); if (brush->ob_mode & OB_MODE_TEXTURE_PAINT) { @@ -2105,11 +2105,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 266, 6)) { + if (!MAIN_VERSION_ATLEAST(bmain, 266, 6)) { Brush *brush; #define BRUSH_TEXTURE_OVERLAY (1 << 21) - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.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); @@ -2117,11 +2117,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) #undef BRUSH_TEXTURE_OVERLAY } - if (main->versionfile < 267) { + if (bmain->versionfile < 267) { //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) { Brush *brush; - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->stencil_dimension[0] == 0) { brush->stencil_dimension[0] = 256; brush->stencil_dimension[1] = 256; @@ -2146,12 +2146,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } /* default values in Freestyle settings */ - if (main->versionfile < 267) { + if (bmain->versionfile < 267) { Scene *sce; SceneRenderLayer *srl; FreestyleLineStyle *linestyle; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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; @@ -2187,7 +2187,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) { + for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) { #if 1 /* disable the Misc panel for now */ if (linestyle->panel == LS_PANEL_MISC) { @@ -2205,13 +2205,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (main->versionfile < 267) { + 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 = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; for (sa = screen->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -2233,17 +2233,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) break; } - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.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(main, 267, 1)) { + if (MAIN_VERSION_OLDER(bmain, 267, 1)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { @@ -2261,17 +2261,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 268, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 268, 1)) { Brush *brush; - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { brush->spacing = MAX2(1, brush->spacing); } } - if (!MAIN_VERSION_ATLEAST(main, 268, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 268, 2)) { Brush *brush; #define BRUSH_FIXED (1 << 6) - for (brush = main->brush.first; brush; brush = brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { brush->flag &= ~BRUSH_FIXED; if (brush->cursor_overlay_alpha < 2) @@ -2285,11 +2285,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } - if (!MAIN_VERSION_ATLEAST(main, 268, 4)) { + if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) { bScreen *sc; Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bConstraint *con; for (con = ob->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) { @@ -2302,7 +2302,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { @@ -2321,7 +2321,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) * * We moved this check to the do versions to be sure the value makes any sense. */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -2336,7 +2336,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bSensor *sens; bTouchSensor *ts; bCollisionSensor *cs; @@ -2363,12 +2363,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 268, 5)) { + if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) { bScreen *sc; ScrArea *sa; /* add missing (+) expander in node editor */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { for (sa = sc->areabase.first; sa; sa = sa->next) { ARegion *ar, *arnew; @@ -2397,9 +2397,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 269, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) { /* Removal of Cycles SSS Compatible falloff */ - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -2413,9 +2413,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (!MAIN_VERSION_ATLEAST(main, 269, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) { /* Initialize CDL settings for Color Balance nodes */ - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -2440,14 +2440,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (!MAIN_VERSION_ATLEAST(main, 269, 3)) { + 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 = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.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) { @@ -2466,7 +2466,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; for (tracking_object = tracking->objects.first; @@ -2487,7 +2487,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Triangulate) { @@ -2505,7 +2505,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { /* this can now be turned off */ ToolSettings *ts = scene->toolsettings; if (ts->sculpt) @@ -2529,17 +2529,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 269, 4)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 4)) { /* Internal degrees to radians conversions... */ { Scene *scene; Object *ob; Lamp *lamp; - for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) + for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) lamp->spotsize = DEG2RADF(lamp->spotsize); - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; bSensor *bs; bActuator *ba; @@ -2578,7 +2578,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { Sequence *seq; SEQ_BEGIN (scene->ed, seq) { @@ -2590,7 +2590,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) SEQ_END } - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -2613,7 +2613,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTrackingPlaneTrack *plane_track; for (plane_track = clip->tracking.plane_tracks.first; plane_track; @@ -2625,9 +2625,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 269, 7)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 7)) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { Sculpt *sd = scene->toolsettings->sculpt; if (sd) { @@ -2645,20 +2645,20 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 269, 8)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 8)) { Curve *cu; - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { if (cu->str) { cu->len_wchar = BLI_strlen_utf8(cu->str); } } } - if (!MAIN_VERSION_ATLEAST(main, 269, 9)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Build) { @@ -2671,10 +2671,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 269, 11)) { + if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) { bScreen *sc; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *space_link; diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 86e6071180e..e1b91726821 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -347,14 +347,14 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void } -void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) +void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) { - if (!MAIN_VERSION_ATLEAST(main, 270, 0)) { + if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) { if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Bevel) { @@ -367,7 +367,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } /* nodes don't use fixed node->id any more, clean up */ - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -381,7 +381,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { bScreen *screen; - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *area; for (area = screen->areabase.first; area; area = area->next) { SpaceLink *space_link; @@ -399,18 +399,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { clip->tracking.settings.default_weight = 1.0f; } } } - if (!MAIN_VERSION_ATLEAST(main, 270, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 270, 1)) { Scene *sce; Object *ob; /* Update Transform constraint (another deg -> rad stuff). */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { do_version_constraints_radians_degrees_270_1(&ob->constraints); if (ob->pose) { @@ -422,39 +422,39 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) { sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO; } } } - if (!MAIN_VERSION_ATLEAST(main, 270, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 270, 2)) { Mesh *me; /* Mesh smoothresh deg->rad. */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { me->smoothresh = DEG2RADF(me->smoothresh); } } - if (!MAIN_VERSION_ATLEAST(main, 270, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 270, 3)) { FreestyleLineStyle *linestyle; - for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) { + for (linestyle = bmain->linestyle.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(main, 270, 4)) { + 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 = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -471,11 +471,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 270, 5)) { + if (!MAIN_VERSION_ATLEAST(bmain, 270, 5)) { Object *ob; /* Update Transform constraint (again :|). */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { do_version_constraints_radians_degrees_270_5(&ob->constraints); if (ob->pose) { @@ -488,18 +488,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 271, 0)) { + if (!MAIN_VERSION_ATLEAST(bmain, 271, 0)) { if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) { Material *ma; - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) ma->mode2 = MA_CASTSHADOW; } if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) { Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->r.bake.flag = R_BAKE_CLEAR; sce->r.bake.width = 512; sce->r.bake.height = 512; @@ -521,7 +521,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) { FreestyleLineStyle *linestyle; - for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) { + for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) { linestyle->flag |= LS_TEXTURE; linestyle->texstep = 1.0; } @@ -529,18 +529,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.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(main, 271, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 271, 1)) { if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) { Material *mat; - for (mat = main->mat.first; mat; mat = mat->id.next) { + for (mat = bmain->mat.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; } @@ -548,17 +548,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { scene->r.preview_start_resolution = 64; } } } - if (!MAIN_VERSION_ATLEAST(main, 271, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 271, 2)) { /* init up & track axis property of trackto actuators */ Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bActuator *act; for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_EDIT_OBJECT) { @@ -577,16 +577,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 271, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 271, 3)) { Brush *br; - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { @@ -599,9 +599,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 271, 6)) { + if (!MAIN_VERSION_ATLEAST(bmain, 271, 6)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { @@ -615,27 +615,27 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 272, 0)) { + if (!MAIN_VERSION_ATLEAST(bmain, 272, 0)) { if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { scene->r.preview_start_resolution = 64; } } } - if (!MAIN_VERSION_ATLEAST(main, 272, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 272, 1)) { Brush *br; - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.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(main, 272, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 272, 2)) { if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) { Image *image; - for (image = main->image.first; image != NULL; image = image->id.next) { + for (image = bmain->image.first; image != NULL; image = image->id.next) { image->gen_color[3] = 1.0f; } } @@ -644,7 +644,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) Object *ob; /* Update Transform constraint (again :|). */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { do_version_constraints_stretch_to_limits(&ob->constraints); if (ob->pose) { @@ -658,13 +658,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 273, 1)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 1)) { #define BRUSH_RAKE (1 << 7) #define BRUSH_RANDOM_ROTATION (1 << 25) Brush *br; - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.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; @@ -682,11 +682,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) #undef BRUSH_RANDOM_ROTATION /* Customizable Safe Areas */ - if (!MAIN_VERSION_ATLEAST(main, 273, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 2)) { if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.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); @@ -695,9 +695,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 273, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) { ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (part->clumpcurve) part->child_flag |= PART_CHILD_USE_CLUMP_CURVE; if (part->roughcurve) @@ -705,11 +705,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 273, 6)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 6)) { if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) { Object *ob; ModifierData *md; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -727,21 +727,21 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) { ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.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 = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.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 = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { int a; for (a = 0; a < MAX_MTEX; a++) { MTex *mtex = part->mtex[a]; @@ -755,7 +755,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Hook) { @@ -767,7 +767,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) { - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { bNode *node; for (node = ntree->nodes.first; node; node = node->next) { @@ -785,7 +785,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) { Camera *ca; - for (ca = main->camera.first; ca; ca = ca->id.next) { + for (ca = bmain->camera.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; @@ -794,9 +794,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 273, 8)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 8)) { Object *ob; - for (ob = main->object.first; ob != NULL; ob = ob->id.next) { + for (ob = bmain->object.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)) { @@ -808,14 +808,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 273, 9)) { + if (!MAIN_VERSION_ATLEAST(bmain, 273, 9)) { bScreen *scr; ScrArea *sa; SpaceLink *sl; ARegion *ar; /* Make sure sequencer preview area limits zoom */ - for (scr = main->screen.first; scr; scr = scr->id.next) { + for (scr = bmain->screen.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) { @@ -833,12 +833,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 274, 1)) { + 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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (psys = ob->particlesystem.first; psys; psys = psys->next) { if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) { psys->recalc |= PSYS_RECALC_RESET; @@ -850,7 +850,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* hysteresis setted to 10% but not actived */ if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { LodLevel *level; for (level = ob->lodlevels.first; level; level = level->next) { level->obhysteresis = 10; @@ -860,14 +860,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) { Scene *scene; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { scene->gm.scehysteresis = 10; } } } - if (!MAIN_VERSION_ATLEAST(main, 274, 2)) { - FOREACH_NODETREE(main, ntree, id) { + if (!MAIN_VERSION_ATLEAST(bmain, 274, 2)) { + FOREACH_NODETREE(bmain, ntree, id) { bNode *node; bNodeSocket *sock; @@ -893,7 +893,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } FOREACH_NODETREE_END } - if (!MAIN_VERSION_ATLEAST(main, 274, 4)) { + if (!MAIN_VERSION_ATLEAST(bmain, 274, 4)) { SceneRenderView *srv; wmWindowManager *wm; bScreen *screen; @@ -902,7 +902,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) Camera *cam; Image *ima; - for (scene = main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { Sequence *seq; BKE_scene_add_render_view(scene, STEREO_LEFT_NAME); @@ -932,7 +932,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) SEQ_END } - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; for (sa = screen->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -959,12 +959,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (cam = main->camera.first; cam; cam = cam->id.next) { + for (cam = bmain->camera.first; cam; cam = cam->id.next) { cam->stereo.interocular_distance = 0.065f; cam->stereo.convergence_distance = 30.0f * 0.065f; } - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format"); if (ima->packedfile) { @@ -977,18 +977,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (wm = main->wm.first; wm; wm = wm->id.next) { + 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(main, 274, 6)) { + if (!MAIN_VERSION_ATLEAST(bmain, 274, 6)) { bScreen *screen; if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) { - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; for (sa = screen->areabase.first; sa; sa = sa->next) { @@ -1009,7 +1009,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) { Scene *scene; - for (scene = main->scene.first; scene != NULL; scene = scene->id.next) { + for (scene = bmain->scene.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; } @@ -1018,7 +1018,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Decimate) { @@ -1030,20 +1030,20 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 275, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 275, 3)) { Brush *br; #define BRUSH_TORUS (1 << 1) - for (br = main->brush.first; br; br = br->id.next) { + for (br = bmain->brush.first; br; br = br->id.next) { br->flag &= ~BRUSH_TORUS; } #undef BRUSH_TORUS } - if (!MAIN_VERSION_ATLEAST(main, 276, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 276, 2)) { if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->pose) { bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { @@ -1056,7 +1056,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { bScreen *screen; #define RV3D_VIEW_PERSPORTHO 7 - for (screen = main->screen.first; screen; screen = screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { ScrArea *sa; for (sa = screen->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1085,7 +1085,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { Lamp *lamp; #define LA_YF_PHOTON 5 - for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) { + for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) { if (lamp->type == LA_YF_PHOTON) { lamp->type = LA_LOCAL; } @@ -1095,7 +1095,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->body_type == OB_BODY_TYPE_CHARACTER && (ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) { ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX; } @@ -1104,10 +1104,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } - if (!MAIN_VERSION_ATLEAST(main, 276, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 276, 3)) { if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) { Scene *scene; - for (scene = main->scene.first; scene != NULL; scene = scene->id.next) { + for (scene = bmain->scene.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); @@ -1119,8 +1119,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 276, 4)) { - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + if (!MAIN_VERSION_ATLEAST(bmain, 276, 4)) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; if (ts->gp_sculpt.brush[0].size == 0) { @@ -1195,7 +1195,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { + for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) { bool enabled = false; /* Ensure that the datablock's onionskinning toggle flag @@ -1214,18 +1214,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!DNA_struct_elem_find(fd->filesdna, "Object", "unsigned char", "max_jumps")) { - for (Object *ob = main->object.first; ob; ob = ob->id.next) { + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { ob->max_jumps = 1; } } } - if (!MAIN_VERSION_ATLEAST(main, 276, 5)) { + 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(main, lbarray); + a = set_listbasepointers(bmain, lbarray); while (a--) { for (ID *id = lbarray[a]->first; id; id = id->next) { id->flag &= LIB_FAKEUSER; @@ -1233,15 +1233,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 276, 7)) { + if (!MAIN_VERSION_ATLEAST(bmain, 276, 7)) { Scene *scene; - for (scene = main->scene.first; scene != NULL; scene = scene->id.next) { + for (scene = bmain->scene.first; scene != NULL; scene = scene->id.next) { scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL; } } - if (!MAIN_VERSION_ATLEAST(main, 277, 1)) { - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + if (!MAIN_VERSION_ATLEAST(bmain, 277, 1)) { + for (Scene *scene = bmain->scene.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) { @@ -1250,7 +1250,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (bScreen *screen = bmain->screen.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; @@ -1283,7 +1283,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings; if (cps->error_threshold == 0) { cps->curve_type = CU_BEZIER; @@ -1294,7 +1294,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { Sequence *seq; SEQ_BEGIN (scene->ed, seq) @@ -1318,7 +1318,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } /* Adding "Properties" region to DopeSheet */ - for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (bScreen *screen = bmain->screen.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) { @@ -1336,14 +1336,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 277, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 277, 2)) { if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) { - for (bArmature *arm = main->armature.first; arm; arm = arm->id.next) { + for (bArmature *arm = bmain->armature.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 = main->object.first; ob; ob = ob->id.next) { + for (Object *ob = bmain->object.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()... */ @@ -1363,7 +1363,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) { + for (Camera *camera = bmain->camera.first; camera != NULL; camera = camera->id.next) { if (camera->stereo.pole_merge_angle_from == 0.0f && camera->stereo.pole_merge_angle_to == 0.0f) { @@ -1375,7 +1375,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_NormalEdit) { @@ -1388,7 +1388,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Boolean) { @@ -1399,7 +1399,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Brush *br = main->brush.first; br; br = br->id.next) { + for (Brush *br = bmain->brush.first; br; br = br->id.next) { if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) { br->flag |= BRUSH_ACCUMULATE; } @@ -1408,7 +1408,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) { Object *ob; ModifierData *md; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -1425,10 +1425,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 277, 3)) { + 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 = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; /* initialize use position for sculpt brushes */ ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION; @@ -1447,8 +1447,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } /* create a default grease pencil drawing brushes set */ - if (!BLI_listbase_is_empty(&main->gpencil)) { - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + if (!BLI_listbase_is_empty(&bmain->gpencil)) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; if (BLI_listbase_is_empty(&ts->gp_brushes)) { BKE_gpencil_brush_init_presets(ts); @@ -1458,7 +1458,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* Convert Grease Pencil to new palettes/brushes * Loop all strokes and create the palette and all colors */ - for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { + for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) { if (BLI_listbase_is_empty(&gpd->palettes)) { /* create palette */ bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true); @@ -1511,10 +1511,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* ------- end of grease pencil initialization --------------- */ } - if (!MAIN_VERSION_ATLEAST(main, 278, 0)) { + if (!MAIN_VERSION_ATLEAST(bmain, 278, 0)) { if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) { MovieClip *clip; - for (clip = main->movieclip.first; clip; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip; clip = clip->id.next) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; for (tracking_object = tracking->objects.first; @@ -1535,7 +1535,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) { MovieClip *clip; - for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) { + for (clip = bmain->movieclip.first; clip != NULL; clip = clip->id.next) { if (clip->tracking.stabilization.rot_track) { migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization); } @@ -1555,15 +1555,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } - if (!MAIN_VERSION_ATLEAST(main, 278, 2)) { + if (!MAIN_VERSION_ATLEAST(bmain, 278, 2)) { if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) { - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.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 = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { /* fall back to behaviour from before we introduced CRF for old files */ scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE; } @@ -1573,7 +1573,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) Object *ob; ModifierData *md; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; @@ -1588,8 +1588,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 278, 3)) { - for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) { + if (!MAIN_VERSION_ATLEAST(bmain, 278, 3)) { + for (Scene *scene = bmain->scene.first; scene != NULL; scene = scene->id.next) { if (scene->toolsettings != NULL) { ToolSettings *ts = scene->toolsettings; ParticleEditSettings *pset = &ts->particle; @@ -1603,7 +1603,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { RigidBodyCon *rbc = ob->rigidbody_constraint; if (rbc) { rbc->spring_stiffness_ang_x = 10.0; @@ -1618,7 +1618,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* 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 = main->scene.first; scene != NULL; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene != NULL; scene = scene->id.next) { if (scene->toolsettings != NULL) { ToolSettings *ts = scene->toolsettings; if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) { @@ -1628,16 +1628,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 278, 4)) { + if (!MAIN_VERSION_ATLEAST(bmain, 278, 4)) { const float sqrt_3 = (float)M_SQRT3; - for (Brush *br = main->brush.first; br; br = br->id.next) { + for (Brush *br = bmain->brush.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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bMotionPath *mpath; bPoseChannel *pchan; mpath = ob->mpath; @@ -1665,9 +1665,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - if (!MAIN_VERSION_ATLEAST(main, 278, 5)) { + if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) { /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */ - for (Mask *mask = main->mask.first; mask; mask = mask->id.next) { + for (Mask *mask = bmain->mask.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; @@ -1682,7 +1682,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* 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(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { ntreeSetTypes(NULL, ntree); for (bNode *node = ntree->nodes.first; node; node = node->next) { @@ -1705,7 +1705,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) { - for (Object *ob = main->object.first; ob; ob = ob->id.next) { + for (Object *ob = bmain->object.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; @@ -1715,32 +1715,32 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - FOREACH_NODETREE(main, ntree, id) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { do_versions_compositor_render_passes(ntree); } } FOREACH_NODETREE_END } - if (!MAIN_VERSION_ATLEAST(main, 279, 0)) { - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) { + for (Scene *scene = bmain->scene.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 = main->mesh.first; me; me = me->id.next) { + for (Mesh *me = bmain->mesh.first; me; me = me->id.next) { CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, ""); } } - if (!MAIN_VERSION_ATLEAST(main, 279, 3)) { + if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) { if (!DNA_struct_elem_find(fd->filesdna, "SmokeDomainSettings", "float", "clipping")) { Object *ob; ModifierData *md; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; @@ -1755,7 +1755,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { /* Fix for invalid state of screen due to bug in older versions. */ - for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) { + for (bScreen *sc = bmain->screen.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; @@ -1764,7 +1764,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "falloff_angle")) { - for (Brush *br = main->brush.first; br; br = br->id.next) { + for (Brush *br = bmain->brush.first; br; br = br->id.next) { br->falloff_angle = DEG2RADF(80); br->flag &= ~( BRUSH_FLAG_DEPRECATED_1 | BRUSH_FLAG_DEPRECATED_2 | @@ -1772,7 +1772,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) BRUSH_FRONTFACE_FALLOFF); } - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; for (int i = 0; i < 2; i++) { VPaint *vp = i ? ts->vpaint : ts->wpaint; @@ -1787,7 +1787,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) /* 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 = main->object.first; ob; ob = ob->id.next) { + for (Object *ob = bmain->object.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; @@ -1797,7 +1797,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } - for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { int preset = scene->r.ffcodecdata.ffmpeg_preset; if (preset == FFM_PRESET_NONE || preset >= FFM_PRESET_GOOD) { continue; @@ -1815,7 +1815,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!DNA_struct_elem_find(fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) { - for (Object *ob = main->object.first; ob; ob = ob->id.next) { + for (Object *ob = bmain->object.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; @@ -1828,11 +1828,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } -void do_versions_after_linking_270(Main *main) +void do_versions_after_linking_270(Main *bmain) { /* To be added to next subversion bump! */ - if (!MAIN_VERSION_ATLEAST(main, 279, 0)) { - FOREACH_NODETREE(main, ntree, id) { + if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) { + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { ntreeSetTypes(NULL, ntree); for (bNode *node = ntree->nodes.first; node; node = node->next) { @@ -1844,9 +1844,9 @@ void do_versions_after_linking_270(Main *main) } FOREACH_NODETREE_END } - if (!MAIN_VERSION_ATLEAST(main, 279, 2)) { + 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(main, do_version_bbone_easing_fcurve_fix, NULL); + BKE_fcurves_main_cb(bmain, do_version_bbone_easing_fcurve_fix, NULL); } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index e2bfcad3f7f..c4868af76cf 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -581,13 +581,13 @@ void blo_do_version_old_trackto_to_constraints(Object *ob) ob->track = NULL; } -void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) +void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (main->versionfile == 100) { + if (bmain->versionfile == 100) { /* tex->extend and tex->imageflag have changed: */ - Tex *tex = main->tex.first; + Tex *tex = bmain->tex.first; while (tex) { if (tex->id.tag & LIB_TAG_NEED_LINK) { @@ -606,9 +606,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 101) { + if (bmain->versionfile <= 101) { /* frame mapping */ - Scene *sce = main->scene.first; + Scene *sce = bmain->scene.first; while (sce) { sce->r.framapto = 100; sce->r.images = 100; @@ -617,18 +617,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 102) { + if (bmain->versionfile <= 102) { /* init halo's at 1.0 */ - Material *ma = main->mat.first; + Material *ma = bmain->mat.first; while (ma) { ma->add = 1.0; ma = ma->id.next; } } - if (main->versionfile <= 103) { + if (bmain->versionfile <= 103) { /* new variable in object: colbits */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; int a; while (ob) { ob->colbits = 0; @@ -642,9 +642,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 104) { + if (bmain->versionfile <= 104) { /* timeoffs moved */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; while (ob) { if (ob->transflag & 1) { ob->transflag -= 1; @@ -653,8 +653,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 105) { - Object *ob = main->object.first; + if (bmain->versionfile <= 105) { + Object *ob = bmain->object.first; while (ob) { ob->dupon = 1; ob->dupoff = 0; @@ -664,9 +664,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 106) { + if (bmain->versionfile <= 106) { /* mcol changed */ - Mesh *me = main->mesh.first; + Mesh *me = bmain->mesh.first; while (me) { if (me->mcol) vcol_to_fcol(me); @@ -675,14 +675,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if (main->versionfile <= 107) { + if (bmain->versionfile <= 107) { Object *ob; - Scene *sce = main->scene.first; + Scene *sce = bmain->scene.first; while (sce) { sce->r.mode |= R_GAMMA; sce = sce->id.next; } - ob = main->object.first; + ob = bmain->object.first; while (ob) { if (ob->dt == 0) ob->dt = OB_SOLID; @@ -691,9 +691,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if (main->versionfile <= 109) { + if (bmain->versionfile <= 109) { /* new variable: gridlines */ - bScreen *sc = main->screen.first; + bScreen *sc = bmain->screen.first; while (sc) { ScrArea *sa = sc->areabase.first; while (sa) { @@ -713,8 +713,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 113) { - Material *ma = main->mat.first; + if (bmain->versionfile <= 113) { + Material *ma = bmain->mat.first; while (ma) { if (ma->flaresize == 0.0f) ma->flaresize = 1.0f; @@ -724,8 +724,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 134) { - Tex *tex = main->tex.first; + if (bmain->versionfile <= 134) { + Tex *tex = bmain->tex.first; while (tex) { if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && @@ -740,9 +740,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 140) { + if (bmain->versionfile <= 140) { /* r-g-b-fac in texture */ - Tex *tex = main->tex.first; + Tex *tex = bmain->tex.first; while (tex) { if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && @@ -757,8 +757,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 153) { - Scene *sce = main->scene.first; + if (bmain->versionfile <= 153) { + Scene *sce = bmain->scene.first; while (sce) { if (sce->r.blurfac == 0.0f) sce->r.blurfac = 1.0f; @@ -766,8 +766,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 163) { - Scene *sce = main->scene.first; + if (bmain->versionfile <= 163) { + Scene *sce = bmain->scene.first; while (sce) { if (sce->r.frs_sec == 0) sce->r.frs_sec = 25; @@ -775,16 +775,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 164) { - Mesh *me = main->mesh.first; + if (bmain->versionfile <= 164) { + Mesh *me = bmain->mesh.first; while (me) { me->smoothresh = 30; me = me->id.next; } } - if (main->versionfile <= 165) { - Mesh *me = main->mesh.first; + if (bmain->versionfile <= 165) { + Mesh *me = bmain->mesh.first; TFace *tface; int nr; char *cp; @@ -810,8 +810,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 169) { - Mesh *me = main->mesh.first; + if (bmain->versionfile <= 169) { + Mesh *me = bmain->mesh.first; while (me) { if (me->subdiv == 0) me->subdiv = 1; @@ -819,8 +819,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 169) { - bScreen *sc = main->screen.first; + if (bmain->versionfile <= 169) { + bScreen *sc = bmain->screen.first; while (sc) { ScrArea *sa = sc->areabase.first; while (sa) { @@ -838,8 +838,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 170) { - Object *ob = main->object.first; + if (bmain->versionfile <= 170) { + Object *ob = bmain->object.first; PartEff *paf; while (ob) { paf = blo_do_version_give_parteff_245(ob); @@ -852,8 +852,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 171) { - bScreen *sc = main->screen.first; + if (bmain->versionfile <= 171) { + bScreen *sc = bmain->screen.first; while (sc) { ScrArea *sa = sc->areabase.first; while (sa) { @@ -871,9 +871,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 173) { + if (bmain->versionfile <= 173) { int a, b; - Mesh *me = main->mesh.first; + Mesh *me = bmain->mesh.first; while (me) { if (me->tface) { TFace *tface = me->tface; @@ -888,9 +888,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 191) { - Object *ob = main->object.first; - Material *ma = main->mat.first; + if (bmain->versionfile <= 191) { + Object *ob = bmain->object.first; + Material *ma = bmain->mat.first; /* let faces have default add factor of 0.0 */ while (ma) { @@ -907,8 +907,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 193) { - Object *ob = main->object.first; + if (bmain->versionfile <= 193) { + Object *ob = bmain->object.first; while (ob) { ob->inertia = 1.0f; ob->rdamping = 0.1f; @@ -916,8 +916,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 196) { - Mesh *me = main->mesh.first; + if (bmain->versionfile <= 196) { + Mesh *me = bmain->mesh.first; int a, b; while (me) { if (me->tface) { @@ -933,8 +933,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 200) { - Object *ob = main->object.first; + if (bmain->versionfile <= 200) { + Object *ob = bmain->object.first; while (ob) { ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); /* 64 is do_fh */ @@ -943,9 +943,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 201) { + if (bmain->versionfile <= 201) { /* add-object + end-object are joined to edit-object actuator */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; bProperty *prop; bActuator *act; bIpoActuator *ia; @@ -983,10 +983,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 202) { + if (bmain->versionfile <= 202) { /* add-object and end-object are joined to edit-object * actuator */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; bActuator *act; bObjectActuator *oa; while (ob) { @@ -1002,9 +1002,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 204) { + if (bmain->versionfile <= 204) { /* patches for new physics */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; bActuator *act; bObjectActuator *oa; bSound *sound; @@ -1031,7 +1031,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = ob->id.next; } - sound = main->sound.first; + sound = bmain->sound.first; while (sound) { if (sound->volume < 0.01f) { sound->volume = 1.0f; @@ -1040,9 +1040,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 205) { + if (bmain->versionfile <= 205) { /* patches for new physics */ - Object *ob = main->object.first; + Object *ob = bmain->object.first; bActuator *act; bSensor *sens; bEditObjectActuator *oa; @@ -1108,7 +1108,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* have to check the exact multiplier */ } - if (main->versionfile <= 211) { + if (bmain->versionfile <= 211) { /* Render setting: per scene, the applicable gamma value * can be set. Default is 1.0, which means no * correction. */ @@ -1117,14 +1117,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; /* added alpha in obcolor */ - ob = main->object.first; + ob = bmain->object.first; while (ob) { ob->col[3] = 1.0; ob = ob->id.next; } /* added alpha in obcolor */ - ob = main->object.first; + ob = bmain->object.first; while (ob) { act = ob->actuators.first; while (act) { @@ -1150,13 +1150,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 212) { + if (bmain->versionfile <= 212) { bSound *sound; bProperty *prop; Object *ob; Mesh *me; - sound = main->sound.first; + sound = bmain->sound.first; while (sound) { sound->max_gain = 1.0; sound->min_gain = 0.0; @@ -1170,7 +1170,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sound = sound->id.next; } - ob = main->object.first; + ob = bmain->object.first; while (ob) { prop = ob->prop.first; @@ -1190,7 +1190,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) * it a subsurf, and reset the subdiv level because subsurf * takes a lot more work to calculate. */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (me->flag & ME_SMESH) { me->flag &= ~ME_SMESH; me->flag |= ME_SUBSURF; @@ -1206,11 +1206,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 220) { + if (bmain->versionfile <= 220) { Object *ob; Mesh *me; - ob = main->object.first; + ob = bmain->object.first; /* adapt form factor in order to get the 'old' physics * behavior back... @@ -1234,7 +1234,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) * old file vertex colors are undefined, reset them * to be fully opaque. -zr */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (me->mcol) { int i; @@ -1259,8 +1259,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 221) { - Scene *sce = main->scene.first; + if (bmain->versionfile <= 221) { + Scene *sce = bmain->scene.first; /* new variables for std-alone player and runtime */ while (sce) { @@ -1273,8 +1273,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if (main->versionfile <= 222) { - Scene *sce = main->scene.first; + if (bmain->versionfile <= 222) { + Scene *sce = bmain->scene.first; /* new variables for std-alone player and runtime */ while (sce) { @@ -1284,24 +1284,24 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 223) { + if (bmain->versionfile <= 223) { VFont *vf; Image *ima; Object *ob; - for (vf = main->vfont.first; vf; vf = vf->id.next) { + for (vf = bmain->vfont.first; vf; vf = vf->id.next) { if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) { strcpy(vf->name, FO_BUILTIN_NAME); } } /* Old textures animate at 25 FPS */ - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { ima->animspeed = 25; } /* Zr remapped some keyboard codes to be linear (stupid zr) */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { bSensor *sens; for (sens = ob->sensors.first; sens; sens = sens->next) { @@ -1316,13 +1316,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 224) { + if (bmain->versionfile <= 224) { bSound *sound; Scene *sce; Mesh *me; bScreen *sc; - for (sound = main->sound.first; sound; sound = sound->id.next) { + for (sound = bmain->sound.first; sound; sound = sound->id.next) { if (sound->packedfile) { if (sound->newpackedfile == NULL) { sound->newpackedfile = sound->packedfile; @@ -1331,17 +1331,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if ((me->flag & ME_SUBSURF) && (me->subdivr == 0)) me->subdivr = me->subdiv; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->r.stereomode = 1; // no stereo } /* some oldfile patch, moved from set_func_space */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1357,15 +1357,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 225) { + if (bmain->versionfile <= 225) { World *wo; /* Use Sumo for old games */ - for (wo = main->world.first; wo; wo = wo->id.next) { + for (wo = bmain->world.first; wo; wo = wo->id.next) { wo->physicsEngine = 2; } } - if (main->versionfile <= 227) { + if (bmain->versionfile <= 227) { Scene *sce; Material *ma; bScreen *sc; @@ -1374,7 +1374,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* 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 = main->object.first; + ob = bmain->object.first; while (ob) { ListBase *list; @@ -1417,14 +1417,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = ob->id.next; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->audio.mixrate = 48000; sce->audio.flag |= AUDIO_SCRUB; sce->r.mode |= R_ENVMAP; } /* init new shader vars */ - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { ma->refrac = 4.0f; ma->roughness = 0.5f; ma->param[0] = 0.5f; @@ -1434,7 +1434,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* patch for old wrong max view2d settings, allows zooming out more */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1454,7 +1454,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 228) { + if (bmain->versionfile <= 228) { Scene *sce; bScreen *sc; Object *ob; @@ -1462,7 +1462,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* As of now, this insures that the transition from the old Track system * to the new full constraint Track is painless for everyone. */ - ob = main->object.first; + ob = bmain->object.first; while (ob) { ListBase *list; @@ -1501,12 +1501,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = ob->id.next; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->r.mode |= R_ENVMAP; } /* convert old mainb values for new button panels */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1576,11 +1576,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) * check apart from the do_versions() */ - if (main->versionfile <= 230) { + if (bmain->versionfile <= 230) { bScreen *sc; /* new variable blockscale, for panels in any area */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -1597,9 +1597,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 231) { + if (bmain->versionfile <= 231) { /* new bit flags for showing/hiding grid floor and axes */ - bScreen *sc = main->screen.first; + bScreen *sc = bmain->screen.first; while (sc) { ScrArea *sa = sc->areabase.first; @@ -1624,9 +1624,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 231) { - Material *ma = main->mat.first; - bScreen *sc = main->screen.first; + if (bmain->versionfile <= 231) { + Material *ma = bmain->mat.first; + bScreen *sc = bmain->screen.first; Scene *sce; Lamp *la; World *wrld; @@ -1646,13 +1646,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ma = ma->id.next; } - sce = main->scene.first; + sce = bmain->scene.first; while (sce) { if (sce->r.gauss == 0.0f) sce->r.gauss = 1.0f; sce = sce->id.next; } - la = main->lamp.first; + la = bmain->lamp.first; while (la) { if (la->k == 0.0f) la->k = 1.0; if (la->ray_samp == 0) @@ -1669,7 +1669,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) la->area_sizez = 1.0f; la = la->id.next; } - wrld = main->world.first; + wrld = bmain->world.first; while (wrld) { if (wrld->range == 0.0f) { wrld->range = 1.0f / wrld->exposure; @@ -1702,9 +1702,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 232) { - Tex *tex = main->tex.first; - World *wrld = main->world.first; + if (bmain->versionfile <= 232) { + Tex *tex = bmain->tex.first; + World *wrld = bmain->world.first; bScreen *sc; Scene *sce; @@ -1745,7 +1745,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* new variable blockscale, for panels in any area, do again because new * areas didnt initialize it to 0.7 yet */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1758,7 +1758,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - sce = main->scene.first; + sce = bmain->scene.first; while (sce) { if (sce->r.ocres == 0) sce->r.ocres = 64; @@ -1767,10 +1767,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if (main->versionfile <= 233) { + if (bmain->versionfile <= 233) { bScreen *sc; - Material *ma = main->mat.first; - /* Object *ob = main->object.first; */ + Material *ma = bmain->mat.first; + /* Object *ob = bmain->object.first; */ while (ma) { if (ma->rampfac_col == 0.0f) @@ -1782,7 +1782,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ma = ma->id.next; } - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1796,17 +1796,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 234) { + if (bmain->versionfile <= 234) { World *wo; bScreen *sc; /* force sumo engine to be active */ - for (wo = main->world.first; wo; wo = wo->id.next) { + for (wo = bmain->world.first; wo; wo = wo->id.next) { if (wo->physicsEngine == 0) wo->physicsEngine = 2; } - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1825,9 +1825,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 235) { - Tex *tex = main->tex.first; - Scene *sce = main->scene.first; + if (bmain->versionfile <= 235) { + Tex *tex = bmain->tex.first; + Scene *sce = bmain->scene.first; Sequence *seq; Editing *ed; @@ -1851,9 +1851,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 236) { + if (bmain->versionfile <= 236) { Object *ob; - Camera *cam = main->camera.first; + Camera *cam = bmain->camera.first; Material *ma; bScreen *sc; @@ -1868,7 +1868,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* set manipulator type */ /* force oops draw if depgraph was set*/ /* set time line var */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -1882,7 +1882,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } /* init new shader vars */ - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->darkness == 0.0f) { ma->rms = 0.1f; ma->darkness = 1.0f; @@ -1890,7 +1890,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* softbody init new vars */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->soft) { if (ob->soft->defgoal == 0.0f) ob->soft->defgoal = 0.7f; @@ -1913,20 +1913,20 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 237) { + if (bmain->versionfile <= 237) { bArmature *arm; bConstraint *con; Object *ob; Bone *bone; /* armature recode checks */ - for (arm = main->armature.first; arm; arm = arm->id.next) { + for (arm = bmain->armature.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 = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.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) @@ -1936,7 +1936,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* btw. armature_rebuild_pose is further only called on leave editmode */ if (ob->type == OB_ARMATURE) { if (ob->pose) - BKE_pose_tag_recalc(main, ob->pose); + BKE_pose_tag_recalc(bmain, ob->pose); /* cannot call stuff now (pointers!), done in setup_app_data */ ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; @@ -1987,13 +1987,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 238) { + if (bmain->versionfile <= 238) { Lattice *lt; Object *ob; bArmature *arm; Mesh *me; Key *key; - Scene *sce = main->scene.first; + Scene *sce = bmain->scene.first; while (sce) { if (sce->toolsettings == NULL) { @@ -2003,7 +2003,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sce = sce->id.next; } - for (lt = main->latt.first; lt; lt = lt->id.next) { + for (lt = bmain->latt.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, <->fu, <->du); calc_lat_fudu(lt->flag, lt->pntsv, <->fv, <->dv); @@ -2011,7 +2011,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; PartEff *paf; @@ -2060,7 +2060,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) data->rootbone = -1; /* update_pose_etc handles rootbone == -1 */ - BKE_pose_tag_recalc(main, ob->pose); + BKE_pose_tag_recalc(bmain, ob->pose); } } } @@ -2078,12 +2078,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (arm = main->armature.first; arm; arm = arm->id.next) { + for (arm = bmain->armature.first; arm; arm = arm->id.next) { bone_version_238(&arm->bonebase); arm->deformflag |= ARM_DEF_VGROUP; } - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (!me->medge) { BKE_mesh_calc_edges_legacy(me, true); /* true = use mface->edcode */ } @@ -2092,7 +2092,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (key = main->key.first; key; key = key->id.next) { + for (key = bmain->key.first; key; key = key->id.next) { KeyBlock *kb; int index = 1; @@ -2111,16 +2111,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 239) { + if (bmain->versionfile <= 239) { bArmature *arm; Object *ob; - Scene *sce = main->scene.first; - Camera *cam = main->camera.first; - Material *ma = main->mat.first; + Scene *sce = bmain->scene.first; + Camera *cam = bmain->camera.first; + Material *ma = bmain->mat.first; int set_passepartout = 0; /* deformflag is local in modifier now */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; for (md = ob->modifiers.first; md; md = md->next) { @@ -2136,7 +2136,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* updating stepsize for ghost drawing */ - for (arm = main->armature.first; arm; arm = arm->id.next) { + for (arm = bmain->armature.first; arm; arm = arm->id.next) { if (arm->ghostsize == 0) arm->ghostsize = 1; bone_version_239(&arm->bonebase); @@ -2179,7 +2179,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 241) { + if (bmain->versionfile <= 241) { Object *ob; Tex *tex; Scene *sce; @@ -2189,22 +2189,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) bArmature *arm; bNodeTree *ntree; - for (wo = main->world.first; wo; wo = wo->id.next) { + for (wo = bmain->world.first; wo; wo = wo->id.next) { /* Migrate to Bullet for games, except for the NaN versions */ /* People can still explicitly choose for Sumo (after 2.42 is out) */ - if (main->versionfile > 225) + if (bmain->versionfile > 225) wo->physicsEngine = WOPHY_BULLET; if (WO_AODIST == wo->aomode) wo->aocolor = WO_AOPLAIN; } /* updating layers still */ - for (arm = main->armature.first; arm; arm = arm->id.next) { + for (arm = bmain->armature.first; arm; arm = arm->id.next) { bone_version_239(&arm->bonebase); if (arm->layer == 0) arm->layer = 1; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->audio.mixrate == 0) sce->audio.mixrate = 48000; @@ -2252,28 +2252,28 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_241(ntree); - for (la = main->lamp.first; la; la = la->id.next) + for (la = bmain->lamp.first; la; la = la->id.next) if (la->buffers == 0) la->buffers = 1; - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->env && tex->env->viewscale == 0.0f) tex->env->viewscale = 1.0f; //tex->imaflag |= TEX_GAUSS_MIP; } /* for empty drawsize and drawtype */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->empty_drawsize == 0.0f) { ob->empty_drawtype = OB_ARROWS; ob->empty_drawsize = 1.0; } } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { /* stucci returns intensity from now on */ int a; for (a = 0; a < MAX_MTEX; a++) { @@ -2289,9 +2289,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* during 2.41 images with this name were used for viewer node output, lets fix that */ - if (main->versionfile == 241) { + if (bmain->versionfile == 241) { Image *ima; - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { if (STREQ(ima->name, "Compositor")) { strcpy(ima->id.name + 2, "Viewer Node"); strcpy(ima->name, "Viewer Node"); @@ -2300,7 +2300,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 242) { + if (bmain->versionfile <= 242) { Scene *sce; bScreen *sc; Object *ob; @@ -2314,7 +2314,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) bNodeTree *ntree; int a; - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; sa = sc->areabase.first; while (sa) { @@ -2331,7 +2331,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->select_thresh == 0.0f) sce->toolsettings->select_thresh = 0.01f; @@ -2345,11 +2345,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ntree_version_242(sce->nodetree); } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_242(ntree); /* add default radius values to old curve points */ - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu) { if (nu->bezt) { @@ -2368,7 +2368,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ModifierData *md; ListBase *list; list = &ob->constraints; @@ -2456,27 +2456,27 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->shad_alpha == 0.0f) ma->shad_alpha = 1.0f; if (ma->nodetree) ntree_version_242(ma->nodetree); } - for (me = main->mesh.first; me; me = me->id.next) + for (me = bmain->mesh.first; me; me = me->id.next) customdata_version_242(me); - for (group = main->group.first; group; group = group->id.next) + for (group = bmain->group.first; group; group = group->id.next) if (group->layer == 0) group->layer = (1 << 20) - 1; /* now, subversion control! */ - if (main->subversionfile < 3) { + if (bmain->subversionfile < 3) { Image *ima; Tex *tex; /* Image refactor initialize */ - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { ima->source = IMA_SRC_FILE; ima->type = IMA_TYPE_IMAGE; @@ -2493,7 +2493,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (tex = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->type == TEX_IMAGE && tex->ima) { ima = blo_do_versions_newlibadr(fd, lib, tex->ima); if (tex->imaflag & TEX_ANIM5_) @@ -2509,17 +2509,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex->iuser.sfra = tex->sfra; tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) do_version_ntree_242_2(sce->nodetree); } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) do_version_ntree_242_2(ntree); - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->nodetree) do_version_ntree_242_2(ma->nodetree); - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; @@ -2537,8 +2537,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->subversionfile < 4) { - for (sce = main->scene.first; sce; sce = sce->id.next) { + if (bmain->subversionfile < 4) { + for (sce = bmain->scene.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_osa = 5; @@ -2547,11 +2547,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 243) { - Object *ob = main->object.first; + if (bmain->versionfile <= 243) { + Object *ob = bmain->object.first; Material *ma; - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->sss_scale == 0.0f) { ma->sss_radius[0] = 1.0f; ma->sss_radius[1] = 1.0f; @@ -2586,7 +2586,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 243 || main->subversionfile < 1) { + if (bmain->versionfile < 243 || bmain->subversionfile < 1) { ModifierData *md; /* translate old mirror modifier axis values to new flags */ @@ -2613,26 +2613,26 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* render layer added, this is not the active layer */ - if (main->versionfile <= 243 || main->subversionfile < 2) { + if (bmain->versionfile <= 243 || bmain->subversionfile < 2) { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) + for (me = bmain->mesh.first; me; me = me->id.next) customdata_version_243(me); } } - if (main->versionfile <= 244) { + if (bmain->versionfile <= 244) { Scene *sce; bScreen *sc; Lamp *la; World *wrld; - if (main->versionfile != 244 || main->subversionfile < 2) { - for (sce = main->scene.first; sce; sce = sce->id.next) + if (bmain->versionfile != 244 || bmain->subversionfile < 2) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) sce->r.mode |= R_SSS; /* correct older action editors - incorrect scrolling */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; sa = sc->areabase.first; while (sa) { @@ -2654,10 +2654,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile != 244 || main->subversionfile < 3) { + if (bmain->versionfile != 244 || bmain->subversionfile < 3) { /* constraints recode version patch used to be here. Moved to 245 now... */ - for (wrld = main->world.first; wrld; wrld = wrld->id.next) { + for (wrld = bmain->world.first; wrld; wrld = wrld->id.next) { if (wrld->mode & WO_AMB_OCC) wrld->ao_samp_method = WO_AOSAMP_CONSTANT; else @@ -2666,7 +2666,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) wrld->ao_adapt_thresh = 0.005f; } - for (la = main->lamp.first; la; la = la->id.next) { + for (la = bmain->lamp.first; la; la = la->id.next) { if (la->type == LA_AREA) la->ray_samp_method = LA_SAMP_CONSTANT; else @@ -2677,7 +2677,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile <= 245) { + if (bmain->versionfile <= 245) { Scene *sce; Object *ob; Image *ima; @@ -2692,10 +2692,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ParticleSystem *psys; /* unless the file was created 2.44.3 but not 2.45, update the constraints */ - if (!(main->versionfile == 244 && main->subversionfile == 3) && - ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile == 0)) ) + if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) && + ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0)) ) { - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ListBase *list; list = &ob->constraints; @@ -2762,16 +2762,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* fix all versions before 2.45 */ - if (main->versionfile != 245) { + if (bmain->versionfile != 245) { /* repair preview from 242 - 244*/ - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { ima->preview = NULL; } } /* add point caches */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->soft && !ob->soft->pointcache) ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches); @@ -2799,7 +2799,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* Copy over old per-level multires vertex data * into a single vertex array in struct Multires */ - for (me = main->mesh.first; me; me = me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (me->mr && !me->mr->verts) { MultiresLevel *lvl = me->mr->levels.last; if (lvl) { @@ -2814,8 +2814,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile != 245 || main->subversionfile < 1) { - for (la = main->lamp.first; la; la = la->id.next) { + if (bmain->versionfile != 245 || bmain->subversionfile < 1) { + for (la = bmain->lamp.first; la; la = la->id.next) { if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS; else @@ -2828,7 +2828,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (ma = main->mat.first; ma; ma = ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->samp_gloss_mir == 0) { ma->gloss_mir = ma->gloss_tra = 1.0f; ma->aniso_gloss_mir = 1.0f; @@ -2842,7 +2842,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ma->strand_min = 1.0f; } - for (part = main->particle.first; part; part = part->id.next) { + for (part = bmain->particle.first; part; part = part->id.next) { if (part->ren_child_nbr == 0) part->ren_child_nbr = part->child_nbr; @@ -2854,12 +2854,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (wrld = main->world.first; wrld; wrld = wrld->id.next) { + for (wrld = bmain->world.first; wrld; wrld = wrld->id.next) { if (wrld->ao_approx_error == 0.0f) wrld->ao_approx_error = 0.25f; } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) ntree_version_245(fd, lib, sce->nodetree); @@ -2877,18 +2877,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_245(fd, lib, ntree); /* fix for temporary flag changes during 245 cycle */ - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.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 = main->tex.first; tex; tex = tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->iuser.flag & IMA_OLD_PREMUL) { tex->iuser.flag &= ~IMA_OLD_PREMUL; } @@ -2904,7 +2904,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* sanity check for skgen */ { Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] || sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] || sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2]) @@ -2917,24 +2917,24 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 2)) { Image *ima; /* initialize 1:1 Aspect */ - for (ima = main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { ima->aspx = ima->aspy = 1.0f; } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 4)) { bArmature *arm; ModifierData *md; Object *ob; - for (arm = main->armature.first; arm; arm = arm->id.next) + for (arm = bmain->armature.first; arm; arm = arm->id.next) arm->deformflag |= ARM_DEF_B_BONE_REST; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.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; @@ -2942,10 +2942,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 5)) { /* foreground color needs to be something other then black */ Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.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 */ @@ -2953,21 +2953,21 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 6)) { Scene *sce; /* fix frs_sec_base */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->r.frs_sec_base == 0) { sce->r.frs_sec_base = 1; } } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 7)) { Object *ob; bPoseChannel *pchan; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.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); @@ -2992,12 +2992,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 8)) { Scene *sce; Object *ob; PartEff *paf = NULL; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->soft && ob->soft->keys) { SoftBody *sb = ob->soft; int k; @@ -3024,7 +3024,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); psys->pointcache = BKE_ptcache_add(&psys->ptcaches); - part = psys->part = BKE_particlesettings_add(main, "ParticleSettings"); + 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); @@ -3104,7 +3104,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* dupliobjects */ if (ob->transflag & OB_DUPLIVERTS) { - Object *dup = main->object.first; + Object *dup = bmain->object.first; for (; dup; dup = dup->id.next) { if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) { @@ -3132,7 +3132,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { ParticleEditSettings *pset = &sce->toolsettings->particle; int a; @@ -3153,31 +3153,31 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 9)) { Material *ma; int a; - for (ma = main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->mode & MA_NORMAP_TANG) for (a = 0; a < MAX_MTEX; a++) if (ma->mtex[a] && ma->mtex[a]->tex) ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT; } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 10)) { Object *ob; /* dupliface scale */ - for (ob = main->object.first; ob; ob = ob->id.next) + for (ob = bmain->object.first; ob; ob = ob->id.next) ob->dupfacesca = 1.0f; } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) { Object *ob; bActionStrip *strip; /* nla-strips - scale */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (strip = ob->nlastrips.first; strip; strip = strip->next) { float length, actlength, repeat; @@ -3202,11 +3202,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 14)) { Scene *sce; Sequence *seq; - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { SEQ_BEGIN (sce->ed, seq) { if (seq->blend_mode == 0) @@ -3217,41 +3217,41 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* fix broken group lengths in id properties */ - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) { - idproperties_fix_group_lengths(main->scene); - idproperties_fix_group_lengths(main->library); - idproperties_fix_group_lengths(main->object); - idproperties_fix_group_lengths(main->mesh); - idproperties_fix_group_lengths(main->curve); - idproperties_fix_group_lengths(main->mball); - idproperties_fix_group_lengths(main->mat); - idproperties_fix_group_lengths(main->tex); - idproperties_fix_group_lengths(main->image); - idproperties_fix_group_lengths(main->latt); - idproperties_fix_group_lengths(main->lamp); - idproperties_fix_group_lengths(main->camera); - idproperties_fix_group_lengths(main->ipo); - idproperties_fix_group_lengths(main->key); - idproperties_fix_group_lengths(main->world); - idproperties_fix_group_lengths(main->screen); - idproperties_fix_group_lengths(main->vfont); - idproperties_fix_group_lengths(main->text); - idproperties_fix_group_lengths(main->sound); - idproperties_fix_group_lengths(main->group); - idproperties_fix_group_lengths(main->armature); - idproperties_fix_group_lengths(main->action); - idproperties_fix_group_lengths(main->nodetree); - idproperties_fix_group_lengths(main->brush); - idproperties_fix_group_lengths(main->particle); + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 15)) { + idproperties_fix_group_lengths(bmain->scene); + idproperties_fix_group_lengths(bmain->library); + idproperties_fix_group_lengths(bmain->object); + idproperties_fix_group_lengths(bmain->mesh); + idproperties_fix_group_lengths(bmain->curve); + idproperties_fix_group_lengths(bmain->mball); + idproperties_fix_group_lengths(bmain->mat); + idproperties_fix_group_lengths(bmain->tex); + idproperties_fix_group_lengths(bmain->image); + idproperties_fix_group_lengths(bmain->latt); + idproperties_fix_group_lengths(bmain->lamp); + idproperties_fix_group_lengths(bmain->camera); + idproperties_fix_group_lengths(bmain->ipo); + idproperties_fix_group_lengths(bmain->key); + idproperties_fix_group_lengths(bmain->world); + idproperties_fix_group_lengths(bmain->screen); + idproperties_fix_group_lengths(bmain->vfont); + idproperties_fix_group_lengths(bmain->text); + idproperties_fix_group_lengths(bmain->sound); + idproperties_fix_group_lengths(bmain->group); + idproperties_fix_group_lengths(bmain->armature); + idproperties_fix_group_lengths(bmain->action); + idproperties_fix_group_lengths(bmain->nodetree); + idproperties_fix_group_lengths(bmain->brush); + idproperties_fix_group_lengths(bmain->particle); } /* sun/sky */ - if (main->versionfile < 246) { + if (bmain->versionfile < 246) { Object *ob; bActuator *act; /* dRot actuator change direction in 2.46 */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_OBJECT) { bObjectActuator *ba = act->data; @@ -3265,10 +3265,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* convert fluids to modifier */ - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->fluidsimSettings) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim); BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd); @@ -3286,32 +3286,32 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) { Mesh *me; - for (me = main->mesh.first; me; me = me->id.next) + for (me = bmain->mesh.first; me; me = me->id.next) alphasort_version_246(fd, lib, me); } - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) ob->pd->f_noise = 0.0f; } } - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) { + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 2)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->gameflag |= OB_COLLISION; ob->margin = 0.06f; } } - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) { + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 3)) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* Starting from subversion 3, ACTOR is a separate feature. * Before it was conditioning all the other dynamic flags */ if (!(ob->gameflag & OB_ACTOR)) @@ -3320,8 +3320,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) { - Lamp *la = main->lamp.first; + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 5)) { + Lamp *la = bmain->lamp.first; for (; la; la = la->id.next) { la->skyblendtype = MA_RAMP_ADD; la->skyblendfac = 1.0f; @@ -3329,11 +3329,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* set the curve radius interpolation to 2.47 default - easy */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) { + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 6)) { Curve *cu; Nurb *nu; - for (cu = main->curve.first; cu; cu = cu->id.next) { + for (cu = bmain->curve.first; cu; cu = cu->id.next) { for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu) { nu->radius_interp = 3; @@ -3352,11 +3352,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* direction constraint actuators were always local in previous version */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) { + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 7)) { bActuator *act; Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_CONSTRAINT) { bConstraintActuator *coa = act->data; @@ -3368,19 +3368,19 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) { - Lamp *la = main->lamp.first; + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 9)) { + Lamp *la = bmain->lamp.first; for (; la; la = la->id.next) { la->sky_exposure = 1.0f; } } /* BGE message actuators needed OB prefix, very confusing */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) { + if (bmain->versionfile < 247 || (bmain->versionfile == 247 && bmain->subversionfile < 10)) { bActuator *act; Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_MESSAGE) { bMessageActuator *msgAct = (bMessageActuator *) act->data; @@ -3397,10 +3397,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 248) { + if (bmain->versionfile < 248) { Lamp *la; - for (la = main->lamp.first; la; la = la->id.next) { + for (la = bmain->lamp.first; la; la = la->id.next) { if (la->atm_turbidity == 0.0f) { la->sun_effect_type = 0; la->horizon_brightness = 1.0f; @@ -3417,11 +3417,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) { + if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 2)) { Scene *sce; /* Note, these will need to be added for painting */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->toolsettings->imapaint.seam_bleed = 2; sce->toolsettings->imapaint.normal_angle = 80; @@ -3452,11 +3452,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { + if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) { bScreen *sc; /* adjust default settings for Animation Editors */ - for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -3490,22 +3490,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { + if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 3)) { Object *ob; /* Adjustments needed after Bullets update */ - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->damping *= 0.635f; ob->rdamping = 0.1f + (0.8f * ob->rdamping); } } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) { + if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 4)) { Scene *sce; World *wrld; /* Dome (Fisheye) default parameters */ - for (sce = main->scene.first; sce; sce = sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { sce->r.domeangle = 180; sce->r.domemode = 1; sce->r.domeres = 4; @@ -3513,16 +3513,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sce->r.dometilt = 0; } /* DBVT culling by default */ - for (wrld = main->world.first; wrld; wrld = wrld->id.next) { + for (wrld = bmain->world.first; wrld; wrld = wrld->id.next) { wrld->mode |= WO_DBVT_CULLING; wrld->occlusionRes = 128; } } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) { + if (bmain->versionfile < 248 || (bmain->versionfile == 248 && bmain->subversionfile < 5)) { Object *ob; World *wrld; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->parent) { /* check if top parent has compound shape set and if yes, set this object * to compound shaper as well (was the behavior before, now it's optional) */ @@ -3536,7 +3536,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - for (wrld = main->world.first; wrld; wrld = wrld->id.next) { + for (wrld = bmain->world.first; wrld; wrld = wrld->id.next) { wrld->ticrate = 60; wrld->maxlogicstep = 5; wrld->physubstep = 1; @@ -3545,17 +3545,17 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } /* correct introduce of seed for wind force */ - if (main->versionfile < 249 && main->subversionfile < 1) { + if (bmain->versionfile < 249 && bmain->subversionfile < 1) { Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->pd) ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer())) + 1) % 128; } } - if (main->versionfile < 249 && main->subversionfile < 2) { - Scene *sce = main->scene.first; + if (bmain->versionfile < 249 && bmain->subversionfile < 2) { + Scene *sce = bmain->scene.first; Sequence *seq; Editing *ed; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 549800ae02b..288d42f6398 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4142,7 +4142,7 @@ bool BLO_write_file( * 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, G.main->name, NULL); + BKE_bpath_absolute_convert(mainvar, BKE_main_blendfile_path_from_global(), NULL); } } } diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 99547551a12..a3b710abc66 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -113,7 +113,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) // make absolute source path BLI_strncpy(source_path, image->name, sizeof(source_path)); - BLI_path_abs(source_path, G.main->name); + BLI_path_abs(source_path, BKE_main_blendfile_path_from_global()); BLI_cleanup_path(NULL, source_path); if (use_copies) { diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp index 7786359c06a..f7fcf63fabb 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp @@ -31,6 +31,7 @@ #include "BLI_string.h" #include "BKE_image.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_scene.h" @@ -100,11 +101,10 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution() if (width != 0 && height != 0) { void *exrhandle; - Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; BKE_image_path_from_imtype( - filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR, + filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR, (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL); exrhandle = this->get_handle(filename); @@ -190,11 +190,10 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution() if (width != 0 && height != 0) { void *exrhandle; - Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; BKE_image_path_from_imtype( - filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, + filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL); exrhandle = this->get_handle(filename); @@ -283,7 +282,6 @@ void OutputStereoOperation::deinitExecution() if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) { ImBuf *ibuf[3] = {NULL}; const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; - Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; int i; @@ -307,7 +305,7 @@ void OutputStereoOperation::deinitExecution() ibuf[2] = IMB_stereo3d_ImBuf(this->m_format, ibuf[0], ibuf[1]); BKE_image_path_from_imformat( - filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format, + filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format, (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL); BKE_imbuf_write(ibuf[2], filename, this->m_format); diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index db816816034..39877e35605 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -28,6 +28,7 @@ #include "BLI_string.h" #include "BKE_image.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_scene.h" @@ -185,7 +186,6 @@ void OutputSingleLayerOperation::deinitExecution() int size = get_datatype_size(this->m_datatype); ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), this->m_format->planes, 0); - Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; const char *suffix; @@ -200,7 +200,7 @@ void OutputSingleLayerOperation::deinitExecution() suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName); BKE_image_path_from_imformat( - filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format, + filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format, (this->m_rd->scemode & R_EXTENSION) != 0, true, suffix); if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) @@ -271,14 +271,13 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() unsigned int width = this->getWidth(); unsigned int height = this->getHeight(); if (width != 0 && height != 0) { - Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; const char *suffix; void *exrhandle = IMB_exr_get_handle(); suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName); BKE_image_path_from_imtype( - filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, + filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, (this->m_rd->scemode & R_EXTENSION) != 0, true, suffix); BLI_make_existing_file(filename); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index a8531fad477..4f5e7a67367 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -742,7 +742,7 @@ static int editsource_text_edit( } if (text == NULL) { - text = BKE_text_load(bmain, filepath, bmain->name); + text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain)); id_us_ensure_real(&text->id); } diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 08181af2ef3..671857443d2 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -79,11 +79,11 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent * Main *bmain = CTX_data_main(C); char filepath[FILE_MAX]; - if (bmain->name[0] == '\0') { + if (BKE_main_blendfile_path(bmain)[0] == '\0') { BLI_strncpy(filepath, "untitled", sizeof(filepath)); } else { - BLI_strncpy(filepath, bmain->name, sizeof(filepath)); + BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); } BLI_replace_extension(filepath, sizeof(filepath), ".abc"); @@ -422,12 +422,12 @@ static int get_sequence_len(char *filename, int *ofs) } char path[FILE_MAX]; - BLI_path_abs(filename, G.main->name); + BLI_path_abs(filename, BKE_main_blendfile_path_from_global()); BLI_split_dir_part(filename, path, FILE_MAX); if (path[0] == '\0') { /* The filename had no path, so just use the blend file path. */ - BLI_split_dir_part(G.main->name, path, FILE_MAX); + BLI_split_dir_part(BKE_main_blendfile_path_from_global(), path, FILE_MAX); } DIR *dir = opendir(path); diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index eb79d0bec13..b13eaced843 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -60,7 +60,7 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve char filepath[FILE_MAX]; Main *bmain = CTX_data_main(C); - BLI_strncpy(filepath, bmain->name, sizeof(filepath)); + BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); BLI_replace_extension(filepath, sizeof(filepath), ".abc"); RNA_string_set(op->ptr, "filepath", filepath); } diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 83f5af0709d..d61eb80e9bc 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -60,13 +60,16 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { + Main *bmain = CTX_data_main(C); + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; + const char *blendfile_path = BKE_main_blendfile_path(bmain); - if (G.main->name[0] == 0) + if (blendfile_path[0] == '\0') BLI_strncpy(filepath, "untitled", sizeof(filepath)); else - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); BLI_replace_extension(filepath, sizeof(filepath), ".dae"); RNA_string_set(op->ptr, "filepath", filepath); diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 3e0f62154ac..c9be331b6d5 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -1010,7 +1010,8 @@ cage_cleanup: BakeData *bake = &scene->r.bake; char name[FILE_MAX]; - BKE_image_path_from_imtype(name, filepath, bmain->name, 0, bake->im_format.imtype, true, false, NULL); + BKE_image_path_from_imtype(name, filepath, BKE_main_blendfile_path(bmain), + 0, bake->im_format.imtype, true, false, NULL); if (is_automatic_name) { BLI_path_suffix(name, FILE_MAX, ob_low->id.name + 2, "_"); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index c79be8ed223..b42732bd25d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1308,7 +1308,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); if (relative) - BLI_path_rel(path, bmain->name); + BLI_path_rel(path, BKE_main_blendfile_path(bmain)); CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index cdbfac06422..53849e0b3f3 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -407,7 +407,7 @@ static void screen_opengl_render_write(OGLRender *oglrender) rr = RE_AcquireResultRead(oglrender->re); BKE_image_path_from_imformat( - name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, + name, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, false, NULL); /* write images as individual images or stereo */ @@ -936,7 +936,7 @@ static void write_result_func(TaskPool * __restrict pool, char name[FILE_MAX]; BKE_image_path_from_imformat(name, scene->r.pic, - oglrender->bmain->name, + BKE_main_blendfile_path(oglrender->bmain), cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, @@ -1027,7 +1027,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) if (!is_movie) { BKE_image_path_from_imformat( - name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, + name, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL); if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index dc79d5d9847..808e36a0d90 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -114,7 +114,7 @@ ImBuf *get_brush_icon(Brush *brush) // first use the path directly to try and load the file BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); /* use default colorspaces for brushes */ brush->icon_imbuf = IMB_loadiffname(path, flags, NULL); @@ -123,7 +123,7 @@ ImBuf *get_brush_icon(Brush *brush) if (!(brush->icon_imbuf)) { folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons"); - BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath); + BLI_make_file_string(BKE_main_blendfile_path_from_global(), path, folder, brush->icon_filepath); if (path[0]) { /* use fefault color spaces */ @@ -278,7 +278,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty Base *base; Main *pr_main = sp->pr_main; - memcpy(pr_main->name, bmain->name, sizeof(pr_main->name)); + memcpy(pr_main->name, BKE_main_blendfile_path(bmain), sizeof(pr_main->name)); sce = preview_get_scene(pr_main); if (sce) { diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index fe87f8bdbb2..2083317f6a7 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -1572,13 +1572,14 @@ static int envmap_save_exec(bContext *C, wmOperator *op) static int envmap_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { + Main *bmain = CTX_data_main(C); //Scene *scene= CTX_data_scene(C); if (RNA_struct_property_is_set(op->ptr, "filepath")) return envmap_save_exec(C, op); //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype); - RNA_string_set(op->ptr, "filepath", G.main->name); + RNA_string_set(op->ptr, "filepath", BKE_main_blendfile_path(bmain)); WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 8274ca68d7e..ec01aceeb6c 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -192,7 +192,7 @@ static int screenshot_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); /* operator ensures the extension */ ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); @@ -231,7 +231,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( /* extension is added by 'screenshot_check' after */ char filepath[FILE_MAX] = "//screen"; if (G.relbase_valid) { - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + BLI_strncpy(filepath, BKE_main_blendfile_path_from_global(), sizeof(filepath)); BLI_replace_extension(filepath, sizeof(filepath), ""); /* strip '.blend' */ } RNA_string_set(op->ptr, "filepath", filepath); @@ -407,7 +407,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float int ok; BKE_image_path_from_imformat( - name, rd.pic, sj->bmain->name, rd.cfra, + name, rd.pic, BKE_main_blendfile_path(sj->bmain), rd.cfra, &rd.im_format, (rd.scemode & R_EXTENSION) != 0, true, NULL); ibuf->rect = sj->dumprect; diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index a7660092e6d..ad8469a7c6a 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -374,7 +374,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) specs.rate = scene->r.ffcodecdata.audio_mixrate; BLI_strncpy(filename, path, sizeof(filename)); - BLI_path_abs(filename, bmain->name); + BLI_path_abs(filename, BKE_main_blendfile_path(bmain)); if (split) result = AUD_mixdown_per_channel(scene->sound_scene, SFRA * specs.rate / FPS, (EFRA - SFRA + 1) * specs.rate / FPS, diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 813f4202a49..47f97b8087f 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -102,6 +102,7 @@ typedef struct FileBrowseOp { static int file_browse_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); FileBrowseOp *fbo = op->customdata; ID *id; char *str, path[FILE_MAX]; @@ -118,14 +119,14 @@ static int file_browse_exec(bContext *C, wmOperator *op) id = fbo->ptr.id.data; BLI_strncpy(path, str, FILE_MAX); - BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); + BLI_path_abs(path, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain)); if (BLI_is_dir(path)) { /* do this first so '//' isnt converted to '//\' on windows */ BLI_add_slash(path); if (is_relative) { BLI_strncpy(path, str, FILE_MAX); - BLI_path_rel(path, G.main->name); + BLI_path_rel(path, BKE_main_blendfile_path(bmain)); str = MEM_reallocN(str, strlen(path) + 2); BLI_strncpy(str, path, FILE_MAX); } diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index af5a33bbebe..172ea0f8554 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -317,7 +317,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) if (!clip) return OPERATOR_CANCELLED; - BKE_movieclip_reload(clip); + BKE_movieclip_reload(CTX_data_main(C), clip); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); @@ -1314,7 +1314,7 @@ static void proxy_endjob(void *pjv) if (pj->clip->source == MCLIP_SRC_MOVIE) { /* Timecode might have changed, so do a full reload to deal with this. */ - BKE_movieclip_reload(pj->clip); + BKE_movieclip_reload(pj->main, pj->clip); } else { /* For image sequences we'll preserve original cache. */ diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index befdf6751ee..fd9a9ff9ab1 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -412,6 +412,7 @@ static void file_draw_preview( static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) { + Main *bmain = CTX_data_main(C); char newname[FILE_MAX + 12]; char orgname[FILE_MAX + 12]; char filename[FILE_MAX + 12]; @@ -420,10 +421,11 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname); + const char *blendfile_path = BKE_main_blendfile_path(bmain); + BLI_make_file_string(blendfile_path, orgname, sfile->params->dir, oldname); BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_filename_make_safe(filename); - BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); + BLI_make_file_string(blendfile_path, newname, sfile->params->dir, filename); if (!STREQ(orgname, newname)) { if (!BLI_exists(newname)) { diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 977d9fe7f3a..742715039cf 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -109,9 +109,9 @@ void file_filename_enter_handle(bContext *C, void *arg_unused, void *arg_but); int file_highlight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath); -void file_sfile_to_operator_ex(struct wmOperator *op, struct SpaceFile *sfile, char *filepath); -void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile); -void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); +void file_sfile_to_operator_ex(bContext *C, struct wmOperator *op, struct SpaceFile *sfile, char *filepath); +void file_sfile_to_operator(bContext *C, struct wmOperator *op, struct SpaceFile *sfile); +void file_operator_to_sfile(bContext *C, struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 828cca53012..0cd31ce7ca5 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -176,6 +176,7 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) { + Main *bmain = CTX_data_main(C); FileSelect retval = FILE_SELECT_NOTHING; SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); @@ -213,7 +214,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) } } else { - BLI_cleanup_dir(G.main->name, params->dir); + BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir); strcat(params->dir, file->relpath); BLI_add_slash(params->dir); } @@ -826,6 +827,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) /* Note we could get rid of this one, but it's used by some addon so... Does not hurt keeping it around for now. */ static int bookmark_select_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); PropertyRNA *prop; @@ -835,7 +837,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) RNA_property_string_get(op->ptr, prop, entry); BLI_strncpy(params->dir, entry, sizeof(params->dir)); - BLI_cleanup_dir(G.main->name, params->dir); + BLI_cleanup_dir(BKE_main_blendfile_path(bmain), params->dir); ED_file_change_dir(C); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); @@ -1200,15 +1202,16 @@ void FILE_OT_cancel(struct wmOperatorType *ot) } -void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) +void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, char *filepath) { + Main *bmain = CTX_data_main(C); PropertyRNA *prop; BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */ if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) { if (RNA_property_boolean_get(op->ptr, prop)) { - BLI_path_rel(filepath, G.main->name); + BLI_path_rel(filepath, BKE_main_blendfile_path(bmain)); } } @@ -1270,15 +1273,16 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) } } -void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile) +void file_sfile_to_operator(bContext *C, wmOperator *op, SpaceFile *sfile) { char filepath[FILE_MAX]; - file_sfile_to_operator_ex(op, sfile, filepath); + file_sfile_to_operator_ex(C, op, sfile, filepath); } -void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) +void file_operator_to_sfile(bContext *C, SpaceFile *sfile, wmOperator *op) { + Main *bmain = CTX_data_main(C); PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ @@ -1298,7 +1302,7 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) /* we could check for relative_path property which is used when converting * in the other direction but doesnt hurt to do this every time */ - BLI_path_abs(sfile->params->dir, G.main->name); + BLI_path_abs(sfile->params->dir, BKE_main_blendfile_path(bmain)); /* XXX, files and dirs updates missing, not really so important though */ } @@ -1330,11 +1334,11 @@ void file_draw_check(bContext *C) wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { - file_sfile_to_operator(op, sfile); + file_sfile_to_operator(C, op, sfile); /* redraw */ if (op->type->check(C, op)) { - file_operator_to_sfile(sfile, op); + file_operator_to_sfile(C, sfile, op); /* redraw, else the changed settings wont get updated */ ED_area_tag_redraw(CTX_wm_area(C)); @@ -1369,6 +1373,7 @@ bool file_draw_check_exists(SpaceFile *sfile) int file_exec(bContext *C, wmOperator *exec_op) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); const struct FileDirEntry *file = filelist_file(sfile->files, sfile->params->active_file); @@ -1384,7 +1389,7 @@ int file_exec(bContext *C, wmOperator *exec_op) BLI_parent_dir(sfile->params->dir); } else { - BLI_cleanup_path(G.main->name, sfile->params->dir); + BLI_cleanup_path(BKE_main_blendfile_path(bmain), sfile->params->dir); BLI_path_append(sfile->params->dir, sizeof(sfile->params->dir) - 1, file->relpath); BLI_add_slash(sfile->params->dir); } @@ -1413,14 +1418,14 @@ int file_exec(bContext *C, wmOperator *exec_op) sfile->op = NULL; - file_sfile_to_operator_ex(op, sfile, filepath); + file_sfile_to_operator_ex(C, op, sfile, filepath); if (BLI_exists(sfile->params->dir)) { fsmenu_insert_entry(ED_fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, NULL, FS_INSERT_SAVE | FS_INSERT_FIRST); } - BLI_make_file_string(G.main->name, filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), + BLI_make_file_string(BKE_main_blendfile_path(bmain), filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(ED_fsmenu_get(), filepath); WM_event_fileselect_event(wm, op, EVT_FILESELECT_EXEC); @@ -1452,11 +1457,12 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (BLI_parent_dir(sfile->params->dir)) { - BLI_cleanup_dir(G.main->name, sfile->params->dir); + BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir); ED_file_change_dir(C); if (sfile->params->recursion_level > 1) { /* Disable 'dirtree' recursion when going up in tree. */ @@ -1694,7 +1700,7 @@ static int filepath_drop_exec(bContext *C, wmOperator *op) file_sfile_filepath_set(sfile, filepath); if (sfile->op) { - file_sfile_to_operator(sfile->op, sfile); + file_sfile_to_operator(C, sfile->op, sfile); file_draw_check(C); } @@ -1840,12 +1846,13 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) /* TODO This should go to BLI_path_utils. */ static void file_expand_directory(bContext *C) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (BLI_path_is_rel(sfile->params->dir)) { /* Use of 'default' folder here is just to avoid an error message on '//' prefix. */ - BLI_path_abs(sfile->params->dir, G.relbase_valid ? G.main->name : BKE_appdir_folder_default()); + BLI_path_abs(sfile->params->dir, G.relbase_valid ? BKE_main_blendfile_path(bmain) : BKE_appdir_folder_default()); } else if (sfile->params->dir[0] == '~') { char tmpstr[sizeof(sfile->params->dir) - 1]; @@ -1898,6 +1905,7 @@ static bool can_create_dir(const char *dir) void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but)) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { @@ -1928,7 +1936,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN } } - BLI_cleanup_dir(G.main->name, sfile->params->dir); + BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir); if (filelist_is_dir(sfile->files, sfile->params->dir)) { /* if directory exists, enter it immediately */ @@ -1975,6 +1983,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg_but) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); uiBut *but = arg_but; char matched_file[FILE_MAX]; @@ -2004,7 +2013,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg /* if directory, open it and empty filename field */ if (filelist_is_dir(sfile->files, filepath)) { - BLI_cleanup_dir(G.main->name, filepath); + BLI_cleanup_dir(BKE_main_blendfile_path(bmain), filepath); BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); sfile->params->file[0] = '\0'; ED_file_change_dir(C); @@ -2269,6 +2278,7 @@ static int file_delete_poll(bContext *C) int file_delete_exec(bContext *C, wmOperator *op) { char str[FILE_MAX]; + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); @@ -2281,7 +2291,7 @@ int file_delete_exec(bContext *C, wmOperator *op) for (i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) { file = filelist_file(sfile->files, i); - BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relpath); + BLI_make_file_string(BKE_main_blendfile_path(bmain), str, sfile->params->dir, file->relpath); if (BLI_delete(str, false, false) != 0 || BLI_exists(str)) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index c975479e402..0dd0aca48c6 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1419,7 +1419,7 @@ void filelist_setdir(struct FileList *filelist, char *r_dir) { BLI_assert(strlen(r_dir) < FILE_MAX_LIBEXTRA); - BLI_cleanup_dir(G.main->name, r_dir); + BLI_cleanup_dir(BKE_main_blendfile_path_from_global(), r_dir); const bool is_valid_path = filelist->checkdirf(filelist, r_dir, true); BLI_assert(is_valid_path); UNUSED_VARS_NDEBUG(is_valid_path); @@ -2700,13 +2700,14 @@ static void filelist_readjob_free(void *flrjv) void filelist_readjob_start(FileList *filelist, const bContext *C) { + Main *bmain = CTX_data_main(C); wmJob *wm_job; FileListReadJob *flrj; /* prepare job data */ flrj = MEM_callocN(sizeof(*flrj), __func__); flrj->filelist = filelist; - BLI_strncpy(flrj->main_name, G.main->name, sizeof(flrj->main_name)); + BLI_strncpy(flrj->main_name, BKE_main_blendfile_path(bmain), sizeof(flrj->main_name)); filelist->flags &= ~(FL_FORCE_RESET | FL_IS_READY); filelist->flags |= FL_IS_PENDING; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 99307b1961d..4723ee07a7d 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -96,11 +96,13 @@ short ED_fileselect_set_params(SpaceFile *sfile) FileSelectParams *params; wmOperator *op = sfile->op; + const char *blendfile_path = BKE_main_blendfile_path_from_global(); + /* create new parameters if necessary */ if (!sfile->params) { sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams"); /* set path to most recently opened .blend */ - BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); + BLI_split_dirfile(blendfile_path, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; /* set the default thumbnails size */ sfile->params->thumbnail_size = 128; @@ -149,8 +151,8 @@ short ED_fileselect_set_params(SpaceFile *sfile) } if (params->dir[0]) { - BLI_cleanup_dir(G.main->name, params->dir); - BLI_path_abs(params->dir, G.main->name); + BLI_cleanup_dir(blendfile_path, params->dir); + BLI_path_abs(params->dir, blendfile_path); } if (is_directory == true && is_filename == false && is_filepath == false && is_files == false) { @@ -282,8 +284,8 @@ short ED_fileselect_set_params(SpaceFile *sfile) sfile->folders_prev = folderlist_new(); if (!sfile->params->dir[0]) { - if (G.main->name[0]) { - BLI_split_dir_part(G.main->name, sfile->params->dir, sizeof(sfile->params->dir)); + if (blendfile_path[0] != '\0') { + BLI_split_dir_part(blendfile_path, sfile->params->dir, sizeof(sfile->params->dir)); } else { const char *doc_path = BKE_appdir_folder_default(); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index dea1f761073..bfebc850b08 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -226,7 +226,7 @@ static int space_image_file_exists_poll(bContext *C) ibuf = ED_space_image_acquire_buffer(sima, &lock); if (ibuf) { BLI_strncpy(name, ibuf->name, FILE_MAX); - BLI_path_abs(name, bmain->name); + BLI_path_abs(name, BKE_main_blendfile_path(bmain)); if (BLI_exists(name) == false) { CTX_wm_operator_poll_msg_set(C, "image file not found"); @@ -1259,11 +1259,11 @@ static int image_open_exec(bContext *C, wmOperator *op) BLI_strncpy(filepath_range, frame_range->filepath, sizeof(filepath_range)); if (was_relative) { - BLI_path_rel(filepath_range, bmain->name); + BLI_path_rel(filepath_range, BKE_main_blendfile_path(bmain)); } Image *ima_range = image_open_single( - op, filepath_range, bmain->name, + op, filepath_range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview, frame_range_seq_len); /* take the first image */ @@ -1278,7 +1278,7 @@ static int image_open_exec(bContext *C, wmOperator *op) else { /* for drag & drop etc. */ ima = image_open_single( - op, filepath, bmain->name, + op, filepath, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview, 1); } @@ -1686,12 +1686,12 @@ static int save_image_options_init(Main *bmain, SaveImageOptions *simopts, Space } else { BLI_strncpy(simopts->filepath, "//untitled", sizeof(simopts->filepath)); - BLI_path_abs(simopts->filepath, bmain->name); + BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain)); } } else { BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2); - BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : bmain->name); + BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain)); } } @@ -1715,7 +1715,7 @@ static void save_image_options_from_op(Main *bmain, SaveImageOptions *simopts, w if (RNA_struct_property_is_set(op->ptr, "filepath")) { RNA_string_get(op->ptr, "filepath", simopts->filepath); - BLI_path_abs(simopts->filepath, bmain->name); + BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain)); } } @@ -2296,7 +2296,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) char name[FILE_MAX]; BLI_strncpy(name, ibuf->name, sizeof(name)); - BLI_path_abs(name, bmain->name); + BLI_path_abs(name, BKE_main_blendfile_path(bmain)); if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 981630e96f6..acd0a856f1a 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -364,7 +364,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_bpath_relative_convert(bmain, bmain->name, op->reports); + BKE_bpath_relative_convert(bmain, BKE_main_blendfile_path(bmain), op->reports); /* redraw everything so any changed paths register */ WM_main_add_notifier(NC_WINDOW, NULL); @@ -397,7 +397,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_bpath_absolute_convert(bmain, bmain->name, op->reports); + BKE_bpath_absolute_convert(bmain, BKE_main_blendfile_path(bmain), op->reports); /* redraw everything so any changed paths register */ WM_main_add_notifier(NC_WINDOW, NULL); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0ea69164034..ec7fd99ee5e 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -497,7 +497,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) BKE_library_filepath_set(bmain, lib, lib->name); BLI_strncpy(expanded, lib->name, sizeof(expanded)); - BLI_path_abs(expanded, bmain->name); + BLI_path_abs(expanded, BKE_main_blendfile_path(bmain)); if (!BLI_exists(expanded)) { BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Library path '%s' does not exist, correct this before saving", expanded); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 98370ea9dee..5c332925011 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -117,7 +117,7 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, Main *bmain = CTX_data_main(C); char path[FILE_MAX]; BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); - BLI_path_abs(path, bmain->name); + BLI_path_abs(path, BKE_main_blendfile_path(bmain)); RNA_string_set(op->ptr, identifier, path); } } @@ -199,7 +199,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato } if ((is_file != -1) && relative) - BLI_path_rel(seq_load->path, bmain->name); + BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain)); if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 97ff55bf883..e93a18449b0 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -3773,7 +3773,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) /* TODO, shouldn't this already be relative from the filesel? * (as the 'filepath' is) for now just make relative here, * but look into changing after 2.60 - campbell */ - BLI_path_rel(directory, bmain->name); + BLI_path_rel(directory, BKE_main_blendfile_path(bmain)); } BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir)); @@ -3889,10 +3889,10 @@ static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; - if (bmain->name[0] == '\0') + if (BKE_main_blendfile_path(bmain)[0] == '\0') BLI_strncpy(filepath, "untitled", sizeof(filepath)); else - BLI_strncpy(filepath, bmain->name, sizeof(filepath)); + BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); BLI_replace_extension(filepath, sizeof(filepath), ".srt"); RNA_string_set(op->ptr, "filepath", filepath); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 3c2d3c557f6..de5ff36f462 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -234,7 +234,7 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); - text = BKE_text_load_ex(bmain, str, bmain->name, internal); + text = BKE_text_load_ex(bmain, str, BKE_main_blendfile_path(bmain), internal); if (!text) { if (op->customdata) MEM_freeN(op->customdata); @@ -274,7 +274,7 @@ static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e { Main *bmain = CTX_data_main(C); Text *text = CTX_data_edit_text(C); - const char *path = (text && text->name) ? text->name : bmain->name; + const char *path = (text && text->name) ? text->name : BKE_main_blendfile_path(bmain); if (RNA_struct_property_is_set(op->ptr, "filepath")) return text_open_exec(C, op); @@ -465,7 +465,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports) char filepath[FILE_MAX]; BLI_strncpy(filepath, text->name, FILE_MAX); - BLI_path_abs(filepath, bmain->name); + BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); fp = BLI_fopen(filepath, "w"); if (fp == NULL) { @@ -562,7 +562,7 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE else if (text->flags & TXT_ISMEM) str = text->id.name + 2; else - str = bmain->name; + str = BKE_main_blendfile_path(bmain); RNA_string_set(op->ptr, "filepath", str); WM_event_add_fileselect(C, op); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 7c3e24c3cc9..8175f494cf0 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -254,7 +254,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha BLI_split_file_part(abs_name, fi, sizeof(fi)); BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); if (!STREQ(abs_name, local_name)) { - switch (checkPackedFile(bmain->name, local_name, pf)) { + switch (checkPackedFile(BKE_main_blendfile_path(bmain), local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), local_name); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); @@ -287,7 +287,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha } } - switch (checkPackedFile(bmain->name, abs_name, pf)) { + switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name); //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 80640d8dffe..8b2b0c119b6 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -282,7 +282,7 @@ typedef enum ID_Type { #define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM)) -#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : (_bmain)->name) +#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path((_bmain))) #define ID_MISSING(_id) (((_id)->tag & LIB_TAG_MISSING) != 0) diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index d51436df563..8f3160e84d2 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -574,7 +574,7 @@ static const EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_ite return items; } -static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; @@ -591,7 +591,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) else if (GS(id->name) == ID_MC) { MovieClip *clip = (MovieClip *) id; - BKE_movieclip_reload(clip); + BKE_movieclip_reload(bmain, clip); /* all sequencers for now, we don't know which scenes are using this clip as a strip */ BKE_sequencer_cache_cleanup(); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index f5f7ade6390..b50e263e01d 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -66,7 +66,7 @@ static void rna_ImagePackedFile_save(ImagePackedFile *imapf, Main *bmain, ReportList *reports) { - if (writePackedFile(reports, bmain->name, imapf->filepath, imapf->packedfile, 0) != RET_OK) { + if (writePackedFile(reports, BKE_main_blendfile_path(bmain), imapf->filepath, imapf->packedfile, 0) != RET_OK) { BKE_reportf(reports, RPT_ERROR, "Could not save packed file to disk as '%s'", imapf->filepath); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 18a69ca4d88..7d5c327f25a 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -481,7 +481,7 @@ static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *f Text *txt; errno = 0; - txt = BKE_text_load_ex(bmain, filepath, bmain->name, is_internal); + txt = BKE_text_load_ex(bmain, filepath, BKE_main_blendfile_path(bmain), is_internal); if (!txt) BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index d63f3fe76f8..3639c8547ba 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -56,11 +56,11 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" -static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_MovieClip_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { MovieClip *clip = (MovieClip *)ptr->id.data; - BKE_movieclip_reload(clip); + BKE_movieclip_reload(bmain, clip); DAG_id_tag_update(&clip->id, 0); } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 6eaaf842cb9..f976c286ea9 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2963,7 +2963,7 @@ static void rna_ShaderNodeTexIES_mode_set(PointerRNA *ptr, int value) if (value == NODE_IES_EXTERNAL && text->name) { BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath)); - BLI_path_rel(nss->filepath, G.main->name); + BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global()); } id_us_min(node->id); @@ -2988,7 +2988,7 @@ static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value) if (value == NODE_SCRIPT_EXTERNAL && text->name) { BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath)); - BLI_path_rel(nss->filepath, G.main->name); + BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global()); } id_us_min(node->id); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 70c4b912d9f..70023679e3c 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -148,7 +148,7 @@ static void rna_SceneRender_get_frame_path( } else { BKE_image_path_from_imformat( - name, rd->pic, bmain->name, (frame == INT_MIN) ? rd->cfra : frame, + name, rd->pic, BKE_main_blendfile_path(bmain), (frame == INT_MIN) ? rd->cfra : frame, &rd->im_format, (rd->scemode & R_EXTENSION) != 0, true, suffix); } } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index b0c6b0ca800..f806a03f426 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -727,7 +727,7 @@ void BPY_modules_load_user(bContext *C) G.f |= G_SCRIPT_AUTOEXEC_FAIL; BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Text '%s'", text->id.name + 2); - printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2); + printf("scripts disabled for \"%s\", skipping '%s'\n", BKE_main_blendfile_path(bmain), text->id.name + 2); } } else { diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c index 20226ffe6a3..e66b4e834dc 100644 --- a/source/blender/python/intern/bpy_library_load.c +++ b/source/blender/python/intern/bpy_library_load.c @@ -205,7 +205,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject * BLI_strncpy(ret->relpath, filename, sizeof(ret->relpath)); BLI_strncpy(ret->abspath, filename, sizeof(ret->abspath)); - BLI_path_abs(ret->abspath, bmain->name); + BLI_path_abs(ret->abspath, BKE_main_blendfile_path(bmain)); ret->blo_handle = NULL; ret->flag = ((is_link ? FILE_LINK : 0) | diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c index 9ca6092eab3..ead10efb212 100644 --- a/source/blender/python/intern/bpy_library_write.c +++ b/source/blender/python/intern/bpy_library_write.c @@ -107,7 +107,7 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject } BLI_strncpy(filepath_abs, filepath, FILE_MAX); - BLI_path_abs(filepath_abs, G.main->name); + BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global()); BKE_blendfile_write_partial_begin(bmain_src); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index d01815a8bf2..9e93a30d212 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3319,7 +3319,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr else { char name[FILE_MAX]; BKE_image_path_from_imformat( - name, scene->r.pic, bmain->name, scene->r.cfra, + name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, false, NULL); /* reports only used for Movie */ @@ -3559,7 +3559,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie BLI_strncpy(name, name_override, sizeof(name)); else BKE_image_path_from_imformat( - name, scene->r.pic, bmain->name, scene->r.cfra, + name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL); /* write images as individual images or stereo */ @@ -3754,7 +3754,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if (is_movie == false) { if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) BKE_image_path_from_imformat( - name, scene->r.pic, bmain->name, scene->r.cfra, + name, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, true, NULL); if (scene->r.mode & R_NO_OVERWRITE) { @@ -4076,7 +4076,7 @@ bool RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, /* to save, we first get absolute path */ BLI_strncpy(filepath, relpath, sizeof(filepath)); - BLI_path_abs(filepath, G.main->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); ok = BKE_imbuf_write(ibuf, filepath, &imf); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 6d2d0c8d490..1531d60c83b 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1160,7 +1160,7 @@ void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const void render_result_exr_file_path(Scene *scene, const char *layname, int sample, char *filepath) { char name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100]; - const char *fi = BLI_path_basename(G.main->name); + const char *fi = BLI_path_basename(BKE_main_blendfile_path_from_global()); if (sample == 0) { BLI_snprintf(name, sizeof(name), "%s_%s_%s.exr", fi, scene->id.name + 2, layname); @@ -1254,10 +1254,11 @@ static void render_result_exr_file_cache_path(Scene *sce, const char *root, char char path_hexdigest[33]; /* If root is relative, use either current .blend file dir, or temp one if not saved. */ - if (G.main->name[0]) { - BLI_split_dirfile(G.main->name, dirname, filename, sizeof(dirname), sizeof(filename)); + const char *blendfile_path = BKE_main_blendfile_path_from_global(); + if (blendfile_path[0] != '\0') { + BLI_split_dirfile(blendfile_path, dirname, filename, sizeof(dirname), sizeof(filename)); BLI_replace_extension(filename, sizeof(filename), ""); /* strip '.blend' */ - BLI_hash_md5_buffer(G.main->name, strlen(G.main->name), path_digest); + BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest); } else { BLI_strncpy(dirname, BKE_tempdir_base(), sizeof(dirname)); diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index c45bde300e7..0d9f7b197e1 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -425,7 +425,7 @@ void cache_voxeldata(Tex *tex, int scene_frame) init_frame_hair(vd, scene_frame); return; case TEX_VD_BLENDERVOXEL: - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); fp = BLI_fopen(path, "rb"); if (!fp) return; @@ -435,7 +435,7 @@ void cache_voxeldata(Tex *tex, int scene_frame) fclose(fp); return; case TEX_VD_RAW_8BIT: - BLI_path_abs(path, G.main->name); + BLI_path_abs(path, BKE_main_blendfile_path_from_global()); fp = BLI_fopen(path, "rb"); if (!fp) return; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index d52f622d8b4..66080e3722f 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -559,6 +559,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* we didn't succeed, now try to read Blender file */ if (retval == BKE_READ_EXOTIC_OK_BLEND) { + Main *bmain = CTX_data_main(C); int G_f = G.f; ListBase wmbase; @@ -570,7 +571,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) G.relbase_valid = 1; retval = BKE_blendfile_read(C, filepath, reports, 0); /* when loading startup.blend's, we can be left with a blank path */ - if (G.main->name[0]) { + if (BKE_main_blendfile_path(bmain)) { G.save_over = 1; } else { @@ -655,6 +656,7 @@ int wm_homefile_read( bool use_factory_settings, bool use_empty_data, bool use_userdef, const char *filepath_startup_override, const char *app_template_override) { + Main *bmain = CTX_data_main(C); ListBase wmbase; bool success = false; @@ -855,7 +857,7 @@ int wm_homefile_read( wm_window_match_do(C, &wmbase); WM_check(C); /* opens window(s), checks keymaps */ - G.main->name[0] = '\0'; + bmain->name[0] = '\0'; if (use_userdef) { /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ @@ -961,16 +963,18 @@ static void wm_history_file_write(void) static void wm_history_file_update(void) { RecentFile *recent; + const char *blendfile_name = BKE_main_blendfile_path_from_global(); /* no write history for recovered startup files */ - if (G.main->name[0] == 0) + if (blendfile_name[0] == '\0') { return; + } recent = G.recent_files.first; /* refresh recent-files.txt of recent opened files, when current file was changed */ - if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) { + if (!(recent) || (BLI_path_cmp(recent->filepath, blendfile_name) != 0)) { - recent = wm_file_history_find(G.main->name); + recent = wm_file_history_find(blendfile_name); if (recent) { BLI_remlink(&G.recent_files, recent); } @@ -980,7 +984,7 @@ static void wm_history_file_update(void) recent_next = recent->next; wm_history_file_free(recent); } - recent = wm_history_file_new(G.main->name); + recent = wm_history_file_new(blendfile_name); } /* add current file to the beginning of list */ @@ -990,7 +994,7 @@ static void wm_history_file_update(void) wm_history_file_write(); /* also update most recent files on System */ - GHOST_addToSystemRecentFiles(G.main->name); + GHOST_addToSystemRecentFiles(blendfile_name); } } @@ -1077,7 +1081,7 @@ bool write_crash_blend(void) char path[FILE_MAX]; int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */ - BLI_strncpy(path, G.main->name, sizeof(path)); + BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path)); BLI_replace_extension(path, sizeof(path), "_crash.blend"); if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) { printf("written: %s\n", path); @@ -1094,6 +1098,7 @@ bool write_crash_blend(void) */ static int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports) { + Main *bmain = CTX_data_main(C); Library *li; int len; int ret = -1; @@ -1123,7 +1128,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor * its handy for scripts to save to a predefined name without blender editing it */ /* send the OnSave event */ - for (li = G.main->library.first; li; li = li->id.next) { + for (li = bmain->library.first; li; li = li->id.next) { if (BLI_path_cmp(li->filepath, filepath) == 0) { BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath); return ret; @@ -1131,7 +1136,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor } /* Call pre-save callbacks befores writing preview, that way you can generate custom file thumbnail... */ - BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE); /* blend file thumbnail */ /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */ @@ -1144,7 +1149,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor /* operator now handles overwrite checks */ if (G.fileflags & G_AUTOPACK) { - packAll(G.main, reports, false); + packAll(bmain, reports, false); } /* don't forget not to return without! */ @@ -1156,19 +1161,19 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor /* first time saving */ /* XXX temp solution to solve bug, real fix coming (ton) */ - if ((G.main->name[0] == '\0') && !(fileflags & G_FILE_SAVE_COPY)) { - BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); + if ((BKE_main_blendfile_path(bmain)[0] == '\0') && !(fileflags & G_FILE_SAVE_COPY)) { + BLI_strncpy(bmain->name, filepath, sizeof(bmain->name)); } /* XXX temp solution to solve bug, real fix coming (ton) */ - G.main->recovered = 0; + bmain->recovered = 0; if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0); if (!(fileflags & G_FILE_SAVE_COPY)) { G.relbase_valid = 1; - BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ + BLI_strncpy(bmain->name, filepath, sizeof(bmain->name)); /* is guaranteed current file */ G.save_over = 1; /* disable untitled.blend convention */ } @@ -1181,7 +1186,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor wm_history_file_update(); } - BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_POST); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { @@ -1215,7 +1220,7 @@ void wm_autosave_location(char *filepath) #endif if (G.main && G.relbase_valid) { - const char *basename = BLI_path_basename(G.main->name); + const char *basename = BLI_path_basename(BKE_main_blendfile_path_from_global()); int len = strlen(basename) - 6; BLI_snprintf(path, sizeof(path), "%.*s.blend", len, basename); } @@ -1709,7 +1714,8 @@ struct FileRuntime { static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - const char *openname = G.main->name; + Main *bmain = CTX_data_main(C); + const char *openname = BKE_main_blendfile_path(bmain); if (CTX_wm_window(C) == NULL) { /* in rare cases this could happen, when trying to invoke in background @@ -1848,6 +1854,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot) static int wm_revert_mainfile_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bool success; char filepath[FILE_MAX]; @@ -1858,7 +1865,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op) else G.f &= ~G_SCRIPT_AUTOEXEC; - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); success = wm_file_read_opwrap(C, filepath, op->reports, !(G.f & G_SCRIPT_AUTOEXEC)); if (success) { @@ -1896,6 +1903,7 @@ void WM_OT_revert_mainfile(wmOperatorType *ot) void WM_recover_last_session(bContext *C, ReportList *reports) { + Main *bmain = CTX_data_main(C); char filepath[FILE_MAX]; BLI_make_file_string("/", filepath, BKE_tempdir_base(), BLENDER_QUIT_FILE); @@ -1908,8 +1916,9 @@ void WM_recover_last_session(bContext *C, ReportList *reports) G.fileflags &= ~G_FILE_RECOVER; /* XXX bad global... fixme */ - if (G.main->name[0]) + if (BKE_main_blendfile_path(bmain)[0] != '\0') { G.file_loaded = 1; /* prevents splash to show */ + } else { G.relbase_valid = 0; G.save_over = 0; /* start with save preference untitled.blend */ @@ -2008,20 +2017,21 @@ static void save_set_compress(wmOperator *op) } } -static void save_set_filepath(wmOperator *op) +static void save_set_filepath(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); PropertyRNA *prop; char name[FILE_MAX]; prop = RNA_struct_find_property(op->ptr, "filepath"); if (!RNA_property_is_set(op->ptr, prop)) { /* if not saved before, get the name of the most recently used .blend file */ - if (G.main->name[0] == 0 && G.recent_files.first) { + if (BKE_main_blendfile_path(bmain)[0] == '\0' && G.recent_files.first) { struct RecentFile *recent = G.recent_files.first; BLI_strncpy(name, recent->filepath, FILE_MAX); } else { - BLI_strncpy(name, G.main->name, FILE_MAX); + BLI_strncpy(name, bmain->name, FILE_MAX); } wm_filepath_default(name); @@ -2033,7 +2043,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent { save_set_compress(op); - save_set_filepath(op); + save_set_filepath(C, op); WM_event_add_fileselect(C, op); @@ -2043,6 +2053,7 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent /* function used for WM_OT_save_mainfile too */ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); char path[FILE_MAX]; int fileflags; @@ -2052,7 +2063,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); } else { - BLI_strncpy(path, G.main->name, FILE_MAX); + BLI_strncpy(path, BKE_main_blendfile_path(bmain), FILE_MAX); wm_filepath_default(path); } @@ -2146,7 +2157,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U return OPERATOR_CANCELLED; save_set_compress(op); - save_set_filepath(op); + save_set_filepath(C, op); /* if we're saving for the first time and prefer relative paths - any existing paths will be absolute, * enable the option to remap paths to avoid confusion [#37240] */ diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index a2cd701b768..5f0c905dfd4 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -115,7 +115,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNU } else if (G.relbase_valid) { char path[FILE_MAX]; - BLI_strncpy(path, G.main->name, sizeof(G.main->name)); + BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path)); BLI_parent_dir(path); RNA_string_set(op->ptr, "filepath", path); } @@ -297,7 +297,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path); return OPERATOR_CANCELLED; } - else if (BLI_path_cmp(bmain->name, libname) == 0) { + else if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) { BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path); return OPERATOR_CANCELLED; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index d47152700ec..dd4a150305d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -259,11 +259,11 @@ void WM_init(bContext *C, int argc, const char **argv) /* allow a path of "", this is what happens when making a new file */ #if 0 - if (G.main->name[0] == 0) + if (BKE_main_blendfile_path_from_global()[0] == '\0') BLI_make_file_string("/", G.main->name, BKE_appdir_folder_default(), "untitled.blend"); #endif - BLI_strncpy(G.lib, G.main->name, FILE_MAX); + BLI_strncpy(G.lib, BKE_main_blendfile_path_from_global(), sizeof(G.lib)); #ifdef WITH_COMPOSITOR if (1) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index f4acfb6d809..c0c6b1edcaf 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1335,7 +1335,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i if (is_relative_path ) { if (exists == false) { if (idcode == ID_IM) { - BLI_path_rel(((Image *)id)->name, bmain->name); + BLI_path_rel(((Image *)id)->name, BKE_main_blendfile_path(bmain)); } else { BLI_assert(0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d49df7ae09b..c7805184819 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -338,6 +338,7 @@ static void wm_block_confirm_quit_save(bContext *C, void *arg_block, void *UNUSE /* Build the confirm dialog UI */ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar, void *UNUSED(arg1)) { + Main *bmain = CTX_data_main(C); uiStyle *style = UI_style_get(); uiBlock *block = UI_block_begin(C, ar, "confirm_quit_popup", UI_EMBOSS); @@ -351,11 +352,11 @@ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar /* Text and some vertical space */ { char *message; - if (G.main->name[0] == '\0') { + if (BKE_main_blendfile_path(bmain)[0] == '\0') { message = BLI_strdup(IFACE_("This file has not been saved yet. Save before closing?")); } else { - const char *basename = BLI_path_basename(G.main->name); + const char *basename = BLI_path_basename(BKE_main_blendfile_path(bmain)); message = BLI_sprintfN(IFACE_("Save changes to \"%s\" before closing?"), basename); } uiItemL(layout, message, ICON_ERROR); @@ -496,9 +497,10 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) } else if (win->ghostwin) { /* this is set to 1 if you don't have startup.blend open */ - if (G.save_over && G.main->name[0]) { - char str[sizeof(G.main->name) + 24]; - BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", G.main->name, + if (G.save_over && BKE_main_blendfile_path_from_global()[0]) { + char str[sizeof(((Main *)NULL)->name) + 24]; + BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", + BKE_main_blendfile_path_from_global(), G.main->recovered ? " (Recovered)" : ""); GHOST_SetTitle(win->ghostwin, str); } -- cgit v1.2.3