Refactor: Move simulation foreach_id to new IDTypeInfo structure.

This commit is contained in:
Bastien Montagne 2020-05-20 17:07:00 +02:00
parent ee44283393
commit 3a284a37fd
2 changed files with 17 additions and 11 deletions

View File

@ -882,11 +882,7 @@ static void library_foreach_ID_link(Main *bmain,
break;
}
case ID_SIM: {
Simulation *simulation = (Simulation *)id;
if (simulation->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
BKE_library_foreach_ID_embedded(&data, (ID **)&simulation->nodetree);
}
BLI_assert(0);
break;
}

View File

@ -87,13 +87,13 @@ static void simulation_free_data(ID *id)
}
}
void *BKE_simulation_add(Main *bmain, const char *name)
static void simulation_foreach_id(ID *id, LibraryForeachIDData *data)
{
Simulation *simulation = (Simulation *)BKE_libblock_alloc(bmain, ID_SIM, name, 0);
simulation_init_data(&simulation->id);
return simulation;
Simulation *simulation = (Simulation *)id;
if (simulation->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
BKE_library_foreach_ID_embedded(data, (ID **)&simulation->nodetree);
}
}
IDTypeInfo IDType_ID_SIM = {
@ -110,8 +110,18 @@ IDTypeInfo IDType_ID_SIM = {
/* copy_data */ simulation_copy_data,
/* free_data */ simulation_free_data,
/* make_local */ nullptr,
/* foreach_id */ simulation_foreach_id,
};
void *BKE_simulation_add(Main *bmain, const char *name)
{
Simulation *simulation = (Simulation *)BKE_libblock_alloc(bmain, ID_SIM, name, 0);
simulation_init_data(&simulation->id);
return simulation;
}
void BKE_simulation_data_update(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(scene))
{
}