Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-07-04 14:00:46 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-07-04 19:40:33 +0300
commitc43443d530bff67693dc2db4efdca6307703ce61 (patch)
tree40305a5fe154a25387c3fd3afcbfc560346bf383 /source/blender/blenloader
parent4e2228525fc9bbcff58e315c5e3bbc193cd63a0b (diff)
Workspaces: store view layer per main window, instead of per workspace.
It was a bit odd that the scene was stored per window but not the view layer. The reasoning was that you would use different view layers for different tasks. This is still possible, but it's more predictable to switch them both explicitly, and with child window support manually syncing the view layers between multiple windows is no longer needed as often.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c35
-rw-r--r--source/blender/blenloader/intern/versioning_280.c19
-rw-r--r--source/blender/blenloader/intern/writefile.c6
3 files changed, 16 insertions, 44 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4fa897bb689..b3a2d2f0b0b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2866,19 +2866,6 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
/* ************ READ WORKSPACES *************** */
-static void lib_link_workspace_scene_data(FileData *fd, WorkSpace *workspace)
-{
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first;
- relation != NULL;
- relation = relation->next)
- {
- relation->scene = newlibadr(fd, workspace->id.lib, relation->scene);
- }
-
- /* Free any relations that got lost due to missing datablocks. */
- BKE_workspace_scene_relations_free_invalid(workspace);
-}
-
static void lib_link_workspaces(FileData *fd, Main *bmain)
{
for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
@@ -2891,8 +2878,6 @@ static void lib_link_workspaces(FileData *fd, Main *bmain)
IDP_LibLinkProperty(id->properties, fd);
id_us_ensure_real(id);
- lib_link_workspace_scene_data(fd, workspace);
-
for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
bScreen *screen = newlibadr(fd, id->lib, BKE_workspace_layout_screen_get(layout));
@@ -2918,7 +2903,6 @@ 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_layer_relations);
link_list(fd, &workspace->owner_ids);
link_list(fd, &workspace->tools);
@@ -7140,19 +7124,6 @@ static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
}
-static void lib_link_workspace_scene_data_restore(struct IDNameLib_Map *id_map, WorkSpace *workspace)
-{
- for (WorkSpaceSceneRelation *relation = workspace->scene_layer_relations.first;
- relation != NULL;
- relation = relation->next)
- {
- relation->scene = restore_pointer_by_name(id_map, &relation->scene->id, USER_IGNORE);
- }
-
- /* Free any relations that got lost due to missing datablocks or view layers. */
- BKE_workspace_scene_relations_free_invalid(workspace);
-}
-
static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene)
{
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -7415,9 +7386,6 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain);
for (WorkSpace *workspace = newmain->workspaces.first; workspace; workspace = workspace->id.next) {
- lib_link_workspace_scene_data_restore(id_map, workspace);
- BKE_workspace_view_layer_set(workspace, cur_view_layer, curscene);
-
ListBase *layouts = BKE_workspace_layouts_get(workspace);
for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
@@ -7436,6 +7404,9 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
if (win->scene == NULL) {
win->scene = curscene;
}
+ if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) {
+ STRNCPY(win->view_layer_name, cur_view_layer->name);
+ }
BKE_workspace_active_set(win->workspace_hook, workspace);
/* keep cursor location through undo */
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 757e17ce82b..3bdd4db3b94 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -97,15 +97,10 @@ 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 = BLI_findlink(&scene->view_layers, scene->r.actlay);
if (screen->temp) {
continue;
}
- if (!layer) {
- layer = BKE_view_layer_default_view(scene);
- }
if (screen_parent) {
/* fullscreen with "Back to Previous" option, don't create
@@ -117,7 +112,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
workspace = BKE_workspace_add(bmain, screen->id.name + 2);
}
BKE_workspace_layout_add(bmain, workspace, screen, screen->id.name + 2);
- BKE_workspace_view_layer_set(workspace, layer, scene);
}
}
@@ -178,7 +172,16 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
BKE_workspace_active_set(win->workspace_hook, workspace);
BKE_workspace_active_layout_set(win->workspace_hook, layouts->first);
- win->scene = screen->scene;
+ /* Move scene and view layer to window. */
+ Scene *scene = screen->scene;
+ ViewLayer *layer = BLI_findlink(&scene->view_layers, scene->r.actlay);
+ if (!layer) {
+ layer = BKE_view_layer_default_view(scene);
+ }
+
+ win->scene = scene;
+ STRNCPY(win->view_layer_name, layer->name);
+
/* Deprecated from now on! */
win->screen = NULL;
}
@@ -594,7 +597,7 @@ void do_versions_after_linking_280(Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
/* same render-layer as do_version_workspaces_after_lib_link will activate,
- * so same layer as BKE_view_layer_from_workspace_get would return */
+ * so same layer as BKE_view_layer_default_view would return */
ViewLayer *layer = screen->scene->view_layers.first;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 146494e6196..0a2d09d0c86 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -166,6 +166,7 @@
#include "BKE_constraint.h"
#include "BKE_global.h" // for G
#include "BKE_idcode.h"
+#include "BKE_layer.h"
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_library_override.h"
#include "BKE_main.h"
@@ -1147,7 +1148,6 @@ static void current_screen_compat(
{
wmWindowManager *wm;
wmWindow *window = NULL;
- WorkSpace *workspace;
/* find a global current screen in the first open window, to have
* a reasonable default for reading in older versions */
@@ -1171,11 +1171,10 @@ static void current_screen_compat(
window = wm->windows.first;
}
}
- workspace = (window) ? BKE_workspace_active_get(window->workspace_hook) : NULL;
*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, *r_scene) : NULL;
+ *r_render_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) : NULL;
}
typedef struct RenderInfo {
@@ -3646,7 +3645,6 @@ 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, WorkSpaceSceneRelation, &workspace->scene_layer_relations);
writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
writelist(wd, DATA, bToolRef, &workspace->tools);
for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {