diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-20 17:58:56 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-20 19:43:46 +0300 |
commit | ee442833930ce5c29aa015c273eea784b583348e (patch) | |
tree | 875fa27fa2b9eccbe05651add162a561f0462700 /source | |
parent | 2059b30ee2d1f7018c4d1c18c68027db7d22ec63 (diff) |
Refactor: Move pointcloud and volume foreach_id to new IDTypeInfo structure.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcloud.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/volume.cc | 10 |
3 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 713eef6d0a1..be535e28f17 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -869,17 +869,11 @@ static void library_foreach_ID_link(Main *bmain, break; } case ID_PT: { - PointCloud *pointcloud = (PointCloud *)id; - for (i = 0; i < pointcloud->totcol; i++) { - CALLBACK_INVOKE(pointcloud->mat[i], IDWALK_CB_USER); - } + BLI_assert(0); break; } case ID_VO: { - Volume *volume = (Volume *)id; - for (i = 0; i < volume->totcol; i++) { - CALLBACK_INVOKE(volume->mat[i], IDWALK_CB_USER); - } + BLI_assert(0); break; } diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index 1639f0b0899..e03888dcad7 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -21,6 +21,7 @@ #include "MEM_guardedalloc.h" #include "DNA_defaults.h" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_pointcloud_types.h" @@ -89,6 +90,14 @@ static void pointcloud_free_data(ID *id) MEM_SAFE_FREE(pointcloud->mat); } +static void pointcloud_foreach_id(ID *id, LibraryForeachIDData *data) +{ + PointCloud *pointcloud = (PointCloud *)id; + for (int i = 0; i < pointcloud->totcol; i++) { + BKE_LIB_FOREACHID_PROCESS(data, pointcloud->mat[i], IDWALK_CB_USER); + } +} + IDTypeInfo IDType_ID_PT = { .id_code = ID_PT, .id_filter = FILTER_ID_PT, @@ -103,6 +112,7 @@ IDTypeInfo IDType_ID_PT = { .copy_data = pointcloud_copy_data, .free_data = pointcloud_free_data, .make_local = NULL, + .foreach_id = pointcloud_foreach_id, }; static void pointcloud_random(PointCloud *pointcloud) diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 9bcc53363ad..26c5810aefa 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -21,6 +21,7 @@ #include "MEM_guardedalloc.h" #include "DNA_defaults.h" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_volume_types.h" @@ -474,6 +475,14 @@ static void volume_free_data(ID *id) #endif } +static void volume_foreach_id(ID *id, LibraryForeachIDData *data) +{ + Volume *volume = (Volume *)id; + for (int i = 0; i < volume->totcol; i++) { + BKE_LIB_FOREACHID_PROCESS(data, volume->mat[i], IDWALK_CB_USER); + } +} + IDTypeInfo IDType_ID_VO = { /* id_code */ ID_VO, /* id_filter */ FILTER_ID_VO, @@ -488,6 +497,7 @@ IDTypeInfo IDType_ID_VO = { /* copy_data */ volume_copy_data, /* free_data */ volume_free_data, /* make_local */ nullptr, + /* foreach_id */ volume_foreach_id, }; void BKE_volume_init_grids(Volume *volume) |