diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 121 |
1 files changed, 112 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 4aa4eddaddb..57292b7adc3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -78,12 +78,16 @@ #include "BKE_paint.h" #include "BKE_font.h" #include "BKE_node.h" -#include "BKE_depsgraph.h" #include "BKE_speaker.h" +#include "BKE_lightprobe.h" #include "BKE_movieclip.h" #include "BKE_mask.h" #include "BKE_gpencil.h" #include "BKE_linestyle.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -93,6 +97,7 @@ #include "DNA_mesh_types.h" #include "DNA_speaker_types.h" #include "DNA_sound_types.h" +#include "DNA_lightprobe_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" #include "DNA_group_types.h" @@ -115,6 +120,8 @@ # include "BPY_extern.h" #endif +#include "WM_api.h" + static void rna_idname_validate(const char *name, char *r_name) { @@ -170,14 +177,15 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports (scene_new = scene->id.next)) { if (do_unlink) { - bScreen *sc = CTX_wm_screen(C); - if (sc->scene == scene) { + wmWindow *win = CTX_wm_window(C); + + if (WM_window_get_active_scene(win) == scene) { #ifdef WITH_PYTHON BPy_BEGIN_ALLOW_THREADS; #endif - ED_screen_set_scene(C, sc, scene_new); + WM_window_change_active_scene(bmain, C, win, scene_new); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -241,7 +249,6 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char } ob = BKE_object_add_only_object(bmain, type, safe_name); - id_us_min(&ob->id); ob->data = data; test_object_materials(ob, ob->data); @@ -293,9 +300,26 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 1 - preview, 2 - render */ Mesh *rna_Main_meshes_new_from_object( - Main *bmain, ReportList *reports, Scene *sce, + Main *bmain, ReportList *reports, Scene *sce, ViewLayer *view_layer, Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) { + EvaluationContext eval_ctx; + + /* XXX: This should never happen, but render pipeline is not ready to give + * proper view_layer, and will always pass NULL here. For until we port + * pipeline form SceneRenderLayer to ViewLayer we have this stub to prevent + * some obvious crashes. + * - sergey - + */ + if (view_layer == NULL) { + view_layer = sce->view_layers.first; + } + + DEG_evaluation_context_init(&eval_ctx, settings); + eval_ctx.ctime = (float)sce->r.cfra + sce->r.subframe; + eval_ctx.view_layer = view_layer; + eval_ctx.depsgraph = BKE_scene_get_depsgraph(sce, view_layer, false); + switch (ob->type) { case OB_FONT: case OB_CURVE: @@ -308,7 +332,7 @@ Mesh *rna_Main_meshes_new_from_object( return NULL; } - return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); + return BKE_mesh_new_from_object(&eval_ctx, bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); } static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type) @@ -544,7 +568,7 @@ static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, cons } if (clip != NULL) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } else { BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, @@ -573,13 +597,23 @@ static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name return linestyle; } +static LightProbe *rna_Main_lightprobe_new(Main *bmain, const char *name) +{ + char safe_name[MAX_ID_NAME - 2]; + rna_idname_validate(name, safe_name); + + LightProbe *probe = BKE_lightprobe_add(bmain, safe_name); + id_us_min(&probe->id); + return probe; +} + /* tag and is_updated functions, all the same */ #define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ static void rna_Main_##_func_name##_tag(Main *bmain, int value) { \ BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ } \ static int rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \ - return DAG_id_type_tagged(ptr->data, _id_type) != 0; \ + return DEG_id_type_tagged(ptr->data, _id_type) != 0; \ } RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA) @@ -615,6 +649,8 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(masks, mask, ID_MSK) RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyle, ID_LS) RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) +RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) +RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobe, ID_LP) #undef RNA_MAIN_ID_TAG_FUNCS_DEF @@ -881,6 +917,8 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Scene layer within which to evaluate modifiers"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); @@ -1676,6 +1714,7 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL); } + void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -1927,4 +1966,68 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL); } +void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataWorkSpaces"); + srna = RNA_def_struct(brna, "BlendDataWorkSpaces", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Workspaces", "Collection of workspaces"); + + func = RNA_def_function(srna, "tag", "rna_Main_workspaces_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_workspaces_is_updated_get", NULL); +} + +void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataProbes"); + srna = RNA_def_struct(brna, "BlendDataProbes", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Light Probes", "Collection of light probes"); + + func = RNA_def_function(srna, "new", "rna_Main_lightprobe_new"); + RNA_def_function_ui_description(func, "Add a new probe to the main database"); + parm = RNA_def_string(func, "name", "Probe", 0, "", "New name for the data-block"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "New light probe data-block"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a probe from the current blendfile"); + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "Probe to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_boolean(func, "do_unlink", true, "", + "Unlink all usages of this probe before deleting it " + "(WARNING: will also delete objects instancing that light probe data)"); + RNA_def_boolean(func, "do_id_user", true, "", + "Decrement user counter of all datablocks used by this light probe"); + RNA_def_boolean(func, "do_ui_user", true, "", + "Make sure interface does not reference this light probe"); + + func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_lightprobes_is_updated_get", NULL); +} + #endif |