Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_main_api.c
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| # include "BKE_armature.h" | # include "BKE_armature.h" | ||||
| # include "BKE_brush.h" | # include "BKE_brush.h" | ||||
| # include "BKE_camera.h" | # include "BKE_camera.h" | ||||
| # include "BKE_collection.h" | # include "BKE_collection.h" | ||||
| # include "BKE_curve.h" | # include "BKE_curve.h" | ||||
| # include "BKE_displist.h" | # include "BKE_displist.h" | ||||
| # include "BKE_font.h" | # include "BKE_font.h" | ||||
| # include "BKE_gpencil.h" | # include "BKE_gpencil.h" | ||||
| # include "BKE_hair.h" | |||||
| # include "BKE_icons.h" | # include "BKE_icons.h" | ||||
| # include "BKE_idcode.h" | # include "BKE_idcode.h" | ||||
| # include "BKE_image.h" | # include "BKE_image.h" | ||||
| # include "BKE_light.h" | # include "BKE_light.h" | ||||
| # include "BKE_lattice.h" | # include "BKE_lattice.h" | ||||
| # include "BKE_lib_remap.h" | # include "BKE_lib_remap.h" | ||||
| # include "BKE_lightprobe.h" | # include "BKE_lightprobe.h" | ||||
| # include "BKE_linestyle.h" | # include "BKE_linestyle.h" | ||||
| # include "BKE_mask.h" | # include "BKE_mask.h" | ||||
| # include "BKE_material.h" | # include "BKE_material.h" | ||||
| # include "BKE_mball.h" | # include "BKE_mball.h" | ||||
| # include "BKE_mesh.h" | # include "BKE_mesh.h" | ||||
| # include "BKE_movieclip.h" | # include "BKE_movieclip.h" | ||||
| # include "BKE_node.h" | # include "BKE_node.h" | ||||
| # include "BKE_object.h" | # include "BKE_object.h" | ||||
| # include "BKE_paint.h" | # include "BKE_paint.h" | ||||
| # include "BKE_particle.h" | # include "BKE_particle.h" | ||||
| # include "BKE_pointcloud.h" | |||||
| # include "BKE_scene.h" | # include "BKE_scene.h" | ||||
| # include "BKE_sound.h" | # include "BKE_sound.h" | ||||
| # include "BKE_speaker.h" | # include "BKE_speaker.h" | ||||
| # include "BKE_text.h" | # include "BKE_text.h" | ||||
| # include "BKE_texture.h" | # include "BKE_texture.h" | ||||
| # include "BKE_volume.h" | |||||
| # include "BKE_workspace.h" | # include "BKE_workspace.h" | ||||
| # include "BKE_world.h" | # include "BKE_world.h" | ||||
| # include "DEG_depsgraph_build.h" | # include "DEG_depsgraph_build.h" | ||||
| # include "DEG_depsgraph_query.h" | # include "DEG_depsgraph_query.h" | ||||
| # include "DNA_armature_types.h" | # include "DNA_armature_types.h" | ||||
| # include "DNA_camera_types.h" | # include "DNA_camera_types.h" | ||||
| # include "DNA_curve_types.h" | # include "DNA_curve_types.h" | ||||
| # include "DNA_hair_types.h" | |||||
| # include "DNA_light_types.h" | # include "DNA_light_types.h" | ||||
| # include "DNA_material_types.h" | # include "DNA_material_types.h" | ||||
| # include "DNA_mesh_types.h" | # include "DNA_mesh_types.h" | ||||
| # include "DNA_speaker_types.h" | # include "DNA_speaker_types.h" | ||||
| # include "DNA_sound_types.h" | # include "DNA_sound_types.h" | ||||
| # include "DNA_lightprobe_types.h" | # include "DNA_lightprobe_types.h" | ||||
| # include "DNA_text_types.h" | # include "DNA_text_types.h" | ||||
| # include "DNA_texture_types.h" | # include "DNA_texture_types.h" | ||||
| # include "DNA_collection_types.h" | # include "DNA_collection_types.h" | ||||
| # include "DNA_brush_types.h" | # include "DNA_brush_types.h" | ||||
| # include "DNA_lattice_types.h" | # include "DNA_lattice_types.h" | ||||
| # include "DNA_meta_types.h" | # include "DNA_meta_types.h" | ||||
| # include "DNA_world_types.h" | # include "DNA_world_types.h" | ||||
| # include "DNA_particle_types.h" | # include "DNA_particle_types.h" | ||||
| # include "DNA_pointcloud_types.h" | |||||
| # include "DNA_vfont_types.h" | # include "DNA_vfont_types.h" | ||||
| # include "DNA_volume_types.h" | |||||
| # include "DNA_node_types.h" | # include "DNA_node_types.h" | ||||
| # include "DNA_movieclip_types.h" | # include "DNA_movieclip_types.h" | ||||
| # include "DNA_mask_types.h" | # include "DNA_mask_types.h" | ||||
| # include "DNA_gpencil_types.h" | # include "DNA_gpencil_types.h" | ||||
| # include "ED_screen.h" | # include "ED_screen.h" | ||||
| # include "BLT_translation.h" | # include "BLT_translation.h" | ||||
| ▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | switch (GS(data->name)) { | ||||
| type = OB_GPENCIL; | type = OB_GPENCIL; | ||||
| break; | break; | ||||
| case ID_AR: | case ID_AR: | ||||
| type = OB_ARMATURE; | type = OB_ARMATURE; | ||||
| break; | break; | ||||
| case ID_LP: | case ID_LP: | ||||
| type = OB_LIGHTPROBE; | type = OB_LIGHTPROBE; | ||||
| break; | break; | ||||
| case ID_HA: | |||||
| type = OB_HAIR; | |||||
| break; | |||||
| case ID_PT: | |||||
| type = OB_POINTCLOUD; | |||||
| break; | |||||
| case ID_VO: | |||||
| type = OB_VOLUME; | |||||
| break; | |||||
| default: { | default: { | ||||
| const char *idname; | const char *idname; | ||||
| if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) { | if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) { | ||||
| idname = "UNKNOWN"; | idname = "UNKNOWN"; | ||||
| } | } | ||||
| BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname); | BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname); | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | static bGPdata *rna_Main_gpencils_new(Main *bmain, const char *name) | ||||
| char safe_name[MAX_ID_NAME - 2]; | char safe_name[MAX_ID_NAME - 2]; | ||||
| rna_idname_validate(name, safe_name); | rna_idname_validate(name, safe_name); | ||||
| bGPdata *gpd = BKE_gpencil_data_addnew(bmain, safe_name); | bGPdata *gpd = BKE_gpencil_data_addnew(bmain, safe_name); | ||||
| id_us_min(&gpd->id); | id_us_min(&gpd->id); | ||||
| return gpd; | return gpd; | ||||
| } | } | ||||
| # ifdef WITH_NEW_OBJECT_TYPES | |||||
| static Hair *rna_Main_hairs_new(Main *bmain, const char *name) | |||||
| { | |||||
| char safe_name[MAX_ID_NAME - 2]; | |||||
| rna_idname_validate(name, safe_name); | |||||
| Hair *hair = BKE_hair_add(bmain, safe_name); | |||||
| id_us_min(&hair->id); | |||||
| return hair; | |||||
| } | |||||
| static PointCloud *rna_Main_pointclouds_new(Main *bmain, const char *name) | |||||
| { | |||||
| char safe_name[MAX_ID_NAME - 2]; | |||||
| rna_idname_validate(name, safe_name); | |||||
| PointCloud *pointcloud = BKE_pointcloud_add(bmain, safe_name); | |||||
| id_us_min(&pointcloud->id); | |||||
| return pointcloud; | |||||
| } | |||||
| # endif | |||||
| static Volume *rna_Main_volumes_new(Main *bmain, const char *name) | |||||
| { | |||||
| char safe_name[MAX_ID_NAME - 2]; | |||||
| rna_idname_validate(name, safe_name); | |||||
| Volume *volume = BKE_volume_add(bmain, safe_name); | |||||
| id_us_min(&volume->id); | |||||
| return volume; | |||||
| } | |||||
| /* tag functions, all the same */ | /* tag functions, all the same */ | ||||
| # define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ | # define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ | ||||
| static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \ | static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \ | ||||
| { \ | { \ | ||||
| BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ | BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ | ||||
| } | } | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, cameras, ID_CA) | RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, cameras, ID_CA) | ||||
| Show All 26 Lines | |||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(gpencils, gpencils, ID_GD) | RNA_MAIN_ID_TAG_FUNCS_DEF(gpencils, gpencils, ID_GD) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(movieclips, movieclips, ID_MC) | RNA_MAIN_ID_TAG_FUNCS_DEF(movieclips, movieclips, ID_MC) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(masks, masks, ID_MSK) | RNA_MAIN_ID_TAG_FUNCS_DEF(masks, masks, ID_MSK) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyles, ID_LS) | RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyles, ID_LS) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) | 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(paintcurves, paintcurves, ID_PC) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) | RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) | ||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP) | RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP) | ||||
| # ifdef WITH_NEW_OBJECT_TYPES | |||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA) | |||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT) | |||||
| # endif | |||||
| RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO) | |||||
| # undef RNA_MAIN_ID_TAG_FUNCS_DEF | # undef RNA_MAIN_ID_TAG_FUNCS_DEF | ||||
| #else | #else | ||||
| void RNA_api_main(StructRNA *UNUSED(srna)) | void RNA_api_main(StructRNA *UNUSED(srna)) | ||||
| { | { | ||||
| # if 0 | # if 0 | ||||
| ▲ Show 20 Lines • Show All 1,368 Lines • ▼ Show 20 Lines | void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| RNA_def_boolean( | RNA_def_boolean( | ||||
| func, "do_ui_user", true, "", "Make sure interface does not reference this light probe"); | func, "do_ui_user", true, "", "Make sure interface does not reference this light probe"); | ||||
| func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag"); | func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag"); | ||||
| parm = RNA_def_boolean(func, "value", 0, "Value", ""); | parm = RNA_def_boolean(func, "value", 0, "Value", ""); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| } | } | ||||
| void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "BlendDataHairs"); | |||||
| srna = RNA_def_struct(brna, "BlendDataHairs", NULL); | |||||
| RNA_def_struct_sdna(srna, "Main"); | |||||
| RNA_def_struct_ui_text(srna, "Main Hairs", "Collection of hairs"); | |||||
| func = RNA_def_function(srna, "new", "rna_Main_hairs_new"); | |||||
| RNA_def_function_ui_description(func, "Add a new hair to the main database"); | |||||
| parm = RNA_def_string(func, "name", "Hair", 0, "", "New name for the data-block"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "hair", "Hair", "", "New hair 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 hair from the current blendfile"); | |||||
| parm = RNA_def_pointer(func, "hair", "Hair", "", "Hair 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 hair before deleting it " | |||||
| "(WARNING: will also delete objects instancing that hair data)"); | |||||
| RNA_def_boolean(func, | |||||
| "do_id_user", | |||||
| true, | |||||
| "", | |||||
| "Decrement user counter of all datablocks used by this hair data"); | |||||
| RNA_def_boolean( | |||||
| func, "do_ui_user", true, "", "Make sure interface does not reference this hair data"); | |||||
| func = RNA_def_function(srna, "tag", "rna_Main_hairs_tag"); | |||||
| parm = RNA_def_boolean(func, "value", 0, "Value", ""); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| } | |||||
| void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "BlendDataPointClouds"); | |||||
| srna = RNA_def_struct(brna, "BlendDataPointClouds", NULL); | |||||
| RNA_def_struct_sdna(srna, "Main"); | |||||
| RNA_def_struct_ui_text(srna, "Main Point Clouds", "Collection of point clouds"); | |||||
| func = RNA_def_function(srna, "new", "rna_Main_pointclouds_new"); | |||||
| RNA_def_function_ui_description(func, "Add a new point cloud to the main database"); | |||||
| parm = RNA_def_string(func, "name", "PointCloud", 0, "", "New name for the data-block"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "New point cloud 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 point cloud from the current blendfile"); | |||||
| parm = RNA_def_pointer(func, "pointcloud", "PointCloud", "", "Point cloud 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 point cloud before deleting it " | |||||
| "(WARNING: will also delete objects instancing that point cloud data)"); | |||||
| RNA_def_boolean(func, | |||||
| "do_id_user", | |||||
| true, | |||||
| "", | |||||
| "Decrement user counter of all datablocks used by this point cloud data"); | |||||
| RNA_def_boolean(func, | |||||
| "do_ui_user", | |||||
| true, | |||||
| "", | |||||
| "Make sure interface does not reference this point cloud data"); | |||||
| func = RNA_def_function(srna, "tag", "rna_Main_pointclouds_tag"); | |||||
| parm = RNA_def_boolean(func, "value", 0, "Value", ""); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| } | |||||
| void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "BlendDataVolumes"); | |||||
| srna = RNA_def_struct(brna, "BlendDataVolumes", NULL); | |||||
| RNA_def_struct_sdna(srna, "Main"); | |||||
| RNA_def_struct_ui_text(srna, "Main Volumes", "Collection of volumes"); | |||||
| func = RNA_def_function(srna, "new", "rna_Main_volumes_new"); | |||||
| RNA_def_function_ui_description(func, "Add a new volume to the main database"); | |||||
| parm = RNA_def_string(func, "name", "Volume", 0, "", "New name for the data-block"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "volume", "Volume", "", "New volume 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 volume from the current blendfile"); | |||||
| parm = RNA_def_pointer(func, "volume", "Volume", "", "Volume 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 volume before deleting it " | |||||
| "(WARNING: will also delete objects instancing that volume data)"); | |||||
| RNA_def_boolean(func, | |||||
| "do_id_user", | |||||
| true, | |||||
| "", | |||||
| "Decrement user counter of all datablocks used by this volume data"); | |||||
| RNA_def_boolean( | |||||
| func, "do_ui_user", true, "", "Make sure interface does not reference this volume data"); | |||||
| func = RNA_def_function(srna, "tag", "rna_Main_volumes_tag"); | |||||
| parm = RNA_def_boolean(func, "value", 0, "Value", ""); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| } | |||||
| #endif | #endif | ||||