[Bf-blender-cvs] [d7936c2de04] temp-asset-representation: Merge branch 'master' into temp-asset-representation

Julian Eisel noreply at git.blender.org
Wed Nov 2 12:21:11 CET 2022


Commit: d7936c2de0410141621d6ca7ccf6441135fd9958
Author: Julian Eisel
Date:   Wed Nov 2 12:20:55 2022 +0100
Branches: temp-asset-representation
https://developer.blender.org/rBd7936c2de0410141621d6ca7ccf6441135fd9958

Merge branch 'master' into temp-asset-representation

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



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

diff --cc source/blender/blenkernel/BKE_asset_library.hh
index fe3ddf805c0,2058df71f6a..e089e30c345
--- a/source/blender/blenkernel/BKE_asset_library.hh
+++ b/source/blender/blenkernel/BKE_asset_library.hh
@@@ -10,9 -10,8 +10,11 @@@
  #  error This is a C++-only header file. Use BKE_asset_library.h instead.
  #endif
  
+ #include "DNA_asset_types.h"
+ 
 +#include "BLI_string_ref.hh"
 +#include "BLI_vector.hh"
 +
  #include "BKE_asset_library.h"
  
  #include "BKE_asset_catalog.hh"
diff --cc source/blender/blenkernel/intern/asset_catalog.cc
index e19982155b4,62d03b2d79b..a9fe59eba64
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@@ -513,9 -515,8 +514,8 @@@ CatalogFilePath AssetCatalogService::fi
      char asset_lib_cdf_path[PATH_MAX];
      BLI_path_join(asset_lib_cdf_path,
                    sizeof(asset_lib_cdf_path),
 -                  suitable_root_path,
 +                  suitable_root_path.c_str(),
-                   DEFAULT_CATALOG_FILENAME.c_str(),
-                   nullptr);
+                   DEFAULT_CATALOG_FILENAME.c_str());
      return asset_lib_cdf_path;
    }
  
diff --cc source/blender/blenkernel/intern/asset_library.cc
index dc67f2c4453,b8420af1168..0e14ad2b4cc
--- a/source/blender/blenkernel/intern/asset_library.cc
+++ b/source/blender/blenkernel/intern/asset_library.cc
@@@ -181,10 -181,25 +182,31 @@@ void AssetLibrary::refresh_catalog_simp
    STRNCPY(asset_data->catalog_simple_name, catalog->simple_name.c_str());
  }
  
+ Vector<AssetLibraryReference> all_valid_asset_library_refs()
+ {
+   Vector<AssetLibraryReference> result;
+   int i;
+   LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
+     if (!BLI_is_dir(asset_library->path)) {
+       continue;
+     }
+     AssetLibraryReference library_ref{};
+     library_ref.custom_library_index = i;
+     library_ref.type = ASSET_LIBRARY_CUSTOM;
+     result.append(library_ref);
+   }
+ 
+   AssetLibraryReference library_ref{};
+   library_ref.custom_library_index = -1;
+   library_ref.type = ASSET_LIBRARY_LOCAL;
+   result.append(library_ref);
+   return result;
+ }
+ 
 +AssetRepresentation &AssetStorage::append(std::unique_ptr<AssetRepresentation> asset)
 +{
 +  assets_.append(std::move(asset));
 +  return *assets_.last();
 +}
 +
  }  // namespace blender::bke
diff --cc source/blender/editors/space_file/filelist.cc
index b4b41d73b39,3257534f94d..f2d407e0455
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@@ -118,9 -114,10 +118,12 @@@ struct FileListInternEntry 
    /** When the file represents an asset read from another file, it is stored here.
     * Owning pointer. */
    AssetMetaData *imported_asset_data;
 +  /* References an asset in the asset library storage. */
 +  bke::AssetRepresentation *asset; /* Non-owning. */
  
+   /* See #FILE_ENTRY_BLENDERLIB_NO_PREVIEW. */
+   bool blenderlib_has_no_preview;
+ 
    /** Defined in BLI_fileops.h */
    eFileAttributes attributes;
    BLI_stat_t st;
@@@ -3001,17 -3009,14 +3016,22 @@@ static void filelist_readjob_list_lib_a
      entry->relpath = BLI_strdup(datablock_info->name);
    }
    entry->typeflag |= FILE_TYPE_BLENDERLIB;
-   if (datablock_info && datablock_info->asset_data) {
-     entry->typeflag |= FILE_TYPE_ASSET;
-     /* Moves ownership! */
-     entry->imported_asset_data = datablock_info->asset_data;
-     if (filelist->asset_library) {
-       /* TODO imported_asset_data points to moved from data */
-       /* TODO copying asset metadata like this does a shallow copy. E.g. custom properties are not
-        * duplicated properly. */
-       std::unique_ptr asset = std::make_unique<bke::AssetRepresentation>(
-           std::move(*datablock_info->asset_data));
-       entry->asset = &filelist->asset_library->asset_storage.append(std::move(asset));
 -
+   if (datablock_info) {
+     entry->blenderlib_has_no_preview = datablock_info->no_preview_found;
+ 
+     if (datablock_info->asset_data) {
+       entry->typeflag |= FILE_TYPE_ASSET;
+       /* Moves ownership! */
+       entry->imported_asset_data = datablock_info->asset_data;
++
++      if (filelist->asset_library) {
++        /* TODO imported_asset_data points to moved from data */
++        /* TODO copying asset metadata like this does a shallow copy. E.g. custom properties are not
++         * duplicated properly. */
++        std::unique_ptr asset = std::make_unique<bke::AssetRepresentation>(
++            std::move(*datablock_info->asset_data));
++        entry->asset = &filelist->asset_library->asset_storage.append(std::move(asset));
++      }
      }
    }
    entry->blentype = idcode;



More information about the Bf-blender-cvs mailing list