diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-24 16:20:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-26 18:06:14 +0300 |
commit | 67b014af484ad4ba6667e3cf9907422bedc8238a (patch) | |
tree | 68408128f8377b864c7b77be7c91b1fcead601b7 /source/blender/blenkernel/intern | |
parent | c490428bd4dff75fb371777d4e95ea270c77ea94 (diff) |
Workspaces: active view layer now always comes from workspace, not scene.
Both the scene and workspace had an active view layer, and it was confusing
which settings were being used or displayed where. Now we always have one,
so there is no mismatch.
The "View Layers" tab in the properties editor is now "View Layer", no longer
showing a list of layers. Instead view layers can be added and removed with
the workspace view layer selector. They are also listed and selectable in the
outliner.
Single layer rendering uses the active view layer from the workspace.
This fixes bugs where the wrong active view layer was used, but more places
remain that are wrong and are now using the first view layer in the scene.
These are all marked with BKE_view_layer_context_active_PLACEHOLDER.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 43 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/linestyle.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 2 |
6 files changed, 44 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 74e6c996329..34079d778f7 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -194,7 +194,7 @@ static void setup_app_data( } if (cur_view_layer == NULL) { /* fallback to scene layer */ - cur_view_layer = BKE_view_layer_from_scene_get(curscene); + cur_view_layer = BKE_view_layer_default_view(curscene); } if (track_undo_scene) { diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 41bdc3bb9ef..215826454a9 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -75,15 +75,37 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag); /* RenderLayer */ -/** - * Returns the ViewLayer to be used for rendering - * Most of the time BKE_view_layer_from_workspace_get should be used instead - */ -ViewLayer *BKE_view_layer_from_scene_get(const Scene *scene) +/* Returns the default view layer to view in workspaces if there is + * none linked to the workspace yet. */ +ViewLayer *BKE_view_layer_default_view(const Scene *scene) { - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); - BLI_assert(view_layer); - return view_layer; + /* TODO: it makes more sense to have the Viewport layer as the default, + * but this breaks view layer tests so change it later. */ +#if 0 + for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { + if (!(view_layer->flag & VIEW_LAYER_RENDER)) { + return view_layer; + } + } + + BLI_assert(scene->view_layers.first); + return scene->view_layers.first; +#else + return BKE_view_layer_default_render(scene); +#endif +} + +/* Returns the default view layer to render if we need to render just one. */ +ViewLayer *BKE_view_layer_default_render(const Scene *scene) +{ + for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { + if (view_layer->flag & VIEW_LAYER_RENDER) { + return view_layer; + } + } + + BLI_assert(scene->view_layers.first); + return scene->view_layers.first; } /** @@ -100,7 +122,8 @@ ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const st */ ViewLayer *BKE_view_layer_context_active_PLACEHOLDER(const Scene *scene) { - return BKE_view_layer_from_scene_get(scene); + BLI_assert(scene->view_layers.first); + return scene->view_layers.first; } static ViewLayer *view_layer_add(const char *name, SceneCollection *master_scene_collection) @@ -2253,7 +2276,7 @@ void BKE_view_layer_renderable_objects_iterator_next(BLI_Iterator *iter) /* Look for an object in the next set. */ while ((data->iter.set = data->iter.set->set)) { - ViewLayer *view_layer = BKE_view_layer_from_scene_get(data->iter.set); + ViewLayer *view_layer = BKE_view_layer_default_render(data->iter.set); data->base_temp.next = view_layer->object_bases.first; data->iter.base = &data->base_temp; return; diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index dd1315fe3fa..5757ae7480b 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -212,17 +212,11 @@ void BKE_linestyle_make_local(struct Main *bmain, FreestyleLineStyle *linestyle, BKE_id_make_local_generic(bmain, &linestyle->id, true, lib_local); } -FreestyleLineStyle *BKE_linestyle_active_from_scene(Scene *scene) +FreestyleLineStyle *BKE_linestyle_active_from_view_layer(ViewLayer *view_layer) { - ViewLayer *active_render_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); - if (active_render_layer) { - FreestyleConfig *config = &active_render_layer->freestyle_config; - FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); - if (lineset) { - return lineset->linestyle; - } - } - return NULL; + FreestyleConfig *config = &view_layer->freestyle_config; + FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); + return (lineset) ? lineset->linestyle : NULL; } static LineStyleModifier *new_modifier(const char *name, int type, size_t size) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 91ff3c15502..758db5178de 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -346,7 +346,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) rv = sce_copy->r.views; curvemapping_free_data(&sce_copy->r.mblur_shutter_curve); sce_copy->r = sce->r; - sce_copy->active_view_layer = 0; sce_copy->r.views = rv; sce_copy->unit = sce->unit; sce_copy->physics_settings = sce->physics_settings; @@ -934,7 +933,7 @@ int BKE_scene_base_iter_next( if (iter->phase == F_START) { ViewLayer *view_layer = (depsgraph) ? DEG_get_evaluated_view_layer(depsgraph) : - BKE_view_layer_from_scene_get(*scene); + BKE_view_layer_context_active_PLACEHOLDER(*scene); *base = view_layer->object_bases.first; if (*base) { *ob = (*base)->object; @@ -944,7 +943,7 @@ int BKE_scene_base_iter_next( /* exception: empty scene layer */ while ((*scene)->set) { (*scene) = (*scene)->set; - ViewLayer *view_layer_set = BKE_view_layer_from_scene_get((*scene)); + ViewLayer *view_layer_set = BKE_view_layer_default_render((*scene)); if (view_layer_set->object_bases.first) { *base = view_layer_set->object_bases.first; *ob = (*base)->object; @@ -965,7 +964,7 @@ int BKE_scene_base_iter_next( /* (*scene) is finished, now do the set */ while ((*scene)->set) { (*scene) = (*scene)->set; - ViewLayer *view_layer_set = BKE_view_layer_from_scene_get((*scene)); + ViewLayer *view_layer_set = BKE_view_layer_default_render((*scene)); if (view_layer_set->object_bases.first) { *base = view_layer_set->object_bases.first; *ob = (*base)->object; @@ -1465,7 +1464,7 @@ Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base) next_set: /* Reached the end, get the next base in the set. */ while ((*sce_iter = (*sce_iter)->set)) { - ViewLayer *view_layer_set = BKE_view_layer_from_scene_get((*sce_iter)); + ViewLayer *view_layer_set = BKE_view_layer_default_render((*sce_iter)); base = (Base *)view_layer_set->object_bases.first; if (base) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 974c2faeadf..a282f535df6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3269,7 +3269,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree; /* Get view layer for the strip. */ - ViewLayer *view_layer = BKE_view_layer_from_scene_get(scene); + ViewLayer *view_layer = BKE_view_layer_default_render(scene); /* Depsgraph will be NULL when doing rendering. */ Depsgraph *depsgraph = NULL; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index ebd4c04e8ce..3314e8d01b6 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -401,7 +401,7 @@ void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4 if (scene->camera) ob = scene->camera; else - ob = BKE_view_layer_camera_find(BKE_view_layer_from_scene_get(scene)); + ob = BKE_view_layer_camera_find(BKE_view_layer_context_active_PLACEHOLDER(scene)); } if (ob) |