Cleanup: Keep IDTypeInfo separated from ID type specific API.

Also do not define IDTypeInfo callback when default generic code is
enough...
This commit is contained in:
Bastien Montagne 2020-05-13 19:11:19 +02:00
parent 73f38f8db0
commit 658b254e3e
1 changed files with 27 additions and 32 deletions

View File

@ -78,17 +78,6 @@ static void world_init_data(ID *id)
MEMCPY_STRUCT_AFTER(wrld, DNA_struct_default_get(World), id);
}
World *BKE_world_add(Main *bmain, const char *name)
{
World *wrld;
wrld = BKE_libblock_alloc(bmain, ID_WO, name, 0);
world_init_data(&wrld->id);
return wrld;
}
/**
* Only copy internal data of World ID from source
* to already allocated/initialized destination.
@ -122,6 +111,33 @@ static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
}
}
IDTypeInfo IDType_ID_WO = {
.id_code = ID_WO,
.id_filter = FILTER_ID_WO,
.main_listbase_index = INDEX_ID_WO,
.struct_size = sizeof(World),
.name = "World",
.name_plural = "worlds",
.translation_context = BLT_I18NCONTEXT_ID_WORLD,
.flags = 0,
.init_data = world_init_data,
.copy_data = world_copy_data,
.free_data = world_free_data,
.make_local = NULL,
};
World *BKE_world_add(Main *bmain, const char *name)
{
World *wrld;
wrld = BKE_libblock_alloc(bmain, ID_WO, name, 0);
world_init_data(&wrld->id);
return wrld;
}
World *BKE_world_copy(Main *bmain, const World *wrld)
{
World *wrld_copy;
@ -159,27 +175,6 @@ World *BKE_world_localize(World *wrld)
return wrldn;
}
static void world_make_local(Main *bmain, ID *id, const int flags)
{
BKE_lib_id_make_local_generic(bmain, id, flags);
}
IDTypeInfo IDType_ID_WO = {
.id_code = ID_WO,
.id_filter = FILTER_ID_WO,
.main_listbase_index = INDEX_ID_WO,
.struct_size = sizeof(World),
.name = "World",
.name_plural = "worlds",
.translation_context = BLT_I18NCONTEXT_ID_WORLD,
.flags = 0,
.init_data = world_init_data,
.copy_data = world_copy_data,
.free_data = world_free_data,
.make_local = world_make_local,
};
void BKE_world_eval(struct Depsgraph *depsgraph, World *world)
{
DEG_debug_print_eval(depsgraph, __func__, world->id.name, world);