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:
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_catalog.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc b/source/blender/blenkernel/intern/asset_catalog.cc
index a1647426c41..41510ff1d02 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -154,18 +154,20 @@ AssetCatalog *AssetCatalogService::find_catalog_by_path(const AssetCatalogPath &
return *best_choice_it;
}
+bool AssetCatalogService::is_catalog_known(CatalogID catalog_id) const
+{
+ BLI_assert(catalog_collection_);
+ return catalog_collection_->catalogs_.contains(catalog_id);
+}
+
AssetCatalogFilter AssetCatalogService::create_catalog_filter(
const CatalogID active_catalog_id) const
{
Set<CatalogID> matching_catalog_ids;
+ Set<CatalogID> known_catalog_ids;
matching_catalog_ids.add(active_catalog_id);
const AssetCatalog *active_catalog = find_catalog(active_catalog_id);
- if (!active_catalog) {
- /* If the UUID is unknown (i.e. not mapped to an actual Catalog), it is impossible to determine
- * its children. The filter can still work on the given UUID. */
- return AssetCatalogFilter(std::move(matching_catalog_ids));
- }
/* This cannot just iterate over tree items to get all the required data, because tree items only
* represent single UUIDs. It could be used to get the main UUIDs of the children, though, and
@@ -173,12 +175,13 @@ AssetCatalogFilter AssetCatalogService::create_catalog_filter(
* call). Without an extra indexed-by-path acceleration structure, this is still going to require
* a linear search, though. */
for (const auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
- if (catalog_uptr->path.is_contained_in(active_catalog->path)) {
+ if (active_catalog && catalog_uptr->path.is_contained_in(active_catalog->path)) {
matching_catalog_ids.add(catalog_uptr->catalog_id);
}
+ known_catalog_ids.add(catalog_uptr->catalog_id);
}
- return AssetCatalogFilter(std::move(matching_catalog_ids));
+ return AssetCatalogFilter(std::move(matching_catalog_ids), std::move(known_catalog_ids));
}
void AssetCatalogService::delete_catalog_by_id_soft(const CatalogID catalog_id)
@@ -1063,8 +1066,10 @@ std::string AssetCatalog::sensible_simple_name_for_path(const AssetCatalogPath &
return "..." + name.substr(name.length() - 60);
}
-AssetCatalogFilter::AssetCatalogFilter(Set<CatalogID> &&matching_catalog_ids)
- : matching_catalog_ids(std::move(matching_catalog_ids))
+AssetCatalogFilter::AssetCatalogFilter(Set<CatalogID> &&matching_catalog_ids,
+ Set<CatalogID> &&known_catalog_ids)
+ : matching_catalog_ids(std::move(matching_catalog_ids)),
+ known_catalog_ids(std::move(known_catalog_ids))
{
}
@@ -1073,4 +1078,12 @@ bool AssetCatalogFilter::contains(const CatalogID asset_catalog_id) const
return matching_catalog_ids.contains(asset_catalog_id);
}
+bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const
+{
+ if (BLI_uuid_is_nil(asset_catalog_id)) {
+ return false;
+ }
+ return known_catalog_ids.contains(asset_catalog_id);
+}
+
} // namespace blender::bke