General Idea
We want to have some sort of ID_type structure, similar to what we have for e.g. modifiers or constraints.
This structure would mainly contain:
- ID info data, like name, UI name, plural name, etc.
- note: this is mostly handled in BKE_idcode currently.
- Callbacks for common ID operations (create, copy, delete, make local, etc.)
- note: those are mostly scattered in each ID type BKE's code currently, and called from BKE_lib API through switch/case pattern.
Process
See D6966 and rBc328049535a4 for the initial implementation, including 'demo' for the ID_OB object type.
To add a new IDTypeInfo you need to:
- Define the IDTypeInfo in the relevant BKE's implementation file (e.g. mesh.c for ID_ME, etc.).
- Please put the static callbacks and then the IDTypeInfo struct definition at the start of those files.
- If you need extra helpers, put only their forward declaration there, and implement them below the IDTypeInfo definition. This allows for a consistent clear separation between common info and specific APIs for each ID type implementation file.
- The callbacks should basically be moving around code from existing BKE_XXX_copy_data(), BKE_XXX_init() etc. functions. Those existing functions become therefore wrappers around the static callbacks as well (and shall be removed in later cleanup steps).
- The IDTypeInfo should be named from its idcode (e.g. IDType_ID_OB for object).
- Please put the static callbacks and then the IDTypeInfo struct definition at the start of those files.
- Add the extern declaration of the new IDType in BKE_idtype.h.
- Register the new IDType in id_type_init() of idtype.c.
Tasks for Cleanup Friday
Now we have to create those for all remaining ID types. Please put your name in the list below for IDTypes you want to handle (I already reserved the oddballs ones I suspect to be the trickiest ;) ).
- ID_SCE Scene ~~@Bastien Montagne (mont29)
- ID_LI Library ~~@Bastien Montagne (mont29)
- ID_OB Object ~~@Bastien Montagne (mont29)
- ID_ME Mesh ~~@Bastien Montagne (mont29)
- ID_CU Curve ~~@Bastien Montagne (mont29)
- ID_MB MetaBall ~~@Bastien Montagne (mont29)
- ID_MA Material ~~@Bastien Montagne (mont29)
- ID_TE Texture ~~@Bastien Montagne (mont29)
- ID_IM Image ~~@Bastien Montagne (mont29)
- ID_LT Lattice ~~@Bastien Montagne (mont29)
- ID_LA Light ~~@Brecht Van Lommel (brecht)
- ID_CA Camera ~~@Brecht Van Lommel (brecht)
- ID_IP Ipo (deprecated) ~~@Bastien Montagne (mont29)
- ID_KE Shape key ~~@Bastien Montagne (mont29)
- ID_WO World ~~@Brecht Van Lommel (brecht)
- ID_SCR Screen ~~@Bastien Montagne (mont29)
- ID_VF VFont~~@Dalai Felinto (dfelinto)
- ID_TXT Text~~@Dalai Felinto (dfelinto)
- ID_SPK Speaker ~~@Bastien Montagne (mont29)
- ID_SO Sound ~~@Bastien Montagne (mont29)
- ID_GR Group ~~@Dalai Felinto (dfelinto)
- ID_AR Armature @Dalai Felinto (dfelinto)
- ID_AC Action @Dalai Felinto (dfelinto)
- ID_NT NodeTree ~~@Bastien Montagne (mont29)
- ID_BR Brush ~~@Bastien Montagne (mont29)
- ID_PA ParticleSettings ~~@Bastien Montagne (mont29)
- ID_GD Grease Pencil ~~@Bastien Montagne (mont29)
- ID_WM WindowManager ~~@Bastien Montagne (mont29)
- ID_MC MovieClip ~~@Bastien Montagne (mont29)
- ID_MSK Mask ~~@Bastien Montagne (mont29)
- ID_LS FreestyleLineStyle ~~@Bastien Montagne (mont29)
- ID_PAL Palette ~~@Bastien Montagne (mont29)
- ID_PC PaintCurve ~~@Bastien Montagne (mont29)
- ID_CF CacheFile ~~@Bastien Montagne (mont29)
- ID_WS WorkSpace ~~@Bastien Montagne (mont29)
- ID_LP LightProbe ~~@Brecht Van Lommel (brecht)
- ID_HA Hair ~~@Brecht Van Lommel (brecht)
- ID_PT PointCloud ~~@Brecht Van Lommel (brecht)
- ID_VO Volume ~~@Brecht Van Lommel (brecht)