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:
authorHans Goudey <h.goudey@me.com>2022-11-01 18:09:49 +0300
committerHans Goudey <h.goudey@me.com>2022-11-01 18:09:58 +0300
commitcf985180551da833d4160afcdf2cb4292e138174 (patch)
tree03b8301bec77937b1d67653b27e22af76095c345 /source/blender/blenkernel/intern/asset_library.cc
parente6823f32e9a7372ca06a5989d56d855df31afea8 (diff)
Nodes: Add node group assets in add menu
This patch builds on the work from bdb57541475f to add node group assets directly in the node editor add menu. Assets are added after separators to distinguish them, but otherwise they look like any other node. The catalog trees from all configured libraries are used to build the menu hierarchy. Only catalogs with matching asset types are used though. There are a few limitations of this initial version. For now this only supports geometry nodes. Support for other built-in node systems just requires some refactoring of the corresponding add menu though. Lazy loading will be added in a followup commit. For now there is a label the first time the menu is opened. Like the search menu integration, re-saving asset library files in 3.4 is required, if it hasn't been done already. Implementation wise, there is a some ugly code here. A lot of that is because the asset system isn't complete. The RNA API doesn't work well yet, and the system isn't built to interact with multiple libraries at once. It's also ugly because of the way we combine automatic menu generation with builtin menus. As noted in a code comment, these two systems could be merged completely so that the menus for builtin nodes are also generated in the same way. Differential Revision: https://developer.blender.org/D16135
Diffstat (limited to 'source/blender/blenkernel/intern/asset_library.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_library.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset_library.cc b/source/blender/blenkernel/intern/asset_library.cc
index 968873cbcbe..b8420af1168 100644
--- a/source/blender/blenkernel/intern/asset_library.cc
+++ b/source/blender/blenkernel/intern/asset_library.cc
@@ -10,6 +10,7 @@
#include "BKE_main.h"
#include "BKE_preferences.h"
+#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "DNA_asset_types.h"
@@ -19,6 +20,13 @@
bool blender::bke::AssetLibrary::save_catalogs_when_file_is_saved = true;
+blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain,
+ const AssetLibraryReference &library_reference)
+{
+ blender::bke::AssetLibraryService *service = blender::bke::AssetLibraryService::get();
+ return service->get_asset_library(bmain, library_reference);
+}
+
/**
* Loading an asset library at this point only means loading the catalogs. Later on this should
* invoke reading of asset representations too.
@@ -172,4 +180,26 @@ void AssetLibrary::refresh_catalog_simplename(struct AssetMetaData *asset_data)
}
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;
+}
+
} // namespace blender::bke