Geometry Nodes: Node group operators initial phase #108947
|
@ -17,6 +17,7 @@
|
|||
#include "AS_asset_catalog_tree.hh"
|
||||
|
||||
struct AssetFilterSettings;
|
||||
struct AssetLibraryReference;
|
||||
struct bContext;
|
||||
|
||||
namespace blender::asset_system {
|
||||
|
@ -47,6 +48,7 @@ struct AssetItemTree {
|
|||
};
|
||||
|
||||
AssetItemTree build_filtered_all_catalog_tree(
|
||||
const AssetLibraryReference &library_ref,
|
||||
const bContext &C,
|
||||
HooglyBoogly marked this conversation as resolved
|
||||
const AssetFilterSettings &filter_settings,
|
||||
FunctionRef<bool(const AssetMetaData &)> meta_data_filter = {});
|
||||
|
|
|
@ -52,6 +52,7 @@ bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
|
|||
namespace blender::ed::asset {
|
||||
|
||||
AssetItemTree build_filtered_all_catalog_tree(
|
||||
HooglyBoogly marked this conversation as resolved
Julian Eisel
commented
Would suggest letting this take an Would suggest letting this take an `AssetLibraryReference` as parameter, there's nothing specific to the all asset library here really.
|
||||
const AssetLibraryReference &library_ref,
|
||||
const bContext &C,
|
||||
const AssetFilterSettings &filter_settings,
|
||||
const FunctionRef<bool(const AssetMetaData &)> meta_data_filter)
|
||||
|
@ -59,17 +60,14 @@ AssetItemTree build_filtered_all_catalog_tree(
|
|||
MultiValueMap<asset_system::AssetCatalogPath, asset_system::AssetRepresentation *>
|
||||
assets_per_path;
|
||||
|
||||
const AssetLibraryReference all_library_ref = asset_system::all_library_reference();
|
||||
|
||||
ED_assetlist_storage_fetch(&all_library_ref, &C);
|
||||
ED_assetlist_ensure_previews_job(&all_library_ref, &C);
|
||||
|
||||
asset_system::AssetLibrary *all_library = get_all_library_once_available();
|
||||
if (!all_library) {
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
ED_assetlist_ensure_previews_job(&library_ref, &C);
|
||||
asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(library_ref);
|
||||
if (!library) {
|
||||
return {};
|
||||
}
|
||||
|
||||
ED_assetlist_iterate(all_library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -82,7 +80,7 @@ AssetItemTree build_filtered_all_catalog_tree(
|
|||
return true;
|
||||
}
|
||||
|
||||
const asset_system::AssetCatalog *catalog = all_library->catalog_service->find_catalog(
|
||||
const asset_system::AssetCatalog *catalog = library->catalog_service->find_catalog(
|
||||
meta_data.catalog_id);
|
||||
if (catalog == nullptr) {
|
||||
return true;
|
||||
|
@ -93,12 +91,12 @@ AssetItemTree build_filtered_all_catalog_tree(
|
|||
|
||||
/* Build an own tree without any of the catalogs that don't have proper node group assets. */
|
||||
HooglyBoogly marked this conversation as resolved
Jacques Lucke
commented
This comment seems outdated because it talks about node groups while this function seems to be more general. This comment seems outdated because it talks about node groups while this function seems to be more general.
|
||||
asset_system::AssetCatalogTree catalogs_with_node_assets;
|
||||
asset_system::AssetCatalogTree &catalog_tree = *all_library->catalog_service->get_catalog_tree();
|
||||
asset_system::AssetCatalogTree &catalog_tree = *library->catalog_service->get_catalog_tree();
|
||||
catalog_tree.foreach_item([&](asset_system::AssetCatalogTreeItem &item) {
|
||||
if (assets_per_path.lookup(item.catalog_path()).is_empty()) {
|
||||
return;
|
||||
}
|
||||
asset_system::AssetCatalog *catalog = all_library->catalog_service->find_catalog(
|
||||
asset_system::AssetCatalog *catalog = library->catalog_service->find_catalog(
|
||||
item.get_catalog_id());
|
||||
if (catalog == nullptr) {
|
||||
return;
|
||||
|
|
|
@ -396,7 +396,8 @@ static asset::AssetItemTree build_catalog_tree(const bContext &C)
|
|||
}
|
||||
return true;
|
||||
};
|
||||
return asset::build_filtered_all_catalog_tree(C, type_filter, meta_data_filter);
|
||||
const AssetLibraryReference library = asset_system::all_library_reference();
|
||||
return asset::build_filtered_all_catalog_tree(library, C, type_filter, meta_data_filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,7 +95,8 @@ static asset::AssetItemTree build_catalog_tree(const bContext &C, const bNodeTre
|
|||
}
|
||||
return true;
|
||||
};
|
||||
return asset::build_filtered_all_catalog_tree(C, type_filter, meta_data_filter);
|
||||
const AssetLibraryReference library = asset_system::all_library_reference();
|
||||
return asset::build_filtered_all_catalog_tree(library, C, type_filter, meta_data_filter);
|
||||
}
|
||||
|
||||
static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
|
||||
|
|
Loading…
Reference in New Issue
Would default this to
nullptr
. While in your case (geometry nodes stuff) it's necessary, I'm not sure if you'd need to filter by metadata usually.