Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_scene.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | |||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_color_types.h" | #include "DNA_color_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_text_types.h" | #include "DNA_text_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| ▲ Show 20 Lines • Show All 1,385 Lines • ▼ Show 20 Lines | static void object_simplify_update(Object *ob) | ||||
| if (ob->dup_group) { | if (ob->dup_group) { | ||||
| GroupObject *gob; | GroupObject *gob; | ||||
| for (gob = ob->dup_group->gobject.first; gob; gob = gob->next) | for (gob = ob->dup_group->gobject.first; gob; gob = gob->next) | ||||
| object_simplify_update(gob->ob); | object_simplify_update(gob->ob); | ||||
| } | } | ||||
| } | } | ||||
| static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) | static void rna_Scene_use_simplify_update(bContext *C, PointerRNA *ptr) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| Scene *sce = ptr->id.data; | Scene *sce = ptr->id.data; | ||||
| Scene *sce_iter; | Scene *sce_iter; | ||||
| Base *base; | Base *base; | ||||
| BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); | BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); | ||||
| for (SETLOOPER(sce, sce_iter, base)) | for (SETLOOPER(sce, workspace, sce_iter, base)) | ||||
| object_simplify_update(base->object); | object_simplify_update(base->object); | ||||
| WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); | WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&sce->id, 0); | ||||
| } | } | ||||
| static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) | static void rna_Scene_simplify_update(bContext *C, PointerRNA *ptr) | ||||
| { | { | ||||
| Scene *sce = ptr->id.data; | Scene *sce = ptr->id.data; | ||||
| if (sce->r.mode & R_SIMPLIFY) | if (sce->r.mode & R_SIMPLIFY) | ||||
| rna_Scene_use_simplify_update(bmain, sce, ptr); | rna_Scene_use_simplify_update(C, ptr); | ||||
| } | } | ||||
| static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | ||||
| { | { | ||||
| Scene *sce = ptr->id.data; | Scene *sce = ptr->id.data; | ||||
| DEG_id_tag_update(&sce->id, 0); | DEG_id_tag_update(&sce->id, 0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,134 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| { | { | ||||
| SceneLayer *sl = (SceneLayer *)ptr->data; | SceneLayer *sl = (SceneLayer *)ptr->data; | ||||
| rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip); | rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip); | ||||
| } | } | ||||
| static void rna_SceneLayer_engine_set(PointerRNA *ptr, int value) | |||||
| { | |||||
| SceneLayer *sl = (SceneLayer *)ptr->data; | |||||
| RenderEngineType *type = BLI_findlink(&R_engines, value); | |||||
| if (type) | |||||
| BKE_scene_layer_engine_set(sl, type->idname); | |||||
| } | |||||
| static EnumPropertyItem *rna_SceneLayer_engine_itemf( | |||||
| bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) | |||||
| { | |||||
| RenderEngineType *type; | |||||
| EnumPropertyItem *item = NULL; | |||||
| EnumPropertyItem tmp = {0, "", 0, "", ""}; | |||||
| int a = 0, totitem = 0; | |||||
| for (type = R_engines.first; type; type = type->next, a++) { | |||||
| tmp.value = a; | |||||
| tmp.identifier = type->idname; | |||||
| tmp.name = type->name; | |||||
| RNA_enum_item_add(&item, &totitem, &tmp); | |||||
| } | |||||
| RNA_enum_item_end(&item, &totitem); | |||||
| *r_free = true; | |||||
| return item; | |||||
| } | |||||
| static int rna_SceneLayer_engine_get(PointerRNA *ptr) | |||||
| { | |||||
| SceneLayer *sl = (SceneLayer *)ptr->data; | |||||
| RenderEngineType *type; | |||||
| int a = 0; | |||||
| for (type = R_engines.first; type; type = type->next, a++) | |||||
| if (STREQ(type->idname, sl->engine)) | |||||
| return a; | |||||
| return 0; | |||||
| } | |||||
| static void rna_SceneLayer_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| ED_render_engine_changed(bmain); | |||||
| } | |||||
| static int rna_SceneLayer_multiple_engines_get(PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| return (BLI_listbase_count(&R_engines) > 1); | |||||
| } | |||||
| static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C) | static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C) | ||||
| { | { | ||||
| Depsgraph *graph = CTX_data_depsgraph(C); | Depsgraph *graph = CTX_data_depsgraph(C); | ||||
| DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL) | DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL) | ||||
| { | { | ||||
| /* Don't do anything, we just need to run the iterator to flush | /* Don't do anything, we just need to run the iterator to flush | ||||
| * the base info to the objects. */ | * the base info to the objects. */ | ||||
| UNUSED_VARS(ob); | UNUSED_VARS(ob); | ||||
| ▲ Show 20 Lines • Show All 3,984 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void rna_def_scene_layer(BlenderRNA *brna) | static void rna_def_scene_layer(BlenderRNA *brna) | ||||
| { | { | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| static EnumPropertyItem engine_items[] = { | |||||
| {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| srna = RNA_def_struct(brna, "SceneLayer", NULL); | srna = RNA_def_struct(brna, "SceneLayer", NULL); | ||||
| RNA_def_struct_ui_text(srna, "Render Layer", "Render layer"); | RNA_def_struct_ui_text(srna, "Render Layer", "Render layer"); | ||||
| RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); | RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneLayer_name_set"); | RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneLayer_name_set"); | ||||
| RNA_def_property_ui_text(prop, "Name", "Render layer name"); | RNA_def_property_ui_text(prop, "Name", "Render layer name"); | ||||
| RNA_def_struct_name_property(srna, prop); | RNA_def_struct_name_property(srna, prop); | ||||
| Show All 19 Lines | static void rna_def_scene_layer(BlenderRNA *brna) | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); | RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); | ||||
| /* Override settings */ | /* Override settings */ | ||||
| prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL); | RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL); | ||||
| RNA_def_property_struct_type(prop, "SceneLayerSettings"); | RNA_def_property_struct_type(prop, "SceneLayerSettings"); | ||||
| RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings"); | RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings"); | ||||
| /* engine */ | |||||
| prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_items(prop, engine_items); | |||||
| RNA_def_property_enum_funcs(prop, "rna_SceneLayer_engine_get", "rna_SceneLayer_engine_set", | |||||
| "rna_SceneLayer_engine_itemf"); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); | |||||
| RNA_def_property_update(prop, NC_WINDOW, "rna_SceneLayer_engine_update"); | |||||
| prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_funcs(prop, "rna_SceneLayer_multiple_engines_get", NULL); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); | |||||
| /* debug update routine */ | /* debug update routine */ | ||||
| func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged"); | func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged"); | ||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT); | RNA_def_function_flag(func, FUNC_USE_CONTEXT); | ||||
| RNA_def_function_ui_description(func, | RNA_def_function_ui_description(func, | ||||
| "Update data tagged to be updated from previous access to data or operators"); | "Update data tagged to be updated from previous access to data or operators"); | ||||
| } | } | ||||
| static void rna_def_scene_layers(BlenderRNA *brna, PropertyRNA *cprop) | static void rna_def_scene_layers(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| ▲ Show 20 Lines • Show All 1,685 Lines • ▼ Show 20 Lines | #endif | ||||
| RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL); | RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine"); | RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine"); | ||||
| /* simplify */ | /* simplify */ | ||||
| prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY); | RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY); | ||||
| RNA_def_property_ui_text(prop, "Use Simplify", "Enable simplification of scene for quicker preview renders"); | RNA_def_property_ui_text(prop, "Use Simplify", "Enable simplification of scene for quicker preview renders"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_use_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_use_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_subdivision", PROP_INT, PROP_UNSIGNED); | prop = RNA_def_property(srna, "simplify_subdivision", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_int_sdna(prop, NULL, "simplify_subsurf"); | RNA_def_property_int_sdna(prop, NULL, "simplify_subsurf"); | ||||
| RNA_def_property_ui_range(prop, 0, 6, 1, -1); | RNA_def_property_ui_range(prop, 0, 6, 1, -1); | ||||
| RNA_def_property_ui_text(prop, "Simplify Subdivision", "Global maximum subdivision level"); | RNA_def_property_ui_text(prop, "Simplify Subdivision", "Global maximum subdivision level"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_child_particles", PROP_FLOAT, PROP_FACTOR); | prop = RNA_def_property(srna, "simplify_child_particles", PROP_FLOAT, PROP_FACTOR); | ||||
| RNA_def_property_float_sdna(prop, NULL, "simplify_particles"); | RNA_def_property_float_sdna(prop, NULL, "simplify_particles"); | ||||
| RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage"); | RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_subdivision_render", PROP_INT, PROP_UNSIGNED); | prop = RNA_def_property(srna, "simplify_subdivision_render", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_int_sdna(prop, NULL, "simplify_subsurf_render"); | RNA_def_property_int_sdna(prop, NULL, "simplify_subsurf_render"); | ||||
| RNA_def_property_ui_range(prop, 0, 6, 1, -1); | RNA_def_property_ui_range(prop, 0, 6, 1, -1); | ||||
| RNA_def_property_ui_text(prop, "Simplify Subdivision", "Global maximum subdivision level during rendering"); | RNA_def_property_ui_text(prop, "Simplify Subdivision", "Global maximum subdivision level during rendering"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_child_particles_render", PROP_FLOAT, PROP_FACTOR); | prop = RNA_def_property(srna, "simplify_child_particles_render", PROP_FLOAT, PROP_FACTOR); | ||||
| RNA_def_property_float_sdna(prop, NULL, "simplify_particles_render"); | RNA_def_property_float_sdna(prop, NULL, "simplify_particles_render"); | ||||
| RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage during rendering"); | RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage during rendering"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_shadow_samples", PROP_INT, PROP_UNSIGNED); | prop = RNA_def_property(srna, "simplify_shadow_samples", PROP_INT, PROP_UNSIGNED); | ||||
| RNA_def_property_int_sdna(prop, NULL, "simplify_shadowsamples"); | RNA_def_property_int_sdna(prop, NULL, "simplify_shadowsamples"); | ||||
| RNA_def_property_ui_range(prop, 1, 16, 1, -1); | RNA_def_property_ui_range(prop, 1, 16, 1, -1); | ||||
| RNA_def_property_ui_text(prop, "Simplify Shadow Samples", "Global maximum shadow samples"); | RNA_def_property_ui_text(prop, "Simplify Shadow Samples", "Global maximum shadow samples"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "simplify_ao_sss", PROP_FLOAT, PROP_FACTOR); | prop = RNA_def_property(srna, "simplify_ao_sss", PROP_FLOAT, PROP_FACTOR); | ||||
| RNA_def_property_float_sdna(prop, NULL, "simplify_aosss"); | RNA_def_property_float_sdna(prop, NULL, "simplify_aosss"); | ||||
| RNA_def_property_ui_text(prop, "Simplify AO and SSS", "Global approximate AO and SSS quality factor"); | RNA_def_property_ui_text(prop, "Simplify AO and SSS", "Global approximate AO and SSS quality factor"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); | ||||
| prop = RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); | RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); | ||||
| RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated"); | RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated"); | ||||
| /* persistent data */ | /* persistent data */ | ||||
| prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE); | ||||
| ▲ Show 20 Lines • Show All 754 Lines • Show Last 20 Lines | |||||