[Bf-blender-cvs] [c9daab79365] master: Assets: Recursive reading of asset libraries

Julian Eisel noreply at git.blender.org
Thu Sep 16 16:41:51 CEST 2021


Commit: c9daab7936562b1e02262cd28f1d6cc4dde91d71
Author: Julian Eisel
Date:   Thu Sep 16 16:39:51 2021 +0200
Branches: master
https://developer.blender.org/rBc9daab7936562b1e02262cd28f1d6cc4dde91d71

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

===================================================================

M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/makesdna/DNA_space_types.h

===================================================================

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,



More information about the Bf-blender-cvs mailing list