diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-12-01 17:47:24 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-12-01 18:15:30 +0300 |
commit | e8c15e0ed15f8369d0d0f706b4953fb64e357902 (patch) | |
tree | 0eb072454c535b438caf8eed3033d27b3c17e99b /source/blender/editors/screen | |
parent | 983b1a34783e9600731b973ba52ecc8924bff169 (diff) |
Workspaces: Store an active view-layer per scene
Instead of storing a single active view-layer in the workspace, one is
stored for each scene the workspace showed before.
With this, some things become possible:
* Multiple windows in the same workspace but showing different scenes.
* Toggling back and forth scene keeps same active view-layer for each scene.
* Activating workspace which didn't show current scene before, the current view-layer is kept.
A necessary evil for this is that accessing view-layer and object mode
from .py can't be done via workspace directly anymore. It has to be done
through the window, so RNA can use the correct scene.
So instead of `workspace.view_layer`, it's `window.view_layer` now (same
with mode) even though it's still workspace data.
Fixes T53432.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 37 |
2 files changed, 22 insertions, 17 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index d84f256bc32..4c62253bef6 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -91,7 +91,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); Object *obedit = scene->obedit; - Object *obact = view_layer->basact ? view_layer->basact->object : NULL; + Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL; if (CTX_data_dir(member)) { CTX_data_dir_set(result, screen_context_dir); diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 84288740df8..00dc1003121 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -71,15 +71,16 @@ * \{ */ WorkSpace *ED_workspace_add( - Main *bmain, const char *name, ViewLayer *act_view_layer, ViewRender *view_render) + Main *bmain, const char *name, Scene *scene, + ViewLayer *act_view_layer, ViewRender *view_render) { WorkSpace *workspace = BKE_workspace_add(bmain, name); - BKE_workspace_view_layer_set(workspace, act_view_layer); + BKE_workspace_view_layer_set(workspace, act_view_layer, scene); BKE_viewrender_copy(&workspace->view_render, view_render); #ifdef USE_WORKSPACE_MODE - BKE_workspace_object_mode_set(workspace, OB_MODE_OBJECT); + BKE_workspace_object_mode_set(workspace, scene, OB_MODE_OBJECT); #endif return workspace; @@ -94,8 +95,9 @@ static void workspace_change_update_mode( const WorkSpace *workspace_old, const WorkSpace *workspace_new, bContext *C, Object *ob_act, ReportList *reports) { - eObjectMode mode_old = BKE_workspace_object_mode_get(workspace_old); - eObjectMode mode_new = BKE_workspace_object_mode_get(workspace_new); + const Scene *scene = CTX_data_scene(C); + eObjectMode mode_old = BKE_workspace_object_mode_get(workspace_old, scene); + eObjectMode mode_new = BKE_workspace_object_mode_get(workspace_new, scene); if (mode_old != mode_new) { ED_object_mode_compat_set(C, ob_act, mode_new, reports); @@ -105,10 +107,11 @@ static void workspace_change_update_mode( #endif static void workspace_change_update_view_layer( - WorkSpace *workspace_new, const WorkSpace *workspace_old) + WorkSpace *workspace_new, const WorkSpace *workspace_old, + Scene *scene) { - if (!BKE_workspace_view_layer_get(workspace_new)) { - BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old)); + if (!BKE_workspace_view_layer_get(workspace_new, scene)) { + BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old, scene), scene); } } @@ -117,7 +120,7 @@ static void workspace_change_update( bContext *C, wmWindowManager *wm) { /* needs to be done before changing mode! (to ensure right context) */ - workspace_change_update_view_layer(workspace_new, workspace_old); + workspace_change_update_view_layer(workspace_new, workspace_old, CTX_data_scene(C)); #ifdef USE_WORKSPACE_MODE workspace_change_update_mode(workspace_old, workspace_new, C, CTX_data_active_object(C), &wm->reports); #else @@ -199,7 +202,7 @@ bool ED_workspace_change( screen_changed_update(C, win, screen_new); workspace_change_update(workspace_new, workspace_old, C, wm); - BLI_assert(BKE_workspace_view_layer_get(workspace_new) != NULL); + BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL); BLI_assert(CTX_wm_workspace(C) == workspace_new); WM_toolsystem_unlink(C, workspace_old); @@ -220,15 +223,16 @@ WorkSpace *ED_workspace_duplicate( { WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); + Scene *scene = WM_window_get_active_scene(win); WorkSpace *workspace_new = ED_workspace_add( - bmain, workspace_old->id.name + 2, - BKE_workspace_view_layer_get(workspace_old), + bmain, workspace_old->id.name + 2, scene, + BKE_workspace_view_layer_get(workspace_old, scene), &workspace_old->view_render); ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old); ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new); #ifdef USE_WORKSPACE_MODE - BKE_workspace_object_mode_set(workspace_new, BKE_workspace_object_mode_get(workspace_old)); + BKE_workspace_object_mode_set(workspace_new, scene, BKE_workspace_object_mode_get(workspace_old, scene)); #endif BLI_duplicatelist(transform_orientations_new, transform_orientations_old); @@ -279,11 +283,12 @@ void ED_workspace_scene_data_sync( } void ED_workspace_view_layer_unset( - const Main *bmain, const ViewLayer *layer_unset, ViewLayer *layer_new) + const Main *bmain, Scene *scene, + const ViewLayer *layer_unset, ViewLayer *layer_new) { for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { - if (BKE_workspace_view_layer_get(workspace) == layer_unset) { - BKE_workspace_view_layer_set(workspace, layer_new); + if (BKE_workspace_view_layer_get(workspace, scene) == layer_unset) { + BKE_workspace_view_layer_set(workspace, layer_new, scene); } } } |