From 561b54d06e44c888cf377d4348f6870f0c327b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 5 Feb 2024 17:16:04 +0100 Subject: [PATCH] ID: Document the steps to properly add a new ID data-block type Extend the existing documentation of how to add a new `IDTypeInfo`, so that it includes all the places in which the new ID datatype has to be added before Blender truely can work with it. This is based on what I had to do for the new `Animation` data-block introduced in #114098. --- docs/features/core/datablocks/id_type.md | 47 +++++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/docs/features/core/datablocks/id_type.md b/docs/features/core/datablocks/id_type.md index 70da3d5f..f678ffc7 100644 --- a/docs/features/core/datablocks/id_type.md +++ b/docs/features/core/datablocks/id_type.md @@ -183,5 +183,48 @@ To add a new `IDTypeInfo` you need to: for object). 2. Add the `extern` declaration of the new `IDType` in `BKE_idtype.h`. -3. Register the new `IDTypeInfo` in `id_type_init()` of - `idtype.cc`. +3. `idtype.cc`: + - Register the new `IDTypeInfo` in `id_type_init()`. + - Add a new `case` to `BKE_idtype_idcode_to_idfilter()` + - Add a new `case` to `BKE_idtype_idcode_to_index()` + - Add a new `case` to `BKE_idtype_idcode_from_index()` + +Additionally, there are some other areas in the source code where a reference to +the new type might be added: + +4. `lib_query.cc`: in `BKE_library_id_can_use_filter_id()`. +5. `blenkernel/intern/main.cc`: + - `which_libbase()` + - `set_listbasepointers()` +6. `readfile.c`: in `dataname()` +7. `BLT_translation.h`: add a `#define BLT_I18NCONTEXT_ID...` line +8. Dependency graph handling: `deg_builder_nodes.h`, `deg_builder_nodes.cc`, + `deg_builder_relations.h`, and `deg_builder_relations.cc`, +9. `editors/interface/interface_icons.cc` in `UI_icon_from_idcode()` +10. `editors/interface/interface_templates.cc` in `template_id_browse_tip()` +11. `editors/render/render_opengl.cc` in `gather_frames_to_render_for_id()` +12. Outliner support in `editors/space_outliner`: + - `outliner_intern.hh`: `TREESTORE_ID_TYPE` + - `outliner_draw.cc`: `tree_element_get_icon_from_id()` + - `outliner_tools.cc`: `get_element_operation_type()` + - `tree_element_id.cc`: `TreeElementID::create_from_id()` +13. Filtering: + - `DNA_ID.h`: add a `#define FILTER_ID_...` line and add it to `FILTER_ID_ALL`. + - `DNA_ID.h`: add an entry to `eID_Index` + - `rna_space.cc`: add to `rna_enum_space_file_id_filter_categories` +14. `DNA_ID_enums.h`: add to `enum ID_Type` +15. If your DNA definition has default values in `DNA_..._defaults.h`, add this to`dna_defaults.c`: + - add a `SDNA_DEFAULT_DECL_STRUCT(...)` line for each struct that has defaults. + - add a `SDNA_DEFAULT_DECL(...)` line to `DNA_default_table()` for each such struct. +16. If you want to have RNA support: + - `makesrna.cc`: add an entry to `PROCESS_ITEMS` for your RNA definition file. + - `rna_ID.cc`: add to `rna_enum_id_type_items`, `rna_enum_id_type_filter_items`, `RNA_type_to_ID_code()`, `rna_ID_update_tag()` + - `rna_internal.hh`: + - add declaration of your RNA definition entry function (`void RNA_def_yourtype(BlenderRNA *brna);`) + - add declaration for the `bpy.data.yourdata` collection (`void RNA_def_main_yourdata(BlenderRNA *brna, PropertyRNA *cprop);`) + - `rna_main.cc`: + - add a `RNA_MAIN_LISTBASE_FUNCS_DEF(yourdata)` line. + - add your type to the `RNA_def_main()` function. + - `rna_main_api.cc`: add these functions: + - `static YourType *rna_Main_yourdata_new(Main *bmain, const char *name)` + - `void RNA_def_main_yourdata(BlenderRNA *brna, PropertyRNA *cprop)` -- 2.30.2