[Bf-blender-cvs] [807e85976ae] temp-bundled-assets: initial assets
Jacques Lucke
noreply at git.blender.org
Tue Jan 24 19:29:55 CET 2023
Commit: 807e85976ae0b962740bfff927ba40a13b91df68
Author: Jacques Lucke
Date: Wed Jan 18 16:01:34 2023 +0100
Branches: temp-bundled-assets
https://developer.blender.org/rB807e85976ae0b962740bfff927ba40a13b91df68
initial assets
===================================================================
M source/blender/asset_system/intern/asset_library.cc
M source/blender/asset_system/intern/asset_library_service.cc
M source/blender/editors/asset/intern/asset_library_reference_enum.cc
M source/blender/editors/asset/intern/asset_list.cc
M source/blender/editors/space_file/filesel.cc
M source/blender/makesdna/DNA_asset_types.h
===================================================================
diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc
index 2379e738e37..d7fb16f99ac 100644
--- a/source/blender/asset_system/intern/asset_library.cc
+++ b/source/blender/asset_system/intern/asset_library.cc
@@ -259,6 +259,12 @@ StringRefNull AssetLibrary::root_path() const
Vector<AssetLibraryReference> all_valid_asset_library_refs()
{
Vector<AssetLibraryReference> result;
+ {
+ AssetLibraryReference library_ref{};
+ library_ref.custom_library_index = -1;
+ library_ref.type = ASSET_LIBRARY_BUNDLED;
+ result.append(library_ref);
+ }
int i;
LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
if (!BLI_is_dir(asset_library->path)) {
diff --git a/source/blender/asset_system/intern/asset_library_service.cc b/source/blender/asset_system/intern/asset_library_service.cc
index af48a173bc0..af6011af832 100644
--- a/source/blender/asset_system/intern/asset_library_service.cc
+++ b/source/blender/asset_system/intern/asset_library_service.cc
@@ -60,6 +60,11 @@ AssetLibrary *AssetLibraryService::get_asset_library(
const eAssetLibraryType type = eAssetLibraryType(library_reference.type);
switch (type) {
+ case ASSET_LIBRARY_BUNDLED: {
+ const std::string root_path =
+ "/home/jacques/blender/build_release/bin/3.5/datafiles/assets/base_meshes";
+ return get_asset_library_on_disk(root_path);
+ }
case ASSET_LIBRARY_LOCAL: {
/* For the "Current File" library we get the asset library root path based on main. */
std::string root_path = bmain ? AS_asset_library_find_suitable_root_path_from_main(bmain) :
diff --git a/source/blender/editors/asset/intern/asset_library_reference_enum.cc b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
index d20f3205a77..14051a3adb3 100644
--- a/source/blender/editors/asset/intern/asset_library_reference_enum.cc
+++ b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
@@ -47,7 +47,7 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
if (value < ASSET_LIBRARY_CUSTOM) {
library.type = value;
library.custom_library_index = -1;
- BLI_assert(ELEM(value, ASSET_LIBRARY_ALL, ASSET_LIBRARY_LOCAL));
+ BLI_assert(ELEM(value, ASSET_LIBRARY_ALL, ASSET_LIBRARY_LOCAL, ASSET_LIBRARY_BUNDLED));
return library;
}
@@ -100,6 +100,18 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
RNA_enum_item_add_separator(&item, &totitem);
}
+ {
+ AssetLibraryReference library_reference;
+ library_reference.type = ASSET_LIBRARY_BUNDLED;
+ library_reference.custom_library_index = -1;
+ const int enum_value = ED_asset_library_reference_to_enum_value(&library_reference);
+ EnumPropertyItem tmp = {
+ enum_value, "BUNDLED", ICON_NONE, "Bundled", "Show assets that came bundled with Blender"};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ RNA_enum_item_add_separator(&item, &totitem);
+
int i;
LISTBASE_FOREACH_INDEX (bUserAssetLibrary *, user_library, &U.asset_libraries, i) {
/* Note that the path itself isn't checked for validity here. If an invalid library path is
diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc
index 64934316413..1749391356c 100644
--- a/source/blender/editors/asset/intern/asset_list.cc
+++ b/source/blender/editors/asset/intern/asset_list.cc
@@ -372,6 +372,7 @@ std::optional<eFileSelectType> AssetListStorage::asset_library_reference_to_file
switch (eAssetLibraryType(library_reference.type)) {
case ASSET_LIBRARY_ALL:
return FILE_ASSET_LIBRARY_ALL;
+ case ASSET_LIBRARY_BUNDLED:
case ASSET_LIBRARY_CUSTOM:
return FILE_ASSET_LIBRARY;
case ASSET_LIBRARY_LOCAL:
diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc
index 12d05054e9b..cbd4e1d7836 100644
--- a/source/blender/editors/space_file/filesel.cc
+++ b/source/blender/editors/space_file/filesel.cc
@@ -424,7 +424,13 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params)
}
}
- switch (library->type) {
+ switch (eAssetLibraryType(library->type)) {
+ case ASSET_LIBRARY_BUNDLED:
+ BLI_strncpy(base_params->dir,
+ "/home/jacques/blender/build_release/bin/3.5/datafiles/assets/base_meshes",
+ sizeof(base_params->dir));
+ base_params->type = FILE_ASSET_LIBRARY;
+ break;
case ASSET_LIBRARY_ALL:
base_params->dir[0] = '\0';
base_params->type = FILE_ASSET_LIBRARY_ALL;
diff --git a/source/blender/makesdna/DNA_asset_types.h b/source/blender/makesdna/DNA_asset_types.h
index 195cc059f18..504d05d45dd 100644
--- a/source/blender/makesdna/DNA_asset_types.h
+++ b/source/blender/makesdna/DNA_asset_types.h
@@ -86,7 +86,7 @@ typedef struct AssetMetaData {
typedef enum eAssetLibraryType {
/* For the future. Display assets bundled with Blender by default. */
- // ASSET_LIBRARY_BUNDLED = 0,
+ ASSET_LIBRARY_BUNDLED = 0,
/** Display assets from the current session (current "Main"). */
ASSET_LIBRARY_LOCAL = 1,
ASSET_LIBRARY_ALL = 2,
More information about the Bf-blender-cvs
mailing list