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 130 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" // for G | #include "BKE_global.h" // for G | ||||
| #include "BKE_group.h" | #include "BKE_group.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_library.h" // for which_libbase | #include "BKE_library.h" // for which_libbase | ||||
| #include "BKE_library_idmap.h" | #include "BKE_library_idmap.h" | ||||
| #include "BKE_library_override.h" | |||||
| #include "BKE_library_query.h" | #include "BKE_library_query.h" | ||||
| #include "BKE_idcode.h" | #include "BKE_idcode.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_main.h" // for Main | #include "BKE_main.h" // for Main | ||||
| #include "BKE_mesh.h" // for ME_ defines (patching) | #include "BKE_mesh.h" // for ME_ defines (patching) | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| ▲ Show 20 Lines • Show All 2,062 Lines • ▼ Show 20 Lines | if (prv) { | ||||
| prv->tag = 0; | prv->tag = 0; | ||||
| } | } | ||||
| return prv; | return prv; | ||||
| } | } | ||||
| /* ************ READ ID *************** */ | /* ************ READ ID *************** */ | ||||
| static void lib_link_id(FileData *fd, Main *main) | |||||
| { | |||||
| ListBase *lbarray[MAX_LIBARRAY]; | |||||
| int base_count, i; | |||||
| base_count = set_listbasepointers(main, lbarray); | |||||
| for (i = 0; i < base_count; i++) { | |||||
| ListBase *lb = lbarray[i]; | |||||
| ID *id; | |||||
| for (id = lb->first; id; id = id->next) { | |||||
| if (id->override_static) { | |||||
| id->override_static->reference = newlibadr_us(fd, id->lib, id->override_static->reference); | |||||
| id->override_static->storage = newlibadr_us(fd, id->lib, id->override_static->storage); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| static void direct_link_id_override_property_operation_cb(FileData *fd, void *data) | |||||
| { | |||||
| IDOverrideStaticPropertyOperation *opop = data; | |||||
| opop->subitem_reference_name = newdataadr(fd, opop->subitem_reference_name); | |||||
| opop->subitem_local_name = newdataadr(fd, opop->subitem_local_name); | |||||
| } | |||||
| static void direct_link_id_override_property_cb(FileData *fd, void *data) | |||||
| { | |||||
| IDOverrideStaticProperty *op = data; | |||||
| op->rna_path = newdataadr(fd, op->rna_path); | |||||
| link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb); | |||||
| } | |||||
| static void direct_link_id(FileData *fd, ID *id) | static void direct_link_id(FileData *fd, ID *id) | ||||
| { | { | ||||
| /*link direct data of ID properties*/ | /*link direct data of ID properties*/ | ||||
| if (id->properties) { | if (id->properties) { | ||||
| id->properties = newdataadr(fd, id->properties); | id->properties = newdataadr(fd, id->properties); | ||||
| /* this case means the data was written incorrectly, it should not happen */ | /* this case means the data was written incorrectly, it should not happen */ | ||||
| IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | ||||
| } | } | ||||
| id->py_instance = NULL; | id->py_instance = NULL; | ||||
| /* Link direct data of overrides. */ | |||||
| if (id->override_static) { | |||||
| id->override_static = newdataadr(fd, id->override_static); | |||||
| link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb); | |||||
| } | |||||
| } | } | ||||
| /* ************ READ CurveMapping *************** */ | /* ************ READ CurveMapping *************** */ | ||||
| /* cuma itself has been read! */ | /* cuma itself has been read! */ | ||||
| static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap) | static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap) | ||||
| { | { | ||||
| int a; | int a; | ||||
| ▲ Show 20 Lines • Show All 6,444 Lines • ▼ Show 20 Lines | // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile); | ||||
| do_versions_after_linking_270(main); | do_versions_after_linking_270(main); | ||||
| do_versions_after_linking_280(main); | do_versions_after_linking_280(main); | ||||
| } | } | ||||
| static void lib_link_all(FileData *fd, Main *main) | static void lib_link_all(FileData *fd, Main *main) | ||||
| { | { | ||||
| oldnewmap_sort(fd); | oldnewmap_sort(fd); | ||||
| lib_link_id(fd, main); | |||||
| /* No load UI for undo memfiles */ | /* No load UI for undo memfiles */ | ||||
| if (fd->memfile == NULL) { | if (fd->memfile == NULL) { | ||||
| lib_link_windowmanager(fd, main); | lib_link_windowmanager(fd, main); | ||||
| } | } | ||||
| /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */ | /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */ | ||||
| lib_link_screen(fd, main); | lib_link_screen(fd, main); | ||||
| lib_link_scene(fd, main); | lib_link_scene(fd, main); | ||||
| lib_link_object(fd, main); | lib_link_object(fd, main); | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | 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); | ||||
| /* Now that all our data-blocks are loaded, we can re-generate overrides from their references. */ | |||||
| if (fd->memfile == NULL) { | |||||
| /* Do not apply in undo case! */ | |||||
| BKE_main_override_static_update(bfd->main); | |||||
| } | |||||
| 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,966 Lines • Show Last 20 Lines | |||||