From ee442833930ce5c29aa015c273eea784b583348e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 20 May 2020 16:58:56 +0200 Subject: Refactor: Move pointcloud and volume foreach_id to new IDTypeInfo structure. --- source/blender/blenkernel/intern/lib_query.c | 10 ++-------- source/blender/blenkernel/intern/pointcloud.c | 10 ++++++++++ source/blender/blenkernel/intern/volume.cc | 10 ++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'source/blender') 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) -- cgit v1.2.3