diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-20 18:07:00 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-20 19:43:46 +0300 |
commit | 3a284a37fde9daae7d987a33555e8529cdfdd488 (patch) | |
tree | 55a4175730cbfe13dab640fe1939dc21eef84105 /source/blender | |
parent | ee442833930ce5c29aa015c273eea784b583348e (diff) |
Refactor: Move simulation foreach_id to new IDTypeInfo structure.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/simulation.cc | 22 |
2 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index be535e28f17..1c17250d49e 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -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; } diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index b4cfa7cf0ef..50770125a18 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -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)) { } |