Blender V5.3
filelist_readjob_asset_library_essentials.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "AS_asset_library.hh"
11
12#include "BLI_listbase.hh"
13#include "BLI_path_utils.hh"
14#include "BLI_string.hh"
15
16#include "DNA_asset_types.h"
17
18#include "filelist_intern.hh"
19#include "filelist_readjob.hh"
20
21namespace blender {
22
24 bool *stop,
25 bool *do_update,
26 float *progress)
27{
28 FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */
29 BLI_assert(filelist->filelist.entries.is_empty() &&
31
32 filelist_readjob_load_asset_library_data(job_params, do_update);
33
34 /* A valid, but empty file-list from now. */
35 filelist->filelist.entries_num = 0;
36
37 /* Read the bundled essentials. */
41 filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);
42 }
43 else {
44 /* Can't actually be selected from the UI. But be nice and support loading just the online
45 * essentials. Scripts may want to do that. */
47 }
48
49 /* The rest of the function handles online essentials. Can exit early if these are disabled. */
50 if (!(U.asset_flag & USER_ASSETS_USE_ONLINE_ESSENTIALS)) {
51 return;
52 }
53
54 /* Override library info to read online essentials. */
57
59 BLI_path_slash_ensure(filelist->filelist.root, sizeof(filelist->filelist.root));
60
61 if (job_params->remote_library_requests.is_empty()) {
62 filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);
63 return;
64 }
65 BLI_assert_msg(job_params->remote_library_requests.size() <= 1,
66 "reading callback for a single remote library should only have a single remote "
67 "library request registered (check what the starting callback is requesting)");
68 for (auto [url, request] : job_params->remote_library_requests.items()) {
69 /* Will load the already downloaded online essentials. */
70 remote_asset_library_load(job_params, *request, stop, do_update, progress);
71 break;
72 }
73}
74
76{
77 /* Request online essentials library (#remote_asset_library_request() will check if online access
78 * is enabled). */
83}
84
95
96} // namespace blender
#define BLI_assert_msg(a, msg)
#define FILEDIR_NBR_ENTRIES_UNSET
StringRefNull online_essentials_cache_directory_path()
StringRefNull online_essentials_url()
StringRefNull essentials_directory_path()
AssetLibraryReference online_essentials_library_reference()
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ USER_ASSETS_USE_ONLINE_ESSENTIALS
char * STRNCPY(char(&dst)[N], const char *src)
void remote_asset_library_request(FileListReadJob *job_params, const asset_system::RemoteLibraryDefinitionRef &library)
bool is_filtered_asset_library(FileListInternEntry *file, const char *root, FileListFilter *filter)
void prepare_filter_asset_library(const FileList *filelist, FileListFilter *filter)
@ ASSET_LIBRARY_ESSENTIALS
@ ASSET_LIBRARY_ONLINE_ESSENTIALS
void remote_asset_library_load(FileListReadJob *job_params, RemoteLibraryRequest &request, bool *stop, bool *do_update, float *progress)
void filelist_set_readjob_essentials_asset_library(FileList *filelist)
bool filelist_checkdir_return_always_valid(const FileList *, char[1024+258], const bool)
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
void filelist_readjob_load_asset_library_data(FileListReadJob *job_params, bool *do_update)
static void filelist_start_job_essentials_asset_library(FileListReadJob *job_params)
asset_system::AssetLibrary * AS_asset_library_load(const Main *bmain, const AssetLibraryReference &library_reference)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
@ FILELIST_TAGS_APPLY_FUZZY_SEARCH
void filelist_timer_step_remote_asset_library(FileListReadJob *job_params)
static void filelist_readjob_essentials_asset_library(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress)
void filelist_readjob_recursive_dir_add_items(const bool do_lib, FileListReadJob *job_params, const bool *stop, bool *do_update, float *progress)
ListBaseT< struct FileListInternEntry > entries
asset_system::AssetLibrary * load_asset_library
Map< std::string, std::unique_ptr< RemoteLibraryRequest > > remote_library_requests
void(*) prepare_filter_fn(const FileList *filelist, FileListFilter *filter)
void(*) timer_step_fn(FileListReadJob *job_params)
bool(*) check_dir_fn(const FileList *filelist, char dirpath[FILE_MAX_LIBEXTRA], const bool do_change)
void(*) start_job_fn(FileListReadJob *job_params)
AssetLibraryReference * asset_library_ref
void(*) read_job_fn(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress)
FileDirEntryArr filelist
bool(*) filter_fn(FileListInternEntry *file, const char *root, FileListFilter *filter)