Refactor: Move texture foreach_id to new IDTypeInfo structure.

This commit is contained in:
Bastien Montagne 2020-05-12 18:46:57 +02:00
parent 5fd64c014f
commit 8ce0c9111d
2 changed files with 13 additions and 6 deletions

View File

@ -915,12 +915,7 @@ static void library_foreach_ID_link(Main *bmain,
}
case ID_TE: {
Tex *texture = (Tex *)id;
if (texture->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
BKE_library_foreach_ID_embedded(&data, (ID **)&texture->nodetree);
}
CALLBACK_INVOKE(texture->ima, IDWALK_CB_USER);
BLI_assert(0);
break;
}

View File

@ -57,6 +57,7 @@
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_scene.h"
@ -123,6 +124,16 @@ static void texture_free_data(ID *id)
BKE_previewimg_free(&texture->preview);
}
static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
{
Tex *texture = (Tex *)id;
if (texture->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
BKE_library_foreach_ID_embedded(data, (ID **)&texture->nodetree);
}
BKE_LIB_FOREACHID_PROCESS(data, texture->ima, IDWALK_CB_USER);
}
IDTypeInfo IDType_ID_TE = {
.id_code = ID_TE,
.id_filter = FILTER_ID_TE,
@ -137,6 +148,7 @@ IDTypeInfo IDType_ID_TE = {
.copy_data = texture_copy_data,
.free_data = texture_free_data,
.make_local = NULL,
.foreach_id = texture_foreach_id,
};
/* ****************** Mapping ******************* */