Brush Assets: Add catalog option to asset pushing operator #118382
|
@ -1268,6 +1268,17 @@ static asset_system::AssetCatalog &asset_library_ensure_catalog(
|
|||
return *library.catalog_service->create_catalog(path);
|
||||
}
|
||||
|
||||
static asset_system::AssetCatalog &asset_library_ensure_catalogs_in_path(
|
||||
asset_system::AssetLibrary &library, const asset_system::AssetCatalogPath &path)
|
||||
{
|
||||
asset_system::AssetCatalogPath parent = "";
|
||||
path.iterate_components([&](StringRef component_name, bool is_last_component) {
|
||||
asset_library_ensure_catalog(library, parent / component_name);
|
||||
parent = parent / component_name;
|
||||
|
||||
});
|
||||
return *library.catalog_service->find_catalog_by_path(path);
|
||||
}
|
||||
|
||||
static AssetLibraryReference user_library_to_library_ref(const bUserAssetLibrary &user_library)
|
||||
{
|
||||
AssetLibraryReference library_ref{};
|
||||
|
@ -1320,7 +1331,8 @@ static int brush_asset_save_as_exec(bContext *C, wmOperator *op)
|
|||
/* Add asset to catalog. */
|
||||
char catalog_path[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path);
|
||||
const asset_system::AssetCatalog &catalog = asset_library_ensure_catalog(*library, catalog_path);
|
||||
const asset_system::AssetCatalog &catalog = asset_library_ensure_catalogs_in_path(*library,
|
||||
catalog_path);
|
||||
const asset_system::CatalogID catalog_id = catalog.catalog_id;
|
||||
const std::string catalog_simple_name = catalog.simple_name;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Creating a catalog with missing parent catalogs should work fine, the parents would be created with
create_missing_catalogs()
. Is this not working for you?No, that's the infinite recursion I was mentioning in chat. It creates the missing parent catalogs with a null catalog ID and an empty simple name. If you want, you should be able to reproduce it by calling
asset_library_ensure_catalog
instead ofasset_library_ensure_catalogs_in_path
below.