forked from bartvdbraak/blender
Cleanup: use new accessors to blendfile path (Main.name).
This commit is contained in:
parent
1d97e948d2
commit
481cdb08ed
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 <memory2> 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)
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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) {
|
||||
|
@ -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 : "<untitled>");
|
||||
SNPRINTF(stamp_data->file, do_prefix ? "File %s" : "%s",
|
||||
G.relbase_valid ? BKE_main_blendfile_path_from_global() : "<untitled>");
|
||||
}
|
||||
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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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, "_");
|
||||
|
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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)) {
|
||||
|
@ -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 */
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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"))) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) |
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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] */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user