Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 5,639 Lines • ▼ Show 20 Lines | static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc) | ||||
| for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | ||||
| lib_link_scene_collection(fd, lib, nsc); | lib_link_scene_collection(fd, lib, nsc); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_scene(FileData *fd, Main *main) | static void lib_link_scene(FileData *fd, Main *main) | ||||
| { | { | ||||
| Scene *sce; | Scene *sce; | ||||
| Base *base, *next; | Base *base_legacy, *base_legacy_next; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| SceneLayer *sl; | SceneLayer *sl; | ||||
| SceneRenderLayer *srl; | SceneRenderLayer *srl; | ||||
| FreestyleModuleConfig *fmc; | FreestyleModuleConfig *fmc; | ||||
| FreestyleLineSet *fls; | FreestyleLineSet *fls; | ||||
| #ifdef USE_SETSCENE_CHECK | #ifdef USE_SETSCENE_CHECK | ||||
| bool need_check_set = false; | bool need_check_set = false; | ||||
| Show All 35 Lines | if (sce->id.tag & LIB_TAG_NEED_LINK) { | ||||
| if (sce->toolsettings->imapaint.canvas) | if (sce->toolsettings->imapaint.canvas) | ||||
| sce->toolsettings->imapaint.canvas = | sce->toolsettings->imapaint.canvas = | ||||
| newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas); | newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas); | ||||
| sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template); | sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template); | ||||
| sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object); | sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object); | ||||
| for (base = sce->base.first; base; base = next) { | for (base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) { | ||||
| next = base->next; | base_legacy_next = base_legacy->next; | ||||
| base->object = newlibadr_us(fd, sce->id.lib, base->object); | base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object); | ||||
| if (base->object == NULL) { | if (base_legacy->object == NULL) { | ||||
| blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), | blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), | ||||
| sce->id.name + 2); | sce->id.name + 2); | ||||
| BLI_remlink(&sce->base, base); | BLI_remlink(&sce->base, base_legacy); | ||||
| if (base == sce->basact) sce->basact = NULL; | if (base_legacy == sce->basact) sce->basact = NULL; | ||||
| MEM_freeN(base); | MEM_freeN(base_legacy); | ||||
| } | } | ||||
| } | } | ||||
| SEQ_BEGIN (sce->ed, seq) | SEQ_BEGIN (sce->ed, seq) | ||||
| { | { | ||||
| if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system | if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| if (seq->scene) { | if (seq->scene) { | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if (sce->id.tag & LIB_TAG_NEED_LINK) { | ||||
| sce->gm.dome.warptext = newlibadr(fd, sce->id.lib, sce->gm.dome.warptext); | sce->gm.dome.warptext = newlibadr(fd, sce->id.lib, sce->gm.dome.warptext); | ||||
| /* Motion Tracking */ | /* Motion Tracking */ | ||||
| sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip); | sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip); | ||||
| lib_link_scene_collection(fd, sce->id.lib, sce->collection); | lib_link_scene_collection(fd, sce->id.lib, sce->collection); | ||||
| for (sl = sce->render_layers.first; sl; sl = sl->next) { | for (sl = sce->render_layers.first; sl; sl = sl->next) { | ||||
| for (ObjectBase *ob_base = sl->object_bases.first; ob_base; ob_base = ob_base->next) { | for (ObjectBase *base = sl->object_bases.first; base; base = base->next) { | ||||
| /* we only bump the use count for the collection objects */ | /* we only bump the use count for the collection objects */ | ||||
| ob_base->object = newlibadr(fd, sce->id.lib, ob_base->object); | base->object = newlibadr(fd, sce->id.lib, base->object); | ||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_SETSCENE_CHECK | #ifdef USE_SETSCENE_CHECK | ||||
| if (sce->set != NULL) { | if (sce->set != NULL) { | ||||
| /* link flag for scenes with set would be reset later, | /* link flag for scenes with set would be reset later, | ||||
| * so this way we only check cyclic for newly linked scenes. | * so this way we only check cyclic for newly linked scenes. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 2,642 Lines • ▼ Show 20 Lines | static void do_versions(FileData *fd, Library *lib, Main *main) | ||||
| /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ | /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ | ||||
| /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ | /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ | ||||
| /* don't forget to set version number in BKE_blender_version.h! */ | /* don't forget to set version number in BKE_blender_version.h! */ | ||||
| } | } | ||||
| static void do_versions_after_linking(Main *main) | static void do_versions_after_linking(Main *main) | ||||
| { | { | ||||
| UNUSED_VARS(main); | UNUSED_VARS(main); | ||||
| // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name, | // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name, | ||||
| // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile); | // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile); | ||||
| blo_do_versions_after_linking_280(main); | blo_do_versions_after_linking_280(main); | ||||
mont29: Not so happy with the name, would keep version number last (so… | |||||
| } | } | ||||
| static void lib_link_all(FileData *fd, Main *main) | static void lib_link_all(FileData *fd, Main *main) | ||||
| { | { | ||||
| oldnewmap_sort(fd); | oldnewmap_sort(fd); | ||||
| /* No load UI for undo memfiles */ | /* No load UI for undo memfiles */ | ||||
| if (fd->memfile == NULL) { | if (fd->memfile == NULL) { | ||||
| ▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | if (fd->memfile == NULL) { | ||||
| do_versions_userdef(fd, bfd); | do_versions_userdef(fd, bfd); | ||||
| } | } | ||||
| read_libraries(fd, &mainlist); | read_libraries(fd, &mainlist); | ||||
| blo_join_main(&mainlist); | blo_join_main(&mainlist); | ||||
| lib_link_all(fd, bfd->main); | lib_link_all(fd, bfd->main); | ||||
| /* Skip in undo case. */ | /* Skip in undo case. */ | ||||
| if (fd->memfile == NULL) { | if (fd->memfile == NULL) { | ||||
| /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ | /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ | ||||
| blo_split_main(&mainlist, bfd->main); | blo_split_main(&mainlist, bfd->main); | ||||
| for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { | for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { | ||||
| BLI_assert(mainvar->versionfile != 0); | BLI_assert(mainvar->versionfile != 0); | ||||
| do_versions_after_linking(mainvar); | do_versions_after_linking(mainvar); | ||||
| } | } | ||||
| blo_join_main(&mainlist); | blo_join_main(&mainlist); | ||||
| } | } | ||||
| BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); | BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); | ||||
Done Inline ActionsShould be skipped in undo cases as well (like with 'normal' do_versions call). mont29: Should be skipped in undo cases as well (like with 'normal' do_versions call). | |||||
| lib_verify_nodetree(bfd->main, true); | lib_verify_nodetree(bfd->main, true); | ||||
| fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */ | fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */ | ||||
| link_global(fd, bfd); /* as last */ | link_global(fd, bfd); /* as last */ | ||||
| fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */ | fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */ | ||||
| return bfd; | return bfd; | ||||
| ▲ Show 20 Lines • Show All 1,908 Lines • Show Last 20 Lines | |||||
Not so happy with the name, would keep version number last (so blo_do_versions_after_linking_280)…