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 2,911 Lines • ▼ Show 20 Lines | for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; | ||||
| relation->parent = newglobadr(fd, relation->parent); /* data from window - need to access through global oldnew-map */ | relation->parent = newglobadr(fd, relation->parent); /* data from window - need to access through global oldnew-map */ | ||||
| relation->value = newdataadr(fd, relation->value); | relation->value = newdataadr(fd, relation->value); | ||||
| } | } | ||||
| if (ID_IS_LINKED(&workspace->id)) { | if (ID_IS_LINKED(&workspace->id)) { | ||||
| /* Appending workspace so render layer is likely from a different scene. Unset | /* Appending workspace so render layer is likely from a different scene. Unset | ||||
| * now, when activating workspace later we set a valid one from current scene. */ | * now, when activating workspace later we set a valid one from current scene. */ | ||||
| BKE_workspace_relations_free(&workspace->scene_viewlayer_relations); | BKE_workspace_relations_free(&workspace->scene_viewlayer_relations); | ||||
| workspace->view_layer = NULL; | |||||
| } | } | ||||
| /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data | /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data | ||||
| * when reading windows, so have to update windows after/when reading workspaces. */ | * when reading windows, so have to update windows after/when reading workspaces. */ | ||||
| for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) { | for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) { | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| WorkSpaceLayout *act_layout = newdataadr(fd, BKE_workspace_active_layout_get(win->workspace_hook)); | WorkSpaceLayout *act_layout = newdataadr(fd, BKE_workspace_active_layout_get(win->workspace_hook)); | ||||
| if (act_layout) { | if (act_layout) { | ||||
| ▲ Show 20 Lines • Show All 7,390 Lines • ▼ Show 20 Lines | if ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0) { | ||||
| ob->id.tag &= ~LIB_TAG_INDIRECT; | ob->id.tag &= ~LIB_TAG_INDIRECT; | ||||
| ob->id.tag |= LIB_TAG_EXTERN; | ob->id.tag |= LIB_TAG_EXTERN; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void give_base_to_groups( | static void give_base_to_groups( | ||||
| Main *mainvar, Scene *scene, ViewLayer *view_layer, Library *UNUSED(lib), const short UNUSED(flag)) | Main *mainvar, Scene *scene, ViewLayer *view_layer, WorkSpace *workspace, | ||||
| Library *UNUSED(lib), const short UNUSED(flag)) | |||||
| { | { | ||||
| Group *group; | Group *group; | ||||
| Base *base; | Base *base; | ||||
| Object *ob; | Object *ob; | ||||
| SceneCollection *scene_collection; | SceneCollection *scene_collection; | ||||
| /* If the group is empty this function is not even called, so it's safe to ensure a collection at this point. */ | /* If the group is empty this function is not even called, so it's safe to ensure a collection at this point. */ | ||||
| scene_collection = get_scene_collection_active_or_create(scene, view_layer, FILE_ACTIVE_COLLECTION); | scene_collection = get_scene_collection_active_or_create(scene, view_layer, FILE_ACTIVE_COLLECTION); | ||||
| Show All 13 Lines | if (group->id.tag & LIB_TAG_DOIT) { | ||||
| if (base->flag & BASE_SELECTABLED) { | if (base->flag & BASE_SELECTABLED) { | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| BKE_scene_object_base_flag_sync_from_base(base); | BKE_scene_object_base_flag_sync_from_base(base); | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | ||||
| view_layer->basact = base; | view_layer->basact = base; | ||||
| BKE_workspace_active_base_changed(workspace, view_layer); | |||||
| /* Assign the group. */ | /* Assign the group. */ | ||||
| ob->dup_group = group; | ob->dup_group = group; | ||||
| ob->transflag |= OB_DUPLIGROUP; | ob->transflag |= OB_DUPLIGROUP; | ||||
| copy_v3_v3(ob->loc, scene->cursor); | copy_v3_v3(ob->loc, scene->cursor); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | for (ID *id = lbarray[i]->first, *idnext; id; id = idnext) { | ||||
| BLI_remlink(lbarray[i], id); | BLI_remlink(lbarray[i], id); | ||||
| BLI_addtail(lbarray_newid[i], id); | BLI_addtail(lbarray_newid[i], id); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* scene and v3d may be NULL. */ | /* scene and v3d may be NULL. */ | ||||
| static void library_link_end(Main *mainl, FileData **fd, const short flag, Scene *scene, ViewLayer *view_layer) | static void library_link_end( | ||||
| Main *mainl, FileData **fd, const short flag, | |||||
| Scene *scene, ViewLayer *view_layer, | |||||
| WorkSpace *workspace) | |||||
| { | { | ||||
| Main *mainvar; | Main *mainvar; | ||||
| Library *curlib; | Library *curlib; | ||||
| /* expander now is callback function */ | /* expander now is callback function */ | ||||
| BLO_main_expander(expand_doit_library); | BLO_main_expander(expand_doit_library); | ||||
| /* make main consistent */ | /* make main consistent */ | ||||
| Show All 38 Lines | static void library_link_end( | ||||
| BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false); | BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false); | ||||
| lib_verify_nodetree(mainvar, 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(G.main->name, 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. | /* 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, | * Only directly linked objects & groups are instantiated by `BLO_library_link_named_part_ex()` & co, | ||||
| * here we handle indirect ones and other possible edge-cases. */ | * here we handle indirect ones and other possible edge-cases. */ | ||||
| if (scene) { | if (scene && view_layer && workspace) { | ||||
| give_base_to_objects(mainvar, scene, view_layer, curlib, flag); | give_base_to_objects(mainvar, scene, view_layer, curlib, flag); | ||||
| if (flag & FILE_GROUP_INSTANCE) { | if (flag & FILE_GROUP_INSTANCE) { | ||||
| give_base_to_groups(mainvar, scene, view_layer, curlib, flag); | give_base_to_groups(mainvar, scene, view_layer, workspace, curlib, flag); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* printf("library_append_end, scene is NULL (objects wont get bases)\n"); */ | /* printf("library_append_end, scene is NULL (objects wont get bases)\n"); */ | ||||
| } | } | ||||
| /* clear group instantiating tag */ | /* clear group instantiating tag */ | ||||
| BKE_main_id_tag_listbase(&(mainvar->group), LIB_TAG_DOIT, false); | BKE_main_id_tag_listbase(&(mainvar->group), LIB_TAG_DOIT, false); | ||||
| Show All 11 Lines | |||||
| * \note Do not use \a bh after calling this function, it may frees it. | * \note Do not use \a bh after calling this function, it may frees it. | ||||
| * | * | ||||
| * \param mainl The main database to link from (not the active one). | * \param mainl The main database to link from (not the active one). | ||||
| * \param bh The blender file handle (WARNING! may be freed by this function!). | * \param bh The blender file handle (WARNING! may be freed by this function!). | ||||
| * \param flag Options for linking, used for instantiating. | * \param flag Options for linking, used for instantiating. | ||||
| * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done). | * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done). | ||||
| * \param view_layer The scene layer in which to instantiate objects/groups (if NULL, no instantiation is done). | * \param view_layer The scene layer in which to instantiate objects/groups (if NULL, no instantiation is done). | ||||
| */ | */ | ||||
| void BLO_library_link_end(Main *mainl, BlendHandle **bh, int flag, Scene *scene, ViewLayer *view_layer) | void BLO_library_link_end( | ||||
| Main *mainl, BlendHandle **bh, int flag, | |||||
| Scene *scene, ViewLayer *view_layer, | |||||
| WorkSpace *workspace) | |||||
| { | { | ||||
| FileData *fd = (FileData*)(*bh); | FileData *fd = (FileData*)(*bh); | ||||
| library_link_end(mainl, &fd, flag, scene, view_layer); | library_link_end(mainl, &fd, flag, scene, view_layer, workspace); | ||||
| *bh = (BlendHandle*)fd; | *bh = (BlendHandle*)fd; | ||||
| } | } | ||||
| void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname) | void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname) | ||||
| { | { | ||||
| return read_struct(fd, bh, blockname); | return read_struct(fd, bh, blockname); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines | |||||