diff options
author | Hans Goudey <h.goudey@me.com> | 2022-11-01 18:09:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-11-01 18:09:58 +0300 |
commit | cf985180551da833d4160afcdf2cb4292e138174 (patch) | |
tree | 03b8301bec77937b1d67653b27e22af76095c345 /source/blender/editors/asset | |
parent | e6823f32e9a7372ca06a5989d56d855df31afea8 (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/editors/asset')
-rw-r--r-- | source/blender/editors/asset/ED_asset_list.h | 1 | ||||
-rw-r--r-- | source/blender/editors/asset/intern/asset_list.cc | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/editors/asset/ED_asset_list.h b/source/blender/editors/asset/ED_asset_list.h index b54f81004f2..3d2aaa3bda1 100644 --- a/source/blender/editors/asset/ED_asset_list.h +++ b/source/blender/editors/asset/ED_asset_list.h @@ -23,6 +23,7 @@ struct wmNotifier; */ void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference, const struct bContext *C); +bool ED_assetlist_is_loaded(const struct AssetLibraryReference *library_reference); void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference, const struct bContext *C); void ED_assetlist_clear(const struct AssetLibraryReference *library_reference, struct bContext *C); diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index 7fdb924d769..01a6dc46c48 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -422,6 +422,18 @@ void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference, AssetListStorage::fetch_library(*library_reference, *C); } +bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference) +{ + AssetList *list = AssetListStorage::lookup_list(*library_reference); + if (!list) { + return false; + } + if (list->needsRefetch()) { + return false; + } + return true; +} + void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference, const bContext *C) { |