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:
authorJulian Eisel <julian@blender.org>2021-09-29 14:18:44 +0300
committerJulian Eisel <julian@blender.org>2021-09-29 14:18:44 +0300
commitadaf4f56e1ed2d8ff55be4681838c9705da022ad (patch)
tree45e3551e250709edad62e220f1c3b41075ae4856 /source/blender/editors/space_file
parent78b9a8c7b993991c22ac2bd1ffbfaf1d896e4431 (diff)
Support loading catalogs in the Current File asset library
When the Asset Browser shows the "Current File" asset library, now it also attempts to load an asset catalog definition file from location of the current .blend file. This happens as follows: * First, see if the file is inside of an asset library that is "mounted" in the Preferences. Load the catalogs from there if so. * Otherwise, if the file is saved, load the catalogs from the directory the file is saved in. * If the file is not saved, no catalogs will be loaded. Unit tests are being worked on in D12689. Creating catalogs from the "Current File" asset library still doesn't work, as the asset catalog service doesn't construct an in-memory catalog definition file in that case yet. Differential Revision: https://developer.blender.org/D12675
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/filelist.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 194e577e19e..60fe5364aba 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -3398,15 +3398,34 @@ static void filelist_readjob_lib(FileListReadJob *job_params,
filelist_readjob_do(true, job_params, stop, do_update, progress);
}
+static void filelist_asset_library_path(const FileListReadJob *job_params,
+ char r_library_root_path[FILE_MAX])
+{
+ if (job_params->filelist->type == FILE_MAIN_ASSET) {
+ /* For the "Current File" library (#FILE_MAIN_ASSET) we get the asset library root path based
+ * on main. */
+ BKE_asset_library_find_suitable_root_path_from_main(job_params->current_main,
+ r_library_root_path);
+ }
+ else {
+ BLI_strncpy(r_library_root_path, job_params->tmp_filelist->filelist.root, FILE_MAX);
+ }
+}
+
+/**
+ * Load asset library data, which currently means loading the asset catalogs for the library.
+ */
static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params, short *do_update)
{
FileList *tmp_filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */
- /* Check whether assets catalogs need to be loaded. */
if (job_params->filelist->asset_library_ref != NULL) {
+ char library_root_path[FILE_MAX];
+ filelist_asset_library_path(job_params, library_root_path);
+
/* Load asset catalogs, into the temp filelist for thread-safety.
* #filelist_readjob_endjob() will move it into the real filelist. */
- tmp_filelist->asset_library = BKE_asset_library_load(tmp_filelist->filelist.root);
+ tmp_filelist->asset_library = BKE_asset_library_load(library_root_path);
*do_update = true;
}
}