[Bf-blender-cvs] [ea2dda306c7] master: Asset system: New asset system code module (with files from BKE)
Julian Eisel
noreply at git.blender.org
Mon Nov 14 12:48:42 CET 2022
Commit: ea2dda306c7d017618042a1b311caaae202ab1ca
Author: Julian Eisel
Date: Mon Nov 14 12:41:55 2022 +0100
Branches: master
https://developer.blender.org/rBea2dda306c7d017618042a1b311caaae202ab1ca
Asset system: New asset system code module (with files from BKE)
Adds a new `source/blender/asset_system` directory and moves asset
related files from BKE to it. More asset related code can follow
(e.g. asset indexing, ED_assetlist stuff) but needs further work to
untangle it. I also kept `BKE_asset.h` and `asset.cc` as is, since they
deal with asset DNA data mostly, thus make sense in BKE.
Motivation:
- Makes the asset system design more present (term wasn't even used in
code before).
- An `asset_system` directory is quite descriptive (trivial to identify
core asset system features) and makes it easy to find asset code.
- Asset system is mostly runtime data, with little relation to other
`Main`/BKE/DNA types.
- There's a lot of stuff in BKE already. It shouldn't be just a dump for
all stuff that seems core enough.
- Being its own directly helps us be more mindful about encapsulating
the module well, and avoiding dependencies on other modules.
- We can be more free with splitting files here than in BKE.
- In future there might be an asset system BPY module, which would then
map quite nicely to the `asset_system` directory.
Checked with some other core devs, consensus seems that this makes
sense.
===================================================================
M source/blender/CMakeLists.txt
R098 source/blender/blenkernel/BKE_asset_catalog.hh source/blender/asset_system/AS_asset_catalog.hh
R097 source/blender/blenkernel/BKE_asset_catalog_path.hh source/blender/asset_system/AS_asset_catalog_path.hh
R069 source/blender/blenkernel/BKE_asset_library.h source/blender/asset_system/AS_asset_library.h
R085 source/blender/blenkernel/BKE_asset_library.hh source/blender/asset_system/AS_asset_library.hh
A source/blender/asset_system/AS_asset_representation.h
R095 source/blender/blenkernel/BKE_asset_representation.hh source/blender/asset_system/AS_asset_representation.hh
A source/blender/asset_system/CMakeLists.txt
R099 source/blender/blenkernel/intern/asset_catalog.cc source/blender/asset_system/intern/asset_catalog.cc
R097 source/blender/blenkernel/intern/asset_catalog_path.cc source/blender/asset_system/intern/asset_catalog_path.cc
R075 source/blender/blenkernel/intern/asset_library.cc source/blender/asset_system/intern/asset_library.cc
R094 source/blender/blenkernel/intern/asset_library_service.cc source/blender/asset_system/intern/asset_library_service.cc
R094 source/blender/blenkernel/intern/asset_library_service.hh source/blender/asset_system/intern/asset_library_service.hh
R065 source/blender/blenkernel/intern/asset_representation.cc source/blender/asset_system/intern/asset_representation.cc
R098 source/blender/blenkernel/intern/asset_catalog_path_test.cc source/blender/asset_system/tests/asset_catalog_path_test.cc
R099 source/blender/blenkernel/intern/asset_catalog_test.cc source/blender/asset_system/tests/asset_catalog_test.cc
R098 source/blender/blenkernel/intern/asset_library_service_test.cc source/blender/asset_system/tests/asset_library_service_test.cc
R078 source/blender/blenkernel/intern/asset_library_test.cc source/blender/asset_system/tests/asset_library_test.cc
M source/blender/blenkernel/BKE_asset.h
M source/blender/blenkernel/CMakeLists.txt
R100 source/blender/blenkernel/intern/asset_test.cc source/blender/blenkernel/intern/asset_metadata_test.cc
M source/blender/blenkernel/intern/lib_id_delete.c
M source/blender/editors/asset/CMakeLists.txt
M source/blender/editors/asset/ED_asset_catalog.hh
M source/blender/editors/asset/intern/asset_catalog.cc
M source/blender/editors/asset/intern/asset_handle.cc
M source/blender/editors/asset/intern/asset_indexer.cc
M source/blender/editors/asset/intern/asset_ops.cc
M source/blender/editors/interface/CMakeLists.txt
M source/blender/editors/space_file/CMakeLists.txt
M source/blender/editors/space_file/asset_catalog_tree_view.cc
M source/blender/editors/space_file/file_intern.h
M source/blender/editors/space_file/filelist.cc
M source/blender/editors/space_node/CMakeLists.txt
M source/blender/editors/space_node/add_menu_assets.cc
M source/blender/editors/space_node/add_node_search.cc
M source/blender/editors/util/CMakeLists.txt
M source/blender/makesrna/intern/CMakeLists.txt
M source/blender/makesrna/intern/rna_asset.c
M source/blender/makesrna/intern/rna_space.c
M source/blender/windowmanager/CMakeLists.txt
M source/blender/windowmanager/intern/wm_files.c
===================================================================
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 4dd596ad93a..0df742603f1 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -129,6 +129,7 @@ set(SRC_DNA_DEFAULTS_INC
add_subdirectory(datatoc)
add_subdirectory(editors)
add_subdirectory(windowmanager)
+add_subdirectory(asset_system)
add_subdirectory(blenkernel)
add_subdirectory(blenlib)
add_subdirectory(bmesh)
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/asset_system/AS_asset_catalog.hh
similarity index 98%
rename from source/blender/blenkernel/BKE_asset_catalog.hh
rename to source/blender/asset_system/AS_asset_catalog.hh
index 73c2e00c4c4..8160676603d 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/asset_system/AS_asset_catalog.hh
@@ -1,15 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
- * \ingroup bke
+ * \ingroup asset_system
*/
#pragma once
-#ifndef __cplusplus
-# error This is a C++ header. The C interface is yet to be implemented/designed.
-#endif
-
#include "BLI_function_ref.hh"
#include "BLI_map.hh"
#include "BLI_set.hh"
@@ -17,14 +13,14 @@
#include "BLI_uuid.h"
#include "BLI_vector.hh"
-#include "BKE_asset_catalog_path.hh"
+#include "AS_asset_catalog_path.hh"
#include <map>
#include <memory>
#include <set>
#include <string>
-namespace blender::bke {
+namespace blender::asset_system {
class AssetCatalog;
class AssetCatalogCollection;
@@ -521,4 +517,4 @@ class AssetCatalogFilter {
Set<CatalogID> &&known_catalog_ids);
};
-} // namespace blender::bke
+} // namespace blender::asset_system
diff --git a/source/blender/blenkernel/BKE_asset_catalog_path.hh b/source/blender/asset_system/AS_asset_catalog_path.hh
similarity index 97%
rename from source/blender/blenkernel/BKE_asset_catalog_path.hh
rename to source/blender/asset_system/AS_asset_catalog_path.hh
index 93ab0389daf..0ac50ab00c9 100644
--- a/source/blender/blenkernel/BKE_asset_catalog_path.hh
+++ b/source/blender/asset_system/AS_asset_catalog_path.hh
@@ -1,22 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
- * \ingroup bke
+ * \ingroup asset_system
*/
#pragma once
-#ifndef __cplusplus
-# error This is a C++ header.
-#endif
-
#include "BLI_function_ref.hh"
#include "BLI_string_ref.hh"
#include "BLI_sys_types.h"
#include <string>
-namespace blender::bke {
+namespace blender::asset_system {
/**
* Location of an Asset Catalog in the catalog tree, denoted by slash-separated path components.
@@ -129,4 +125,4 @@ class AssetCatalogPath {
/** Output the path as string. */
std::ostream &operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append);
-} // namespace blender::bke
+} // namespace blender::asset_system
diff --git a/source/blender/blenkernel/BKE_asset_library.h b/source/blender/asset_system/AS_asset_library.h
similarity index 69%
rename from source/blender/blenkernel/BKE_asset_library.h
rename to source/blender/asset_system/AS_asset_library.h
index fc648ff6976..8c5c4633c4e 100644
--- a/source/blender/blenkernel/BKE_asset_library.h
+++ b/source/blender/asset_system/AS_asset_library.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
- * \ingroup bke
+ * \ingroup asset_system
*/
#pragma once
@@ -23,18 +23,18 @@ typedef struct AssetLibrary AssetLibrary;
*
* To get the in-memory-only "current file" asset library, pass an empty path.
*/
-struct AssetLibrary *BKE_asset_library_load(const char *library_path);
+struct AssetLibrary *AS_asset_library_load(const char *library_path);
/** Look up the asset's catalog and copy its simple name into #asset_data. */
-void BKE_asset_library_refresh_catalog_simplename(struct AssetLibrary *asset_library,
- struct AssetMetaData *asset_data);
+void AS_asset_library_refresh_catalog_simplename(struct AssetLibrary *asset_library,
+ struct AssetMetaData *asset_data);
/** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */
-bool BKE_asset_library_has_any_unsaved_catalogs(void);
+bool AS_asset_library_has_any_unsaved_catalogs(void);
/** An asset library can include local IDs (IDs in the current file). Their pointers need to be
* remapped on change (or assets removed as IDs gets removed). */
-void BKE_asset_library_remap_ids(struct IDRemapper *mappings);
+void AS_asset_library_remap_ids(struct IDRemapper *mappings);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh
similarity index 85%
rename from source/blender/blenkernel/BKE_asset_library.hh
rename to source/blender/asset_system/AS_asset_library.hh
index f69847bd1ed..a0f1214ad39 100644
--- a/source/blender/blenkernel/BKE_asset_library.hh
+++ b/source/blender/asset_system/AS_asset_library.hh
@@ -1,31 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
- * \ingroup bke
+ * \ingroup asset_system
*/
#pragma once
-#ifndef __cplusplus
-# 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"
+#include "AS_asset_catalog.hh"
#include "BKE_callbacks.h"
#include <memory>
+struct AssetLibrary;
struct AssetLibraryReference;
+struct AssetMetaData;
struct Main;
-namespace blender::bke {
+namespace blender::asset_system {
class AssetRepresentation;
@@ -101,10 +97,10 @@ struct AssetLibrary {
Vector<AssetLibraryReference> all_valid_asset_library_refs();
-} // namespace blender::bke
+} // namespace blender::asset_system
-blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain,
- const AssetLibraryReference &library_reference);
+blender::asset_system::AssetLibrary *AS_asset_library_load(
+ const Main *bmain, const AssetLibraryReference &library_reference);
/**
* Try to find an appropriate location for an asset library root from a file or directory path.
@@ -127,19 +123,20 @@ blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain,
* \return True if the function could find a valid, that is, a non-empty path to return in \a
* r_library_path.
*/
-std::string BKE_asset_library_find_suitable_root_path_from_path(blender::StringRefNull input_path);
+std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRefNull input_path);
/**
* Uses the current location on disk of the file represented by \a bmain as input to
- * #BKE_asset_library_find_suitable_root_path_from_path(). Refer to it for a design
+ * #AS_asset_library_find_suitable_root_path_from_path(). Refer to it for a design
* description.
*
* \return True if the function could find a valid, that is, a non-empty path to return in \a
* r_library_path. If \a bmain wasn't saved into a file yet, the return value will be
* false.
*/
-std::string BKE_asset_library_find_suitable_root_path_from_main(const struct Main *bmain);
+std::string AS_asset_library_find_suitable_root_path_from_main(const struct Main *bmain);
-blender::bke::AssetCatalogService *BKE_asset_library_get_catalog_service(
+blender::asset_system::AssetCatalogService *AS_asset_library_get_catalog_service(
+ const ::AssetLibrary *library);
+blender::asset_system::AssetCatalogTree *AS_asset_library_get_catalog_tree(
const ::AssetLibrary *library);
-blender::bke::AssetCatalogTree *BKE_asset_library_get_catalog_tree(const ::AssetLibrary *library);
diff --git a/source/blender/asset_system/AS_asset_representation.h b/source/blender/asset_system/AS_asset_representation.h
new file mode 100644
index 00000000000..6a5425979aa
--- /dev/null
+++ b/source/blender/asset_system/AS_asset_representation.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup asset_system
+ */
+
+#pragma once
+
+#include "BLI_compiler_attrs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AssetMetaData;
+
+/** C handle for #asset_system::AssetRepresentation. */
+typedef struct AssetRepresentation AssetRepresentation;
+
+const char *AS_asset_representation_name_get(const AssetRepresentation *asset)
+ ATTR_WARN_UNUSED_RESULT;
+AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset)
+ ATTR_WARN_UNUSED_RESULT;
+bool AS_asset_representation_is_local_id(const AssetRepresentation *asset) ATTR_WARN_UNUSED_RESULT;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/blenkernel/BKE_asset_representation.hh b/source/blender/asset_system/AS_asset_representation.hh
similarity index 95%
rename from source/blender/blenkernel/BKE_asset_representation.hh
rename to source/blender/asset_system/AS_asset_representation.hh
index edaa5a203ba..66c49c445dc 100644
--- a/source/blender/blenkernel/BKE_asset_representation.hh
+++ b/source/blender/asset_system/AS_asset_representation.hh
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
- * \ingroup bke
+ * \ingroup asset_system
*/
#pragma once
@@ -14,7 +14,7 @@
struct AssetMetaData;
struct ID;
-namespace blender::bke {
+namespace blender::asset_system {
/**
* \brief Abstraction to reference an asset, with necessary data for display & interaction.
@@ -61,4 +61,4 @@ class AssetRepresentation {
bool is_local_id() const;
};
-} // namespace blender::bke
+} // namespace blender::asset_system
diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt
new file mode 100644
index 00000000000..8bf7a135155
--- /dev/null
+++ b/source/blender/asset_system/CMakeLists.txt
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+set(INC
+ .
+ intern
+ ../blenkernel
+ ../blenlib
+ ../makesdna
+ ../../../intern/clog
+ ../../../intern/guardedalloc
+)
+
+set(INC_SYS
+)
+
+set(SRC
+ intern/asset_catalog.cc
+ intern/asset_catalog_path.cc
+ intern/asset_library.cc
+ intern/asset_library_service.cc
+ int
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list