diff options
author | Aras Pranckevicius <aras@nesnausk.org> | 2022-07-20 14:27:14 +0300 |
---|---|---|
committer | Aras Pranckevicius <aras@nesnausk.org> | 2022-07-20 14:27:14 +0300 |
commit | 7f8d05131a7738327ae125d065df44be492ff1f2 (patch) | |
tree | 2e3e13596dee6bc747ed285374ea83d977b7c745 /source/blender/blenkernel/BKE_lib_id.h | |
parent | 8d69c6c4e7c5417f88603d5ccb2c4bb0e156aa1e (diff) |
IDManagement: Speedup ID unique name assignment by tracking used names/basenames/suffixes
An implementation of T73412, roughly as outlined there:
Track the names that are in use, as well as base names (before
numeric suffix) plus a bit map for each base name, indicating which
numeric suffixes are already used. This is done per-Main/Library,
per-object-type.
Timings (Windows, VS2022 Release build, AMD Ryzen 5950X):
- Scene with 10k cubes, Shift+D to duplicate them all: 8.7s -> 1.9s.
Name map memory usage for resulting 20k objects: 4.3MB.
- Importing a 2.5GB .obj file of exported Blender 3.0 splash scene
(24k objects), using the new C++ importer: 34.2s-> 22.0s. Name map
memory usage for resulting scene: 8.6MB.
- Importing Disney Moana USD scene (almost half a million objects):
56min -> 10min. Name map usage: ~100MB. Blender crashes later on
when trying to render it, in the same place in both cases, but
that's for another day.
Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D14162
Diffstat (limited to 'source/blender/blenkernel/BKE_lib_id.h')
-rw-r--r-- | source/blender/blenkernel/BKE_lib_id.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h index beac608a138..59c842d614e 100644 --- a/source/blender/blenkernel/BKE_lib_id.h +++ b/source/blender/blenkernel/BKE_lib_id.h @@ -478,10 +478,12 @@ void BKE_lib_id_expand_local(struct Main *bmain, struct ID *id, int flags); * * \return true if a new name had to be created. */ -bool BKE_id_new_name_validate(struct ListBase *lb, +bool BKE_id_new_name_validate(struct Main *bmain, + struct ListBase *lb, struct ID *id, const char *name, - bool do_linked_data) ATTR_NONNULL(1, 2); + bool do_linked_data) ATTR_NONNULL(1, 2, 3); + /** * Pull an ID out of a library (make it local). Only call this for IDs that * don't have other library users. @@ -526,7 +528,7 @@ void BKE_main_lib_objects_recalc_all(struct Main *bmain); /** * Only for repairing files via versioning, avoid for general use. */ -void BKE_main_id_repair_duplicate_names_listbase(struct ListBase *lb); +void BKE_main_id_repair_duplicate_names_listbase(struct Main *bmain, struct ListBase *lb); #define MAX_ID_FULL_NAME (64 + 64 + 3 + 1) /* 64 is MAX_ID_NAME - 2 */ #define MAX_ID_FULL_NAME_UI (MAX_ID_FULL_NAME + 3) /* Adds 'keycode' two letters at beginning. */ |