Cleanup: Make asset library function more clear

Got confused by the naming here myself, this should help.
This commit is contained in:
Julian Eisel
2024-02-19 18:46:15 +01:00
parent 783e565110
commit 342f470ccf
3 changed files with 13 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ namespace blender::asset_system {
AllAssetLibrary::AllAssetLibrary() : AssetLibrary(ASSET_LIBRARY_ALL) {}
void AllAssetLibrary::rebuild(const bool reload_catalogs)
void AllAssetLibrary::rebuild_catalogs_from_nested(const bool reload_nested_catalogs)
{
/* Start with empty catalog storage. Don't do this directly in #this.catalog_service to avoid
* race conditions. Rather build into a new service and replace the current one when done. */
@@ -25,7 +25,7 @@ void AllAssetLibrary::rebuild(const bool reload_catalogs)
AssetLibrary::foreach_loaded(
[&](AssetLibrary &nested) {
if (reload_catalogs) {
if (reload_nested_catalogs) {
nested.catalog_service->reload_catalogs();
}
new_catalog_service->add_from_existing(*nested.catalog_service);
@@ -37,7 +37,7 @@ void AllAssetLibrary::rebuild(const bool reload_catalogs)
void AllAssetLibrary::refresh_catalogs()
{
rebuild(/*reload_catalogs=*/true);
rebuild_catalogs_from_nested(/*reload_nested_catalogs=*/true);
}
} // namespace blender::asset_system

View File

@@ -18,7 +18,14 @@ class AllAssetLibrary : public AssetLibrary {
void refresh_catalogs() override;
void rebuild(const bool reload_catalogs);
/**
* Update the available catalogs and catalog tree from the nested asset libraries. Completely
* recreates the catalog service (invalidating pointers to the previous one).
*
* \param reload_nested_catalogs: Re-read catalog definitions of nested libraries from disk and
* merge them into the in-memory representations.
*/
void rebuild_catalogs_from_nested(bool reload_nested_catalogs);
};
} // namespace blender::asset_system

View File

@@ -190,7 +190,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_current_file()
void AssetLibraryService::rebuild_all_library()
{
if (all_library_) {
all_library_->rebuild(false);
all_library_->rebuild_catalogs_from_nested(false);
}
}
@@ -217,7 +217,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_all(const Main *bmain)
all_library_ = std::make_unique<AllAssetLibrary>();
/* Don't reload catalogs on this initial read, they've just been loaded above. */
all_library_->rebuild(/*reload_catalogs=*/false);
all_library_->rebuild_catalogs_from_nested(/*reload_nested_catalogs=*/false);
return all_library_.get();
}