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-16 17:39:51 +0300
committerJulian Eisel <julian@blender.org>2021-09-16 17:41:31 +0300
commitc9daab7936562b1e02262cd28f1d6cc4dde91d71 (patch)
tree6956cd7b233b0b327164acd583307234b1f007ae
parent73ed07648901c047887f2e8e94750a3eae9afb08 (diff)
Assets: Recursive reading of asset libraries
With this, asset libraries can be directory structures and all assets in sub-directories will show up in an Asset Browser. With complex directory structures and many .blend files inside, asset library reading will be quite slow for now. There's initial work being done to introduce indexing for this (T82979), other optimizations are being discussed as well. Addresses T91406. Differential Revision: https://developer.blender.org/D12139
-rw-r--r--source/blender/blenloader/intern/versioning_300.c13
-rw-r--r--source/blender/editors/space_file/filesel.c3
-rw-r--r--source/blender/makesdna/DNA_space_types.h7
3 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 55aed4ddc2b..538634f4c9e 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1261,5 +1261,18 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+ if (sfile->asset_params) {
+ sfile->asset_params->base_params.recursion_level = FILE_SELECT_MAX_RECURSIONS;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 4ab7014cf82..11b06d2b414 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -135,7 +135,8 @@ static void fileselect_ensure_updated_asset_params(SpaceFile *sfile)
base_params->filter_id = FILTER_ID_OB | FILTER_ID_GR;
base_params->display = FILE_IMGDISPLAY;
base_params->sort = FILE_SORT_ALPHA;
- base_params->recursion_level = 1;
+ /* Asset libraries include all sub-directories, so enable maximal recursion. */
+ base_params->recursion_level = FILE_SELECT_MAX_RECURSIONS;
/* 'SMALL' size by default. More reasonable since this is typically used as regular editor,
* space is more of an issue here. */
base_params->thumbnail_size = 96;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 13e6904662e..5475e1bacd8 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -913,6 +913,13 @@ enum eFileDetails {
#define FILE_MAX_LIBEXTRA (FILE_MAX + MAX_ID_NAME)
+/**
+ * Maximum level of recursions accepted for #FileSelectParams.recursion_level. Rather than a
+ * completely arbitrary limit or none at all, make it just enough to support the most extreme case
+ * where the maximal path length is used with single letter directory/file names only.
+ */
+#define FILE_SELECT_MAX_RECURSIONS (FILE_MAX_LIBEXTRA / 2)
+
/* filesel types */
typedef enum eFileSelectType {
FILE_LOADLIB = 1,