Initial Grease Pencil 3.0 stage #106848

Merged
Falk David merged 224 commits from filedescriptor/blender:grease-pencil-v3 into main 2023-05-30 11:14:22 +02:00
49 changed files with 367 additions and 283 deletions
Showing only changes of commit 99bde3d4f3 - Show all commits

View File

@ -953,9 +953,9 @@ void GHOST_WindowWayland::setOpaque() const
struct wl_region *region; struct wl_region *region;
/* Make the window opaque. */ /* Make the window opaque. */
region = wl_compositor_create_region(system_->compositor()); region = wl_compositor_create_region(system_->wl_compositor());
wl_region_add(region, 0, 0, UNPACK2(window_->size)); wl_region_add(region, 0, 0, UNPACK2(window_->size));
wl_surface_set_opaque_region(window_->surface, region); wl_surface_set_opaque_region(window_->wl_surface, region);
wl_region_destroy(region); wl_region_destroy(region);
} }
#endif #endif

View File

@ -129,6 +129,7 @@ set(SRC_DNA_DEFAULTS_INC
add_subdirectory(datatoc) add_subdirectory(datatoc)
add_subdirectory(editors) add_subdirectory(editors)
add_subdirectory(windowmanager) add_subdirectory(windowmanager)
add_subdirectory(asset_system)
add_subdirectory(blenkernel) add_subdirectory(blenkernel)
add_subdirectory(blenlib) add_subdirectory(blenlib)
add_subdirectory(bmesh) add_subdirectory(bmesh)

View File

@ -1,15 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #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_function_ref.hh"
#include "BLI_map.hh" #include "BLI_map.hh"
#include "BLI_set.hh" #include "BLI_set.hh"
@ -17,14 +13,14 @@
#include "BLI_uuid.h" #include "BLI_uuid.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "BKE_asset_catalog_path.hh" #include "AS_asset_catalog_path.hh"
#include <map> #include <map>
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
namespace blender::bke { namespace blender::asset_system {
class AssetCatalog; class AssetCatalog;
class AssetCatalogCollection; class AssetCatalogCollection;
@ -521,4 +517,4 @@ class AssetCatalogFilter {
Set<CatalogID> &&known_catalog_ids); Set<CatalogID> &&known_catalog_ids);
}; };
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,22 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #pragma once
#ifndef __cplusplus
# error This is a C++ header.
#endif
#include "BLI_function_ref.hh" #include "BLI_function_ref.hh"
#include "BLI_string_ref.hh" #include "BLI_string_ref.hh"
#include "BLI_sys_types.h" #include "BLI_sys_types.h"
#include <string> #include <string>
namespace blender::bke { namespace blender::asset_system {
/** /**
* Location of an Asset Catalog in the catalog tree, denoted by slash-separated path components. * 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. */ /** Output the path as string. */
std::ostream &operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append); std::ostream &operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append);
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #pragma once
@ -23,18 +23,18 @@ typedef struct AssetLibrary AssetLibrary;
* *
* To get the in-memory-only "current file" asset library, pass an empty path. * 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. */ /** 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, void AS_asset_library_refresh_catalog_simplename(struct AssetLibrary *asset_library,
struct AssetMetaData *asset_data); struct AssetMetaData *asset_data);
/** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */ /** 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 /** 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). */ * 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 #ifdef __cplusplus
} }

View File

@ -1,31 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #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 "DNA_asset_types.h"
#include "BLI_string_ref.hh" #include "BLI_string_ref.hh"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "BKE_asset_library.h" #include "AS_asset_catalog.hh"
#include "BKE_asset_catalog.hh"
#include "BKE_callbacks.h" #include "BKE_callbacks.h"
#include <memory> #include <memory>
struct AssetLibrary;
struct AssetLibraryReference; struct AssetLibraryReference;
struct AssetMetaData;
struct Main; struct Main;
namespace blender::bke { namespace blender::asset_system {
class AssetRepresentation; class AssetRepresentation;
@ -101,10 +97,10 @@ struct AssetLibrary {
Vector<AssetLibraryReference> all_valid_asset_library_refs(); Vector<AssetLibraryReference> all_valid_asset_library_refs();
} // namespace blender::bke } // namespace blender::asset_system
blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain, blender::asset_system::AssetLibrary *AS_asset_library_load(
const AssetLibraryReference &library_reference); const Main *bmain, const AssetLibraryReference &library_reference);
/** /**
* Try to find an appropriate location for an asset library root from a file or directory path. * 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 * \return True if the function could find a valid, that is, a non-empty path to return in \a
* r_library_path. * 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 * 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. * description.
* *
* \return True if the function could find a valid, that is, a non-empty path to return in \a * \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 * r_library_path. If \a bmain wasn't saved into a file yet, the return value will be
* false. * 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); const ::AssetLibrary *library);
blender::bke::AssetCatalogTree *BKE_asset_library_get_catalog_tree(const ::AssetLibrary *library);

View File

@ -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

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #pragma once
@ -14,7 +14,7 @@
struct AssetMetaData; struct AssetMetaData;
struct ID; struct ID;
namespace blender::bke { namespace blender::asset_system {
/** /**
* \brief Abstraction to reference an asset, with necessary data for display & interaction. * \brief Abstraction to reference an asset, with necessary data for display & interaction.
@ -61,4 +61,4 @@ class AssetRepresentation {
bool is_local_id() const; bool is_local_id() const;
}; };
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -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
intern/asset_representation.cc
AS_asset_catalog.hh
AS_asset_catalog_path.hh
AS_asset_library.hh
AS_asset_representation.hh
intern/asset_library_service.hh
AS_asset_library.h
AS_asset_representation.h
)
set(LIB
)
blender_add_lib(bf_asset_system "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(WITH_GTESTS)
set(TEST_SRC
tests/asset_catalog_test.cc
tests/asset_catalog_path_test.cc
tests/asset_library_service_test.cc
tests/asset_library_test.cc
)
set(TEST_LIB
bf_asset_system
)
include(GTestTesting)
blender_add_test_lib(bf_asset_system_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
endif()

View File

@ -1,15 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#include <fstream> #include <fstream>
#include <set> #include <set>
#include "BKE_asset_catalog.hh" #include "AS_asset_catalog.hh"
#include "BKE_asset_library.h" #include "AS_asset_library.h"
#include "BKE_asset_library.hh" #include "AS_asset_library.hh"
#include "BLI_fileops.hh" #include "BLI_fileops.hh"
#include "BLI_path_util.h" #include "BLI_path_util.h"
@ -21,9 +21,9 @@
#include "CLG_log.h" #include "CLG_log.h"
static CLG_LogRef LOG = {"bke.asset_service"}; static CLG_LogRef LOG = {"asset_system.asset_catalog_service"};
namespace blender::bke { namespace blender::asset_system {
const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt"; const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt";
@ -508,7 +508,7 @@ CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing(
"catalog definition file should be put"); "catalog definition file should be put");
/* Ask the asset library API for an appropriate location. */ /* Ask the asset library API for an appropriate location. */
const std::string suitable_root_path = BKE_asset_library_find_suitable_root_path_from_path( const std::string suitable_root_path = AS_asset_library_find_suitable_root_path_from_path(
blend_file_path); blend_file_path);
if (!suitable_root_path.empty()) { if (!suitable_root_path.empty()) {
char asset_lib_cdf_path[PATH_MAX]; char asset_lib_cdf_path[PATH_MAX];
@ -1132,4 +1132,4 @@ bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const
return known_catalog_ids.contains(asset_catalog_id); return known_catalog_ids.contains(asset_catalog_id);
} }
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,14 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#include "BKE_asset_catalog_path.hh" #include "AS_asset_catalog_path.hh"
#include "BLI_path_util.h" #include "BLI_path_util.h"
namespace blender::bke { namespace blender::asset_system {
const char AssetCatalogPath::SEPARATOR = '/'; const char AssetCatalogPath::SEPARATOR = '/';
@ -221,4 +221,4 @@ AssetCatalogPath AssetCatalogPath::rebase(const AssetCatalogPath &from_path,
return to_path / path_suffix; return to_path / path_suffix;
} }
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,13 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#include <memory> #include <memory>
#include "BKE_asset_library.hh" #include "AS_asset_library.h"
#include "BKE_asset_representation.hh" #include "AS_asset_library.hh"
#include "AS_asset_representation.hh"
#include "BKE_lib_remap.h" #include "BKE_lib_remap.h"
#include "BKE_main.h" #include "BKE_main.h"
#include "BKE_preferences.h" #include "BKE_preferences.h"
@ -21,12 +23,15 @@
#include "asset_library_service.hh" #include "asset_library_service.hh"
bool blender::bke::AssetLibrary::save_catalogs_when_file_is_saved = true; using namespace blender;
using namespace blender::asset_system;
blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain, bool asset_system::AssetLibrary::save_catalogs_when_file_is_saved = true;
const AssetLibraryReference &library_reference)
asset_system::AssetLibrary *AS_asset_library_load(const Main *bmain,
const AssetLibraryReference &library_reference)
{ {
blender::bke::AssetLibraryService *service = blender::bke::AssetLibraryService::get(); AssetLibraryService *service = AssetLibraryService::get();
return service->get_asset_library(bmain, library_reference); return service->get_asset_library(bmain, library_reference);
} }
@ -34,26 +39,26 @@ blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain,
* Loading an asset library at this point only means loading the catalogs. Later on this should * Loading an asset library at this point only means loading the catalogs. Later on this should
* invoke reading of asset representations too. * invoke reading of asset representations too.
*/ */
struct AssetLibrary *BKE_asset_library_load(const char *library_path) struct ::AssetLibrary *AS_asset_library_load(const char *library_path)
{ {
blender::bke::AssetLibraryService *service = blender::bke::AssetLibraryService::get(); AssetLibraryService *service = AssetLibraryService::get();
blender::bke::AssetLibrary *lib; asset_system::AssetLibrary *lib;
if (library_path == nullptr || library_path[0] == '\0') { if (library_path == nullptr || library_path[0] == '\0') {
lib = service->get_asset_library_current_file(); lib = service->get_asset_library_current_file();
} }
else { else {
lib = service->get_asset_library_on_disk(library_path); lib = service->get_asset_library_on_disk(library_path);
} }
return reinterpret_cast<struct AssetLibrary *>(lib); return reinterpret_cast<struct ::AssetLibrary *>(lib);
} }
bool BKE_asset_library_has_any_unsaved_catalogs() bool AS_asset_library_has_any_unsaved_catalogs()
{ {
blender::bke::AssetLibraryService *service = blender::bke::AssetLibraryService::get(); AssetLibraryService *service = AssetLibraryService::get();
return service->has_any_unsaved_catalogs(); return service->has_any_unsaved_catalogs();
} }
std::string BKE_asset_library_find_suitable_root_path_from_path( std::string AS_asset_library_find_suitable_root_path_from_path(
const blender::StringRefNull input_path) const blender::StringRefNull input_path)
{ {
if (bUserAssetLibrary *preferences_lib = BKE_preferences_asset_library_containing_path( if (bUserAssetLibrary *preferences_lib = BKE_preferences_asset_library_containing_path(
@ -66,27 +71,25 @@ std::string BKE_asset_library_find_suitable_root_path_from_path(
return buffer; return buffer;
} }
std::string BKE_asset_library_find_suitable_root_path_from_main(const Main *bmain) std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain)
{ {
return BKE_asset_library_find_suitable_root_path_from_path(bmain->filepath); return AS_asset_library_find_suitable_root_path_from_path(bmain->filepath);
} }
blender::bke::AssetCatalogService *BKE_asset_library_get_catalog_service( AssetCatalogService *AS_asset_library_get_catalog_service(const ::AssetLibrary *library_c)
const ::AssetLibrary *library_c)
{ {
if (library_c == nullptr) { if (library_c == nullptr) {
return nullptr; return nullptr;
} }
const blender::bke::AssetLibrary &library = reinterpret_cast<const blender::bke::AssetLibrary &>( const asset_system::AssetLibrary &library = reinterpret_cast<const asset_system::AssetLibrary &>(
*library_c); *library_c);
return library.catalog_service.get(); return library.catalog_service.get();
} }
blender::bke::AssetCatalogTree *BKE_asset_library_get_catalog_tree(const ::AssetLibrary *library) AssetCatalogTree *AS_asset_library_get_catalog_tree(const ::AssetLibrary *library)
{ {
blender::bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service( AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(library);
library);
if (catalog_service == nullptr) { if (catalog_service == nullptr) {
return nullptr; return nullptr;
} }
@ -94,21 +97,21 @@ blender::bke::AssetCatalogTree *BKE_asset_library_get_catalog_tree(const ::Asset
return catalog_service->get_catalog_tree(); return catalog_service->get_catalog_tree();
} }
void BKE_asset_library_refresh_catalog_simplename(struct AssetLibrary *asset_library, void AS_asset_library_refresh_catalog_simplename(struct ::AssetLibrary *asset_library,
struct AssetMetaData *asset_data) struct AssetMetaData *asset_data)
{ {
blender::bke::AssetLibrary *lib = reinterpret_cast<blender::bke::AssetLibrary *>(asset_library); asset_system::AssetLibrary *lib = reinterpret_cast<asset_system::AssetLibrary *>(asset_library);
lib->refresh_catalog_simplename(asset_data); lib->refresh_catalog_simplename(asset_data);
} }
void BKE_asset_library_remap_ids(IDRemapper *mappings) void AS_asset_library_remap_ids(IDRemapper *mappings)
{ {
blender::bke::AssetLibraryService *service = blender::bke::AssetLibraryService::get(); AssetLibraryService *service = AssetLibraryService::get();
service->foreach_loaded_asset_library( service->foreach_loaded_asset_library(
[mappings](blender::bke::AssetLibrary &library) { library.remap_ids(*mappings); }); [mappings](asset_system::AssetLibrary &library) { library.remap_ids(*mappings); });
} }
namespace blender::bke { namespace blender::asset_system {
AssetLibrary::AssetLibrary() : catalog_service(std::make_unique<AssetCatalogService>()) AssetLibrary::AssetLibrary() : catalog_service(std::make_unique<AssetCatalogService>())
{ {
@ -272,4 +275,4 @@ Vector<AssetLibraryReference> all_valid_asset_library_refs()
return result; return result;
} }
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,12 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#include "asset_library_service.hh" #include "asset_library_service.hh"
#include "AS_asset_library.hh"
#include "BKE_asset_library.hh"
#include "BKE_blender.h" #include "BKE_blender.h"
#include "BKE_preferences.h" #include "BKE_preferences.h"
@ -19,9 +19,9 @@
#include "CLG_log.h" #include "CLG_log.h"
static CLG_LogRef LOG = {"bke.asset_service"}; static CLG_LogRef LOG = {"asset_system.asset_library_service"};
namespace blender::bke { namespace blender::asset_system {
std::unique_ptr<AssetLibraryService> AssetLibraryService::instance_; std::unique_ptr<AssetLibraryService> AssetLibraryService::instance_;
bool AssetLibraryService::atexit_handler_registered_ = false; bool AssetLibraryService::atexit_handler_registered_ = false;
@ -48,8 +48,7 @@ AssetLibrary *AssetLibraryService::get_asset_library(
{ {
if (library_reference.type == ASSET_LIBRARY_LOCAL) { if (library_reference.type == ASSET_LIBRARY_LOCAL) {
/* For the "Current File" library we get the asset library root path based on main. */ /* For the "Current File" library we get the asset library root path based on main. */
std::string root_path = bmain ? BKE_asset_library_find_suitable_root_path_from_main(bmain) : std::string root_path = bmain ? AS_asset_library_find_suitable_root_path_from_main(bmain) : "";
"";
if (root_path.empty()) { if (root_path.empty()) {
/* File wasn't saved yet. */ /* File wasn't saved yet. */
@ -187,4 +186,4 @@ void AssetLibraryService::foreach_loaded_asset_library(FunctionRef<void(AssetLib
} }
} }
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,16 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#pragma once #pragma once
#ifndef __cplusplus #include "AS_asset_library.hh"
# error This is a C++-only header file.
#endif
#include "BKE_asset_library.hh"
#include "BLI_function_ref.hh" #include "BLI_function_ref.hh"
#include "BLI_map.hh" #include "BLI_map.hh"
@ -19,7 +15,7 @@
struct AssetLibraryReference; struct AssetLibraryReference;
namespace blender::bke { namespace blender::asset_system {
/** /**
* Global singleton-ish that provides access to individual #AssetLibrary instances. * Global singleton-ish that provides access to individual #AssetLibrary instances.
@ -87,4 +83,4 @@ class AssetLibraryService {
void app_handler_unregister(); void app_handler_unregister();
}; };
} // namespace blender::bke } // namespace blender::asset_system

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file /** \file
* \ingroup bke * \ingroup asset_system
*/ */
#include <stdexcept> #include <stdexcept>
@ -9,10 +9,12 @@
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_asset_types.h" #include "DNA_asset_types.h"
#include "BKE_asset.h" #include "AS_asset_representation.h"
#include "BKE_asset_representation.hh" #include "AS_asset_representation.hh"
namespace blender::bke { #include "BKE_asset.h"
namespace blender::asset_system {
AssetRepresentation::AssetRepresentation(StringRef name, std::unique_ptr<AssetMetaData> metadata) AssetRepresentation::AssetRepresentation(StringRef name, std::unique_ptr<AssetMetaData> metadata)
: is_local_id_(false), external_asset_() : is_local_id_(false), external_asset_()
@ -66,7 +68,7 @@ bool AssetRepresentation::is_local_id() const
return is_local_id_; return is_local_id_;
} }
} // namespace blender::bke } // namespace blender::asset_system
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/** \name C-API /** \name C-API
@ -74,24 +76,24 @@ bool AssetRepresentation::is_local_id() const
using namespace blender; using namespace blender;
const char *BKE_asset_representation_name_get(const AssetRepresentation *asset_handle) const char *AS_asset_representation_name_get(const AssetRepresentation *asset_handle)
{ {
const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( const asset_system::AssetRepresentation *asset =
asset_handle); reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle);
return asset->get_name().c_str(); return asset->get_name().c_str();
} }
AssetMetaData *BKE_asset_representation_metadata_get(const AssetRepresentation *asset_handle) AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset_handle)
{ {
const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( const asset_system::AssetRepresentation *asset =
asset_handle); reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle);
return &asset->get_metadata(); return &asset->get_metadata();
} }
bool BKE_asset_representation_is_local_id(const AssetRepresentation *asset_handle) bool AS_asset_representation_is_local_id(const AssetRepresentation *asset_handle)
{ {
const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( const asset_system::AssetRepresentation *asset =
asset_handle); reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle);
return asset->is_local_id(); return asset->is_local_id();
} }

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later /* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2020 Blender Foundation. All rights reserved. */ * Copyright 2020 Blender Foundation. All rights reserved. */
#include "BKE_asset_catalog_path.hh" #include "AS_asset_catalog_path.hh"
#include "BLI_set.hh" #include "BLI_set.hh"
#include "BLI_vector.hh" #include "BLI_vector.hh"
@ -11,7 +11,7 @@
#include "testing/testing.h" #include "testing/testing.h"
namespace blender::bke::tests { namespace blender::asset_system::tests {
TEST(AssetCatalogPathTest, construction) TEST(AssetCatalogPathTest, construction)
{ {
@ -265,4 +265,4 @@ TEST(AssetCatalogPathTest, parent)
EXPECT_EQ(empty.parent(), ""); EXPECT_EQ(empty.parent(), "");
} }
} // namespace blender::bke::tests } // namespace blender::asset_system::tests

View File

@ -1,8 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-or-later /* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2020 Blender Foundation. All rights reserved. */ * Copyright 2020 Blender Foundation. All rights reserved. */
#include "AS_asset_catalog.hh"
#include "BKE_appdir.h" #include "BKE_appdir.h"
#include "BKE_asset_catalog.hh"
#include "BKE_preferences.h" #include "BKE_preferences.h"
#include "BLI_fileops.h" #include "BLI_fileops.h"
@ -15,7 +16,7 @@
#include "testing/testing.h" #include "testing/testing.h"
namespace blender::bke::tests { namespace blender::asset_system::tests {
/* UUIDs from lib/tests/asset_library/blender_assets.cats.txt */ /* UUIDs from lib/tests/asset_library/blender_assets.cats.txt */
const bUUID UUID_ID_WITHOUT_PATH("e34dd2c5-5d2e-4668-9794-1db5de2a4f71"); const bUUID UUID_ID_WITHOUT_PATH("e34dd2c5-5d2e-4668-9794-1db5de2a4f71");
@ -1538,4 +1539,4 @@ TEST_F(AssetCatalogTest, undo_redo_more_complex)
EXPECT_EQ(service.find_catalog(UUID_POSES_ELLIE)->path, "character/Ellie/poselib"); /* Undone. */ EXPECT_EQ(service.find_catalog(UUID_POSES_ELLIE)->path, "character/Ellie/poselib"); /* Undone. */
} }
} // namespace blender::bke::tests } // namespace blender::asset_system::tests

View File

@ -16,7 +16,7 @@
#include "testing/testing.h" #include "testing/testing.h"
namespace blender::bke::tests { namespace blender::asset_system::tests {
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78"); const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
@ -219,4 +219,4 @@ TEST_F(AssetLibraryServiceTest, has_any_unsaved_catalogs_after_write)
EXPECT_FALSE(cat->flags.has_unsaved_changes); EXPECT_FALSE(cat->flags.has_unsaved_changes);
} }
} // namespace blender::bke::tests } // namespace blender::asset_system::tests

View File

@ -1,9 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later /* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2020 Blender Foundation. All rights reserved. */ * Copyright 2020 Blender Foundation. All rights reserved. */
#include "AS_asset_catalog.hh"
#include "AS_asset_library.h"
#include "AS_asset_library.hh"
#include "BKE_appdir.h" #include "BKE_appdir.h"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "BKE_callbacks.h" #include "BKE_callbacks.h"
#include "asset_library_service.hh" #include "asset_library_service.hh"
@ -12,7 +14,7 @@
#include "testing/testing.h" #include "testing/testing.h"
namespace blender::bke::tests { namespace blender::asset_system::tests {
class AssetLibraryTest : public testing::Test { class AssetLibraryTest : public testing::Test {
public: public:
@ -29,11 +31,11 @@ class AssetLibraryTest : public testing::Test {
void TearDown() override void TearDown() override
{ {
AssetLibraryService::destroy(); asset_system::AssetLibraryService::destroy();
} }
}; };
TEST_F(AssetLibraryTest, bke_asset_library_load) TEST_F(AssetLibraryTest, AS_asset_library_load)
{ {
const std::string test_files_dir = blender::tests::flags_test_asset_dir(); const std::string test_files_dir = blender::tests::flags_test_asset_dir();
if (test_files_dir.empty()) { if (test_files_dir.empty()) {
@ -42,11 +44,11 @@ TEST_F(AssetLibraryTest, bke_asset_library_load)
/* Load the asset library. */ /* Load the asset library. */
const std::string library_path = test_files_dir + "/" + "asset_library"; const std::string library_path = test_files_dir + "/" + "asset_library";
::AssetLibrary *library_c_ptr = BKE_asset_library_load(library_path.data()); ::AssetLibrary *library_c_ptr = AS_asset_library_load(library_path.data());
ASSERT_NE(nullptr, library_c_ptr); ASSERT_NE(nullptr, library_c_ptr);
/* Check that it can be cast to the C++ type and has a Catalog Service. */ /* Check that it can be cast to the C++ type and has a Catalog Service. */
blender::bke::AssetLibrary *library_cpp_ptr = reinterpret_cast<blender::bke::AssetLibrary *>( asset_system::AssetLibrary *library_cpp_ptr = reinterpret_cast<asset_system::AssetLibrary *>(
library_c_ptr); library_c_ptr);
AssetCatalogService *service = library_cpp_ptr->catalog_service.get(); AssetCatalogService *service = library_cpp_ptr->catalog_service.get();
ASSERT_NE(nullptr, service); ASSERT_NE(nullptr, service);
@ -70,11 +72,11 @@ TEST_F(AssetLibraryTest, load_nonexistent_directory)
/* Load the asset library. */ /* Load the asset library. */
const std::string library_path = test_files_dir + "/" + const std::string library_path = test_files_dir + "/" +
"asset_library/this/subdir/does/not/exist"; "asset_library/this/subdir/does/not/exist";
::AssetLibrary *library_c_ptr = BKE_asset_library_load(library_path.data()); ::AssetLibrary *library_c_ptr = AS_asset_library_load(library_path.data());
ASSERT_NE(nullptr, library_c_ptr); ASSERT_NE(nullptr, library_c_ptr);
/* Check that it can be cast to the C++ type and has a Catalog Service. */ /* Check that it can be cast to the C++ type and has a Catalog Service. */
blender::bke::AssetLibrary *library_cpp_ptr = reinterpret_cast<blender::bke::AssetLibrary *>( asset_system::AssetLibrary *library_cpp_ptr = reinterpret_cast<asset_system::AssetLibrary *>(
library_c_ptr); library_c_ptr);
AssetCatalogService *service = library_cpp_ptr->catalog_service.get(); AssetCatalogService *service = library_cpp_ptr->catalog_service.get();
ASSERT_NE(nullptr, service); ASSERT_NE(nullptr, service);
@ -83,4 +85,4 @@ TEST_F(AssetLibraryTest, load_nonexistent_directory)
EXPECT_TRUE(service->is_empty()); EXPECT_TRUE(service->is_empty());
} }
} // namespace blender::bke::tests } // namespace blender::asset_system::tests

View File

@ -23,9 +23,6 @@ struct ID;
struct IDProperty; struct IDProperty;
struct PreviewImage; struct PreviewImage;
/** C handle for #bke::AssetRepresentation. */
typedef struct AssetRepresentation AssetRepresentation;
typedef void (*PreSaveFn)(void *asset_ptr, struct AssetMetaData *asset_data); typedef void (*PreSaveFn)(void *asset_ptr, struct AssetMetaData *asset_data);
typedef struct AssetTypeInfo { typedef struct AssetTypeInfo {
@ -71,13 +68,6 @@ struct PreviewImage *BKE_asset_metadata_preview_get_from_id(const struct AssetMe
void BKE_asset_metadata_write(struct BlendWriter *writer, struct AssetMetaData *asset_data); void BKE_asset_metadata_write(struct BlendWriter *writer, struct AssetMetaData *asset_data);
void BKE_asset_metadata_read(struct BlendDataReader *reader, struct AssetMetaData *asset_data); void BKE_asset_metadata_read(struct BlendDataReader *reader, struct AssetMetaData *asset_data);
const char *BKE_asset_representation_name_get(const AssetRepresentation *asset)
ATTR_WARN_UNUSED_RESULT;
AssetMetaData *BKE_asset_representation_metadata_get(const AssetRepresentation *asset)
ATTR_WARN_UNUSED_RESULT;
bool BKE_asset_representation_is_local_id(const AssetRepresentation *asset)
ATTR_WARN_UNUSED_RESULT;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -3,6 +3,7 @@
set(INC set(INC
. .
../asset_system
../blenfont ../blenfont
../blenlib ../blenlib
../blenloader ../blenloader
@ -71,11 +72,6 @@ set(SRC
intern/armature_selection.cc intern/armature_selection.cc
intern/armature_update.c intern/armature_update.c
intern/asset.cc intern/asset.cc
intern/asset_catalog.cc
intern/asset_catalog_path.cc
intern/asset_library.cc
intern/asset_library_service.cc
intern/asset_representation.cc
intern/attribute.cc intern/attribute.cc
intern/attribute_access.cc intern/attribute_access.cc
intern/attribute_math.cc intern/attribute_math.cc
@ -322,11 +318,6 @@ set(SRC
BKE_armature.h BKE_armature.h
BKE_armature.hh BKE_armature.hh
BKE_asset.h BKE_asset.h
BKE_asset_catalog.hh
BKE_asset_catalog_path.hh
BKE_asset_library.h
BKE_asset_library.hh
BKE_asset_representation.hh
BKE_attribute.h BKE_attribute.h
BKE_attribute.hh BKE_attribute.hh
BKE_attribute_math.hh BKE_attribute_math.hh
@ -503,7 +494,6 @@ set(SRC
intern/CCGSubSurf.h intern/CCGSubSurf.h
intern/CCGSubSurf_inline.h intern/CCGSubSurf_inline.h
intern/CCGSubSurf_intern.h intern/CCGSubSurf_intern.h
intern/asset_library_service.hh
intern/attribute_access_intern.hh intern/attribute_access_intern.hh
intern/data_transfer_intern.h intern/data_transfer_intern.h
intern/lib_intern.h intern/lib_intern.h
@ -517,6 +507,7 @@ set(SRC
) )
set(LIB set(LIB
bf_asset_system
bf_blenfont bf_blenfont
bf_blenlib bf_blenlib
bf_blenloader bf_blenloader
@ -834,11 +825,7 @@ if(WITH_GTESTS)
set(TEST_SRC set(TEST_SRC
intern/action_test.cc intern/action_test.cc
intern/armature_test.cc intern/armature_test.cc
intern/asset_catalog_path_test.cc intern/asset_metadata_test.cc
intern/asset_catalog_test.cc
intern/asset_library_service_test.cc
intern/asset_library_test.cc
intern/asset_test.cc
intern/bpath_test.cc intern/bpath_test.cc
intern/cryptomatte_test.cc intern/cryptomatte_test.cc
intern/curves_geometry_test.cc intern/curves_geometry_test.cc

View File

@ -19,9 +19,10 @@
#include "BLI_linklist.h" #include "BLI_linklist.h"
#include "BLI_listbase.h" #include "BLI_listbase.h"
#include "AS_asset_library.h"
#include "BKE_anim_data.h" #include "BKE_anim_data.h"
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_library.h"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "BKE_idtype.h" #include "BKE_idtype.h"
#include "BKE_key.h" #include "BKE_key.h"
@ -159,7 +160,7 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
} }
} }
BKE_asset_library_remap_ids(remapper); AS_asset_library_remap_ids(remapper);
BKE_id_remapper_free(remapper); BKE_id_remapper_free(remapper);
BKE_libblock_free_data(id, (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0); BKE_libblock_free_data(id, (flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0);

View File

@ -318,7 +318,7 @@ template<
/** Type of the values stored in this uniform buffer. */ /** Type of the values stored in this uniform buffer. */
typename T, typename T,
/** The number of values that can be stored in this storage buffer at creation. */ /** The number of values that can be stored in this storage buffer at creation. */
int64_t len = max_ii(1u, 512u / sizeof(T)), int64_t len = (512u + (sizeof(T) - 1)) / sizeof(T),
/** True if created on device and no memory host memory is allocated. */ /** True if created on device and no memory host memory is allocated. */
bool device_only = false> bool device_only = false>
class StorageArrayBuffer : public detail::StorageCommon<T, len, device_only> { class StorageArrayBuffer : public detail::StorageCommon<T, len, device_only> {
@ -372,7 +372,7 @@ template<
/** Type of the values stored in this uniform buffer. */ /** Type of the values stored in this uniform buffer. */
typename T, typename T,
/** The number of values that can be stored in this storage buffer at creation. */ /** The number of values that can be stored in this storage buffer at creation. */
int64_t len = max_ii(1u, 512u / sizeof(T))> int64_t len = (512u + (sizeof(T) - 1)) / sizeof(T)>
class StorageVectorBuffer : public StorageArrayBuffer<T, len, false> { class StorageVectorBuffer : public StorageArrayBuffer<T, len, false> {
private: private:
/* Number of items, not the allocated length. */ /* Number of items, not the allocated length. */
@ -957,8 +957,7 @@ class TextureRef : public Texture {
* Dummy type to bind texture as image. * Dummy type to bind texture as image.
* It is just a GPUTexture in disguise. * It is just a GPUTexture in disguise.
*/ */
class Image { class Image {};
};
static inline Image *as_image(GPUTexture *tex) static inline Image *as_image(GPUTexture *tex)
{ {

View File

@ -480,7 +480,8 @@ inline void PassBase<T>::clear(eGPUFrameBufferBits planes,
template<class T> inline void PassBase<T>::clear_multi(Span<float4> colors) template<class T> inline void PassBase<T>::clear_multi(Span<float4> colors)
{ {
create_command(command::Type::ClearMulti).clear_multi = {colors.data(), colors.size()}; create_command(command::Type::ClearMulti).clear_multi = {colors.data(),
static_cast<int>(colors.size())};
} }
template<class T> inline GPUBatch *PassBase<T>::procedural_batch_get(GPUPrimType primitive) template<class T> inline GPUBatch *PassBase<T>::procedural_batch_get(GPUPrimType primitive)

View File

@ -3,6 +3,7 @@
set(INC set(INC
. .
../include ../include
../../asset_system
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib
../../blenloader ../../blenloader

View File

@ -3,8 +3,8 @@
/** \file /** \file
* \ingroup edasset * \ingroup edasset
* *
* UI/Editor level API for catalog operations, creating richer functionality than the BKE catalog * UI/Editor level API for catalog operations, creating richer functionality than the asset system
* API provides (which this uses internally). * catalog API provides (which this uses internally).
* *
* Note that `ED_asset_catalog.h` is part of this API. * Note that `ED_asset_catalog.h` is part of this API.
*/ */
@ -13,22 +13,19 @@
#include <optional> #include <optional>
#include "BKE_asset_catalog.hh" #include "AS_asset_catalog.hh"
#include "BLI_string_ref.hh" #include "BLI_string_ref.hh"
struct AssetLibrary; struct AssetLibrary;
namespace blender::bke {
class AssetCatalog;
} // namespace blender::bke
blender::bke::AssetCatalog *ED_asset_catalog_add(AssetLibrary *library, blender::asset_system::AssetCatalog *ED_asset_catalog_add(
blender::StringRefNull name, AssetLibrary *library, blender::StringRefNull name, blender::StringRef parent_path = nullptr);
blender::StringRef parent_path = nullptr); void ED_asset_catalog_remove(AssetLibrary *library,
void ED_asset_catalog_remove(AssetLibrary *library, const blender::bke::CatalogID &catalog_id); const blender::asset_system::CatalogID &catalog_id);
void ED_asset_catalog_rename(AssetLibrary *library, void ED_asset_catalog_rename(AssetLibrary *library,
blender::bke::CatalogID catalog_id, blender::asset_system::CatalogID catalog_id,
blender::StringRefNull new_name); blender::StringRefNull new_name);
/** /**
* Reinsert catalog identified by \a src_catalog_id as child to catalog identified by \a * Reinsert catalog identified by \a src_catalog_id as child to catalog identified by \a
@ -43,5 +40,5 @@ void ED_asset_catalog_rename(AssetLibrary *library,
*/ */
void ED_asset_catalog_move( void ED_asset_catalog_move(
AssetLibrary *library, AssetLibrary *library,
blender::bke::CatalogID src_catalog_id, blender::asset_system::CatalogID src_catalog_id,
std::optional<blender::bke::CatalogID> dst_parent_catalog_id = std::nullopt); std::optional<blender::asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);

View File

@ -4,8 +4,9 @@
* \ingroup edasset * \ingroup edasset
*/ */
#include "BKE_asset_catalog.hh" #include "AS_asset_library.hh"
#include "BKE_asset_library.hh"
#include "AS_asset_catalog.hh"
#include "BKE_main.h" #include "BKE_main.h"
#include "BLI_string_utils.h" #include "BLI_string_utils.h"
@ -16,7 +17,7 @@
#include "WM_api.h" #include "WM_api.h"
using namespace blender; using namespace blender;
using namespace blender::bke; using namespace blender::asset_system;
struct CatalogUniqueNameFnData { struct CatalogUniqueNameFnData {
const AssetCatalogService &catalog_service; const AssetCatalogService &catalog_service;
@ -43,11 +44,12 @@ static std::string catalog_name_ensure_unique(AssetCatalogService &catalog_servi
return unique_name; return unique_name;
} }
AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library, asset_system::AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
StringRefNull name, StringRefNull name,
StringRef parent_path) StringRef parent_path)
{ {
bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) { if (!catalog_service) {
return nullptr; return nullptr;
} }
@ -56,7 +58,7 @@ AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
AssetCatalogPath fullpath = AssetCatalogPath(parent_path) / unique_name; AssetCatalogPath fullpath = AssetCatalogPath(parent_path) / unique_name;
catalog_service->undo_push(); catalog_service->undo_push();
bke::AssetCatalog *new_catalog = catalog_service->create_catalog(fullpath); asset_system::AssetCatalog *new_catalog = catalog_service->create_catalog(fullpath);
if (!new_catalog) { if (!new_catalog) {
return nullptr; return nullptr;
} }
@ -68,7 +70,8 @@ AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
void ED_asset_catalog_remove(::AssetLibrary *library, const CatalogID &catalog_id) void ED_asset_catalog_remove(::AssetLibrary *library, const CatalogID &catalog_id)
{ {
bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) { if (!catalog_service) {
BLI_assert_unreachable(); BLI_assert_unreachable();
return; return;
@ -84,7 +87,8 @@ void ED_asset_catalog_rename(::AssetLibrary *library,
const CatalogID catalog_id, const CatalogID catalog_id,
const StringRefNull new_name) const StringRefNull new_name)
{ {
bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) { if (!catalog_service) {
BLI_assert_unreachable(); BLI_assert_unreachable();
return; return;
@ -110,7 +114,8 @@ void ED_asset_catalog_move(::AssetLibrary *library,
const CatalogID src_catalog_id, const CatalogID src_catalog_id,
const std::optional<CatalogID> dst_parent_catalog_id) const std::optional<CatalogID> dst_parent_catalog_id)
{ {
bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) { if (!catalog_service) {
BLI_assert_unreachable(); BLI_assert_unreachable();
return; return;
@ -150,7 +155,8 @@ void ED_asset_catalog_move(::AssetLibrary *library,
void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *bmain) void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *bmain)
{ {
bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
if (!catalog_service) { if (!catalog_service) {
BLI_assert_unreachable(); BLI_assert_unreachable();
return; return;
@ -164,10 +170,10 @@ void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save) void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)
{ {
bke::AssetLibrary::save_catalogs_when_file_is_saved = should_save; asset_system::AssetLibrary::save_catalogs_when_file_is_saved = should_save;
} }
bool ED_asset_catalogs_get_save_catalogs_when_file_is_saved() bool ED_asset_catalogs_get_save_catalogs_when_file_is_saved()
{ {
return bke::AssetLibrary::save_catalogs_when_file_is_saved; return asset_system::AssetLibrary::save_catalogs_when_file_is_saved;
} }

View File

@ -6,10 +6,9 @@
#include <string> #include <string>
#include "DNA_space_types.h" #include "AS_asset_representation.h"
#include "BKE_asset.h" #include "DNA_space_types.h"
#include "BKE_asset_representation.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
@ -20,12 +19,12 @@
const char *ED_asset_handle_get_name(const AssetHandle *asset) const char *ED_asset_handle_get_name(const AssetHandle *asset)
{ {
return BKE_asset_representation_name_get(asset->file_data->asset); return AS_asset_representation_name_get(asset->file_data->asset);
} }
AssetMetaData *ED_asset_handle_get_metadata(const AssetHandle *asset_handle) AssetMetaData *ED_asset_handle_get_metadata(const AssetHandle *asset_handle)
{ {
return BKE_asset_representation_metadata_get(asset_handle->file_data->asset); return AS_asset_representation_metadata_get(asset_handle->file_data->asset);
} }
ID *ED_asset_handle_get_local_id(const AssetHandle *asset) ID *ED_asset_handle_get_local_id(const AssetHandle *asset)

View File

@ -22,9 +22,9 @@
#include "BLI_string_ref.hh" #include "BLI_string_ref.hh"
#include "BLI_uuid.h" #include "BLI_uuid.h"
#include "AS_asset_catalog.hh"
#include "BKE_appdir.h" #include "BKE_appdir.h"
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_catalog.hh"
#include "BKE_idprop.hh" #include "BKE_idprop.hh"
#include "BKE_preferences.h" #include "BKE_preferences.h"
@ -34,8 +34,8 @@ static CLG_LogRef LOG = {"ed.asset"};
namespace blender::ed::asset::index { namespace blender::ed::asset::index {
using namespace blender::asset_system;
using namespace blender::io::serialize; using namespace blender::io::serialize;
using namespace blender::bke;
using namespace blender::bke::idprop; using namespace blender::bke::idprop;
/** /**

View File

@ -4,7 +4,9 @@
* \ingroup edasset * \ingroup edasset
*/ */
#include "BKE_asset_library.hh" #include "AS_asset_library.h"
#include "AS_asset_library.hh"
#include "BKE_bpath.h" #include "BKE_bpath.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_global.h" #include "BKE_global.h"
@ -445,7 +447,7 @@ static int asset_catalog_new_exec(bContext *C, wmOperator *op)
struct AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile); struct AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
char *parent_path = RNA_string_get_alloc(op->ptr, "parent_path", nullptr, 0, nullptr); char *parent_path = RNA_string_get_alloc(op->ptr, "parent_path", nullptr, 0, nullptr);
blender::bke::AssetCatalog *new_catalog = ED_asset_catalog_add( blender::asset_system::AssetCatalog *new_catalog = ED_asset_catalog_add(
asset_library, "Catalog", parent_path); asset_library, "Catalog", parent_path);
if (sfile) { if (sfile) {
@ -484,7 +486,7 @@ static int asset_catalog_delete_exec(bContext *C, wmOperator *op)
SpaceFile *sfile = CTX_wm_space_file(C); SpaceFile *sfile = CTX_wm_space_file(C);
struct AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile); struct AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
char *catalog_id_str = RNA_string_get_alloc(op->ptr, "catalog_id", nullptr, 0, nullptr); char *catalog_id_str = RNA_string_get_alloc(op->ptr, "catalog_id", nullptr, 0, nullptr);
bke::CatalogID catalog_id; asset_system::CatalogID catalog_id;
if (!BLI_uuid_parse_string(&catalog_id, catalog_id_str)) { if (!BLI_uuid_parse_string(&catalog_id, catalog_id_str)) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -515,7 +517,7 @@ static void ASSET_OT_catalog_delete(struct wmOperatorType *ot)
RNA_def_string(ot->srna, "catalog_id", nullptr, 0, "Catalog ID", "ID of the catalog to delete"); RNA_def_string(ot->srna, "catalog_id", nullptr, 0, "Catalog ID", "ID of the catalog to delete");
} }
static bke::AssetCatalogService *get_catalog_service(bContext *C) static asset_system::AssetCatalogService *get_catalog_service(bContext *C)
{ {
const SpaceFile *sfile = CTX_wm_space_file(C); const SpaceFile *sfile = CTX_wm_space_file(C);
if (!sfile) { if (!sfile) {
@ -523,12 +525,12 @@ static bke::AssetCatalogService *get_catalog_service(bContext *C)
} }
AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile); AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
return BKE_asset_library_get_catalog_service(asset_lib); return AS_asset_library_get_catalog_service(asset_lib);
} }
static int asset_catalog_undo_exec(bContext *C, wmOperator * /*op*/) static int asset_catalog_undo_exec(bContext *C, wmOperator * /*op*/)
{ {
bke::AssetCatalogService *catalog_service = get_catalog_service(C); asset_system::AssetCatalogService *catalog_service = get_catalog_service(C);
if (!catalog_service) { if (!catalog_service) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -540,7 +542,7 @@ static int asset_catalog_undo_exec(bContext *C, wmOperator * /*op*/)
static bool asset_catalog_undo_poll(bContext *C) static bool asset_catalog_undo_poll(bContext *C)
{ {
const bke::AssetCatalogService *catalog_service = get_catalog_service(C); const asset_system::AssetCatalogService *catalog_service = get_catalog_service(C);
return catalog_service && catalog_service->is_undo_possbile(); return catalog_service && catalog_service->is_undo_possbile();
} }
@ -558,7 +560,7 @@ static void ASSET_OT_catalog_undo(struct wmOperatorType *ot)
static int asset_catalog_redo_exec(bContext *C, wmOperator * /*op*/) static int asset_catalog_redo_exec(bContext *C, wmOperator * /*op*/)
{ {
bke::AssetCatalogService *catalog_service = get_catalog_service(C); asset_system::AssetCatalogService *catalog_service = get_catalog_service(C);
if (!catalog_service) { if (!catalog_service) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -570,7 +572,7 @@ static int asset_catalog_redo_exec(bContext *C, wmOperator * /*op*/)
static bool asset_catalog_redo_poll(bContext *C) static bool asset_catalog_redo_poll(bContext *C)
{ {
const bke::AssetCatalogService *catalog_service = get_catalog_service(C); const asset_system::AssetCatalogService *catalog_service = get_catalog_service(C);
return catalog_service && catalog_service->is_redo_possbile(); return catalog_service && catalog_service->is_redo_possbile();
} }
@ -588,7 +590,7 @@ static void ASSET_OT_catalog_redo(struct wmOperatorType *ot)
static int asset_catalog_undo_push_exec(bContext *C, wmOperator * /*op*/) static int asset_catalog_undo_push_exec(bContext *C, wmOperator * /*op*/)
{ {
bke::AssetCatalogService *catalog_service = get_catalog_service(C); asset_system::AssetCatalogService *catalog_service = get_catalog_service(C);
if (!catalog_service) { if (!catalog_service) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
@ -631,7 +633,7 @@ static bool asset_catalogs_save_poll(bContext *C)
return false; return false;
} }
if (!BKE_asset_library_has_any_unsaved_catalogs()) { if (!AS_asset_library_has_any_unsaved_catalogs()) {
CTX_wm_operator_poll_msg_set(C, "No changes to be saved"); CTX_wm_operator_poll_msg_set(C, "No changes to be saved");
return false; return false;
} }
@ -748,7 +750,7 @@ static int asset_bundle_install_exec(bContext *C, wmOperator *op)
} }
WM_cursor_wait(true); WM_cursor_wait(true);
bke::AssetCatalogService *cat_service = get_catalog_service(C); asset_system::AssetCatalogService *cat_service = get_catalog_service(C);
/* Store undo step, such that on a failed save the 'prepare_to_merge_on_write' call can be /* Store undo step, such that on a failed save the 'prepare_to_merge_on_write' call can be
* un-done. */ * un-done. */
cat_service->undo_push(); cat_service->undo_push();

View File

@ -3,6 +3,7 @@
set(INC set(INC
. .
../include ../include
../../asset_system
../../blenfont ../../blenfont
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib

View File

@ -3,6 +3,7 @@
set(INC set(INC
../asset ../asset
../include ../include
../../asset_system
../../blenfont ../../blenfont
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib

View File

@ -7,9 +7,10 @@
#include "DNA_space_types.h" #include "DNA_space_types.h"
#include "AS_asset_library.hh"
#include "AS_asset_catalog.hh"
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "BLI_string_ref.hh" #include "BLI_string_ref.hh"
@ -33,7 +34,7 @@
#include "filelist.h" #include "filelist.h"
using namespace blender; using namespace blender;
using namespace blender::bke; using namespace blender::asset_system;
namespace blender::ed::asset_browser { namespace blender::ed::asset_browser {
@ -42,7 +43,7 @@ class AssetCatalogTreeViewAllItem;
class AssetCatalogTreeView : public ui::AbstractTreeView { class AssetCatalogTreeView : public ui::AbstractTreeView {
::AssetLibrary *asset_library_; ::AssetLibrary *asset_library_;
/** The asset catalog tree this tree-view represents. */ /** The asset catalog tree this tree-view represents. */
bke::AssetCatalogTree *catalog_tree_; asset_system::AssetCatalogTree *catalog_tree_;
FileAssetSelectParams *params_; FileAssetSelectParams *params_;
SpaceFile &space_file_; SpaceFile &space_file_;
@ -173,7 +174,7 @@ AssetCatalogTreeView::AssetCatalogTreeView(::AssetLibrary *library,
FileAssetSelectParams *params, FileAssetSelectParams *params,
SpaceFile &space_file) SpaceFile &space_file)
: asset_library_(library), : asset_library_(library),
catalog_tree_(BKE_asset_library_get_catalog_tree(library)), catalog_tree_(AS_asset_library_get_catalog_tree(library)),
params_(params), params_(params),
space_file_(space_file) space_file_(space_file)
{ {
@ -486,7 +487,7 @@ AssetCatalog *AssetCatalogDropController::get_drag_catalog(const wmDrag &drag,
if (drag.type != WM_DRAG_ASSET_CATALOG) { if (drag.type != WM_DRAG_ASSET_CATALOG) {
return nullptr; return nullptr;
} }
const bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service( const AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
&asset_library); &asset_library);
const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag); const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
@ -708,7 +709,7 @@ bool file_set_asset_catalog_filter_settings(
void file_ensure_updated_catalog_filter_data( void file_ensure_updated_catalog_filter_data(
FileAssetCatalogFilterSettingsHandle *filter_settings_handle, FileAssetCatalogFilterSettingsHandle *filter_settings_handle,
const bke::AssetLibrary *asset_library) const asset_system::AssetLibrary *asset_library)
{ {
AssetCatalogFilterSettings *filter_settings = reinterpret_cast<AssetCatalogFilterSettings *>( AssetCatalogFilterSettings *filter_settings = reinterpret_cast<AssetCatalogFilterSettings *>(
filter_settings_handle); filter_settings_handle);

View File

@ -225,7 +225,7 @@ void file_create_asset_catalog_tree_view_in_layout(struct AssetLibrary *asset_li
#ifdef __cplusplus #ifdef __cplusplus
namespace blender::bke { namespace blender::asset_system {
struct AssetLibrary; struct AssetLibrary;
} }
@ -242,7 +242,7 @@ bool file_set_asset_catalog_filter_settings(
bUUID catalog_id); bUUID catalog_id);
void file_ensure_updated_catalog_filter_data( void file_ensure_updated_catalog_filter_data(
FileAssetCatalogFilterSettingsHandle *filter_settings_handle, FileAssetCatalogFilterSettingsHandle *filter_settings_handle,
const blender::bke::AssetLibrary *asset_library); const blender::asset_system::AssetLibrary *asset_library);
bool file_is_asset_visible_in_catalog_filter_settings( bool file_is_asset_visible_in_catalog_filter_settings(
const FileAssetCatalogFilterSettingsHandle *filter_settings_handle, const FileAssetCatalogFilterSettingsHandle *filter_settings_handle,
const AssetMetaData *asset_data); const AssetMetaData *asset_data);

View File

@ -19,6 +19,11 @@
# include <direct.h> # include <direct.h>
# include <io.h> # include <io.h>
#endif #endif
#include "AS_asset_library.h"
#include "AS_asset_library.hh"
#include "AS_asset_representation.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLF_api.h" #include "BLF_api.h"
@ -42,9 +47,6 @@
#endif #endif
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_library.h"
#include "BKE_asset_library.hh"
#include "BKE_asset_representation.hh"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_icons.h" #include "BKE_icons.h"
@ -117,7 +119,7 @@ struct FileListInternEntry {
} local_data; } local_data;
/* References an asset in the asset library storage. */ /* References an asset in the asset library storage. */
bke::AssetRepresentation *asset; /* Non-owning. */ asset_system::AssetRepresentation *asset; /* Non-owning. */
/* See #FILE_ENTRY_BLENDERLIB_NO_PREVIEW. */ /* See #FILE_ENTRY_BLENDERLIB_NO_PREVIEW. */
bool blenderlib_has_no_preview; bool blenderlib_has_no_preview;
@ -213,7 +215,7 @@ struct FileList {
eFileSelectType type; eFileSelectType type;
/* The library this list was created for. Stored here so we know when to re-read. */ /* The library this list was created for. Stored here so we know when to re-read. */
AssetLibraryReference *asset_library_ref; AssetLibraryReference *asset_library_ref;
bke::AssetLibrary *asset_library; /* Non-owning. */ asset_system::AssetLibrary *asset_library; /* Non-owning. */
short flags; short flags;
@ -3672,8 +3674,8 @@ static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params
/* Load asset catalogs, into the temp filelist for thread-safety. /* Load asset catalogs, into the temp filelist for thread-safety.
* #filelist_readjob_endjob() will move it into the real filelist. */ * #filelist_readjob_endjob() will move it into the real filelist. */
tmp_filelist->asset_library = BKE_asset_library_load(job_params->current_main, tmp_filelist->asset_library = AS_asset_library_load(job_params->current_main,
*job_params->filelist->asset_library_ref); *job_params->filelist->asset_library_ref);
*do_update = true; *do_update = true;
} }

View File

@ -2,6 +2,7 @@
set(INC set(INC
../include ../include
../../asset_system
../../blenfont ../../blenfont
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib

View File

@ -1,13 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include "AS_asset_catalog.hh"
#include "AS_asset_library.hh"
#include "BLI_multi_value_map.hh" #include "BLI_multi_value_map.hh"
#include "DNA_screen_types.h" #include "DNA_screen_types.h"
#include "DNA_space_types.h" #include "DNA_space_types.h"
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "BKE_screen.h" #include "BKE_screen.h"
@ -48,19 +49,20 @@ struct LibraryAsset {
}; };
struct LibraryCatalog { struct LibraryCatalog {
bke::AssetLibrary *library; asset_system::AssetLibrary *library;
const bke::AssetCatalog *catalog; const asset_system::AssetCatalog *catalog;
}; };
struct AssetItemTree { struct AssetItemTree {
bke::AssetCatalogTree catalogs; asset_system::AssetCatalogTree catalogs;
MultiValueMap<bke::AssetCatalogPath, LibraryAsset> assets_per_path; MultiValueMap<asset_system::AssetCatalogPath, LibraryAsset> assets_per_path;
Map<const bke::AssetCatalogTreeItem *, bke::AssetCatalogPath> full_catalog_per_tree_item; Map<const asset_system::AssetCatalogTreeItem *, asset_system::AssetCatalogPath>
full_catalog_per_tree_item;
}; };
static bool all_loading_finished() static bool all_loading_finished()
{ {
for (const AssetLibraryReference &library : bke::all_valid_asset_library_refs()) { for (const AssetLibraryReference &library : asset_system::all_valid_asset_library_refs()) {
if (!ED_assetlist_is_loaded(&library)) { if (!ED_assetlist_is_loaded(&library)) {
return false; return false;
} }
@ -74,19 +76,19 @@ static AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree *node
return {}; return {};
} }
const Main &bmain = *CTX_data_main(&C); const Main &bmain = *CTX_data_main(&C);
const Vector<AssetLibraryReference> all_libraries = bke::all_valid_asset_library_refs(); const Vector<AssetLibraryReference> all_libraries = asset_system::all_valid_asset_library_refs();
/* Merge catalogs from all libraries to deduplicate menu items. Also store the catalog and /* Merge catalogs from all libraries to deduplicate menu items. Also store the catalog and
* library for each asset ID in order to use them later when retrieving assets and removing * library for each asset ID in order to use them later when retrieving assets and removing
* empty catalogs. */ * empty catalogs. */
Map<bke::CatalogID, LibraryCatalog> id_to_catalog_map; Map<asset_system::CatalogID, LibraryCatalog> id_to_catalog_map;
bke::AssetCatalogTree catalogs_from_all_libraries; asset_system::AssetCatalogTree catalogs_from_all_libraries;
for (const AssetLibraryReference &library_ref : all_libraries) { for (const AssetLibraryReference &library_ref : all_libraries) {
if (bke::AssetLibrary *library = BKE_asset_library_load(&bmain, library_ref)) { if (asset_system::AssetLibrary *library = AS_asset_library_load(&bmain, library_ref)) {
if (bke::AssetCatalogTree *tree = library->catalog_service->get_catalog_tree()) { if (asset_system::AssetCatalogTree *tree = library->catalog_service->get_catalog_tree()) {
tree->foreach_item([&](bke::AssetCatalogTreeItem &item) { tree->foreach_item([&](asset_system::AssetCatalogTreeItem &item) {
const bke::CatalogID &id = item.get_catalog_id(); const asset_system::CatalogID &id = item.get_catalog_id();
bke::AssetCatalog *catalog = library->catalog_service->find_catalog(id); asset_system::AssetCatalog *catalog = library->catalog_service->find_catalog(id);
catalogs_from_all_libraries.insert_item(*catalog); catalogs_from_all_libraries.insert_item(*catalog);
id_to_catalog_map.add(item.get_catalog_id(), LibraryCatalog{library, catalog}); id_to_catalog_map.add(item.get_catalog_id(), LibraryCatalog{library, catalog});
}); });
@ -95,7 +97,7 @@ static AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree *node
} }
/* Find all the matching node group assets for every catalog path. */ /* Find all the matching node group assets for every catalog path. */
MultiValueMap<bke::AssetCatalogPath, LibraryAsset> assets_per_path; MultiValueMap<asset_system::AssetCatalogPath, LibraryAsset> assets_per_path;
for (const AssetLibraryReference &library_ref : all_libraries) { for (const AssetLibraryReference &library_ref : all_libraries) {
AssetFilterSettings type_filter{}; AssetFilterSettings type_filter{};
type_filter.id_types = FILTER_ID_NT; type_filter.id_types = FILTER_ID_NT;
@ -124,21 +126,23 @@ static AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree *node
} }
/* Build the final tree without any of the catalogs that don't have proper node group assets. */ /* Build the final tree without any of the catalogs that don't have proper node group assets. */
bke::AssetCatalogTree catalogs_with_node_assets; asset_system::AssetCatalogTree catalogs_with_node_assets;
catalogs_from_all_libraries.foreach_item([&](bke::AssetCatalogTreeItem &item) { catalogs_from_all_libraries.foreach_item([&](asset_system::AssetCatalogTreeItem &item) {
if (!assets_per_path.lookup(item.catalog_path()).is_empty()) { if (!assets_per_path.lookup(item.catalog_path()).is_empty()) {
const bke::CatalogID &id = item.get_catalog_id(); const asset_system::CatalogID &id = item.get_catalog_id();
const LibraryCatalog &library_catalog = id_to_catalog_map.lookup(id); const LibraryCatalog &library_catalog = id_to_catalog_map.lookup(id);
bke::AssetCatalog *catalog = library_catalog.library->catalog_service->find_catalog(id); asset_system::AssetCatalog *catalog = library_catalog.library->catalog_service->find_catalog(
id);
catalogs_with_node_assets.insert_item(*catalog); catalogs_with_node_assets.insert_item(*catalog);
} }
}); });
/* Build another map storing full asset paths for each tree item, in order to have stable /* Build another map storing full asset paths for each tree item, in order to have stable
* pointers to asset catalog paths to use for context pointers. This is necessary because * pointers to asset catalog paths to use for context pointers. This is necessary because
* #bke::AssetCatalogTreeItem doesn't store its full path directly. */ * #asset_system::AssetCatalogTreeItem doesn't store its full path directly. */
Map<const bke::AssetCatalogTreeItem *, bke::AssetCatalogPath> full_catalog_per_tree_item; Map<const asset_system::AssetCatalogTreeItem *, asset_system::AssetCatalogPath>
catalogs_with_node_assets.foreach_item([&](bke::AssetCatalogTreeItem &item) { full_catalog_per_tree_item;
catalogs_with_node_assets.foreach_item([&](asset_system::AssetCatalogTreeItem &item) {
full_catalog_per_tree_item.add_new(&item, item.catalog_path()); full_catalog_per_tree_item.add_new(&item, item.catalog_path());
}); });
@ -165,11 +169,11 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
if (RNA_pointer_is_null(&menu_path_ptr)) { if (RNA_pointer_is_null(&menu_path_ptr)) {
return; return;
} }
const bke::AssetCatalogPath &menu_path = *static_cast<const bke::AssetCatalogPath *>( const asset_system::AssetCatalogPath &menu_path =
menu_path_ptr.data); *static_cast<const asset_system::AssetCatalogPath *>(menu_path_ptr.data);
const Span<LibraryAsset> asset_items = tree.assets_per_path.lookup(menu_path); const Span<LibraryAsset> asset_items = tree.assets_per_path.lookup(menu_path);
bke::AssetCatalogTreeItem *catalog_item = tree.catalogs.find_item(menu_path); asset_system::AssetCatalogTreeItem *catalog_item = tree.catalogs.find_item(menu_path);
BLI_assert(catalog_item != nullptr); BLI_assert(catalog_item != nullptr);
if (asset_items.is_empty() && !catalog_item->has_children()) { if (asset_items.is_empty() && !catalog_item->has_children()) {
@ -193,10 +197,11 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
uiItemO(col, ED_asset_handle_get_name(&item.handle), ICON_NONE, "NODE_OT_add_group_asset"); uiItemO(col, ED_asset_handle_get_name(&item.handle), ICON_NONE, "NODE_OT_add_group_asset");
} }
catalog_item->foreach_child([&](bke::AssetCatalogTreeItem &child_item) { catalog_item->foreach_child([&](asset_system::AssetCatalogTreeItem &child_item) {
const bke::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(&child_item); const asset_system::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(
&child_item);
PointerRNA path_ptr{ PointerRNA path_ptr{
&screen.id, &RNA_AssetCatalogPath, const_cast<bke::AssetCatalogPath *>(&path)}; &screen.id, &RNA_AssetCatalogPath, const_cast<asset_system::AssetCatalogPath *>(&path)};
uiLayout *col = uiLayoutColumn(layout, false); uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr); uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE); uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE);
@ -260,13 +265,13 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
return menus; return menus;
}(); }();
tree.catalogs.foreach_root_item([&](bke::AssetCatalogTreeItem &item) { tree.catalogs.foreach_root_item([&](asset_system::AssetCatalogTreeItem &item) {
if (all_builtin_menus.contains(item.get_name())) { if (all_builtin_menus.contains(item.get_name())) {
return; return;
} }
const bke::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(&item); const asset_system::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(&item);
PointerRNA path_ptr{ PointerRNA path_ptr{
&screen.id, &RNA_AssetCatalogPath, const_cast<bke::AssetCatalogPath *>(&path)}; &screen.id, &RNA_AssetCatalogPath, const_cast<asset_system::AssetCatalogPath *>(&path)};
uiLayout *col = uiLayoutColumn(layout, false); uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr); uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE); uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE);
@ -303,13 +308,13 @@ void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char *cat
bScreen &screen = *CTX_wm_screen(C); bScreen &screen = *CTX_wm_screen(C);
SpaceNode &snode = *CTX_wm_space_node(C); SpaceNode &snode = *CTX_wm_space_node(C);
AssetItemTree &tree = *snode.runtime->assets_for_menu; AssetItemTree &tree = *snode.runtime->assets_for_menu;
const bke::AssetCatalogTreeItem *item = tree.catalogs.find_root_item(catalog_path); const asset_system::AssetCatalogTreeItem *item = tree.catalogs.find_root_item(catalog_path);
if (!item) { if (!item) {
return; return;
} }
const bke::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(item); const asset_system::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(item);
PointerRNA path_ptr{ PointerRNA path_ptr{
&screen.id, &RNA_AssetCatalogPath, const_cast<bke::AssetCatalogPath *>(&path)}; &screen.id, &RNA_AssetCatalogPath, const_cast<asset_system::AssetCatalogPath *>(&path)};
uiItemS(layout); uiItemS(layout);
uiLayout *col = uiLayoutColumn(layout, false); uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr); uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);

View File

@ -2,14 +2,15 @@
#include <optional> #include <optional>
#include "AS_asset_catalog.hh"
#include "AS_asset_library.hh"
#include "BLI_listbase.h" #include "BLI_listbase.h"
#include "BLI_string_search.h" #include "BLI_string_search.h"
#include "DNA_space_types.h" #include "DNA_space_types.h"
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "BKE_lib_id.h" #include "BKE_lib_id.h"

View File

@ -3,6 +3,7 @@
set(INC set(INC
../include ../include
../space_sequencer ../space_sequencer
../../asset_system
../../blenfont ../../blenfont
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib

View File

@ -620,11 +620,21 @@ void GPUCodegen::generate_graphs()
std::stringstream eval_ss; std::stringstream eval_ss;
eval_ss << "\n/* Generated Functions */\n\n"; eval_ss << "\n/* Generated Functions */\n\n";
LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, func_link, &graph.material_functions) { LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, func_link, &graph.material_functions) {
/* Untag every node in the graph to avoid serializing nodes from other functions */
LISTBASE_FOREACH (GPUNode *, node, &graph.nodes) {
node->tag &= ~GPU_NODE_TAG_FUNCTION;
}
/* Tag only the nodes needed for the current function */
gpu_nodes_tag(func_link->outlink, GPU_NODE_TAG_FUNCTION);
char *fn = graph_serialize(GPU_NODE_TAG_FUNCTION, func_link->outlink); char *fn = graph_serialize(GPU_NODE_TAG_FUNCTION, func_link->outlink);
eval_ss << "float " << func_link->name << "() {\n" << fn << "}\n\n"; eval_ss << "float " << func_link->name << "() {\n" << fn << "}\n\n";
MEM_SAFE_FREE(fn); MEM_SAFE_FREE(fn);
} }
output.material_functions = extract_c_str(eval_ss); output.material_functions = extract_c_str(eval_ss);
/* Leave the function tags as they were before serialization */
LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, funclink, &graph.material_functions) {
gpu_nodes_tag(funclink->outlink, GPU_NODE_TAG_FUNCTION);
}
} }
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph.attributes) { LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph.attributes) {

View File

@ -890,7 +890,7 @@ void gpu_node_graph_free(GPUNodeGraph *graph)
/* Prune Unused Nodes */ /* Prune Unused Nodes */
static void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag) void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag)
{ {
GPUNode *node; GPUNode *node;

View File

@ -186,6 +186,7 @@ typedef struct GPUNodeGraph {
/* Node Graph */ /* Node Graph */
void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag);
void gpu_node_graph_prune_unused(GPUNodeGraph *graph); void gpu_node_graph_prune_unused(GPUNodeGraph *graph);
void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph); void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph);

View File

@ -187,6 +187,7 @@ set(SRC
set(INC set(INC
. .
.. ..
../../asset_system
../../blenfont ../../blenfont
../../blenkernel ../../blenkernel
../../blenlib ../../blenlib

View File

@ -17,8 +17,9 @@
#ifdef RNA_RUNTIME #ifdef RNA_RUNTIME
# include "AS_asset_library.h"
# include "BKE_asset.h" # include "BKE_asset.h"
# include "BKE_asset_library.h"
# include "BKE_context.h" # include "BKE_context.h"
# include "BKE_idprop.h" # include "BKE_idprop.h"
@ -251,7 +252,7 @@ void rna_AssetMetaData_catalog_id_update(struct bContext *C, struct PointerRNA *
} }
AssetMetaData *asset_data = ptr->data; AssetMetaData *asset_data = ptr->data;
BKE_asset_library_refresh_catalog_simplename(asset_library, asset_data); AS_asset_library_refresh_catalog_simplename(asset_library, asset_data);
} }
static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr) static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr)

View File

@ -530,6 +530,8 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = {
#ifdef RNA_RUNTIME #ifdef RNA_RUNTIME
# include "AS_asset_representation.h"
# include "DNA_anim_types.h" # include "DNA_anim_types.h"
# include "DNA_asset_types.h" # include "DNA_asset_types.h"
# include "DNA_scene_types.h" # include "DNA_scene_types.h"
@ -540,7 +542,6 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = {
# include "BLI_string.h" # include "BLI_string.h"
# include "BKE_anim_data.h" # include "BKE_anim_data.h"
# include "BKE_asset.h"
# include "BKE_brush.h" # include "BKE_brush.h"
# include "BKE_colortools.h" # include "BKE_colortools.h"
# include "BKE_context.h" # include "BKE_context.h"
@ -2766,14 +2767,14 @@ static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr
return PointerRNA_NULL; return PointerRNA_NULL;
} }
AssetMetaData *asset_data = BKE_asset_representation_metadata_get(entry->asset); AssetMetaData *asset_data = AS_asset_representation_metadata_get(entry->asset);
/* Note that the owning ID of the RNA pointer (`ptr->owner_id`) has to be set carefully: /* Note that the owning ID of the RNA pointer (`ptr->owner_id`) has to be set carefully:
* Local IDs (`entry->id`) own their asset metadata themselves. Asset metadata from other blend * Local IDs (`entry->id`) own their asset metadata themselves. Asset metadata from other blend
* files are owned by the file browser (`entry`). Only if this is set correctly, we can tell from * files are owned by the file browser (`entry`). Only if this is set correctly, we can tell from
* the metadata RNA pointer if the metadata is stored locally and can thus be edited or not. */ * the metadata RNA pointer if the metadata is stored locally and can thus be edited or not. */
if (BKE_asset_representation_is_local_id(entry->asset)) { if (AS_asset_representation_is_local_id(entry->asset)) {
PointerRNA id_ptr; PointerRNA id_ptr;
RNA_id_pointer_create(entry->id, &id_ptr); RNA_id_pointer_create(entry->id, &id_ptr);
return rna_pointer_inherit_refine(&id_ptr, &RNA_AssetMetaData, asset_data); return rna_pointer_inherit_refine(&id_ptr, &RNA_AssetMetaData, asset_data);

View File

@ -41,16 +41,16 @@ static void node_declare(NodeDeclarationBuilder &b)
.subtype(PROP_DISTANCE) .subtype(PROP_DISTANCE)
.supports_field(); .supports_field();
b.add_output<decl::Bool>(N_("Is Hit")).dependent_field(); b.add_output<decl::Bool>(N_("Is Hit")).dependent_field({6, 7, 8});
b.add_output<decl::Vector>(N_("Hit Position")).dependent_field(); b.add_output<decl::Vector>(N_("Hit Position")).dependent_field({6, 7, 8});
b.add_output<decl::Vector>(N_("Hit Normal")).dependent_field(); b.add_output<decl::Vector>(N_("Hit Normal")).dependent_field({6, 7, 8});
b.add_output<decl::Float>(N_("Hit Distance")).dependent_field(); b.add_output<decl::Float>(N_("Hit Distance")).dependent_field({6, 7, 8});
b.add_output<decl::Vector>(N_("Attribute")).dependent_field({1, 2, 3, 4, 5, 6}); b.add_output<decl::Vector>(N_("Attribute")).dependent_field({6, 7, 8});
b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({1, 2, 3, 4, 5, 6}); b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({6, 7, 8});
b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({1, 2, 3, 4, 5, 6}); b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({6, 7, 8});
b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({1, 2, 3, 4, 5, 6}); b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({6, 7, 8});
b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({1, 2, 3, 4, 5, 6}); b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({6, 7, 8});
} }
static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)

View File

@ -5,6 +5,7 @@ set(INC
. .
gizmo gizmo
gizmo/intern gizmo/intern
../asset_system
../blenfont ../blenfont
../blenkernel ../blenkernel
../blenlib ../blenlib

View File

@ -57,9 +57,10 @@
#include "DNA_windowmanager_types.h" #include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h" #include "DNA_workspace_types.h"
#include "AS_asset_library.h"
#include "BKE_addon.h" #include "BKE_addon.h"
#include "BKE_appdir.h" #include "BKE_appdir.h"
#include "BKE_asset_library.h"
#include "BKE_autoexec.h" #include "BKE_autoexec.h"
#include "BKE_blender.h" #include "BKE_blender.h"
#include "BKE_blendfile.h" #include "BKE_blendfile.h"
@ -159,7 +160,7 @@ void WM_file_tag_modified(void)
bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWindowManager *wm) bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWindowManager *wm)
{ {
return !wm->file_saved || ED_image_should_save_modified(bmain) || return !wm->file_saved || ED_image_should_save_modified(bmain) ||
BKE_asset_library_has_any_unsaved_catalogs(); AS_asset_library_has_any_unsaved_catalogs();
} }
/** \} */ /** \} */
@ -3746,7 +3747,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
has_extra_checkboxes = true; has_extra_checkboxes = true;
} }
if (BKE_asset_library_has_any_unsaved_catalogs()) { if (AS_asset_library_has_any_unsaved_catalogs()) {
static char save_catalogs_when_file_is_closed; static char save_catalogs_when_file_is_closed;
save_catalogs_when_file_is_closed = ED_asset_catalogs_get_save_catalogs_when_file_is_saved(); save_catalogs_when_file_is_closed = ED_asset_catalogs_get_save_catalogs_when_file_is_saved();