diff options
-rw-r--r-- | source/blender/blenkernel/BKE_lib_remap.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_remapper.cc | 32 |
2 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_lib_remap.h b/source/blender/blenkernel/BKE_lib_remap.h index 5fa524e3fc6..f4136ed5cda 100644 --- a/source/blender/blenkernel/BKE_lib_remap.h +++ b/source/blender/blenkernel/BKE_lib_remap.h @@ -204,6 +204,11 @@ void BKE_id_remapper_iter(const struct IDRemapper *id_remapper, IDRemapperIterFunction func, void *user_data); +/** Returns a readable string for the given result. Can be used for debugging purposes. */ +const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result); +/** Prints out the rules inside the given id_remapper. Can be used for debugging purposes. */ +void BKE_id_remapper_print(const struct IDRemapper *id_remapper); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/lib_id_remapper.cc b/source/blender/blenkernel/intern/lib_id_remapper.cc index 7347ccc258d..5af482ac088 100644 --- a/source/blender/blenkernel/intern/lib_id_remapper.cc +++ b/source/blender/blenkernel/intern/lib_id_remapper.cc @@ -157,4 +157,36 @@ void BKE_id_remapper_iter(const struct IDRemapper *id_remapper, const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); remapper->iter(func, user_data); } + +const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result) +{ + switch (result) { + case ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE: + return "not_mappable"; + case ID_REMAP_RESULT_SOURCE_UNAVAILABLE: + return "unavailable"; + case ID_REMAP_RESULT_SOURCE_UNASSIGNED: + return "unassigned"; + case ID_REMAP_RESULT_SOURCE_REMAPPED: + return "remapped"; + default: + BLI_assert_unreachable(); + } + return ""; +} + +static void id_remapper_print_item_cb(ID *old_id, ID *new_id, void *UNUSED(user_data)) +{ + if (old_id != nullptr && new_id != nullptr) { + printf("Remap %s(%p) to %s(%p)\n", old_id->name, old_id, new_id->name, new_id); + } + if (old_id != nullptr && new_id == nullptr) { + printf("Unassign %s(%p)\n", old_id->name, old_id); + } +} + +void BKE_id_remapper_print(const struct IDRemapper *id_remapper) +{ + BKE_id_remapper_iter(id_remapper, id_remapper_print_item_cb, nullptr); +} } |