61 if (library_dirpath ==
nullptr || library_dirpath[0] ==
'\0') {
88 return preferences_lib->dirpath;
109 char r_path_buffer[ 1282],
115 std::optional<AssetLibraryService::ExplodedPath> exploded =
128 r_path_buffer[0] =
'\0';
132 BLI_assert(!exploded->group_component.is_empty());
133 BLI_assert(!exploded->name_component.is_empty());
135 BLI_strncpy(r_path_buffer, exploded->full_path->c_str(), 1282);
137 if (!exploded->dir_component.is_empty()) {
138 r_path_buffer[exploded->dir_component.size()] =
'\0';
139 r_path_buffer[exploded->dir_component.size() + 1 + exploded->group_component.size()] =
'\0';
142 *r_dir = r_path_buffer;
145 *r_group = r_path_buffer + exploded->dir_component.size() + 1;
148 *r_name = r_path_buffer + exploded->dir_component.size() + 1 +
149 exploded->group_component.size() + 1;
153 r_path_buffer[exploded->group_component.size()] =
'\0';
159 *r_group = r_path_buffer;
162 *r_name = r_path_buffer + exploded->group_component.size() + 1;
170 if (
U.experimental.no_data_block_packing) {
195 if (
U.experimental.no_data_block_packing) {
233 root_path_(std::make_shared<std::string>(
utils::normalize_directory_path(
root_path))),
246 const bool include_all_library)
285 std::unique_ptr<AssetMetaData> metadata)
287 return asset_storage_.external_assets.lookup_key_or_add(std::make_shared<AssetRepresentation>(
288 relative_asset_path,
name, id_type, std::move(metadata), *
this));
293 return asset_storage_.local_id_assets.lookup_key_or_add(
294 std::make_shared<AssetRepresentation>(
id, *
this));
301 if (&asset.owner_asset_library_ !=
this) {
305 BLI_assert(asset_storage_.local_id_assets.contains_as(&asset) ||
306 asset_storage_.external_assets.contains_as(&asset));
308 if (asset_storage_.local_id_assets.remove_as(&asset)) {
311 return asset_storage_.external_assets.remove_as(&asset);
318 for (
const auto &asset_ptr : asset_storage_.local_id_assets) {
327 removed_assets.
add(&asset);
337void asset_library_on_save_post(
Main *bmain,
339 const int num_pointers,
352 on_disk_lib->catalog_service().undo_push();
407 if (catalog ==
nullptr) {
417 return library_type_;
437 result.append(library_ref);
447 result.append(library_ref);
453 result.append(library_ref);
462 return all_library_ref;
Main runtime representation of an asset.
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
void BKE_callback_remove(bCallbackFuncStore *funcstore, eCbEvent evt)
@ ID_REMAP_RESULT_SOURCE_UNASSIGNED
struct bUserAssetLibrary * BKE_preferences_asset_library_containing_path(const struct UserDef *userdef, const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
File and directory operations.
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
bool BLI_uuid_is_nil(bUUID uuid)
@ ASSET_IMPORT_APPEND_REUSE
@ ASSET_LIBRARY_ESSENTIALS
@ FILE_ASSET_IMPORT_APPEND_REUSE
void AS_asset_library_remap_ids(const bke::id::IDRemapper &mappings)
std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain)
void AS_asset_libraries_exit()
AssetLibrary * AS_asset_library_load(const Main *bmain, const AssetLibraryReference &library_reference)
void AS_asset_library_essential_import_method_update()
AssetLibrary * AS_asset_library_load_from_directory(const char *name, const char *library_dirpath)
std::string AS_asset_library_find_suitable_root_path_from_path(const blender::StringRefNull input_path)
void AS_asset_library_import_method_ensure_valid(Main &bmain)
static void update_import_method_for_user_libraries()
std::string AS_asset_library_root_path_from_library_ref(const AssetLibraryReference &library_reference)
bool AS_asset_library_has_any_unsaved_catalogs()
void AS_asset_full_path_explode_from_weak_ref(const AssetWeakReference *asset_reference, char r_path_buffer[1282], char **r_dir, char **r_group, char **r_name)
static void update_import_method_for_asset_browsers(Main &bmain)
constexpr bool is_empty() const
constexpr const char * c_str() const
AssetCatalog * find_catalog(CatalogID catalog_id) const
bool write_to_disk(const CatalogFilePath &blend_file_path)
void foreach_loaded_asset_library(FunctionRef< void(AssetLibrary &)> fn, bool include_all_library) const
AssetLibrary * get_asset_library_on_disk_builtin(eAssetLibraryType type, StringRefNull root_path)
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
AssetLibrary * get_asset_library_current_file()
void reload_all_library_catalogs_if_dirty()
std::optional< ExplodedPath > resolve_asset_weak_reference_to_exploded_path(const AssetWeakReference &asset_reference)
static AssetLibrary * move_runtime_current_file_into_on_disk_library(const Main &bmain)
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
static AssetLibraryService * get()
AssetLibrary * get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path)
static std::string root_path_from_library_ref(const AssetLibraryReference &library_reference)
bool has_any_unsaved_catalogs() const
void on_blend_save_post(Main *bmain, PointerRNA **pointers, int num_pointers)
void load_or_reload_catalogs()
static bool save_catalogs_when_file_is_saved
eAssetLibraryType library_type() const
void on_blend_save_handler_register()
std::unique_ptr< AssetCatalogService > catalog_service_
friend class AssetLibraryService
void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings)
std::weak_ptr< AssetRepresentation > add_local_id_asset(ID &id)
friend class AssetRepresentation
bCallbackFuncStore on_save_callback_store_
AssetCatalogService & catalog_service() const
static void foreach_loaded(FunctionRef< void(AssetLibrary &)> fn, bool include_all_library)
AssetLibrary(eAssetLibraryType library_type, StringRef name="", StringRef root_path="")
bool remove_asset(AssetRepresentation &asset)
void refresh_catalog_simplename(AssetMetaData *asset_data)
Mutex catalog_service_mutex_
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
StringRefNull name() const
StringRefNull root_path() const
virtual void refresh_catalogs()
std::weak_ptr< AssetRepresentation > add_external_asset(StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata)
void on_blend_save_handler_unregister()
void update_default_import_method()
IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options, ID *id_self=nullptr) const
AssetLibraryReference all_library_reference()
AssetLibraryReference current_file_library_reference()
void all_library_reload_catalogs_if_dirty()
Vector< AssetLibraryReference > all_valid_asset_library_refs()
FileAssetSelectParams * asset_params
static DynamicLibrary lib