diff options
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r-- | source/blender/editors/render/render_internal.c | 49 | ||||
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 58 |
4 files changed, 49 insertions, 62 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 89dbd3da16d..4e44c9b1185 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -104,7 +104,7 @@ static int render_break(void *rjv); typedef struct RenderJob { Main *main; Scene *scene; - ViewLayer *view_layer; + ViewLayer *single_layer; Scene *current_scene; /* TODO(sergey): Should not be needed once engine will have own * depsgraph and copy-on-write will be implemented. @@ -263,7 +263,7 @@ static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibu /* set callbacks, exported to sequence render too. * Only call in foreground (UI) renders. */ -static void screen_render_view_layer_set(wmOperator *op, Main *mainp, Scene **scene, ViewLayer **view_layer) +static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpace *workspace, Scene **scene, ViewLayer **single_layer) { /* single layer re-render */ if (RNA_struct_property_is_set(op->ptr, "scene")) { @@ -290,7 +290,10 @@ static void screen_render_view_layer_set(wmOperator *op, Main *mainp, Scene **sc rl = (ViewLayer *)BLI_findstring(&(*scene)->view_layers, rl_name, offsetof(ViewLayer, name)); if (rl) - *view_layer = rl; + *single_layer = rl; + } + else if (((*scene)->r.scemode & R_SINGLE_LAYER) && workspace) { + *single_layer = BKE_view_layer_from_workspace_get(*scene, workspace); } } @@ -299,11 +302,12 @@ static int screen_render_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); RenderEngineType *re_type = RE_engines_find(scene->r.engine); - ViewLayer *view_layer = NULL; + ViewLayer *single_layer = NULL; Render *re; Image *ima; View3D *v3d = CTX_wm_view3d(C); Main *mainp = CTX_data_main(C); + WorkSpace *workspace = CTX_wm_workspace(C); unsigned int lay_override; const bool is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); @@ -315,7 +319,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) } /* custom scene and single layer re-render */ - screen_render_view_layer_set(op, mainp, &scene, &view_layer); + screen_render_single_layer_set(op, mainp, workspace, &scene, &single_layer); if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); @@ -344,7 +348,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) if (is_animation) RE_BlenderAnim(re, mainp, scene, camera_override, lay_override, scene->r.sfra, scene->r.efra, scene->r.frame_step); else - RE_BlenderFrame(re, mainp, scene, view_layer, camera_override, lay_override, scene->r.cfra, is_write_still); + RE_BlenderFrame(re, mainp, scene, single_layer, camera_override, lay_override, scene->r.cfra, is_write_still); BLI_threaded_malloc_end(); RE_SetReports(re, NULL); @@ -619,7 +623,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro if (rj->anim) RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay_override, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step); else - RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->view_layer, rj->camera_override, rj->lay_override, rj->scene->r.cfra, rj->write_still); + RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->single_layer, rj->camera_override, rj->lay_override, rj->scene->r.cfra, rj->write_still); RE_SetReports(rj->re, NULL); } @@ -686,7 +690,7 @@ static void render_endjob(void *rjv) /* potentially set by caller */ rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE; - if (rj->view_layer) { + if (rj->single_layer) { nodeUpdateID(rj->scene->nodetree, &rj->scene->id); WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene); } @@ -860,8 +864,8 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *event) { /* new render clears all callbacks */ - Main *mainp; - ViewLayer *view_layer = NULL; + Main *bmain = CTX_data_main(C); + ViewLayer *single_layer = NULL; Scene *scene = CTX_data_scene(C); RenderEngineType *re_type = RE_engines_find(scene->r.engine); Render *re; @@ -873,6 +877,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport"); View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL; + WorkSpace *workspace = CTX_wm_workspace(C); struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; const char *name; ScrArea *sa; @@ -882,14 +887,14 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_CANCELLED; } + /* custom scene and single layer re-render */ + screen_render_single_layer_set(op, bmain, workspace, &scene, &single_layer); + /* only one render job at a time */ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) return OPERATOR_CANCELLED; - if (RE_force_single_renderlayer(scene)) - WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - if (!RE_is_rendering_allowed(scene, camera_override, op->reports)) { + if (!RE_is_rendering_allowed(scene, single_layer, camera_override, op->reports)) { return OPERATOR_CANCELLED; } @@ -901,15 +906,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even /* stop all running jobs, except screen one. currently previews frustrate Render */ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C)); - /* get main */ - if (G.debug_value == 101) { - /* thread-safety experiment, copy main from the undo buffer */ - struct MemFile *memfile = ED_undosys_stack_memfile_get_active(CTX_wm_manager(C)->undo_stack); - mainp = BLO_memfile_main_get(memfile, CTX_data_main(C), &scene); - } - else - mainp = CTX_data_main(C); - /* cancel animation playback */ if (ED_screen_animation_playing(CTX_wm_manager(C))) ED_screen_animation_play(C, 0, 0); @@ -935,18 +931,15 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS; - /* custom scene and single layer re-render */ - screen_render_view_layer_set(op, mainp, &scene, &view_layer); - if (RNA_struct_property_is_set(op->ptr, "layer")) jobflag |= WM_JOB_SUSPEND; /* job custom data */ rj = MEM_callocN(sizeof(RenderJob), "render job"); - rj->main = mainp; + rj->main = bmain; rj->scene = scene; rj->current_scene = rj->scene; - rj->view_layer = view_layer; + rj->single_layer = single_layer; /* TODO(sergey): Render engine should be using own depsgraph. */ rj->depsgraph = CTX_data_depsgraph(C); rj->camera_override = camera_override; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 1c6938cbdb3..bf6aa9c9675 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -713,7 +713,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->iuser.ok = 1; /* create render result */ - RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, scene->active_view_layer, NULL, sizex, sizey, NULL); + RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, NULL, sizex, sizey, NULL); /* create render views */ screen_opengl_views_setup(oglrender); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 9a179ce3b47..03742b489a1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -317,7 +317,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce = preview_get_scene(pr_main); if (sce) { - ViewLayer *view_layer = BKE_view_layer_from_scene_get(sce); + ViewLayer *view_layer = sce->view_layers.first; /* this flag tells render to not execute depsgraph or ipos etc */ sce->r.scemode |= R_BUTS_PREVIEW; diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index c5787a1d46c..e792de01e2c 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -62,6 +62,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_texture.h" +#include "BKE_workspace.h" #include "BKE_world.h" #include "BKE_editmesh.h" @@ -611,10 +612,13 @@ void WORLD_OT_new(wmOperatorType *ot) static int view_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { + WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = BKE_view_layer_add(scene, NULL); - BKE_view_layer_add(scene, NULL); - scene->active_view_layer = BLI_listbase_count(&scene->view_layers) - 1; + if (workspace) { + BKE_workspace_view_layer_set(workspace, view_layer, scene); + } DEG_id_tag_update(&scene->id, 0); DEG_relations_tag_update(CTX_data_main(C)); @@ -641,7 +645,7 @@ static int view_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BKE_view_layer_from_scene_get(scene); + ViewLayer *view_layer = CTX_data_view_layer(C); if (!ED_scene_view_layer_delete(bmain, scene, view_layer, NULL)) { return OPERATOR_CANCELLED; @@ -757,7 +761,7 @@ static int freestyle_active_module_poll(bContext *C) static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); BKE_freestyle_module_add(&view_layer->freestyle_config); @@ -783,7 +787,7 @@ void SCENE_OT_freestyle_module_add(wmOperatorType *ot) static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); FreestyleModuleConfig *module = ptr.data; @@ -813,7 +817,7 @@ void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) static int freestyle_module_move_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); FreestyleModuleConfig *module = ptr.data; int dir = RNA_enum_get(op->ptr, "direction"); @@ -855,7 +859,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, NULL); @@ -881,8 +885,7 @@ void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot) static int freestyle_active_lineset_poll(bContext *C) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); if (!view_layer) { return false; @@ -893,8 +896,7 @@ static int freestyle_active_lineset_poll(bContext *C) static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FRS_copy_active_lineset(&view_layer->freestyle_config); @@ -919,7 +921,7 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FRS_paste_active_lineset(&view_layer->freestyle_config); @@ -947,7 +949,7 @@ void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FRS_delete_active_lineset(&view_layer->freestyle_config); @@ -975,7 +977,7 @@ void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot) static int freestyle_lineset_move_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); int dir = RNA_enum_get(op->ptr, "direction"); if (FRS_move_active_lineset(&view_layer->freestyle_config, dir)) { @@ -1014,8 +1016,7 @@ void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); if (!lineset) { @@ -1052,8 +1053,7 @@ void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot) static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); int type = RNA_enum_get(op->ptr, "type"); @@ -1092,8 +1092,7 @@ void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot) static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); int type = RNA_enum_get(op->ptr, "type"); @@ -1132,8 +1131,7 @@ void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot) static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); int type = RNA_enum_get(op->ptr, "type"); @@ -1172,8 +1170,7 @@ void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot) static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); int type = RNA_enum_get(op->ptr, "type"); @@ -1225,8 +1222,7 @@ static int freestyle_get_modifier_type(PointerRNA *ptr) static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); LineStyleModifier *modifier = ptr.data; @@ -1275,8 +1271,7 @@ void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot) static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); LineStyleModifier *modifier = ptr.data; @@ -1325,8 +1320,7 @@ void SCENE_OT_freestyle_modifier_copy(wmOperatorType *ot) static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); + ViewLayer *view_layer = CTX_data_view_layer(C); FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); LineStyleModifier *modifier = ptr.data; @@ -1391,8 +1385,8 @@ void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot) static int freestyle_stroke_material_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene); + ViewLayer *view_layer = CTX_data_view_layer(C); + FreestyleLineStyle *linestyle = BKE_linestyle_active_from_view_layer(view_layer); if (!linestyle) { BKE_report(op->reports, RPT_ERROR, "No active line style in the current scene"); |