diff options
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 29 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 3 |
3 files changed, 28 insertions, 11 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5d170960158..323586b66b2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2843,6 +2843,14 @@ static void lib_link_workspaces(FileData *fd, Main *bmain) IDP_LibLinkProperty(id->properties, fd); id_us_ensure_real(id); + for (WorkSpaceDataRelation *relation = workspace->scene_viewlayer_relations.first; + relation != NULL; + relation = relation->next) + { + relation->parent = newlibadr(fd, id->lib, relation->parent); + /* relation->value is set in direct_link_workspace_link_scene_data */ + } + for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) { bScreen *screen = newlibadr(fd, id->lib, BKE_workspace_layout_screen_get(layout)); @@ -2868,6 +2876,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main { link_list(fd, BKE_workspace_layouts_get(workspace)); link_list(fd, &workspace->hook_layout_relations); + link_list(fd, &workspace->scene_viewlayer_relations); link_list(fd, BKE_workspace_transform_orientations_get(workspace)); for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; @@ -2881,7 +2890,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main if (ID_IS_LINKED(&workspace->id)) { /* 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. */ - BKE_workspace_view_layer_set(workspace, NULL); + BKE_workspace_relations_free(&workspace->scene_viewlayer_relations); } /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data @@ -6134,13 +6143,19 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb) * Workspaces store a render layer pointer which can only be read after scene is read. */ static void direct_link_workspace_link_scene_data( - FileData *fd, const Scene *scene, const ListBase *workspaces) + FileData *fd, Scene *scene, const ListBase *workspaces) { for (WorkSpace *workspace = workspaces->first; workspace; workspace = workspace->id.next) { - ViewLayer *layer = newdataadr(fd, BKE_workspace_view_layer_get(workspace)); - /* only set when layer is from the scene we read */ - if (layer && (BLI_findindex(&scene->view_layers, layer) != -1)) { - BKE_workspace_view_layer_set(workspace, layer); + for (WorkSpaceDataRelation *relation = workspace->scene_viewlayer_relations.first; + relation != NULL; + relation = relation->next) + { + ViewLayer *layer = newdataadr(fd, relation->value); + if (layer) { + BLI_assert(BLI_findindex(&scene->view_layers, layer) != -1); + /* relation->parent is set in lib_link_workspaces */ + relation->value = layer; + } } } } @@ -7175,7 +7190,7 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) { lib_link_workspace_layout_restore(id_map, newmain, layout); } - BKE_workspace_view_layer_set(workspace, cur_view_layer); + BKE_workspace_view_layer_set(workspace, cur_view_layer, curscene); } for (wmWindow *win = curwm->windows.first; win; win = win->next) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 8da4fef7b21..3b5e248f58b 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -86,8 +86,9 @@ static void do_version_workspaces_create_from_screens(Main *bmain) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { const bScreen *screen_parent = screen_parent_find(screen); + Scene *scene = screen->scene; WorkSpace *workspace; - ViewLayer *layer = BKE_view_layer_from_scene_get(screen->scene); + ViewLayer *layer = BKE_view_layer_from_scene_get(scene); ListBase *transform_orientations; if (screen_parent) { @@ -100,7 +101,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain) workspace = BKE_workspace_add(bmain, screen->id.name + 2); } BKE_workspace_layout_add(workspace, screen, screen->id.name + 2); - BKE_workspace_view_layer_set(workspace, layer); + BKE_workspace_view_layer_set(workspace, layer, scene); #ifdef WITH_CLAY_ENGINE BLI_strncpy(workspace->view_render.engine_id, RE_engine_id_BLENDER_CLAY, @@ -111,7 +112,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain) #endif transform_orientations = BKE_workspace_transform_orientations_get(workspace); - BLI_duplicatelist(transform_orientations, &screen->scene->transform_spaces); + BLI_duplicatelist(transform_orientations, &scene->transform_spaces); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index b20f12e7e70..08ec2231e38 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1138,7 +1138,7 @@ static void current_screen_compat( *r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL; *r_scene = (window) ? window->scene : NULL; - *r_render_layer = (window) ? BKE_workspace_view_layer_get(workspace) : NULL; + *r_render_layer = (window) ? BKE_workspace_view_layer_get(workspace, *r_scene) : NULL; } typedef struct RenderInfo { @@ -3778,6 +3778,7 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace) writestruct(wd, ID_WS, WorkSpace, 1, workspace); writelist(wd, DATA, WorkSpaceLayout, layouts); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); + writelist(wd, DATA, WorkSpaceDataRelation, &workspace->scene_viewlayer_relations); writelist(wd, DATA, TransformOrientation, transform_orientations); } |