diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_linestyle.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 2 | ||||
-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 |
9 files changed, 49 insertions, 31 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 79b61b7c965..27e3d32a510 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -58,7 +58,8 @@ struct WorkSpace; void BKE_layer_exit(void); -struct ViewLayer *BKE_view_layer_from_scene_get(const struct Scene *scene); +struct ViewLayer *BKE_view_layer_default_view(const struct Scene *scene); +struct ViewLayer *BKE_view_layer_default_render(const struct Scene *scene); struct ViewLayer *BKE_view_layer_from_workspace_get(const struct Scene *scene, const struct WorkSpace *workspace); struct ViewLayer *BKE_view_layer_add(struct Scene *scene, const char *name); struct ViewLayer *BKE_view_layer_group_add(struct Group *group); diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h index 3ba4fbe0338..376a324d25c 100644 --- a/source/blender/blenkernel/BKE_linestyle.h +++ b/source/blender/blenkernel/BKE_linestyle.h @@ -48,6 +48,7 @@ struct Main; struct Object; struct ColorBand; struct bContext; +struct ViewLayer; void BKE_linestyle_init(struct FreestyleLineStyle *linestyle); FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name); @@ -59,7 +60,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, const FreestyleLineSt void BKE_linestyle_make_local(struct Main *bmain, struct FreestyleLineStyle *linestyle, const bool lib_local); -FreestyleLineStyle *BKE_linestyle_active_from_scene(struct Scene *scene); +FreestyleLineStyle *BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer); LineStyleModifier *BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type); LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index bdbed9ab6aa..44aa1b04569 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -60,7 +60,7 @@ typedef enum eSceneCopyMethod { /* Use as the contents of a 'for' loop: for (SETLOOPER(...)) { ... */ #define SETLOOPER(_sce_basis, _sce_iter, _base) \ - _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, BKE_view_layer_from_scene_get(_sce_basis), NULL); \ + _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, BKE_view_layer_context_active_PLACEHOLDER(_sce_basis), NULL); \ _base; \ _base = _setlooper_base_step(&_sce_iter, NULL, _base) 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) |