Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / rna_render.c
index c30765d88574f3b2581201abd5ddefe5bcc42bc8..725aa7853323b3e1ae91f9a4240031bbb1ef5721 100644 (file)
@@ -33,6 +33,8 @@
 #include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
+#include "DEG_depsgraph.h"
+
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
@@ -136,7 +138,7 @@ static void engine_unbind_display_space_shader(RenderEngine *UNUSED(engine))
        IMB_colormanagement_finish_glsl_draw();
 }
 
-static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
+static void engine_update(RenderEngine *engine, Main *bmain, Depsgraph *graph, Scene *scene)
 {
        extern FunctionRNA rna_RenderEngine_update_func;
        PointerRNA ptr;
@@ -148,24 +150,25 @@ static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
 
        RNA_parameter_list_create(&list, &ptr, func);
        RNA_parameter_set_lookup(&list, "data", &bmain);
+       RNA_parameter_set_lookup(&list, "depsgraph", &graph);
        RNA_parameter_set_lookup(&list, "scene", &scene);
        engine->type->ext.call(NULL, &ptr, func, &list);
 
        RNA_parameter_list_free(&list);
 }
 
-static void engine_render(RenderEngine *engine, struct Scene *scene)
+static void engine_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
 {
-       extern FunctionRNA rna_RenderEngine_render_func;
+       extern FunctionRNA rna_RenderEngine_render_to_image_func;
        PointerRNA ptr;
        ParameterList list;
        FunctionRNA *func;
 
        RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
-       func = &rna_RenderEngine_render_func;
+       func = &rna_RenderEngine_render_to_image_func;
 
        RNA_parameter_list_create(&list, &ptr, func);
-       RNA_parameter_set_lookup(&list, "scene", &scene);
+       RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph);
        engine->type->ext.call(NULL, &ptr, func, &list);
 
        RNA_parameter_list_free(&list);
@@ -216,15 +219,15 @@ static void engine_view_update(RenderEngine *engine, const struct bContext *cont
        RNA_parameter_list_free(&list);
 }
 
-static void engine_view_draw(RenderEngine *engine, const struct bContext *context)
+static void engine_render_to_view(RenderEngine *engine, const struct bContext *context)
 {
-       extern FunctionRNA rna_RenderEngine_view_draw_func;
+       extern FunctionRNA rna_RenderEngine_render_to_view_func;
        PointerRNA ptr;
        ParameterList list;
        FunctionRNA *func;
 
        RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
-       func = &rna_RenderEngine_view_draw_func;
+       func = &rna_RenderEngine_render_to_view_func;
 
        RNA_parameter_list_create(&list, &ptr, func);
        RNA_parameter_set_lookup(&list, "context", &context);
@@ -251,6 +254,23 @@ static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *nt
        RNA_parameter_list_free(&list);
 }
 
+static void engine_collection_settings_create(RenderEngine *engine, struct IDProperty *props)
+{
+       extern FunctionRNA rna_RenderEngine_collection_settings_create_func;
+       PointerRNA ptr;
+       ParameterList list;
+       FunctionRNA *func;
+
+       RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
+       func = &rna_RenderEngine_collection_settings_create_func;
+
+       RNA_parameter_list_create(&list, &ptr, func);
+       RNA_parameter_set_lookup(&list, "props", &props);
+       engine->type->ext.call(NULL, &ptr, func, &list);
+
+       RNA_parameter_list_free(&list);
+}
+
 static void engine_update_render_passes(RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl)
 {
        extern FunctionRNA rna_RenderEngine_update_render_passes_func;
@@ -289,7 +309,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
        RenderEngineType *et, dummyet = {NULL};
        RenderEngine dummyengine = {NULL};
        PointerRNA dummyptr;
-       int have_function[7];
+       int have_function[8];
 
        /* setup dummy engine & engine type to store static properties in */
        dummyengine.type = &dummyet;
@@ -326,14 +346,15 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo
        RNA_struct_blender_type_set(et->ext.srna, et);
 
        et->update = (have_function[0]) ? engine_update : NULL;
-       et->render = (have_function[1]) ? engine_render : NULL;
+       et->render_to_image = (have_function[1]) ? engine_render_to_image : NULL;
        et->bake = (have_function[2]) ? engine_bake : NULL;
        et->view_update = (have_function[3]) ? engine_view_update : NULL;
-       et->view_draw = (have_function[4]) ? engine_view_draw : NULL;
+       et->render_to_view = (have_function[4]) ? engine_render_to_view : NULL;
        et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL;
        et->update_render_passes = (have_function[6]) ? engine_update_render_passes : NULL;
+       et->collection_settings_create = (have_function[7]) ? engine_collection_settings_create : NULL;
 
-       BLI_addtail(&R_engines, et);
+       RE_engines_register(bmain, et);
 
        return et->ext.srna;
 }
@@ -364,6 +385,16 @@ static PointerRNA rna_RenderEngine_render_get(PointerRNA *ptr)
        }
 }
 
+static PointerRNA rna_RenderEngine_scene_layer_get(PointerRNA *ptr)
+{
+       RenderEngine *engine = (RenderEngine *)ptr->data;
+       if (engine->re != NULL) {
+               SceneLayer* scene_layer = RE_engine_get_scene_layer(engine->re);
+               return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, scene_layer);
+       }
+       return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, NULL);
+}
+
 static PointerRNA rna_RenderEngine_camera_override_get(PointerRNA *ptr)
 {
        RenderEngine *engine = (RenderEngine *)ptr->data;
@@ -462,12 +493,13 @@ static void rna_def_render_engine(BlenderRNA *brna)
        RNA_def_function_ui_description(func, "Export scene data for render");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
        RNA_def_pointer(func, "data", "BlendData", "", "");
+       RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "");
        RNA_def_pointer(func, "scene", "Scene", "", "");
 
-       func = RNA_def_function(srna, "render", NULL);
+       func = RNA_def_function(srna, "render_to_image", NULL);
        RNA_def_function_ui_description(func, "Render scene into an image");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
-       RNA_def_pointer(func, "scene", "Scene", "", "");
+       RNA_def_pointer(func, "desgraph", "Depsgraph", "", "");
 
        func = RNA_def_function(srna, "bake", NULL);
        RNA_def_function_ui_description(func, "Bake passes");
@@ -498,7 +530,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
        RNA_def_pointer(func, "context", "Context", "", "");
 
-       func = RNA_def_function(srna, "view_draw", NULL);
+       func = RNA_def_function(srna, "render_to_view", NULL);
        RNA_def_function_ui_description(func, "Draw viewport render");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
        RNA_def_pointer(func, "context", "Context", "", "");
@@ -510,6 +542,19 @@ static void rna_def_render_engine(BlenderRNA *brna)
        parm = RNA_def_pointer(func, "node", "Node", "", "");
        RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
 
+       func = RNA_def_function(srna, "update_render_passes", NULL);
+       RNA_def_function_ui_description(func, "Update the render passes that will be generated");
+       RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+       parm = RNA_def_pointer(func, "scene", "Scene", "", "");
+       parm = RNA_def_pointer(func, "renderlayer", "SceneRenderLayer", "", "");
+
+       /* per-collection engine settings initialization */
+       func = RNA_def_function(srna, "collection_settings_create", NULL);
+       RNA_def_function_ui_description(func, "Create the per collection settings for the engine");
+       RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+       parm = RNA_def_pointer(func, "collection_settings", "LayerCollectionSettings", "", "");
+       RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+
        /* tag for redraw */
        func = RNA_def_function(srna, "tag_redraw", "engine_tag_redraw");
        RNA_def_function_ui_description(func, "Request redraw for viewport rendering");
@@ -518,12 +563,6 @@ static void rna_def_render_engine(BlenderRNA *brna)
        func = RNA_def_function(srna, "tag_update", "engine_tag_update");
        RNA_def_function_ui_description(func, "Request update call for viewport rendering");
 
-       func = RNA_def_function(srna, "update_render_passes", NULL);
-       RNA_def_function_ui_description(func, "Update the render passes that will be generated");
-       RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
-       parm = RNA_def_pointer(func, "scene", "Scene", "", "");
-       parm = RNA_def_pointer(func, "renderlayer", "SceneRenderLayer", "", "");
-
        func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result");
        RNA_def_function_ui_description(func, "Create render result to write linear floating point render layers and passes");
        parm = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX);
@@ -700,6 +739,11 @@ static void rna_def_render_engine(BlenderRNA *brna)
        prop = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", "");
        RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
 
+       prop = RNA_def_property(srna, "scene_layer", PROP_POINTER, PROP_NONE);
+       RNA_def_property_struct_type(prop, "SceneLayer");
+       RNA_def_property_pointer_funcs(prop, "rna_RenderEngine_scene_layer_get", NULL, NULL, NULL);
+       RNA_def_property_ui_text(prop, "Scene layer", "");
+
        /* registration */
 
        prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);