diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_render.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 122 |
1 files changed, 114 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 1498d161209..530d162b1fe 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -48,12 +48,39 @@ #include "BKE_context.h" #include "BKE_report.h" -/* RenderEngine */ +/* RenderEngine Callbacks */ + +void engine_tag_redraw(RenderEngine *engine) +{ + engine->flag |= RE_ENGINE_DO_DRAW; +} + +void engine_tag_update(RenderEngine *engine) +{ + engine->flag |= RE_ENGINE_DO_UPDATE; +} + +static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene) +{ + extern FunctionRNA rna_RenderEngine_update_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_update_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "data", &bmain); + 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) { extern FunctionRNA rna_RenderEngine_render_func; - PointerRNA ptr; ParameterList list; FunctionRNA *func; @@ -68,6 +95,40 @@ static void engine_render(RenderEngine *engine, struct Scene *scene) RNA_parameter_list_free(&list); } +static void engine_view_update(RenderEngine *engine, const struct bContext *context) +{ + extern FunctionRNA rna_RenderEngine_view_update_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_view_update_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &context); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void engine_view_draw(RenderEngine *engine, const struct bContext *context) +{ + extern FunctionRNA rna_RenderEngine_view_draw_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_view_draw_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &context); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + /* RenderEngine registration */ static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type) @@ -87,7 +148,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine= {NULL}; PointerRNA dummyptr; - int have_function[1]; + int have_function[4]; /* setup dummy engine & engine type to store static properties in */ dummyengine.type= &dummyet; @@ -122,13 +183,22 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo et->ext.free= free; RNA_struct_blender_type_set(et->ext.srna, et); - et->render= (have_function[0])? engine_render: NULL; + et->update= (have_function[0])? engine_update: NULL; + et->render= (have_function[1])? engine_render: NULL; + et->view_update= (have_function[2])? engine_view_update: NULL; + et->view_draw= (have_function[3])? engine_view_draw: NULL; BLI_addtail(&R_engines, et); return et->ext.srna; } +static void **rna_RenderEngine_instance(PointerRNA *ptr) +{ + RenderEngine *engine = ptr->data; + return &engine->py_instance; +} + static StructRNA* rna_RenderEngine_refine(PointerRNA *ptr) { RenderEngine *engine= (RenderEngine*)ptr->data; @@ -203,14 +273,39 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_struct_sdna(srna, "RenderEngine"); RNA_def_struct_ui_text(srna, "Render Engine", "Render engine"); RNA_def_struct_refine_func(srna, "rna_RenderEngine_refine"); - RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister", NULL); + RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister", "rna_RenderEngine_instance"); + + /* final render callbacks */ + func= RNA_def_function(srna, "update", NULL); + RNA_def_function_ui_description(func, "Export scene data for render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "data", "BlendData", "", ""); + RNA_def_pointer(func, "scene", "Scene", "", ""); - /* render */ func= RNA_def_function(srna, "render", NULL); RNA_def_function_ui_description(func, "Render scene into an image"); - RNA_def_function_flag(func, FUNC_REGISTER); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); RNA_def_pointer(func, "scene", "Scene", "", ""); + /* viewport render callbacks */ + func= RNA_def_function(srna, "view_update", NULL); + RNA_def_function_ui_description(func, "Update on data changes for viewport render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); + + func= RNA_def_function(srna, "view_draw", NULL); + RNA_def_function_ui_description(func, "Draw viewport render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); + + /* tag for redraw */ + RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); + RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); + + /* tag for update */ + 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, "begin_result", "RE_engine_begin_result"); prop= RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX); RNA_def_property_flag(prop, PROP_REQUIRED); @@ -251,9 +346,16 @@ static void rna_def_render_engine(BlenderRNA *brna) prop= RNA_def_string(func, "message", "", 0, "Report Message", ""); RNA_def_property_flag(prop, PROP_REQUIRED); - /* registration */ RNA_define_verify_sdna(0); + prop= RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_ANIMATION); + + prop= RNA_def_property(srna, "is_preview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_PREVIEW); + + /* registration */ + prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP); @@ -270,6 +372,10 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop= RNA_def_property(srna, "bl_use_shading_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_define_verify_sdna(1); } |