Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2022-02-11 16:53:08 +0300
committerJeroen Bakker <jeroen@blender.org>2022-02-11 16:53:33 +0300
commita71a513def202b119328035dbd68e86c2c47f7ac (patch)
tree86ed98ed6daf1eab20cad11348eafa65fa2daaa9 /source/blender/blenkernel/intern/lib_id_remapper_test.cc
parent811cbb6c0a426243d957fa00f7ddec15b1d4ae62 (diff)
Remap multiple items in referenced data.
This patch increases the performance when remapping data. {D13615} introduced a mechanism to remap multiple items in a single go. This patch uses the same mechanism when remapping data inside ID datablocks. Benchmark results when loading the village scene of sprite fright on AMD Ryzen 7 3800X 8-Core Processor Before this patch 115 seconds When patch applied less than 43 seconds There is still some room for improvement by porting relink code. Reviewed By: mont29 Maniphest Tasks: T95279 Differential Revision: https://developer.blender.org/D14043
Diffstat (limited to 'source/blender/blenkernel/intern/lib_id_remapper_test.cc')
-rw-r--r--source/blender/blenkernel/intern/lib_id_remapper_test.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_remapper_test.cc b/source/blender/blenkernel/intern/lib_id_remapper_test.cc
index a6cfe60153d..73edc30d077 100644
--- a/source/blender/blenkernel/intern/lib_id_remapper_test.cc
+++ b/source/blender/blenkernel/intern/lib_id_remapper_test.cc
@@ -65,4 +65,44 @@ TEST(lib_id_remapper, unassigned)
BKE_id_remapper_free(remapper);
}
+TEST(lib_id_remapper, unassign_when_mapped_to_self)
+{
+ ID id_self;
+ ID id1;
+ ID id2;
+ ID *idp;
+
+ BLI_strncpy(id_self.name, "OBSelf", sizeof(id1.name));
+ BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
+ BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
+
+ /* Default mapping behavior. Should just remap to id2. */
+ idp = &id1;
+ IDRemapper *remapper = BKE_id_remapper_create();
+ BKE_id_remapper_add(remapper, &id1, &id2);
+ IDRemapperApplyResult result = BKE_id_remapper_apply_ex(
+ remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self);
+ EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_REMAPPED);
+ EXPECT_EQ(idp, &id2);
+
+ /* Default mapping behavior. Should unassign. */
+ idp = &id1;
+ BKE_id_remapper_clear(remapper);
+ BKE_id_remapper_add(remapper, &id1, nullptr);
+ result = BKE_id_remapper_apply_ex(
+ remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self);
+ EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNASSIGNED);
+ EXPECT_EQ(idp, nullptr);
+
+ /* Unmap when remapping to self behavior. Should unassign. */
+ idp = &id1;
+ BKE_id_remapper_clear(remapper);
+ BKE_id_remapper_add(remapper, &id1, &id_self);
+ result = BKE_id_remapper_apply_ex(
+ remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self);
+ EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNASSIGNED);
+ EXPECT_EQ(idp, nullptr);
+ BKE_id_remapper_free(remapper);
+}
+
} // namespace blender::bke::id::remapper::tests