Refactor: Move pointcloud and volume foreach_id to new IDTypeInfo structure.

This commit is contained in:
2020-05-20 16:58:56 +02:00
parent 2059b30ee2
commit ee44283393
3 changed files with 22 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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)