Brush Assets: Save As, Delete, Revert and Update operators #117513
|
@ -306,9 +306,6 @@ class GHOST_SystemCocoa : public GHOST_System {
|
|||
*/
|
||||
GHOST_TSuccess setMouseCursorPosition(int32_t x, int32_t y);
|
||||
|
||||
/** Start time at initialization. */
|
||||
uint64_t m_start_time;
|
||||
|
||||
/** Event has been processed directly by Cocoa (or NDOF manager)
|
||||
* and has sent a ghost event to be dispatched */
|
||||
bool m_outsideLoopEventProcessed;
|
||||
|
|
|
@ -529,11 +529,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
|
|||
|
||||
GHOST_SystemCocoa::GHOST_SystemCocoa()
|
||||
{
|
||||
int mib[2];
|
||||
struct timeval boottime;
|
||||
size_t len;
|
||||
char *rstring = nullptr;
|
||||
|
||||
m_modifierMask = 0;
|
||||
m_outsideLoopEventProcessed = false;
|
||||
m_needDelayedApplicationBecomeActiveEventProcessing = false;
|
||||
|
@ -541,24 +536,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
|
|||
GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
|
||||
m_displayManager->initialize();
|
||||
|
||||
// NSEvent timeStamp is given in system uptime, state start date is boot time
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_BOOTTIME;
|
||||
len = sizeof(struct timeval);
|
||||
|
||||
sysctl(mib, 2, &boottime, &len, nullptr, 0);
|
||||
m_start_time = ((boottime.tv_sec * 1000) + (boottime.tv_usec / 1000));
|
||||
|
||||
/* Detect multi-touch trackpad. */
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_MODEL;
|
||||
sysctl(mib, 2, nullptr, &len, nullptr, 0);
|
||||
rstring = (char *)malloc(len);
|
||||
sysctl(mib, 2, rstring, &len, nullptr, 0);
|
||||
|
||||
free(rstring);
|
||||
rstring = nullptr;
|
||||
|
||||
m_ignoreWindowSizedMessages = false;
|
||||
m_ignoreMomentumScroll = false;
|
||||
m_multiTouchScroll = false;
|
||||
|
@ -696,14 +673,8 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
|
|||
|
||||
uint64_t GHOST_SystemCocoa::getMilliSeconds() const
|
||||
{
|
||||
// Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
|
||||
struct timeval currentTime;
|
||||
|
||||
gettimeofday(¤tTime, nullptr);
|
||||
|
||||
// Return timestamp of system uptime
|
||||
|
||||
return ((currentTime.tv_sec * 1000) + (currentTime.tv_usec / 1000) - m_start_time);
|
||||
// For comparing to NSEvent timestamp, this particular API function matches.
|
||||
return (uint64_t)([[NSProcessInfo processInfo] systemUptime] * 1000);
|
||||
}
|
||||
|
||||
uint8_t GHOST_SystemCocoa::getNumDisplays() const
|
||||
|
|
|
@ -59,11 +59,11 @@ class DATA_PT_curves_surface(DataButtonsPanel, Panel):
|
|||
layout.prop(ob.data, "surface")
|
||||
has_surface = ob.data.surface is not None
|
||||
if has_surface:
|
||||
layout.prop_search(ob.data, "surface_uv_map", ob.data.surface.data, "uv_layers", text="UV Map")
|
||||
layout.prop_search(ob.data, "surface_uv_map", ob.data.surface.data, "uv_layers", text="UV Map", icon='GROUP_UVS')
|
||||
else:
|
||||
row = layout.row()
|
||||
row.prop(ob.data, "surface_uv_map", text="UV Map")
|
||||
row.enabled = has_surface
|
||||
row.active = has_surface
|
||||
|
||||
|
||||
class CURVES_MT_add_attribute(Menu):
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup asset_system
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct AssetWeakReference;
|
||||
struct IDRemapper;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Forward declaration, defined in intern/asset_library.hh */
|
||||
typedef struct AssetLibrary AssetLibrary;
|
||||
|
||||
/**
|
||||
* Force clearing of all asset library data. After calling this, new asset libraries can be loaded
|
||||
* just as usual using #AS_asset_library_load(), no init or other setup is needed.
|
||||
*
|
||||
* Does not need to be called on exit, this is handled internally.
|
||||
*/
|
||||
void AS_asset_libraries_exit(void);
|
||||
|
||||
/**
|
||||
* Return the #AssetLibrary rooted at the given directory path.
|
||||
*
|
||||
* Will return the same pointer for repeated calls, until another blend file is loaded.
|
||||
*
|
||||
* To get the in-memory-only "current file" asset library, pass an empty path.
|
||||
*/
|
||||
struct AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath);
|
||||
|
||||
/** Look up the asset's catalog and copy its simple name into #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 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 AS_asset_library_remap_ids(const struct IDRemapper *mappings);
|
||||
|
||||
/**
|
||||
* Attempt to resolve a full path to an asset based on the currently available (not necessary
|
||||
* loaded) asset libraries, and split it into it's directory, ID group and ID name components. The
|
||||
* path is not guaranteed to exist on disk. On failure to resolve the reference, return arguments
|
||||
* will point to null.
|
||||
*
|
||||
* \note Only works for asset libraries on disk and the "Current File" one (others can't be
|
||||
* resolved).
|
||||
*
|
||||
* \param r_path_buffer: Buffer to hold the result in on success. Will be the full path with null
|
||||
* terminators instead of slashes separating the directory, group and name
|
||||
* components. Must be at least #FILE_MAX_LIBEXTRA long.
|
||||
* \param r_dir: Returns the .blend file path with native slashes on success. Optional (passing
|
||||
* null is allowed). For the "Current File" library this will be empty.
|
||||
* \param r_group: Returns the ID group such as "Object", "Material" or "Brush". Optional (passing
|
||||
* null is allowed).
|
||||
* \param r_name: Returns the ID name on success. Optional (passing null is allowed).
|
||||
*/
|
||||
void AS_asset_full_path_explode_from_weak_ref(const struct AssetWeakReference *asset_reference,
|
||||
char r_path_buffer[1090 /* FILE_MAX_LIBEXTRA */],
|
||||
char **r_dir,
|
||||
char **r_group,
|
||||
char **r_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "BKE_callbacks.h"
|
||||
|
||||
struct AssetLibrary;
|
||||
struct IDRemapper;
|
||||
struct Main;
|
||||
|
||||
|
@ -78,7 +77,7 @@ class AssetLibrary {
|
|||
bCallbackFuncStore on_save_callback_store_{};
|
||||
|
||||
public:
|
||||
/* Controlled by #ED_asset_catalogs_set_save_catalogs_when_file_is_saved,
|
||||
/* Controlled by #ed::asset::catalogs_set_save_catalogs_when_file_is_saved,
|
||||
* for managing the "Save Catalog Changes" in the quit-confirmation dialog box. */
|
||||
static bool save_catalogs_when_file_is_saved;
|
||||
|
||||
|
@ -233,6 +232,61 @@ std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRe
|
|||
std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain);
|
||||
|
||||
blender::asset_system::AssetCatalogService *AS_asset_library_get_catalog_service(
|
||||
const ::AssetLibrary *library);
|
||||
const blender::asset_system::AssetLibrary *library);
|
||||
blender::asset_system::AssetCatalogTree *AS_asset_library_get_catalog_tree(
|
||||
const ::AssetLibrary *library);
|
||||
const blender::asset_system::AssetLibrary *library);
|
||||
|
||||
/**
|
||||
* Force clearing of all asset library data. After calling this, new asset libraries can be loaded
|
||||
* just as usual using #AS_asset_library_load(), no init or other setup is needed.
|
||||
*
|
||||
* Does not need to be called on exit, this is handled internally.
|
||||
*/
|
||||
void AS_asset_libraries_exit();
|
||||
|
||||
/**
|
||||
* Return the #AssetLibrary rooted at the given directory path.
|
||||
*
|
||||
* Will return the same pointer for repeated calls, until another blend file is loaded.
|
||||
*
|
||||
* To get the in-memory-only "current file" asset library, pass an empty path.
|
||||
*/
|
||||
blender::asset_system::AssetLibrary *AS_asset_library_load(const char *name,
|
||||
const char *library_dirpath);
|
||||
|
||||
/** Look up the asset's catalog and copy its simple name into #asset_data. */
|
||||
void AS_asset_library_refresh_catalog_simplename(
|
||||
blender::asset_system::AssetLibrary *asset_library, AssetMetaData *asset_data);
|
||||
|
||||
/** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */
|
||||
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 AS_asset_library_remap_ids(const IDRemapper *mappings);
|
||||
|
||||
/**
|
||||
* Attempt to resolve a full path to an asset based on the currently available (not necessary
|
||||
* loaded) asset libraries, and split it into it's directory, ID group and ID name components. The
|
||||
* path is not guaranteed to exist on disk. On failure to resolve the reference, return arguments
|
||||
* will point to null.
|
||||
*
|
||||
* \note Only works for asset libraries on disk and the "Current File" one (others can't be
|
||||
* resolved).
|
||||
*
|
||||
* \param r_path_buffer: Buffer to hold the result in on success. Will be the full path with null
|
||||
* terminators instead of slashes separating the directory, group and name
|
||||
* components. Must be at least #FILE_MAX_LIBEXTRA long.
|
||||
* \param r_dir: Returns the .blend file path with native slashes on success. Optional (passing
|
||||
* null is allowed). For the "Current File" library this will be empty.
|
||||
* \param r_group: Returns the ID group such as "Object", "Material" or "Brush". Optional (passing
|
||||
* null is allowed).
|
||||
* \param r_name: Returns the ID name on success. Optional (passing null is allowed).
|
||||
*/
|
||||
void AS_asset_full_path_explode_from_weak_ref(const AssetWeakReference *asset_reference,
|
||||
char r_path_buffer[1090 /* FILE_MAX_LIBEXTRA */],
|
||||
char **r_dir,
|
||||
char **r_group,
|
||||
char **r_name);
|
||||
|
|
|
@ -33,8 +33,6 @@ set(SRC
|
|||
intern/asset_library_service.hh
|
||||
intern/asset_storage.hh
|
||||
intern/utils.hh
|
||||
|
||||
AS_asset_library.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "AS_asset_catalog_tree.hh"
|
||||
#include "AS_asset_identifier.hh"
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
#include "AS_asset_representation.hh"
|
||||
|
||||
|
@ -31,7 +30,7 @@
|
|||
using namespace blender;
|
||||
using namespace blender::asset_system;
|
||||
|
||||
bool asset_system::AssetLibrary::save_catalogs_when_file_is_saved = true;
|
||||
bool AssetLibrary::save_catalogs_when_file_is_saved = true;
|
||||
|
||||
void AS_asset_libraries_exit()
|
||||
{
|
||||
|
@ -40,27 +39,27 @@ void AS_asset_libraries_exit()
|
|||
AssetLibraryService::destroy();
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *AS_asset_library_load(const Main *bmain,
|
||||
const AssetLibraryReference &library_reference)
|
||||
AssetLibrary *AS_asset_library_load(const Main *bmain,
|
||||
const AssetLibraryReference &library_reference)
|
||||
{
|
||||
AssetLibraryService *service = AssetLibraryService::get();
|
||||
return service->get_asset_library(bmain, library_reference);
|
||||
}
|
||||
|
||||
::AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath)
|
||||
AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath)
|
||||
{
|
||||
/* NOTE: Loading an asset library at this point only means loading the catalogs.
|
||||
* Later on this should invoke reading of asset representations too. */
|
||||
|
||||
AssetLibraryService *service = AssetLibraryService::get();
|
||||
asset_system::AssetLibrary *lib;
|
||||
AssetLibrary *lib;
|
||||
if (library_dirpath == nullptr || library_dirpath[0] == '\0') {
|
||||
lib = service->get_asset_library_current_file();
|
||||
}
|
||||
else {
|
||||
lib = service->get_asset_library_on_disk_custom(name, library_dirpath);
|
||||
}
|
||||
return reinterpret_cast<::AssetLibrary *>(lib);
|
||||
return lib;
|
||||
}
|
||||
|
||||
bool AS_asset_library_has_any_unsaved_catalogs()
|
||||
|
@ -94,18 +93,15 @@ std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain
|
|||
return AS_asset_library_find_suitable_root_path_from_path(bmain->filepath);
|
||||
}
|
||||
|
||||
AssetCatalogService *AS_asset_library_get_catalog_service(const ::AssetLibrary *library_c)
|
||||
AssetCatalogService *AS_asset_library_get_catalog_service(const AssetLibrary *library)
|
||||
{
|
||||
if (library_c == nullptr) {
|
||||
if (library == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const asset_system::AssetLibrary &library = reinterpret_cast<const asset_system::AssetLibrary &>(
|
||||
*library_c);
|
||||
return library.catalog_service.get();
|
||||
return library->catalog_service.get();
|
||||
}
|
||||
|
||||
AssetCatalogTree *AS_asset_library_get_catalog_tree(const ::AssetLibrary *library)
|
||||
AssetCatalogTree *AS_asset_library_get_catalog_tree(const AssetLibrary *library)
|
||||
{
|
||||
AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(library);
|
||||
if (catalog_service == nullptr) {
|
||||
|
@ -115,20 +111,17 @@ AssetCatalogTree *AS_asset_library_get_catalog_tree(const ::AssetLibrary *librar
|
|||
return catalog_service->get_catalog_tree();
|
||||
}
|
||||
|
||||
void AS_asset_library_refresh_catalog_simplename(::AssetLibrary *asset_library,
|
||||
void AS_asset_library_refresh_catalog_simplename(AssetLibrary *asset_library,
|
||||
AssetMetaData *asset_data)
|
||||
{
|
||||
asset_system::AssetLibrary *lib = reinterpret_cast<asset_system::AssetLibrary *>(asset_library);
|
||||
lib->refresh_catalog_simplename(asset_data);
|
||||
asset_library->refresh_catalog_simplename(asset_data);
|
||||
}
|
||||
|
||||
void AS_asset_library_remap_ids(const IDRemapper *mappings)
|
||||
{
|
||||
AssetLibraryService *service = AssetLibraryService::get();
|
||||
service->foreach_loaded_asset_library(
|
||||
[mappings](asset_system::AssetLibrary &library) {
|
||||
library.remap_ids_and_remove_invalid(*mappings);
|
||||
},
|
||||
[mappings](AssetLibrary &library) { library.remap_ids_and_remove_invalid(*mappings); },
|
||||
true);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "AS_asset_catalog.hh"
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
|
||||
#include "BKE_callbacks.h"
|
||||
|
@ -44,13 +43,11 @@ TEST_F(AssetLibraryTest, AS_asset_library_load)
|
|||
|
||||
/* Load the asset library. */
|
||||
const std::string library_dirpath = test_files_dir + "/" + "asset_library";
|
||||
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_dirpath.data());
|
||||
ASSERT_NE(nullptr, library_c_ptr);
|
||||
AssetLibrary *library = AS_asset_library_load(__func__, library_dirpath.data());
|
||||
ASSERT_NE(nullptr, library);
|
||||
|
||||
/* Check that it can be cast to the C++ type and has a Catalog Service. */
|
||||
asset_system::AssetLibrary *library_cpp_ptr = reinterpret_cast<asset_system::AssetLibrary *>(
|
||||
library_c_ptr);
|
||||
AssetCatalogService *service = library_cpp_ptr->catalog_service.get();
|
||||
AssetCatalogService *service = library->catalog_service.get();
|
||||
ASSERT_NE(nullptr, service);
|
||||
|
||||
/* Check that the catalogs defined in the library are actually loaded. This just tests one single
|
||||
|
@ -72,13 +69,11 @@ TEST_F(AssetLibraryTest, load_nonexistent_directory)
|
|||
/* Load the asset library. */
|
||||
const std::string library_dirpath = test_files_dir + "/" +
|
||||
"asset_library/this/subdir/does/not/exist";
|
||||
::AssetLibrary *library_c_ptr = AS_asset_library_load(__func__, library_dirpath.data());
|
||||
ASSERT_NE(nullptr, library_c_ptr);
|
||||
AssetLibrary *library = AS_asset_library_load(__func__, library_dirpath.data());
|
||||
ASSERT_NE(nullptr, library);
|
||||
|
||||
/* Check that it can be cast to the C++ type and has a Catalog Service. */
|
||||
asset_system::AssetLibrary *library_cpp_ptr = reinterpret_cast<asset_system::AssetLibrary *>(
|
||||
library_c_ptr);
|
||||
AssetCatalogService *service = library_cpp_ptr->catalog_service.get();
|
||||
AssetCatalogService *service = library->catalog_service.get();
|
||||
ASSERT_NE(nullptr, service);
|
||||
|
||||
/* Check that the catalog service doesn't have any catalogs. */
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "DNA_color_types.h"
|
||||
#include "DNA_object_enums.h"
|
||||
|
||||
#include "BKE_paint.hh" /* for ePaintMode */
|
||||
|
||||
enum class PaintMode : int8_t;
|
||||
struct AssetWeakReference;
|
||||
struct Brush;
|
||||
struct ImBuf;
|
||||
struct ImagePool;
|
||||
|
@ -31,6 +31,7 @@ struct UnifiedPaintSettings;
|
|||
void BKE_brush_system_init();
|
||||
void BKE_brush_system_exit();
|
||||
|
||||
/* TODO: Should be somewhere else not specific to brushes. */
|
||||
Brush *BKE_brush_asset_runtime_ensure(Main *bmain,
|
||||
const AssetWeakReference *brush_asset_reference);
|
||||
|
||||
|
@ -179,7 +180,7 @@ void BKE_brush_scale_size(int *r_brush_size,
|
|||
/* Returns true if a brush requires a cube
|
||||
* (often presented to the user as a square) tip inside a specific paint mode.
|
||||
*/
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, ePaintMode paint_mode);
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode);
|
||||
|
||||
/* Accessors */
|
||||
#define BKE_brush_tool_get(brush, p) \
|
||||
|
|
|
@ -533,12 +533,8 @@ void BKE_image_ensure_gpu_texture(struct Image *image, struct ImageUser *iuser);
|
|||
struct GPUTexture *BKE_image_get_gpu_texture(struct Image *image,
|
||||
struct ImageUser *iuser,
|
||||
struct ImBuf *ibuf);
|
||||
struct GPUTexture *BKE_image_get_gpu_tiles(struct Image *image,
|
||||
struct ImageUser *iuser,
|
||||
struct ImBuf *ibuf);
|
||||
struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image,
|
||||
struct ImageUser *iuser,
|
||||
struct ImBuf *ibuf);
|
||||
struct GPUTexture *BKE_image_get_gpu_tiles(struct Image *image, struct ImageUser *iuser);
|
||||
struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image, struct ImageUser *iuser);
|
||||
/**
|
||||
* Is the alpha of the `GPUTexture` for a given image/ibuf premultiplied.
|
||||
*/
|
||||
|
|
|
@ -90,29 +90,29 @@ extern const uchar PAINT_CURSOR_WEIGHT_PAINT[3];
|
|||
extern const uchar PAINT_CURSOR_TEXTURE_PAINT[3];
|
||||
extern const uchar PAINT_CURSOR_SCULPT_CURVES[3];
|
||||
|
||||
enum ePaintMode {
|
||||
PAINT_MODE_SCULPT = 0,
|
||||
enum class PaintMode : int8_t {
|
||||
Sculpt = 0,
|
||||
/** Vertex color. */
|
||||
PAINT_MODE_VERTEX = 1,
|
||||
PAINT_MODE_WEIGHT = 2,
|
||||
Vertex = 1,
|
||||
Weight = 2,
|
||||
/** 3D view (projection painting). */
|
||||
PAINT_MODE_TEXTURE_3D = 3,
|
||||
Texture3D = 3,
|
||||
/** Image space (2D painting). */
|
||||
PAINT_MODE_TEXTURE_2D = 4,
|
||||
PAINT_MODE_SCULPT_UV = 5,
|
||||
PAINT_MODE_GPENCIL = 6,
|
||||
Texture2D = 4,
|
||||
SculptUV = 5,
|
||||
GPencil = 6,
|
||||
/* Grease Pencil Vertex Paint */
|
||||
PAINT_MODE_VERTEX_GPENCIL = 7,
|
||||
PAINT_MODE_SCULPT_GPENCIL = 8,
|
||||
PAINT_MODE_WEIGHT_GPENCIL = 9,
|
||||
VertexGPencil = 7,
|
||||
SculptGPencil = 8,
|
||||
WeightGPencil = 9,
|
||||
/** Curves. */
|
||||
PAINT_MODE_SCULPT_CURVES = 10,
|
||||
SculptCurves = 10,
|
||||
|
||||
/** Keep last. */
|
||||
PAINT_MODE_INVALID = 11,
|
||||
Invalid = 11,
|
||||
};
|
||||
|
||||
#define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
|
||||
#define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PaintMode::SculptUV)
|
||||
|
||||
/* overlay invalidation */
|
||||
enum ePaintOverlayControlFlags {
|
||||
|
@ -177,7 +177,7 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name);
|
|||
* Call when entering each respective paint mode.
|
||||
*/
|
||||
bool BKE_paint_ensure(Main *bmain, ToolSettings *ts, Paint **r_paint);
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const uchar col[3]);
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3]);
|
||||
void BKE_paint_free(Paint *p);
|
||||
/**
|
||||
* Called when copying scene settings, so even if 'src' and 'tar' are the same still do a
|
||||
|
@ -190,17 +190,17 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint);
|
|||
|
||||
void BKE_paint_cavity_curve_preset(Paint *p, int preset);
|
||||
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
|
||||
bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, ePaintMode mode);
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode);
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(ePaintMode mode);
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(ePaintMode mode);
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(PaintMode mode);
|
||||
bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, PaintMode mode);
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode);
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(PaintMode mode);
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(PaintMode mode);
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(PaintMode mode);
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(PaintMode mode);
|
||||
Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer);
|
||||
Paint *BKE_paint_get_active_from_context(const bContext *C);
|
||||
ePaintMode BKE_paintmode_get_active_from_context(const bContext *C);
|
||||
ePaintMode BKE_paintmode_get_from_tool(const bToolRef *tref);
|
||||
PaintMode BKE_paintmode_get_active_from_context(const bContext *C);
|
||||
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref);
|
||||
Brush *BKE_paint_brush(Paint *paint);
|
||||
const Brush *BKE_paint_brush_for_read(const Paint *p);
|
||||
void BKE_paint_brush_set(Paint *paint, Brush *br);
|
||||
|
@ -278,7 +278,7 @@ void BKE_paint_face_set_overlay_color_get(int face_set, int seed, uchar r_color[
|
|||
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
const float mouse_pos[2],
|
||||
ePaintMode paint_mode,
|
||||
PaintMode paint_mode,
|
||||
bool stroke_has_started);
|
||||
void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation);
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ template<const ComponentAttributeProviders &providers>
|
|||
inline bool for_all(const void *owner,
|
||||
FunctionRef<bool(const AttributeIDRef &, const AttributeMetaData &)> fn)
|
||||
{
|
||||
Set<AttributeIDRef> handled_attribute_ids;
|
||||
Set<AttributeIDRef, 16> handled_attribute_ids;
|
||||
for (const BuiltinAttributeProvider *provider : providers.builtin_attribute_providers().values())
|
||||
{
|
||||
if (provider->exists(owner)) {
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "BKE_preview_image.hh"
|
||||
#include "BKE_texture.h"
|
||||
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
|
||||
#include "IMB_colormanagement.hh"
|
||||
#include "IMB_imbuf.hh"
|
||||
|
@ -2703,10 +2703,10 @@ ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool displa
|
|||
return im;
|
||||
}
|
||||
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, ePaintMode paint_mode)
|
||||
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode)
|
||||
{
|
||||
switch (paint_mode) {
|
||||
case PAINT_MODE_SCULPT: {
|
||||
case PaintMode::Sculpt: {
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_MULTIPLANE_SCRAPE) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -470,14 +470,14 @@ GPUTexture *BKE_image_get_gpu_texture(Image *image, ImageUser *iuser, ImBuf *ibu
|
|||
return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_2D);
|
||||
}
|
||||
|
||||
GPUTexture *BKE_image_get_gpu_tiles(Image *image, ImageUser *iuser, ImBuf *ibuf)
|
||||
GPUTexture *BKE_image_get_gpu_tiles(Image *image, ImageUser *iuser)
|
||||
{
|
||||
return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_2D_ARRAY);
|
||||
return image_get_gpu_texture(image, iuser, nullptr, TEXTARGET_2D_ARRAY);
|
||||
}
|
||||
|
||||
GPUTexture *BKE_image_get_gpu_tilemap(Image *image, ImageUser *iuser, ImBuf *ibuf)
|
||||
GPUTexture *BKE_image_get_gpu_tilemap(Image *image, ImageUser *iuser)
|
||||
{
|
||||
return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_TILE_MAPPING);
|
||||
return image_get_gpu_texture(image, iuser, nullptr, TEXTARGET_TILE_MAPPING);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -884,7 +884,7 @@ static void lnor_space_for_single_fan(CornerSplitTaskDataCommon *common_data,
|
|||
static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data,
|
||||
const int ml_curr_index,
|
||||
const int space_index,
|
||||
Vector<float3> *edge_vectors)
|
||||
Vector<float3, 16> *edge_vectors)
|
||||
{
|
||||
CornerNormalSpaceArray *lnors_spacearr = common_data->lnors_spacearr;
|
||||
MutableSpan<float3> corner_normals = common_data->corner_normals;
|
||||
|
@ -920,7 +920,7 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data,
|
|||
|
||||
int2 clnors_avg(0);
|
||||
|
||||
Vector<int, 8> processed_corners;
|
||||
Vector<int, 32> processed_corners;
|
||||
|
||||
/* `mlfan_vert_index` the corner of our current edge might not be the corner of our current
|
||||
* vertex!
|
||||
|
@ -1098,8 +1098,8 @@ static bool corner_split_generator_check_cyclic_smooth_fan(const Span<int> corne
|
|||
}
|
||||
|
||||
static void corner_split_generator(CornerSplitTaskDataCommon *common_data,
|
||||
Vector<int> &r_single_corners,
|
||||
Vector<int> &r_fan_corners)
|
||||
Vector<int, 32> &r_single_corners,
|
||||
Vector<int, 32> &r_fan_corners)
|
||||
{
|
||||
const Span<int> corner_verts = common_data->corner_verts;
|
||||
const Span<int> corner_edges = common_data->corner_edges;
|
||||
|
@ -1242,8 +1242,8 @@ void normals_calc_corners(const Span<float3> vert_positions,
|
|||
build_edge_to_corner_map_with_flip_and_sharp(
|
||||
faces, corner_verts, corner_edges, sharp_faces, sharp_edges, edge_to_corners);
|
||||
|
||||
Vector<int> single_corners;
|
||||
Vector<int> fan_corners;
|
||||
Vector<int, 32> single_corners;
|
||||
Vector<int, 32> fan_corners;
|
||||
corner_split_generator(&common_data, single_corners, fan_corners);
|
||||
|
||||
if (r_lnors_spacearr) {
|
||||
|
@ -1262,7 +1262,7 @@ void normals_calc_corners(const Span<float3> vert_positions,
|
|||
});
|
||||
|
||||
threading::parallel_for(fan_corners.index_range(), 1024, [&](const IndexRange range) {
|
||||
Vector<float3> edge_vectors;
|
||||
Vector<float3, 16> edge_vectors;
|
||||
for (const int i : range) {
|
||||
const int corner = fan_corners[i];
|
||||
const int space_index = single_corners.size() + i;
|
||||
|
|
|
@ -315,7 +315,7 @@ void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag)
|
|||
overlay_flags &= ~(flag);
|
||||
}
|
||||
|
||||
bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, ePaintMode mode)
|
||||
bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, PaintMode mode)
|
||||
{
|
||||
ToolSettings *ts = sce->toolsettings;
|
||||
Paint **paint_ptr = nullptr;
|
||||
|
@ -324,39 +324,39 @@ bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, ePaintMode mode)
|
|||
Paint *paint_tmp = nullptr;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
paint_ptr = (Paint **)&ts->sculpt;
|
||||
break;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
paint_ptr = (Paint **)&ts->vpaint;
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
paint_ptr = (Paint **)&ts->wpaint;
|
||||
break;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
paint_tmp = (Paint *)&ts->imapaint;
|
||||
paint_ptr = &paint_tmp;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
paint_ptr = (Paint **)&ts->uvsculpt;
|
||||
break;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_paint;
|
||||
break;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_vertexpaint;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_sculptpaint;
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
paint_ptr = (Paint **)&ts->gp_weightpaint;
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
paint_ptr = (Paint **)&ts->curves_sculpt;
|
||||
break;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
if (paint_ptr) {
|
||||
|
@ -366,34 +366,34 @@ bool BKE_paint_ensure_from_paintmode(Main *bmain, Scene *sce, ePaintMode mode)
|
|||
return false;
|
||||
}
|
||||
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
|
||||
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
|
||||
{
|
||||
if (sce) {
|
||||
ToolSettings *ts = sce->toolsettings;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return &ts->sculpt->paint;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return &ts->vpaint->paint;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return &ts->wpaint->paint;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return &ts->imapaint.paint;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return &ts->uvsculpt->paint;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return &ts->gp_paint->paint;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return &ts->gp_vertexpaint->paint;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return &ts->gp_sculptpaint->paint;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return &ts->gp_weightpaint->paint;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return &ts->curves_sculpt->paint;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
return nullptr;
|
||||
default:
|
||||
return &ts->imapaint.paint;
|
||||
|
@ -403,61 +403,61 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(const ePaintMode mode)
|
||||
const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return rna_enum_brush_sculpt_tool_items;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return rna_enum_brush_vertex_tool_items;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return rna_enum_brush_weight_tool_items;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return rna_enum_brush_image_tool_items;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return rna_enum_brush_uv_sculpt_tool_items;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return rna_enum_brush_gpencil_types_items;
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return rna_enum_brush_gpencil_vertex_types_items;
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return rna_enum_brush_gpencil_sculpt_types_items;
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return rna_enum_brush_gpencil_weight_types_items;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return rna_enum_brush_curves_sculpt_tool_items;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(const ePaintMode mode)
|
||||
const char *BKE_paint_get_tool_prop_id_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return "sculpt_tool";
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return "vertex_tool";
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return "weight_tool";
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return "image_tool";
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return "uv_sculpt_tool";
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return "gpencil_tool";
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return "gpencil_vertex_tool";
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return "gpencil_sculpt_tool";
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return "gpencil_weight_tool";
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return "curves_sculpt_tool";
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -465,22 +465,22 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(const ePaintMode mode)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(const ePaintMode mode)
|
||||
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::GPencil:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return BLT_I18NCONTEXT_ID_BRUSH;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Vertex:
|
||||
case PaintMode::Weight:
|
||||
case PaintMode::SculptUV:
|
||||
case PaintMode::VertexGPencil:
|
||||
case PaintMode::SculptGPencil:
|
||||
case PaintMode::WeightGPencil:
|
||||
case PaintMode::SculptCurves:
|
||||
case PaintMode::Invalid:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
||||
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
||||
{
|
||||
Scene *sce = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
|
@ -576,81 +576,81 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
|
|||
if ((sima = CTX_wm_space_image(C)) != nullptr) {
|
||||
if (obact && obact->mode == OB_MODE_EDIT) {
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
if (sima->mode == SI_MODE_UV) {
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
else if (obact) {
|
||||
switch (obact->mode) {
|
||||
case OB_MODE_SCULPT:
|
||||
return PAINT_MODE_SCULPT;
|
||||
return PaintMode::Sculpt;
|
||||
case OB_MODE_VERTEX_PAINT:
|
||||
return PAINT_MODE_VERTEX;
|
||||
return PaintMode::Vertex;
|
||||
case OB_MODE_WEIGHT_PAINT:
|
||||
return PAINT_MODE_WEIGHT;
|
||||
return PaintMode::Weight;
|
||||
case OB_MODE_TEXTURE_PAINT:
|
||||
return PAINT_MODE_TEXTURE_3D;
|
||||
return PaintMode::Texture3D;
|
||||
case OB_MODE_EDIT:
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
case OB_MODE_SCULPT_CURVES:
|
||||
return PAINT_MODE_SCULPT_CURVES;
|
||||
return PaintMode::SculptCurves;
|
||||
case OB_MODE_PAINT_GREASE_PENCIL:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
default:
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* default to image paint */
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
|
||||
return PAINT_MODE_INVALID;
|
||||
return PaintMode::Invalid;
|
||||
}
|
||||
|
||||
ePaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
|
||||
PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref)
|
||||
{
|
||||
if (tref->space_type == SPACE_VIEW3D) {
|
||||
switch (tref->mode) {
|
||||
case CTX_MODE_SCULPT:
|
||||
return PAINT_MODE_SCULPT;
|
||||
return PaintMode::Sculpt;
|
||||
case CTX_MODE_PAINT_VERTEX:
|
||||
return PAINT_MODE_VERTEX;
|
||||
return PaintMode::Vertex;
|
||||
case CTX_MODE_PAINT_WEIGHT:
|
||||
return PAINT_MODE_WEIGHT;
|
||||
return PaintMode::Weight;
|
||||
case CTX_MODE_PAINT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
case CTX_MODE_PAINT_TEXTURE:
|
||||
return PAINT_MODE_TEXTURE_3D;
|
||||
return PaintMode::Texture3D;
|
||||
case CTX_MODE_VERTEX_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_VERTEX_GPENCIL;
|
||||
return PaintMode::VertexGPencil;
|
||||
case CTX_MODE_SCULPT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_SCULPT_GPENCIL;
|
||||
return PaintMode::SculptGPencil;
|
||||
case CTX_MODE_WEIGHT_GPENCIL_LEGACY:
|
||||
return PAINT_MODE_WEIGHT_GPENCIL;
|
||||
return PaintMode::WeightGPencil;
|
||||
case CTX_MODE_SCULPT_CURVES:
|
||||
return PAINT_MODE_SCULPT_CURVES;
|
||||
return PaintMode::SculptCurves;
|
||||
case CTX_MODE_PAINT_GREASE_PENCIL:
|
||||
return PAINT_MODE_GPENCIL;
|
||||
return PaintMode::GPencil;
|
||||
}
|
||||
}
|
||||
else if (tref->space_type == SPACE_IMAGE) {
|
||||
switch (tref->mode) {
|
||||
case SI_MODE_PAINT:
|
||||
return PAINT_MODE_TEXTURE_2D;
|
||||
return PaintMode::Texture2D;
|
||||
case SI_MODE_UV:
|
||||
return PAINT_MODE_SCULPT_UV;
|
||||
return PaintMode::SculptUV;
|
||||
}
|
||||
}
|
||||
|
||||
return PAINT_MODE_INVALID;
|
||||
return PaintMode::Invalid;
|
||||
}
|
||||
|
||||
Brush *BKE_paint_brush(Paint *p)
|
||||
|
@ -802,31 +802,31 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
|
|||
}
|
||||
}
|
||||
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
|
||||
uint BKE_paint_get_brush_tool_offset_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return offsetof(Brush, imagepaint_tool);
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return offsetof(Brush, sculpt_tool);
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return offsetof(Brush, vertexpaint_tool);
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return offsetof(Brush, weightpaint_tool);
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return offsetof(Brush, uv_sculpt_tool);
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return offsetof(Brush, gpencil_tool);
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PaintMode::VertexGPencil:
|
||||
return offsetof(Brush, gpencil_vertex_tool);
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PaintMode::SculptGPencil:
|
||||
return offsetof(Brush, gpencil_sculpt_tool);
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PaintMode::WeightGPencil:
|
||||
return offsetof(Brush, gpencil_weight_tool);
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return offsetof(Brush, curves_sculpt_tool);
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
break; /* We don't use these yet. */
|
||||
}
|
||||
return 0;
|
||||
|
@ -1142,25 +1142,25 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset)
|
|||
BKE_curvemapping_changed(cumap, false);
|
||||
}
|
||||
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(const ePaintMode mode)
|
||||
eObjectMode BKE_paint_object_mode_from_paintmode(const PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return OB_MODE_SCULPT;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
return OB_MODE_VERTEX_PAINT;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
return OB_MODE_WEIGHT_PAINT;
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return OB_MODE_TEXTURE_PAINT;
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PaintMode::SculptUV:
|
||||
return OB_MODE_EDIT;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
return OB_MODE_SCULPT_CURVES;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
return OB_MODE_PAINT_GREASE_PENCIL;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
default:
|
||||
return OB_MODE_OBJECT;
|
||||
}
|
||||
|
@ -1253,7 +1253,7 @@ bool BKE_paint_ensure(Main *bmain, ToolSettings *ts, Paint **r_paint)
|
|||
return false;
|
||||
}
|
||||
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const uchar col[3])
|
||||
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3])
|
||||
{
|
||||
UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode);
|
||||
|
@ -1423,7 +1423,7 @@ static bool paint_rake_rotation_active(const MTex &mtex)
|
|||
return mtex.tex && mtex.brush_angle_mode & MTEX_ANGLE_RAKE;
|
||||
}
|
||||
|
||||
static const bool paint_rake_rotation_active(const Brush &brush, ePaintMode paint_mode)
|
||||
static const bool paint_rake_rotation_active(const Brush &brush, PaintMode paint_mode)
|
||||
{
|
||||
return paint_rake_rotation_active(brush.mtex) || paint_rake_rotation_active(brush.mask_mtex) ||
|
||||
BKE_brush_has_cube_tip(&brush, paint_mode);
|
||||
|
@ -1432,7 +1432,7 @@ static const bool paint_rake_rotation_active(const Brush &brush, ePaintMode pain
|
|||
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
const float mouse_pos[2],
|
||||
ePaintMode paint_mode,
|
||||
PaintMode paint_mode,
|
||||
bool stroke_has_started)
|
||||
{
|
||||
bool ok = false;
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
/* TODO(@JulianEisel): For asset shelf region reading/writing. Region read/write should be done via
|
||||
* a #ARegionType callback. */
|
||||
#include "../editors/asset/ED_asset_shelf.h"
|
||||
#include "../editors/asset/ED_asset_shelf.hh"
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
# include "BPY_extern.h"
|
||||
|
@ -1044,7 +1044,7 @@ static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
|
|||
}
|
||||
|
||||
if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
|
||||
ED_asset_shelf_region_blend_write(writer, region);
|
||||
blender::ed::asset::shelf::region_blend_write(writer, region);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1208,7 @@ static void direct_link_region(BlendDataReader *reader, ARegion *region, int spa
|
|||
}
|
||||
}
|
||||
if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
|
||||
ED_asset_shelf_region_blend_read_data(reader, region);
|
||||
blender::ed::asset::shelf::region_blend_read_data(reader, region);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2884,10 +2884,10 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain)
|
|||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::GPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::WeightGPencil);
|
||||
|
||||
/* Set default Draw brush. */
|
||||
if (brush != nullptr) {
|
||||
|
@ -2928,9 +2928,9 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain)
|
|||
/* Reset all grease pencil brushes. */
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::WeightGPencil);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -497,9 +497,9 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
|||
}
|
||||
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::VertexGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::SculptGPencil);
|
||||
BKE_paint_ensure_from_paintmode(bmain, scene, PaintMode::WeightGPencil);
|
||||
|
||||
/* Enable cursor. */
|
||||
if (ts->gp_paint) {
|
||||
|
|
|
@ -34,15 +34,15 @@ class Instance;
|
|||
|
||||
class ObjectKey {
|
||||
/** Hash value of the key. */
|
||||
uint64_t hash_value_;
|
||||
uint64_t hash_value_ = 0;
|
||||
/** Original Object or source object for duplis. */
|
||||
Object *ob_;
|
||||
Object *ob_ = nullptr;
|
||||
/** Original Parent object for duplis. */
|
||||
Object *parent_;
|
||||
Object *parent_ = nullptr;
|
||||
/** Dupli objects recursive unique identifier */
|
||||
int id_[MAX_DUPLI_RECUR];
|
||||
/** Used for particle system hair. */
|
||||
int sub_key_;
|
||||
int sub_key_ = 0;
|
||||
|
||||
public:
|
||||
ObjectKey() = default;
|
||||
|
|
|
@ -69,8 +69,8 @@ PassMain::Sub &MeshPass::get_subpass(
|
|||
GPUTexture *texture = nullptr;
|
||||
GPUTexture *tilemap = nullptr;
|
||||
if (image->source == IMA_SRC_TILED) {
|
||||
texture = BKE_image_get_gpu_tiles(image, iuser, nullptr);
|
||||
tilemap = BKE_image_get_gpu_tilemap(image, iuser, nullptr);
|
||||
texture = BKE_image_get_gpu_tiles(image, iuser);
|
||||
tilemap = BKE_image_get_gpu_tilemap(image, iuser);
|
||||
}
|
||||
else {
|
||||
texture = BKE_image_get_gpu_texture(image, iuser, nullptr);
|
||||
|
|
|
@ -1807,9 +1807,9 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *mater
|
|||
GPUTexture *gputex;
|
||||
ImageUser *iuser = tex->iuser_available ? &tex->iuser : nullptr;
|
||||
if (tex->tiled_mapping_name[0]) {
|
||||
gputex = BKE_image_get_gpu_tiles(tex->ima, iuser, nullptr);
|
||||
gputex = BKE_image_get_gpu_tiles(tex->ima, iuser);
|
||||
drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state);
|
||||
gputex = BKE_image_get_gpu_tilemap(tex->ima, iuser, nullptr);
|
||||
gputex = BKE_image_get_gpu_tilemap(tex->ima, iuser);
|
||||
drw_shgroup_material_texture(grp, gputex, tex->tiled_mapping_name, tex->sampler_state);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -925,11 +925,11 @@ template<class T> inline void PassBase<T>::material_set(Manager &manager, GPUMat
|
|||
/* Image */
|
||||
ImageUser *iuser = tex->iuser_available ? &tex->iuser : nullptr;
|
||||
if (tex->tiled_mapping_name[0]) {
|
||||
GPUTexture *tiles = BKE_image_get_gpu_tiles(tex->ima, iuser, nullptr);
|
||||
GPUTexture *tiles = BKE_image_get_gpu_tiles(tex->ima, iuser);
|
||||
manager.acquire_texture(tiles);
|
||||
bind_texture(tex->sampler_name, tiles, tex->sampler_state);
|
||||
|
||||
GPUTexture *tile_map = BKE_image_get_gpu_tilemap(tex->ima, iuser, nullptr);
|
||||
GPUTexture *tile_map = BKE_image_get_gpu_tilemap(tex->ima, iuser);
|
||||
manager.acquire_texture(tile_map);
|
||||
bind_texture(tex->tiled_mapping_name, tile_map, tex->sampler_state);
|
||||
}
|
||||
|
|
|
@ -282,17 +282,19 @@ static Object *get_poselib_object(bContext *C)
|
|||
|
||||
static void poselib_tempload_exit(PoseBlendData *pbd)
|
||||
{
|
||||
ED_asset_temp_id_consumer_free(&pbd->temp_id_consumer);
|
||||
using namespace blender::ed;
|
||||
asset::temp_id_consumer_free(&pbd->temp_id_consumer);
|
||||
}
|
||||
|
||||
static bAction *poselib_blend_init_get_action(bContext *C, wmOperator *op)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
const AssetRepresentationHandle *asset = CTX_wm_asset(C);
|
||||
|
||||
PoseBlendData *pbd = static_cast<PoseBlendData *>(op->customdata);
|
||||
|
||||
pbd->temp_id_consumer = ED_asset_temp_id_consumer_create(asset);
|
||||
return (bAction *)ED_asset_temp_id_consumer_ensure_local_id(
|
||||
pbd->temp_id_consumer = asset::temp_id_consumer_create(asset);
|
||||
return (bAction *)asset::temp_id_consumer_ensure_local_id(
|
||||
pbd->temp_id_consumer, ID_AC, CTX_data_main(C), op->reports);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,19 +40,17 @@ set(SRC
|
|||
intern/asset_temp_id_consumer.cc
|
||||
intern/asset_type.cc
|
||||
|
||||
ED_asset_catalog.h
|
||||
ED_asset_catalog.hh
|
||||
ED_asset_filter.hh
|
||||
ED_asset_handle.h
|
||||
ED_asset_handle.hh
|
||||
ED_asset_import.hh
|
||||
ED_asset_indexer.h
|
||||
ED_asset_library.h
|
||||
ED_asset_list.h
|
||||
ED_asset_indexer.hh
|
||||
ED_asset_library.hh
|
||||
ED_asset_list.hh
|
||||
ED_asset_mark_clear.h
|
||||
ED_asset_shelf.h
|
||||
ED_asset_temp_id_consumer.h
|
||||
ED_asset_type.h
|
||||
ED_asset_mark_clear.hh
|
||||
ED_asset_shelf.hh
|
||||
ED_asset_temp_id_consumer.hh
|
||||
ED_asset_type.hh
|
||||
intern/asset_library_reference.hh
|
||||
intern/asset_shelf.hh
|
||||
)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edasset
|
||||
*
|
||||
* Supplement for `ED_asset_catalog.hh`. Part of the same API but usable in C.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AssetLibrary;
|
||||
struct Main;
|
||||
|
||||
void ED_asset_catalogs_save_from_main_path(struct AssetLibrary *library, const struct Main *bmain);
|
||||
|
||||
/**
|
||||
* Saving catalog edits when the file is saved is a global option shared for each asset library,
|
||||
* and as such ignores the per asset library #ED_asset_catalogs_read_only().
|
||||
*/
|
||||
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(bool should_save);
|
||||
bool ED_asset_catalogs_get_save_catalogs_when_file_is_saved(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -8,11 +8,11 @@
|
|||
* UI/Editor level API for catalog operations, creating richer functionality than the asset system
|
||||
* catalog API provides (which this uses internally).
|
||||
*
|
||||
* Functions can be expected to not perform any change when #ED_asset_catalogs_read_only() returns
|
||||
* Functions can be expected to not perform any change when #catalogs_read_only() returns
|
||||
* true. Generally UI code should disable such functionality in this case, so these functions are
|
||||
* not called at all.
|
||||
*
|
||||
* Note that `ED_asset_catalog.h` is part of this API.
|
||||
* Note that `ED_asset_catalog.hh` is part of this API.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -23,23 +23,34 @@
|
|||
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
struct AssetLibrary;
|
||||
struct bScreen;
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
void catalogs_save_from_main_path(asset_system::AssetLibrary *library, const Main *bmain);
|
||||
|
||||
/**
|
||||
* Saving catalog edits when the file is saved is a global option shared for each asset library,
|
||||
* and as such ignores the per asset library #catalogs_read_only().
|
||||
*/
|
||||
void catalogs_set_save_catalogs_when_file_is_saved(bool should_save);
|
||||
bool catalogs_get_save_catalogs_when_file_is_saved(void);
|
||||
|
||||
/**
|
||||
* Returns if the catalogs of \a library are allowed to be editable, or if the UI should forbid
|
||||
* edits.
|
||||
*/
|
||||
[[nodiscard]] bool ED_asset_catalogs_read_only(const AssetLibrary &library);
|
||||
[[nodiscard]] bool catalogs_read_only(const asset_system::AssetLibrary &library);
|
||||
|
||||
blender::asset_system::AssetCatalog *ED_asset_catalog_add(
|
||||
AssetLibrary *library, blender::StringRefNull name, blender::StringRef parent_path = nullptr);
|
||||
void ED_asset_catalog_remove(AssetLibrary *library,
|
||||
const blender::asset_system::CatalogID &catalog_id);
|
||||
asset_system::AssetCatalog *catalog_add(asset_system::AssetLibrary *library,
|
||||
StringRefNull name,
|
||||
StringRef parent_path = nullptr);
|
||||
void catalog_remove(asset_system::AssetLibrary *library,
|
||||
const asset_system::CatalogID &catalog_id);
|
||||
|
||||
void ED_asset_catalog_rename(AssetLibrary *library,
|
||||
blender::asset_system::CatalogID catalog_id,
|
||||
blender::StringRefNull new_name);
|
||||
void catalog_rename(asset_system::AssetLibrary *library,
|
||||
asset_system::CatalogID catalog_id,
|
||||
StringRefNull new_name);
|
||||
/**
|
||||
* Reinsert catalog identified by \a src_catalog_id as child to catalog identified by \a
|
||||
* dst_parent_catalog_id. If \a dst_parent_catalog_id is not set, the catalog is moved to the root
|
||||
|
@ -51,7 +62,8 @@ void ED_asset_catalog_rename(AssetLibrary *library,
|
|||
*
|
||||
* Nothing is done (debug builds run into an assert) if the given catalog IDs can't be identified.
|
||||
*/
|
||||
void ED_asset_catalog_move(
|
||||
AssetLibrary *library,
|
||||
blender::asset_system::CatalogID src_catalog_id,
|
||||
std::optional<blender::asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);
|
||||
void catalog_move(asset_system::AssetLibrary *library,
|
||||
asset_system::CatalogID src_catalog_id,
|
||||
std::optional<asset_system::CatalogID> dst_parent_catalog_id = std::nullopt);
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -26,6 +26,8 @@ class AssetLibrary;
|
|||
class AssetRepresentation;
|
||||
} // namespace blender::asset_system
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
/**
|
||||
* Compare \a asset against the settings of \a filter.
|
||||
*
|
||||
|
@ -38,10 +40,8 @@ class AssetRepresentation;
|
|||
* \returns True if the asset should be visible with these filter settings (parameters match).
|
||||
* Otherwise returns false (mismatch).
|
||||
*/
|
||||
bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
|
||||
const blender::asset_system::AssetRepresentation &asset);
|
||||
|
||||
namespace blender::ed::asset {
|
||||
bool filter_matches_asset(const AssetFilterSettings *filter,
|
||||
const blender::asset_system::AssetRepresentation &asset);
|
||||
|
||||
struct AssetItemTree {
|
||||
asset_system::AssetCatalogTree catalogs;
|
||||
|
|
|
@ -19,25 +19,15 @@
|
|||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct AssetHandle;
|
||||
namespace blender::asset_system {
|
||||
class AssetRepresentation;
|
||||
}
|
||||
using AssetRepresentationHandle = blender::asset_system::AssetRepresentation;
|
||||
#else
|
||||
typedef struct AssetRepresentationHandle AssetRepresentationHandle;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace blender::ed::asset {
|
||||
|
||||
struct AssetHandle;
|
||||
asset_system::AssetRepresentation *handle_get_representation(const AssetHandle *asset);
|
||||
int handle_get_preview_icon_id(const AssetHandle *asset);
|
||||
int handle_get_preview_or_type_icon_id(const AssetHandle *asset);
|
||||
|
||||
AssetRepresentationHandle *ED_asset_handle_get_representation(const struct AssetHandle *asset);
|
||||
int ED_asset_handle_get_preview_icon_id(const struct AssetHandle *asset);
|
||||
int ED_asset_handle_get_preview_or_type_icon_id(const struct AssetHandle *asset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::ed::asset
|
|
@ -10,9 +10,7 @@
|
|||
|
||||
#include "ED_file_indexer.hh"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace blender::ed::asset::index {
|
||||
|
||||
/**
|
||||
* File Indexer Service for indexing asset files.
|
||||
|
@ -33,6 +31,4 @@ extern "C" {
|
|||
*/
|
||||
extern const FileIndexerType file_indexer_asset;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::ed::asset::index
|
|
@ -10,23 +10,21 @@
|
|||
|
||||
#include "DNA_asset_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace blender::ed::asset {
|
||||
|
||||
/**
|
||||
* Return an index that can be used to uniquely identify \a library, assuming
|
||||
* that all relevant indices were created with this function.
|
||||
*/
|
||||
int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library);
|
||||
int library_reference_to_enum_value(const AssetLibraryReference *library);
|
||||
/**
|
||||
* Return an asset library reference matching the index returned by
|
||||
* #ED_asset_library_reference_to_enum_value().
|
||||
* #library_reference_to_enum_value().
|
||||
*/
|
||||
AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
|
||||
AssetLibraryReference library_reference_from_enum_value(int value);
|
||||
/**
|
||||
* Translate all available asset libraries to an RNA enum, whereby the enum values match the result
|
||||
* of #ED_asset_library_reference_to_enum_value() for any given library.
|
||||
* of #library_reference_to_enum_value() for any given library.
|
||||
*
|
||||
* Since this is meant for UI display, skips non-displayable libraries, that is, libraries with an
|
||||
* empty name or path.
|
||||
|
@ -36,9 +34,6 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value);
|
|||
* included, since they are stored on disk with a single root directory,
|
||||
* thus have a well defined location that can be written to.
|
||||
*/
|
||||
const struct EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
|
||||
bool include_generated);
|
||||
const EnumPropertyItem *library_reference_to_rna_enum_itemf(bool include_generated);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::ed::asset
|
|
@ -1,96 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edasset
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DNA_asset_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace blender::asset_system {
|
||||
class AssetRepresentation;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AssetLibraryReference;
|
||||
struct ID;
|
||||
struct bContext;
|
||||
struct wmNotifier;
|
||||
struct wmRegionListenerParams;
|
||||
|
||||
/**
|
||||
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
|
||||
* and may return earlier.
|
||||
*
|
||||
* \warning: Asset list reading involves an #AS_asset_library_load() call which may reload asset
|
||||
* library data like catalogs (invalidating pointers). Refer to its warning for details.
|
||||
*/
|
||||
void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference,
|
||||
const struct bContext *C);
|
||||
bool ED_assetlist_is_loaded(const struct AssetLibraryReference *library_reference);
|
||||
void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference,
|
||||
const struct bContext *C);
|
||||
void ED_assetlist_clear(const struct AssetLibraryReference *library_reference,
|
||||
const struct bContext *C);
|
||||
bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *library_reference);
|
||||
/**
|
||||
* Tag all asset lists in the storage that show main data as needing an update (re-fetch).
|
||||
*
|
||||
* This only tags the data. If the asset list is visible on screen, the space is still responsible
|
||||
* for ensuring the necessary redraw. It can use #ED_assetlist_listen() to check if the asset-list
|
||||
* needs a redraw for a given notifier.
|
||||
*/
|
||||
void ED_assetlist_storage_tag_main_data_dirty(void);
|
||||
/**
|
||||
* Remapping of ID pointers within the asset lists. Typically called when an ID is deleted to clear
|
||||
* all references to it (\a id_new is null then).
|
||||
*/
|
||||
void ED_assetlist_storage_id_remap(struct ID *id_old, struct ID *id_new);
|
||||
/**
|
||||
* Can't wait for static deallocation to run. There's nested data allocated with our guarded
|
||||
* allocator, it will complain about unfreed memory on exit.
|
||||
*/
|
||||
void ED_assetlist_storage_exit(void);
|
||||
|
||||
AssetHandle ED_assetlist_asset_handle_get_by_index(const AssetLibraryReference *library_reference,
|
||||
int asset_index);
|
||||
#ifdef __cplusplus
|
||||
blender::asset_system::AssetRepresentation *ED_assetlist_asset_get_by_index(
|
||||
const AssetLibraryReference &library_reference, int asset_index);
|
||||
#endif
|
||||
|
||||
bool ED_assetlist_asset_image_is_loading(const AssetLibraryReference *library_reference,
|
||||
const AssetHandle *asset_handle);
|
||||
struct ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle);
|
||||
|
||||
/**
|
||||
* \return True if the region needs a UI redraw.
|
||||
*/
|
||||
bool ED_assetlist_listen(const struct wmNotifier *notifier);
|
||||
/**
|
||||
* \return The number of assets stored in the asset list for \a library_reference, or -1 if there
|
||||
* is no list fetched for it.
|
||||
*/
|
||||
int ED_assetlist_size(const struct AssetLibraryReference *library_reference);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
void asset_reading_region_listen_fn(const wmRegionListenerParams *params);
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
||||
#endif
|
|
@ -14,12 +14,21 @@
|
|||
|
||||
struct AssetHandle;
|
||||
struct AssetLibraryReference;
|
||||
|
||||
struct AssetLibraryReference;
|
||||
struct ID;
|
||||
struct ImBuf;
|
||||
struct bContext;
|
||||
struct wmNotifier;
|
||||
struct wmRegionListenerParams;
|
||||
namespace blender::asset_system {
|
||||
class AssetLibrary;
|
||||
class AssetRepresentation;
|
||||
} // namespace blender::asset_system
|
||||
|
||||
namespace blender::ed::asset::list {
|
||||
|
||||
void asset_reading_region_listen_fn(const wmRegionListenerParams *params);
|
||||
|
||||
/**
|
||||
* Get the asset library being read into an asset-list and identified using \a library_reference.
|
||||
*
|
||||
|
@ -28,17 +37,68 @@ class AssetRepresentation;
|
|||
* ND_ASSET_LIST_READING` notifiers until loading is done, they can be used to continuously
|
||||
* call this function to retrieve the asset library once available.
|
||||
*/
|
||||
blender::asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *library_get_once_available(
|
||||
const AssetLibraryReference &library_reference);
|
||||
|
||||
/* Can return false to stop iterating. */
|
||||
using AssetListHandleIterFn = blender::FunctionRef<bool(AssetHandle)>;
|
||||
using AssetListIterFn = blender::FunctionRef<bool(blender::asset_system::AssetRepresentation &)>;
|
||||
using AssetListHandleIterFn = FunctionRef<bool(AssetHandle)>;
|
||||
using AssetListIterFn = FunctionRef<bool(asset_system::AssetRepresentation &)>;
|
||||
|
||||
/**
|
||||
* \warning Never keep the asset handle passed to \a fn outside of \a fn's scope. While iterating,
|
||||
* the file data wrapped by the asset handle can be freed, since the file cache has a maximum size.
|
||||
*/
|
||||
void ED_assetlist_iterate(const AssetLibraryReference &library_reference,
|
||||
AssetListHandleIterFn fn);
|
||||
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn);
|
||||
void iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn);
|
||||
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn);
|
||||
|
||||
/**
|
||||
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
|
||||
* and may return earlier.
|
||||
*
|
||||
* \warning: Asset list reading involves an #AS_asset_library_load() call which may reload asset
|
||||
* library data like catalogs (invalidating pointers). Refer to its warning for details.
|
||||
*/
|
||||
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C);
|
||||
bool is_loaded(const AssetLibraryReference *library_reference);
|
||||
void ensure_previews_job(const AssetLibraryReference *library_reference, const bContext *C);
|
||||
void clear(const AssetLibraryReference *library_reference, const bContext *C);
|
||||
bool storage_has_list_for_library(const AssetLibraryReference *library_reference);
|
||||
/**
|
||||
* Tag all asset lists in the storage that show main data as needing an update (re-fetch).
|
||||
*
|
||||
* This only tags the data. If the asset list is visible on screen, the space is still responsible
|
||||
* for ensuring the necessary redraw. It can use #listen() to check if the asset-list
|
||||
* needs a redraw for a given notifier.
|
||||
*/
|
||||
void storage_tag_main_data_dirty();
|
||||
/**
|
||||
* Remapping of ID pointers within the asset lists. Typically called when an ID is deleted to clear
|
||||
* all references to it (\a id_new is null then).
|
||||
*/
|
||||
void storage_id_remap(ID *id_old, ID *id_new);
|
||||
/**
|
||||
* Can't wait for static deallocation to run. There's nested data allocated with our guarded
|
||||
* allocator, it will complain about unfreed memory on exit.
|
||||
*/
|
||||
void storage_exit();
|
||||
|
||||
AssetHandle asset_handle_get_by_index(const AssetLibraryReference *library_reference,
|
||||
int asset_index);
|
||||
blender::asset_system::AssetRepresentation *asset_get_by_index(
|
||||
const AssetLibraryReference &library_reference, int asset_index);
|
||||
|
||||
bool asset_image_is_loading(const AssetLibraryReference *library_reference,
|
||||
const AssetHandle *asset_handle);
|
||||
ImBuf *asset_image_get(const AssetHandle *asset_handle);
|
||||
|
||||
/**
|
||||
* \return True if the region needs a UI redraw.
|
||||
*/
|
||||
bool listen(const wmNotifier *notifier);
|
||||
/**
|
||||
* \return The number of assets stored in the asset list for \a library_reference, or -1 if there
|
||||
* is no list fetched for it.
|
||||
*/
|
||||
int size(const AssetLibraryReference *library_reference);
|
||||
|
||||
} // namespace blender::ed::asset::list
|
||||
|
|
|
@ -8,15 +8,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AssetMetaData;
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct bContext;
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
/**
|
||||
* Mark the datablock as asset.
|
||||
*
|
||||
|
@ -24,14 +22,14 @@ struct bContext;
|
|||
*
|
||||
* \return whether the datablock was marked as asset; false when it is not capable of becoming an
|
||||
* asset, or when it already was an asset. */
|
||||
bool ED_asset_mark_id(struct ID *id);
|
||||
bool mark_id(ID *id);
|
||||
|
||||
/**
|
||||
* Generate preview image for the given datablock.
|
||||
*
|
||||
* The preview image might be generated using a background thread.
|
||||
*/
|
||||
void ED_asset_generate_preview(const struct bContext *C, struct ID *id);
|
||||
void generate_preview(const bContext *C, ID *id);
|
||||
|
||||
/**
|
||||
* Remove the asset metadata, turning the ID into a "normal" ID.
|
||||
|
@ -41,7 +39,7 @@ void ED_asset_generate_preview(const struct bContext *C, struct ID *id);
|
|||
*
|
||||
* \return whether the asset metadata was actually removed; false when the ID was not an asset.
|
||||
*/
|
||||
bool ED_asset_clear_id(struct ID *id);
|
||||
bool clear_id(ID *id);
|
||||
|
||||
/**
|
||||
* Copy the asset metadata to the given destination ID.
|
||||
|
@ -53,12 +51,10 @@ bool ED_asset_clear_id(struct ID *id);
|
|||
* \return true when the copy succeeded, false otherwise. The only reason for
|
||||
* failure is when \a destination is of a type that cannot be an asset.
|
||||
*/
|
||||
bool ED_asset_copy_to_id(const struct AssetMetaData *asset_data, struct ID *destination);
|
||||
bool copy_to_id(const AssetMetaData *asset_data, ID *destination);
|
||||
|
||||
void ED_assets_pre_save(struct Main *bmain);
|
||||
void pre_save_assets(Main *bmain);
|
||||
|
||||
bool ED_asset_can_mark_single_from_context(const struct bContext *C);
|
||||
bool can_mark_single_from_context(const bContext *C);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::ed::asset
|
|
@ -1,76 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edasset
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ARegion;
|
||||
struct ARegionType;
|
||||
struct AssetShelfSettings;
|
||||
struct AssetShelfType;
|
||||
struct bContext;
|
||||
struct bContextDataResult;
|
||||
struct BlendDataReader;
|
||||
struct BlendWriter;
|
||||
struct Main;
|
||||
struct wmWindowManager;
|
||||
struct RegionPollParams;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Asset Shelf Regions
|
||||
*
|
||||
* Naming conventions:
|
||||
* - #ED_asset_shelf_regions_xxx(): Applies to both regions (#RGN_TYPE_ASSET_SHELF and
|
||||
* #RGN_TYPE_ASSET_SHELF_HEADER).
|
||||
* - #ED_asset_shelf_region_xxx(): Applies to the main shelf region (#RGN_TYPE_ASSET_SHELF).
|
||||
* - #ED_asset_shelf_header_region_xxx(): Applies to the shelf header region
|
||||
* (#RGN_TYPE_ASSET_SHELF_HEADER).
|
||||
*
|
||||
* \{ */
|
||||
|
||||
bool ED_asset_shelf_regions_poll(const struct RegionPollParams *params);
|
||||
|
||||
/** Only needed for #RGN_TYPE_ASSET_SHELF (not #RGN_TYPE_ASSET_SHELF_HEADER). */
|
||||
void *ED_asset_shelf_region_duplicate(void *regiondata);
|
||||
void ED_asset_shelf_region_free(struct ARegion *region);
|
||||
void ED_asset_shelf_region_init(struct wmWindowManager *wm, struct ARegion *region);
|
||||
int ED_asset_shelf_region_snap(const struct ARegion *region, int size, int axis);
|
||||
void ED_asset_shelf_region_on_user_resize(const struct ARegion *region);
|
||||
void ED_asset_shelf_region_listen(const struct wmRegionListenerParams *params);
|
||||
void ED_asset_shelf_region_layout(const bContext *C, struct ARegion *region);
|
||||
void ED_asset_shelf_region_draw(const bContext *C, struct ARegion *region);
|
||||
void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, struct ARegion *region);
|
||||
void ED_asset_shelf_region_blend_write(BlendWriter *writer, struct ARegion *region);
|
||||
int ED_asset_shelf_region_prefsizey(void);
|
||||
|
||||
void ED_asset_shelf_header_region_init(struct wmWindowManager *wm, struct ARegion *region);
|
||||
void ED_asset_shelf_header_region(const struct bContext *C, struct ARegion *region);
|
||||
void ED_asset_shelf_header_region_listen(const struct wmRegionListenerParams *params);
|
||||
int ED_asset_shelf_header_region_size(void);
|
||||
void ED_asset_shelf_header_regiontype_register(struct ARegionType *region_type,
|
||||
const int space_type);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void ED_asset_shelf_type_unlink(const struct Main &bmain, const struct AssetShelfType &shelf_type);
|
||||
|
||||
int ED_asset_shelf_tile_width(const struct AssetShelfSettings &settings);
|
||||
int ED_asset_shelf_tile_height(const struct AssetShelfSettings &settings);
|
||||
|
||||
int ED_asset_shelf_context(const struct bContext *C,
|
||||
const char *member,
|
||||
struct bContextDataResult *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,69 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edasset
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct ARegion;
|
||||
struct ARegionType;
|
||||
struct AssetShelfSettings;
|
||||
struct AssetShelfType;
|
||||
struct bContext;
|
||||
struct bContextDataResult;
|
||||
struct BlendDataReader;
|
||||
struct BlendWriter;
|
||||
struct Main;
|
||||
struct wmWindowManager;
|
||||
struct RegionPollParams;
|
||||
|
||||
namespace blender::ed::asset::shelf {
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Asset Shelf Regions
|
||||
*
|
||||
* Naming conventions:
|
||||
* - #regions_xxx(): Applies to both regions (#RGN_TYPE_ASSET_SHELF and
|
||||
* #RGN_TYPE_ASSET_SHELF_HEADER).
|
||||
* - #region_xxx(): Applies to the main shelf region (#RGN_TYPE_ASSET_SHELF).
|
||||
* - #header_region_xxx(): Applies to the shelf header region
|
||||
* (#RGN_TYPE_ASSET_SHELF_HEADER).
|
||||
*
|
||||
* \{ */
|
||||
|
||||
bool regions_poll(const RegionPollParams *params);
|
||||
|
||||
/** Only needed for #RGN_TYPE_ASSET_SHELF (not #RGN_TYPE_ASSET_SHELF_HEADER). */
|
||||
void *region_duplicate(void *regiondata);
|
||||
void region_free(ARegion *region);
|
||||
void region_init(wmWindowManager *wm, ARegion *region);
|
||||
int region_snap(const ARegion *region, int size, int axis);
|
||||
void region_on_user_resize(const ARegion *region);
|
||||
void region_listen(const wmRegionListenerParams *params);
|
||||
void region_layout(const bContext *C, ARegion *region);
|
||||
void region_draw(const bContext *C, ARegion *region);
|
||||
void region_blend_read_data(BlendDataReader *reader, ARegion *region);
|
||||
void region_blend_write(BlendWriter *writer, ARegion *region);
|
||||
int region_prefsizey(void);
|
||||
|
||||
void header_region_init(wmWindowManager *wm, ARegion *region);
|
||||
void header_region(const bContext *C, ARegion *region);
|
||||
void header_region_listen(const wmRegionListenerParams *params);
|
||||
int header_region_size(void);
|
||||
void header_regiontype_register(ARegionType *region_type, const int space_type);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void type_unlink(const Main &bmain, const AssetShelfType &shelf_type);
|
||||
|
||||
int tile_width(const AssetShelfSettings &settings);
|
||||
int tile_height(const AssetShelfSettings &settings);
|
||||
|
||||
int context(const bContext *C, const char *member, bContextDataResult *result);
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
|
@ -15,31 +15,23 @@
|
|||
|
||||
#include "DNA_ID_enums.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct AssetTempIDConsumer;
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct ReportList;
|
||||
namespace blender::asset_system {
|
||||
class AssetRepresentation;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace blender::ed::asset {
|
||||
|
||||
typedef struct AssetTempIDConsumer AssetTempIDConsumer;
|
||||
|
||||
struct Main;
|
||||
struct ReportList;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++" AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
|
||||
AssetTempIDConsumer *temp_id_consumer_create(
|
||||
const blender::asset_system::AssetRepresentation *asset);
|
||||
#endif
|
||||
void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer);
|
||||
struct ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
|
||||
ID_Type id_type,
|
||||
struct Main *bmain,
|
||||
struct ReportList *reports);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
void temp_id_consumer_free(AssetTempIDConsumer **consumer);
|
||||
ID *temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer,
|
||||
ID_Type id_type,
|
||||
Main *bmain,
|
||||
ReportList *reports);
|
||||
|
||||
} // namespace blender::ed::asset
|
|
@ -10,13 +10,11 @@
|
|||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ID;
|
||||
|
||||
bool ED_asset_type_id_is_non_experimental(const struct ID *id);
|
||||
namespace blender::ed::asset {
|
||||
|
||||
bool id_type_is_non_experimental(const ID *id);
|
||||
#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS \
|
||||
(FILTER_ID_MA | FILTER_ID_GR | FILTER_ID_OB | FILTER_ID_AC | FILTER_ID_WO | FILTER_ID_NT)
|
||||
|
||||
|
@ -24,7 +22,7 @@ bool ED_asset_type_id_is_non_experimental(const struct ID *id);
|
|||
* Check if the asset type for \a id (which doesn't need to be an asset right now) can be an asset,
|
||||
* respecting the "Extended Asset Browser" experimental feature flag.
|
||||
*/
|
||||
bool ED_asset_type_is_supported(const ID *id);
|
||||
bool id_type_is_supported(const ID *id);
|
||||
|
||||
/**
|
||||
* Get the filter flags (subset of #FILTER_ID_ALL) representing the asset ID types that may be
|
||||
|
@ -32,7 +30,7 @@ bool ED_asset_type_is_supported(const ID *id);
|
|||
* \note Does not check for #BKE_id_can_be_asset(), so may return filter flags for IDs that can
|
||||
* never be assets.
|
||||
*/
|
||||
int64_t ED_asset_types_supported_as_filter_flags(void);
|
||||
int64_t types_supported_as_filter_flags();
|
||||
|
||||
/**
|
||||
* Utility: A string enumerating the non-experimental asset types. This is useful info to
|
||||
|
@ -43,6 +41,4 @@ int64_t ED_asset_types_supported_as_filter_flags(void);
|
|||
#define ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING \
|
||||
"Material, Collection, Object, Pose Action, Node Group or World"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::ed::asset
|
|
@ -18,15 +18,15 @@
|
|||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "ED_asset_catalog.h"
|
||||
#include "ED_asset_catalog.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
|
||||
using namespace blender;
|
||||
namespace blender::ed::asset {
|
||||
|
||||
using namespace blender::asset_system;
|
||||
|
||||
bool ED_asset_catalogs_read_only(const ::AssetLibrary &library)
|
||||
bool catalogs_read_only(const AssetLibrary &library)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
&library);
|
||||
|
@ -58,16 +58,16 @@ static std::string catalog_name_ensure_unique(AssetCatalogService &catalog_servi
|
|||
return unique_name;
|
||||
}
|
||||
|
||||
asset_system::AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
|
||||
StringRefNull name,
|
||||
StringRef parent_path)
|
||||
asset_system::AssetCatalog *catalog_add(AssetLibrary *library,
|
||||
StringRefNull name,
|
||||
StringRef parent_path)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
library);
|
||||
if (!catalog_service) {
|
||||
return nullptr;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*library)) {
|
||||
if (catalogs_read_only(*library)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ asset_system::AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
|
|||
return new_catalog;
|
||||
}
|
||||
|
||||
void ED_asset_catalog_remove(::AssetLibrary *library, const CatalogID &catalog_id)
|
||||
void catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
library);
|
||||
|
@ -93,7 +93,7 @@ void ED_asset_catalog_remove(::AssetLibrary *library, const CatalogID &catalog_i
|
|||
BLI_assert_unreachable();
|
||||
return;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*library)) {
|
||||
if (catalogs_read_only(*library)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,9 @@ void ED_asset_catalog_remove(::AssetLibrary *library, const CatalogID &catalog_i
|
|||
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
|
||||
}
|
||||
|
||||
void ED_asset_catalog_rename(::AssetLibrary *library,
|
||||
const CatalogID catalog_id,
|
||||
const StringRefNull new_name)
|
||||
void catalog_rename(AssetLibrary *library,
|
||||
const CatalogID catalog_id,
|
||||
const StringRefNull new_name)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
library);
|
||||
|
@ -113,7 +113,7 @@ void ED_asset_catalog_rename(::AssetLibrary *library,
|
|||
BLI_assert_unreachable();
|
||||
return;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*library)) {
|
||||
if (catalogs_read_only(*library)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -133,9 +133,9 @@ void ED_asset_catalog_rename(::AssetLibrary *library,
|
|||
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
|
||||
}
|
||||
|
||||
void ED_asset_catalog_move(::AssetLibrary *library,
|
||||
const CatalogID src_catalog_id,
|
||||
const std::optional<CatalogID> dst_parent_catalog_id)
|
||||
void catalog_move(AssetLibrary *library,
|
||||
const CatalogID src_catalog_id,
|
||||
const std::optional<CatalogID> dst_parent_catalog_id)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
library);
|
||||
|
@ -143,7 +143,7 @@ void ED_asset_catalog_move(::AssetLibrary *library,
|
|||
BLI_assert_unreachable();
|
||||
return;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*library)) {
|
||||
if (catalogs_read_only(*library)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ void ED_asset_catalog_move(::AssetLibrary *library,
|
|||
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
|
||||
}
|
||||
|
||||
void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *bmain)
|
||||
void catalogs_save_from_main_path(AssetLibrary *library, const Main *bmain)
|
||||
{
|
||||
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
|
||||
library);
|
||||
|
@ -187,7 +187,7 @@ void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *
|
|||
BLI_assert_unreachable();
|
||||
return;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*library)) {
|
||||
if (catalogs_read_only(*library)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,12 +197,14 @@ void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *
|
|||
catalog_service->write_to_disk(bmain->filepath);
|
||||
}
|
||||
|
||||
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)
|
||||
void catalogs_set_save_catalogs_when_file_is_saved(const bool 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 catalogs_get_save_catalogs_when_file_is_saved()
|
||||
{
|
||||
return asset_system::AssetLibrary::save_catalogs_when_file_is_saved;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
#include "AS_asset_library.hh"
|
||||
|
||||
#include "ED_asset_filter.hh"
|
||||
#include "ED_asset_handle.h"
|
||||
#include "ED_asset_library.h"
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_handle.hh"
|
||||
#include "ED_asset_library.hh"
|
||||
#include "ED_asset_list.hh"
|
||||
|
||||
using namespace blender;
|
||||
namespace blender::ed::asset {
|
||||
|
||||
bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
|
||||
const asset_system::AssetRepresentation &asset)
|
||||
bool filter_matches_asset(const AssetFilterSettings *filter,
|
||||
const asset_system::AssetRepresentation &asset)
|
||||
{
|
||||
ID_Type asset_type = asset.get_id_type();
|
||||
uint64_t asset_id_filter = BKE_idtype_idcode_to_idfilter(asset_type);
|
||||
|
@ -50,18 +49,15 @@ bool ED_asset_filter_matches_asset(const AssetFilterSettings *filter,
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
asset_system::AssetCatalogTree build_filtered_catalog_tree(
|
||||
const asset_system::AssetLibrary &library,
|
||||
const AssetLibraryReference &library_ref,
|
||||
const blender::FunctionRef<bool(const asset_system::AssetRepresentation &)>
|
||||
is_asset_visible_fn)
|
||||
const FunctionRef<bool(const asset_system::AssetRepresentation &)> is_asset_visible_fn)
|
||||
{
|
||||
Set<StringRef> known_paths;
|
||||
|
||||
/* Collect paths containing assets. */
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!is_asset_visible_fn(asset)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -109,14 +105,14 @@ AssetItemTree build_filtered_all_catalog_tree(
|
|||
assets_per_path;
|
||||
Vector<asset_system::AssetRepresentation *> unassigned_assets;
|
||||
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(library_ref);
|
||||
list::storage_fetch(&library_ref, &C);
|
||||
asset_system::AssetLibrary *library = list::library_get_once_available(library_ref);
|
||||
if (!library) {
|
||||
return {};
|
||||
}
|
||||
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
|
||||
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!filter_matches_asset(&filter_settings, asset)) {
|
||||
return true;
|
||||
}
|
||||
const AssetMetaData &meta_data = asset.get_metadata();
|
||||
|
|
|
@ -22,20 +22,23 @@
|
|||
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "ED_asset_handle.h"
|
||||
#include "ED_asset_handle.hh"
|
||||
|
||||
blender::asset_system::AssetRepresentation *ED_asset_handle_get_representation(
|
||||
const AssetHandle *asset)
|
||||
namespace blender::ed::asset {
|
||||
|
||||
asset_system::AssetRepresentation *handle_get_representation(const AssetHandle *asset)
|
||||
{
|
||||
return asset->file_data->asset;
|
||||
}
|
||||
|
||||
int ED_asset_handle_get_preview_icon_id(const AssetHandle *asset)
|
||||
int handle_get_preview_icon_id(const AssetHandle *asset)
|
||||
{
|
||||
return asset->file_data->preview_icon_id;
|
||||
}
|
||||
|
||||
int ED_asset_handle_get_preview_or_type_icon_id(const AssetHandle *asset)
|
||||
int handle_get_preview_or_type_icon_id(const AssetHandle *asset)
|
||||
{
|
||||
return ED_file_icon(asset->file_data);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <iomanip>
|
||||
#include <optional>
|
||||
|
||||
#include "ED_asset_indexer.h"
|
||||
#include "ED_asset_indexer.hh"
|
||||
|
||||
#include "DNA_asset_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
@ -648,7 +648,7 @@ struct AssetIndex {
|
|||
const int UNKNOWN_VERSION = -1;
|
||||
|
||||
/**
|
||||
* `blender::io::serialize::Value` representing the contents of an index file.
|
||||
* `io::serialize::Value` representing the contents of an index file.
|
||||
*
|
||||
* Value is used over #DictionaryValue as the contents of the index could be corrupted and
|
||||
* doesn't represent an object. In case corrupted files are detected the `get_version` would
|
||||
|
@ -940,8 +940,6 @@ constexpr FileIndexerType asset_indexer()
|
|||
return indexer;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset::index
|
||||
const FileIndexerType file_indexer_asset = asset_indexer();
|
||||
|
||||
extern "C" {
|
||||
const FileIndexerType file_indexer_asset = blender::ed::asset::index::asset_indexer();
|
||||
}
|
||||
} // namespace blender::ed::asset::index
|
||||
|
|
|
@ -23,9 +23,11 @@
|
|||
#include "RNA_enum_types.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "ED_asset_library.h"
|
||||
#include "ED_asset_library.hh"
|
||||
|
||||
int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *library)
|
||||
namespace blender::ed::asset {
|
||||
|
||||
int library_reference_to_enum_value(const AssetLibraryReference *library)
|
||||
{
|
||||
/* Simple case: Predefined repository, just set the value. */
|
||||
if (library->type < ASSET_LIBRARY_CUSTOM) {
|
||||
|
@ -43,7 +45,7 @@ int ED_asset_library_reference_to_enum_value(const AssetLibraryReference *librar
|
|||
return ASSET_LIBRARY_LOCAL;
|
||||
}
|
||||
|
||||
AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
|
||||
AssetLibraryReference library_reference_from_enum_value(int value)
|
||||
{
|
||||
AssetLibraryReference library;
|
||||
|
||||
|
@ -74,7 +76,7 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
|
|||
return library;
|
||||
}
|
||||
|
||||
const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool include_generated)
|
||||
const EnumPropertyItem *library_reference_to_rna_enum_itemf(const bool include_generated)
|
||||
{
|
||||
EnumPropertyItem *item = nullptr;
|
||||
int totitem = 0;
|
||||
|
@ -110,7 +112,7 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
|
|||
library_reference.type = ASSET_LIBRARY_CUSTOM;
|
||||
library_reference.custom_library_index = i;
|
||||
|
||||
const int enum_value = ED_asset_library_reference_to_enum_value(&library_reference);
|
||||
const int enum_value = library_reference_to_enum_value(&library_reference);
|
||||
/* Use library path as description, it's a nice hint for users. */
|
||||
EnumPropertyItem tmp = {
|
||||
enum_value, user_library->name, ICON_NONE, user_library->name, user_library->dirpath};
|
||||
|
@ -120,3 +122,5 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
|
|||
RNA_enum_item_end(&item, &totitem);
|
||||
return item;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -34,13 +34,12 @@
|
|||
#include "../space_file/file_indexer.hh"
|
||||
#include "../space_file/filelist.hh"
|
||||
|
||||
#include "ED_asset_indexer.h"
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_indexer.hh"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_screen.hh"
|
||||
#include "asset_library_reference.hh"
|
||||
|
||||
namespace blender::ed::asset {
|
||||
namespace blender::ed::asset::list {
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Asset list API
|
||||
|
@ -159,7 +158,7 @@ void AssetList::setup()
|
|||
"");
|
||||
|
||||
const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing);
|
||||
filelist_setindexer(files, use_asset_indexer ? &file_indexer_asset : &file_indexer_noop);
|
||||
filelist_setindexer(files, use_asset_indexer ? &index::file_indexer_asset : &file_indexer_noop);
|
||||
|
||||
char dirpath[FILE_MAX_LIBEXTRA] = "";
|
||||
if (!asset_lib_path.empty()) {
|
||||
|
@ -228,9 +227,7 @@ void AssetList::iterate(AssetListHandleIterFn fn) const
|
|||
void AssetList::iterate(AssetListIterFn fn) const
|
||||
{
|
||||
iterate([&fn](AssetHandle handle) {
|
||||
asset_system::AssetRepresentation &asset =
|
||||
reinterpret_cast<blender::asset_system::AssetRepresentation &>(*handle.file_data->asset);
|
||||
|
||||
auto &asset = reinterpret_cast<asset_system::AssetRepresentation &>(*handle.file_data->asset);
|
||||
return fn(asset);
|
||||
});
|
||||
}
|
||||
|
@ -451,21 +448,16 @@ void asset_reading_region_listen_fn(const wmRegionListenerParams *params)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name C-API
|
||||
* \{ */
|
||||
|
||||
using namespace blender;
|
||||
using namespace blender::ed::asset;
|
||||
|
||||
void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
|
||||
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
|
||||
{
|
||||
AssetListStorage::fetch_library(*library_reference, *C);
|
||||
}
|
||||
|
||||
bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference)
|
||||
bool is_loaded(const AssetLibraryReference *library_reference)
|
||||
{
|
||||
AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
if (!list) {
|
||||
|
@ -477,8 +469,7 @@ bool ED_assetlist_is_loaded(const AssetLibraryReference *library_reference)
|
|||
return list->isLoaded();
|
||||
}
|
||||
|
||||
void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference,
|
||||
const bContext *C)
|
||||
void ensure_previews_job(const AssetLibraryReference *library_reference, const bContext *C)
|
||||
{
|
||||
|
||||
AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
|
@ -487,7 +478,7 @@ void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_refer
|
|||
}
|
||||
}
|
||||
|
||||
void ED_assetlist_clear(const AssetLibraryReference *library_reference, const bContext *C)
|
||||
void clear(const AssetLibraryReference *library_reference, const bContext *C)
|
||||
{
|
||||
AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
if (list) {
|
||||
|
@ -495,12 +486,12 @@ void ED_assetlist_clear(const AssetLibraryReference *library_reference, const bC
|
|||
}
|
||||
}
|
||||
|
||||
bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *library_reference)
|
||||
bool storage_has_list_for_library(const AssetLibraryReference *library_reference)
|
||||
{
|
||||
return AssetListStorage::lookup_list(*library_reference) != nullptr;
|
||||
}
|
||||
|
||||
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn)
|
||||
void iterate(const AssetLibraryReference &library_reference, AssetListHandleIterFn fn)
|
||||
{
|
||||
AssetList *list = AssetListStorage::lookup_list(library_reference);
|
||||
if (list) {
|
||||
|
@ -508,7 +499,7 @@ void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetL
|
|||
}
|
||||
}
|
||||
|
||||
void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
|
||||
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
|
||||
{
|
||||
AssetList *list = AssetListStorage::lookup_list(library_reference);
|
||||
if (list) {
|
||||
|
@ -516,7 +507,7 @@ void ED_assetlist_iterate(const AssetLibraryReference &library_reference, AssetL
|
|||
}
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *library_get_once_available(
|
||||
const AssetLibraryReference &library_reference)
|
||||
{
|
||||
const AssetList *list = AssetListStorage::lookup_list(library_reference);
|
||||
|
@ -526,29 +517,28 @@ asset_system::AssetLibrary *ED_assetlist_library_get_once_available(
|
|||
return list->asset_library();
|
||||
}
|
||||
|
||||
AssetHandle ED_assetlist_asset_handle_get_by_index(const AssetLibraryReference *library_reference,
|
||||
int asset_index)
|
||||
AssetHandle asset_handle_get_by_index(const AssetLibraryReference *library_reference,
|
||||
int asset_index)
|
||||
{
|
||||
const AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
return list->asset_get_by_index(asset_index);
|
||||
}
|
||||
|
||||
asset_system::AssetRepresentation *ED_assetlist_asset_get_by_index(
|
||||
asset_system::AssetRepresentation *asset_get_by_index(
|
||||
const AssetLibraryReference &library_reference, int asset_index)
|
||||
{
|
||||
AssetHandle asset_handle = ED_assetlist_asset_handle_get_by_index(&library_reference,
|
||||
asset_index);
|
||||
AssetHandle asset_handle = asset_handle_get_by_index(&library_reference, asset_index);
|
||||
return reinterpret_cast<asset_system::AssetRepresentation *>(asset_handle.file_data->asset);
|
||||
}
|
||||
|
||||
bool ED_assetlist_asset_image_is_loading(const AssetLibraryReference *library_reference,
|
||||
const AssetHandle *asset_handle)
|
||||
bool asset_image_is_loading(const AssetLibraryReference *library_reference,
|
||||
const AssetHandle *asset_handle)
|
||||
{
|
||||
const AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
return list->isAssetPreviewLoading(*asset_handle);
|
||||
}
|
||||
|
||||
ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle)
|
||||
ImBuf *asset_image_get(const AssetHandle *asset_handle)
|
||||
{
|
||||
ImBuf *imbuf = filelist_file_getimage(asset_handle->file_data);
|
||||
if (imbuf) {
|
||||
|
@ -558,12 +548,12 @@ ImBuf *ED_assetlist_asset_image_get(const AssetHandle *asset_handle)
|
|||
return filelist_geticon_image_ex(asset_handle->file_data);
|
||||
}
|
||||
|
||||
bool ED_assetlist_listen(const wmNotifier *notifier)
|
||||
bool listen(const wmNotifier *notifier)
|
||||
{
|
||||
return AssetList::listen(*notifier);
|
||||
}
|
||||
|
||||
int ED_assetlist_size(const AssetLibraryReference *library_reference)
|
||||
int size(const AssetLibraryReference *library_reference)
|
||||
{
|
||||
AssetList *list = AssetListStorage::lookup_list(*library_reference);
|
||||
if (list) {
|
||||
|
@ -572,19 +562,21 @@ int ED_assetlist_size(const AssetLibraryReference *library_reference)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void ED_assetlist_storage_tag_main_data_dirty()
|
||||
void storage_tag_main_data_dirty()
|
||||
{
|
||||
AssetListStorage::tagMainDataDirty();
|
||||
}
|
||||
|
||||
void ED_assetlist_storage_id_remap(ID *id_old, ID *id_new)
|
||||
void storage_id_remap(ID *id_old, ID *id_new)
|
||||
{
|
||||
AssetListStorage::remapID(id_old, id_new);
|
||||
}
|
||||
|
||||
void ED_assetlist_storage_exit()
|
||||
void storage_exit()
|
||||
{
|
||||
AssetListStorage::destruct();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::ed::asset::list
|
||||
|
|
|
@ -23,14 +23,16 @@
|
|||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_mark_clear.h"
|
||||
#include "ED_asset_type.h"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_asset_mark_clear.hh"
|
||||
#include "ED_asset_type.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
bool ED_asset_mark_id(ID *id)
|
||||
namespace blender::ed::asset {
|
||||
|
||||
bool mark_id(ID *id)
|
||||
{
|
||||
if (id->asset_data) {
|
||||
return false;
|
||||
|
@ -49,12 +51,12 @@ bool ED_asset_mark_id(ID *id)
|
|||
}
|
||||
|
||||
/* Important for asset storage to update properly! */
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
list::storage_tag_main_data_dirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ED_asset_generate_preview(const bContext *C, ID *id)
|
||||
void generate_preview(const bContext *C, ID *id)
|
||||
{
|
||||
PreviewImage *preview = BKE_previewimg_id_get(id);
|
||||
if (preview) {
|
||||
|
@ -64,7 +66,7 @@ void ED_asset_generate_preview(const bContext *C, ID *id)
|
|||
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, !G.background);
|
||||
}
|
||||
|
||||
bool ED_asset_clear_id(ID *id)
|
||||
bool clear_id(ID *id)
|
||||
{
|
||||
if (!id->asset_data) {
|
||||
return false;
|
||||
|
@ -73,12 +75,12 @@ bool ED_asset_clear_id(ID *id)
|
|||
id_fake_user_clear(id);
|
||||
|
||||
/* Important for asset storage to update properly! */
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
list::storage_tag_main_data_dirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ED_assets_pre_save(Main *bmain)
|
||||
void pre_save_assets(Main *bmain)
|
||||
{
|
||||
ID *id;
|
||||
FOREACH_MAIN_ID_BEGIN (bmain, id) {
|
||||
|
@ -93,7 +95,7 @@ void ED_assets_pre_save(Main *bmain)
|
|||
FOREACH_MAIN_ID_END;
|
||||
}
|
||||
|
||||
bool ED_asset_can_mark_single_from_context(const bContext *C)
|
||||
bool can_mark_single_from_context(const bContext *C)
|
||||
{
|
||||
/* Context needs a "id" pointer to be set for #ASSET_OT_mark()/#ASSET_OT_mark_single() and
|
||||
* #ASSET_OT_clear()/#ASSET_OT_clear_single() to use. */
|
||||
|
@ -101,10 +103,10 @@ bool ED_asset_can_mark_single_from_context(const bContext *C)
|
|||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
return ED_asset_type_is_supported(id);
|
||||
return id_type_is_supported(id);
|
||||
}
|
||||
|
||||
bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination)
|
||||
bool copy_to_id(const AssetMetaData *asset_data, ID *destination)
|
||||
{
|
||||
if (!BKE_id_can_be_asset(destination)) {
|
||||
return false;
|
||||
|
@ -116,3 +118,5 @@ bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination)
|
|||
destination->asset_data = BKE_asset_metadata_copy(asset_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "RNA_enum_types.hh"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_asset_menu_utils.hh"
|
||||
|
||||
|
@ -70,10 +69,10 @@ static const asset_system::AssetRepresentation *get_local_asset_from_relative_id
|
|||
{
|
||||
AssetLibraryReference library_ref{};
|
||||
library_ref.type = ASSET_LIBRARY_LOCAL;
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
list::storage_fetch(&library_ref, &C);
|
||||
|
||||
const asset_system::AssetRepresentation *matching_asset = nullptr;
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (asset.get_identifier().library_relative_identifier() == relative_identifier) {
|
||||
matching_asset = &asset;
|
||||
return false;
|
||||
|
@ -82,7 +81,7 @@ static const asset_system::AssetRepresentation *get_local_asset_from_relative_id
|
|||
});
|
||||
|
||||
if (reports && !matching_asset) {
|
||||
if (ED_assetlist_is_loaded(&library_ref)) {
|
||||
if (list::is_loaded(&library_ref)) {
|
||||
BKE_reportf(
|
||||
reports, RPT_ERROR, "No asset found at path \"%s\"", relative_identifier.c_str());
|
||||
}
|
||||
|
@ -102,8 +101,8 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
|
|||
}
|
||||
|
||||
const AssetLibraryReference library_ref = asset_system::all_library_reference();
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
list::storage_fetch(&library_ref, &C);
|
||||
asset_system::AssetLibrary *all_library = list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
BKE_report(reports, RPT_WARNING, "Asset loading is unfinished");
|
||||
|
@ -112,7 +111,7 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
|
|||
const std::string full_path = all_library->resolve_asset_weak_reference_to_full_path(weak_ref);
|
||||
|
||||
const asset_system::AssetRepresentation *matching_asset = nullptr;
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (asset.get_identifier().full_path() == full_path) {
|
||||
matching_asset = &asset;
|
||||
return false;
|
||||
|
@ -121,7 +120,7 @@ static const asset_system::AssetRepresentation *find_asset_from_weak_ref(
|
|||
});
|
||||
|
||||
if (reports && !matching_asset) {
|
||||
if (ED_assetlist_is_loaded(&library_ref)) {
|
||||
if (list::is_loaded(&library_ref)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "No asset found at path \"%s\"", full_path.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* \ingroup edasset
|
||||
*/
|
||||
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
#include "AS_asset_representation.hh"
|
||||
|
||||
|
@ -24,7 +23,6 @@
|
|||
#include "BLI_set.hh"
|
||||
|
||||
#include "ED_asset.hh"
|
||||
#include "ED_asset_catalog.hh"
|
||||
#include "ED_screen.hh"
|
||||
#include "ED_util.hh"
|
||||
/* XXX needs access to the file list, should all be done via the asset system in future. */
|
||||
|
@ -41,15 +39,12 @@
|
|||
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
using namespace blender;
|
||||
|
||||
namespace blender::ed::asset {
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
using PointerRNAVec = blender::Vector<PointerRNA>;
|
||||
|
||||
static PointerRNAVec get_single_id_vec_from_context(const bContext *C)
|
||||
static Vector<PointerRNA> get_single_id_vec_from_context(const bContext *C)
|
||||
{
|
||||
PointerRNAVec ids;
|
||||
Vector<PointerRNA> ids;
|
||||
PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID);
|
||||
if (idptr.data) {
|
||||
ids.append(idptr);
|
||||
|
@ -62,9 +57,9 @@ static PointerRNAVec get_single_id_vec_from_context(const bContext *C)
|
|||
* ("selected_ids" context member) over a single active one ("id" context member), since usually
|
||||
* batch operations are more useful.
|
||||
*/
|
||||
static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C)
|
||||
static Vector<PointerRNA> asset_operation_get_ids_from_context(const bContext *C)
|
||||
{
|
||||
PointerRNAVec ids;
|
||||
Vector<PointerRNA> ids;
|
||||
|
||||
/* "selected_ids" context member. */
|
||||
{
|
||||
|
@ -85,7 +80,7 @@ static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C)
|
|||
}
|
||||
|
||||
/**
|
||||
* Information about what's contained in a #PointerRNAVec, returned by
|
||||
* Information about what's contained in a #Vector<PointerRNA>, returned by
|
||||
* #asset_operation_get_id_vec_stats_from_context().
|
||||
*/
|
||||
struct IDVecStats {
|
||||
|
@ -98,7 +93,7 @@ struct IDVecStats {
|
|||
* Helper to report stats about the IDs in context. Operator polls use this, also to report a
|
||||
* helpful disabled hint to the user.
|
||||
*/
|
||||
static IDVecStats asset_operation_get_id_vec_stats_from_ids(const PointerRNAVec &id_pointers)
|
||||
static IDVecStats asset_operation_get_id_vec_stats_from_ids(const Vector<PointerRNA> &id_pointers)
|
||||
{
|
||||
IDVecStats stats;
|
||||
|
||||
|
@ -108,7 +103,7 @@ static IDVecStats asset_operation_get_id_vec_stats_from_ids(const PointerRNAVec
|
|||
BLI_assert(RNA_struct_is_ID(ptr.type));
|
||||
|
||||
ID *id = static_cast<ID *>(ptr.data);
|
||||
if (ED_asset_type_is_supported(id)) {
|
||||
if (id_type_is_supported(id)) {
|
||||
stats.has_supported_type = true;
|
||||
}
|
||||
if (ID_IS_ASSET(id)) {
|
||||
|
@ -134,7 +129,7 @@ static const char *asset_operation_unsupported_type_msg(const bool is_single)
|
|||
|
||||
class AssetMarkHelper {
|
||||
public:
|
||||
void operator()(const bContext &C, const PointerRNAVec &ids);
|
||||
void operator()(const bContext &C, const Vector<PointerRNA> &ids);
|
||||
|
||||
void reportResults(ReportList &reports) const;
|
||||
bool wasSuccessful() const;
|
||||
|
@ -149,7 +144,7 @@ class AssetMarkHelper {
|
|||
Stats stats;
|
||||
};
|
||||
|
||||
void AssetMarkHelper::operator()(const bContext &C, const PointerRNAVec &ids)
|
||||
void AssetMarkHelper::operator()(const bContext &C, const Vector<PointerRNA> &ids)
|
||||
{
|
||||
for (const PointerRNA &ptr : ids) {
|
||||
BLI_assert(RNA_struct_is_ID(ptr.type));
|
||||
|
@ -160,8 +155,8 @@ void AssetMarkHelper::operator()(const bContext &C, const PointerRNAVec &ids)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ED_asset_mark_id(id)) {
|
||||
ED_asset_generate_preview(&C, id);
|
||||
if (mark_id(id)) {
|
||||
generate_preview(&C, id);
|
||||
|
||||
stats.last_id = id;
|
||||
stats.tot_created++;
|
||||
|
@ -199,7 +194,7 @@ void AssetMarkHelper::reportResults(ReportList &reports) const
|
|||
}
|
||||
}
|
||||
|
||||
static int asset_mark_exec(const bContext *C, const wmOperator *op, const PointerRNAVec &ids)
|
||||
static int asset_mark_exec(const bContext *C, const wmOperator *op, const Vector<PointerRNA> &ids)
|
||||
{
|
||||
AssetMarkHelper mark_helper;
|
||||
mark_helper(*C, ids);
|
||||
|
@ -215,7 +210,7 @@ static int asset_mark_exec(const bContext *C, const wmOperator *op, const Pointe
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static bool asset_mark_poll(bContext *C, const PointerRNAVec &ids)
|
||||
static bool asset_mark_poll(bContext *C, const Vector<PointerRNA> &ids)
|
||||
{
|
||||
IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids);
|
||||
|
||||
|
@ -274,7 +269,7 @@ class AssetClearHelper {
|
|||
public:
|
||||
AssetClearHelper(const bool set_fake_user) : set_fake_user_(set_fake_user) {}
|
||||
|
||||
void operator()(const PointerRNAVec &ids);
|
||||
void operator()(const Vector<PointerRNA> &ids);
|
||||
|
||||
void reportResults(const bContext *C, ReportList &reports) const;
|
||||
bool wasSuccessful() const;
|
||||
|
@ -288,7 +283,7 @@ class AssetClearHelper {
|
|||
Stats stats;
|
||||
};
|
||||
|
||||
void AssetClearHelper::operator()(const PointerRNAVec &ids)
|
||||
void AssetClearHelper::operator()(const Vector<PointerRNA> &ids)
|
||||
{
|
||||
for (const PointerRNA &ptr : ids) {
|
||||
BLI_assert(RNA_struct_is_ID(ptr.type));
|
||||
|
@ -298,7 +293,7 @@ void AssetClearHelper::operator()(const PointerRNAVec &ids)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!ED_asset_clear_id(id)) {
|
||||
if (!clear_id(id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -341,7 +336,7 @@ bool AssetClearHelper::wasSuccessful() const
|
|||
return stats.tot_cleared > 0;
|
||||
}
|
||||
|
||||
static int asset_clear_exec(const bContext *C, const wmOperator *op, const PointerRNAVec &ids)
|
||||
static int asset_clear_exec(const bContext *C, const wmOperator *op, const Vector<PointerRNA> &ids)
|
||||
{
|
||||
const bool set_fake_user = RNA_boolean_get(op->ptr, "set_fake_user");
|
||||
AssetClearHelper clear_helper(set_fake_user);
|
||||
|
@ -358,7 +353,7 @@ static int asset_clear_exec(const bContext *C, const wmOperator *op, const Point
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static bool asset_clear_poll(bContext *C, const PointerRNAVec &ids)
|
||||
static bool asset_clear_poll(bContext *C, const Vector<PointerRNA> &ids)
|
||||
{
|
||||
IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids);
|
||||
|
||||
|
@ -456,7 +451,7 @@ static bool asset_library_refresh_poll(bContext *C)
|
|||
return false;
|
||||
}
|
||||
|
||||
return ED_assetlist_storage_has_list_for_library(library);
|
||||
return list::storage_has_list_for_library(library);
|
||||
}
|
||||
|
||||
static int asset_library_refresh_exec(bContext *C, wmOperator * /*unused*/)
|
||||
|
@ -470,7 +465,7 @@ static int asset_library_refresh_exec(bContext *C, wmOperator * /*unused*/)
|
|||
else {
|
||||
/* Execution mode #2: Outside the Asset Browser, use the asset list. */
|
||||
const AssetLibraryReference *library = CTX_wm_asset_library_ref(C);
|
||||
ED_assetlist_clear(library, C);
|
||||
list::clear(library, C);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -501,11 +496,11 @@ static bool asset_catalog_operator_poll(bContext *C)
|
|||
if (!sfile) {
|
||||
return false;
|
||||
}
|
||||
const AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
const asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
if (!asset_library) {
|
||||
return false;
|
||||
}
|
||||
if (ED_asset_catalogs_read_only(*asset_library)) {
|
||||
if (catalogs_read_only(*asset_library)) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Asset catalogs cannot be edited in this asset library");
|
||||
return false;
|
||||
}
|
||||
|
@ -515,10 +510,10 @@ static bool asset_catalog_operator_poll(bContext *C)
|
|||
static int asset_catalog_new_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
char *parent_path = RNA_string_get_alloc(op->ptr, "parent_path", nullptr, 0, nullptr);
|
||||
|
||||
blender::asset_system::AssetCatalog *new_catalog = ED_asset_catalog_add(
|
||||
asset_system::AssetCatalog *new_catalog = catalog_add(
|
||||
asset_library, DATA_("Catalog"), parent_path);
|
||||
|
||||
if (sfile) {
|
||||
|
@ -555,14 +550,14 @@ static void ASSET_OT_catalog_new(wmOperatorType *ot)
|
|||
static int asset_catalog_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
asset_system::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);
|
||||
asset_system::CatalogID catalog_id;
|
||||
if (!BLI_uuid_parse_string(&catalog_id, catalog_id_str)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ED_asset_catalog_remove(asset_library, catalog_id);
|
||||
catalog_remove(asset_library, catalog_id);
|
||||
|
||||
MEM_freeN(catalog_id_str);
|
||||
|
||||
|
@ -595,7 +590,7 @@ static asset_system::AssetCatalogService *get_catalog_service(bContext *C)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
|
||||
asset_system::AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
|
||||
return AS_asset_library_get_catalog_service(asset_lib);
|
||||
}
|
||||
|
||||
|
@ -715,9 +710,9 @@ static bool asset_catalogs_save_poll(bContext *C)
|
|||
static int asset_catalogs_save_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
const SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
|
||||
ED_asset_catalogs_save_from_main_path(asset_library, CTX_data_main(C));
|
||||
catalogs_save_from_main_path(asset_library, CTX_data_main(C));
|
||||
|
||||
WM_event_add_notifier_ex(
|
||||
CTX_wm_manager(C), CTX_wm_window(C), NC_ASSET | ND_ASSET_CATALOGS, nullptr);
|
||||
|
@ -849,7 +844,7 @@ static const EnumPropertyItem *rna_asset_library_reference_itemf(bContext * /*C*
|
|||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(false);
|
||||
const EnumPropertyItem *items = library_reference_to_rna_enum_itemf(false);
|
||||
if (!items) {
|
||||
*r_free = false;
|
||||
return nullptr;
|
||||
|
@ -897,7 +892,7 @@ static bool could_be_asset_bundle(const Main *bmain)
|
|||
static const bUserAssetLibrary *selected_asset_library(wmOperator *op)
|
||||
{
|
||||
const int enum_value = RNA_enum_get(op->ptr, "asset_library_reference");
|
||||
const AssetLibraryReference lib_ref = ED_asset_library_reference_from_enum_value(enum_value);
|
||||
const AssetLibraryReference lib_ref = library_reference_from_enum_value(enum_value);
|
||||
const bUserAssetLibrary *lib = BKE_preferences_asset_library_find_index(
|
||||
&U, lib_ref.custom_library_index);
|
||||
return lib;
|
||||
|
@ -1008,7 +1003,7 @@ static bool has_external_files(Main *bmain, ReportList *reports)
|
|||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void ED_operatortypes_asset()
|
||||
void operatortypes_asset()
|
||||
{
|
||||
WM_operatortype_append(ASSET_OT_mark);
|
||||
WM_operatortype_append(ASSET_OT_mark_single);
|
||||
|
@ -1025,3 +1020,5 @@ void ED_operatortypes_asset()
|
|||
|
||||
WM_operatortype_append(ASSET_OT_library_refresh);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_screen.hh"
|
||||
|
||||
#include "RNA_prototypes.h"
|
||||
|
@ -35,23 +35,18 @@
|
|||
|
||||
#include "WM_api.hh"
|
||||
|
||||
#include "ED_asset_shelf.h"
|
||||
#include "ED_asset_shelf.hh"
|
||||
#include "asset_shelf.hh"
|
||||
|
||||
using namespace blender;
|
||||
using namespace blender::ed::asset;
|
||||
namespace blender::ed::asset::shelf {
|
||||
|
||||
static int asset_shelf_default_tile_height();
|
||||
|
||||
namespace blender::ed::asset::shelf {
|
||||
|
||||
void send_redraw_notifier(const bContext &C)
|
||||
{
|
||||
WM_event_add_notifier(&C, NC_SPACE | ND_REGIONS_ASSET_SHELF, nullptr);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Shelf Type
|
||||
* \{ */
|
||||
|
@ -188,7 +183,7 @@ static AssetShelf *update_active_shelf(const bContext &C,
|
|||
/** \name Asset Shelf Regions
|
||||
* \{ */
|
||||
|
||||
void *ED_asset_shelf_region_duplicate(void *regiondata)
|
||||
void *region_duplicate(void *regiondata)
|
||||
{
|
||||
const RegionAssetShelf *shelf_regiondata = static_cast<RegionAssetShelf *>(regiondata);
|
||||
if (!shelf_regiondata) {
|
||||
|
@ -198,7 +193,7 @@ void *ED_asset_shelf_region_duplicate(void *regiondata)
|
|||
return shelf::regiondata_duplicate(shelf_regiondata);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_free(ARegion *region)
|
||||
void region_free(ARegion *region)
|
||||
{
|
||||
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
|
||||
if (shelf_regiondata) {
|
||||
|
@ -225,7 +220,7 @@ static bool asset_shelf_space_poll(const bContext *C, const SpaceLink *space_lin
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ED_asset_shelf_regions_poll(const RegionPollParams *params)
|
||||
bool regions_poll(const RegionPollParams *params)
|
||||
{
|
||||
return asset_shelf_space_poll(params->context,
|
||||
static_cast<SpaceLink *>(params->area->spacedata.first));
|
||||
|
@ -251,9 +246,9 @@ static void asset_shelf_region_listen(const wmRegionListenerParams *params)
|
|||
}
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_listen(const wmRegionListenerParams *params)
|
||||
void region_listen(const wmRegionListenerParams *params)
|
||||
{
|
||||
if (ED_assetlist_listen(params->notifier)) {
|
||||
if (list::listen(params->notifier)) {
|
||||
ED_region_tag_redraw_no_rebuild(params->region);
|
||||
}
|
||||
/* If the asset list didn't catch the notifier, let the region itself listen. */
|
||||
|
@ -262,7 +257,7 @@ void ED_asset_shelf_region_listen(const wmRegionListenerParams *params)
|
|||
}
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
|
||||
void region_init(wmWindowManager *wm, ARegion *region)
|
||||
{
|
||||
if (!region->regiondata) {
|
||||
region->regiondata = MEM_cnew<RegionAssetShelf>("RegionAssetShelf");
|
||||
|
@ -284,7 +279,7 @@ void ED_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
|
|||
region->v2d.keeptot |= V2D_KEEPTOT_STRICT;
|
||||
|
||||
region->v2d.flag |= V2D_SNAP_TO_PAGESIZE_Y;
|
||||
region->v2d.page_size_y = active_shelf ? ED_asset_shelf_tile_height(active_shelf->settings) :
|
||||
region->v2d.page_size_y = active_shelf ? tile_height(active_shelf->settings) :
|
||||
asset_shelf_default_tile_height();
|
||||
|
||||
/* Ensure the view is snapped to a page still, especially for DPI changes. */
|
||||
|
@ -313,8 +308,7 @@ static int current_tile_draw_height(const ARegion *region)
|
|||
/* It can happen that this function is called before the region is actually initialized, when
|
||||
* user clicks & drags slightly on the 'up arrow' icon of the shelf. */
|
||||
const AssetShelf *active_shelf = shelf_regiondata ? shelf_regiondata->active_shelf : nullptr;
|
||||
return (active_shelf ? ED_asset_shelf_tile_height(active_shelf->settings) :
|
||||
asset_shelf_default_tile_height()) /
|
||||
return (active_shelf ? tile_height(active_shelf->settings) : asset_shelf_default_tile_height()) /
|
||||
(IS_EQF(aspect, 0) ? 1.0f : aspect);
|
||||
}
|
||||
|
||||
|
@ -333,7 +327,7 @@ static int calculate_scaled_region_height_from_row_count(const int row_count,
|
|||
return (row_count * tile_draw_height + 2 * main_region_padding_y());
|
||||
}
|
||||
|
||||
int ED_asset_shelf_region_snap(const ARegion *region, const int size, const int axis)
|
||||
int region_snap(const ARegion *region, const int size, const int axis)
|
||||
{
|
||||
/* Only on Y axis. */
|
||||
if (axis != 1) {
|
||||
|
@ -376,7 +370,7 @@ static void region_resize_to_preferred(ScrArea *area, ARegion *region)
|
|||
}
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_on_user_resize(const ARegion *region)
|
||||
void region_on_user_resize(const ARegion *region)
|
||||
{
|
||||
const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
|
||||
*region);
|
||||
|
@ -390,12 +384,12 @@ void ED_asset_shelf_region_on_user_resize(const ARegion *region)
|
|||
region->sizey * UI_SCALE_FAC, tile_height);
|
||||
}
|
||||
|
||||
int ED_asset_shelf_tile_width(const AssetShelfSettings &settings)
|
||||
int tile_width(const AssetShelfSettings &settings)
|
||||
{
|
||||
return UI_preview_tile_size_x(settings.preview_size);
|
||||
}
|
||||
|
||||
int ED_asset_shelf_tile_height(const AssetShelfSettings &settings)
|
||||
int tile_height(const AssetShelfSettings &settings)
|
||||
{
|
||||
return (settings.display_flag & ASSETSHELF_SHOW_NAMES) ?
|
||||
UI_preview_tile_size_y(settings.preview_size) :
|
||||
|
@ -407,20 +401,20 @@ static int asset_shelf_default_tile_height()
|
|||
return UI_preview_tile_size_x(shelf::DEFAULT_TILE_SIZE);
|
||||
}
|
||||
|
||||
int ED_asset_shelf_region_prefsizey()
|
||||
int region_prefsizey()
|
||||
{
|
||||
/* One row by default (plus padding). */
|
||||
return asset_shelf_default_tile_height() + 2 * main_region_padding_y();
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_layout(const bContext *C, ARegion *region)
|
||||
void region_layout(const bContext *C, ARegion *region)
|
||||
{
|
||||
const SpaceLink *space = CTX_wm_space_data(C);
|
||||
const SpaceType *space_type = BKE_spacetype_from_id(space->spacetype);
|
||||
|
||||
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
|
||||
if (!shelf_regiondata) {
|
||||
/* Region-data should've been created by a previously called #ED_asset_shelf_region_init(). */
|
||||
/* Region-data should've been created by a previously called #region_init(). */
|
||||
BLI_assert_unreachable();
|
||||
return;
|
||||
}
|
||||
|
@ -459,7 +453,7 @@ void ED_asset_shelf_region_layout(const bContext *C, ARegion *region)
|
|||
UI_block_end(C, block);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_draw(const bContext *C, ARegion *region)
|
||||
void region_draw(const bContext *C, ARegion *region)
|
||||
{
|
||||
ED_region_clear(C, region, TH_BACK);
|
||||
|
||||
|
@ -477,19 +471,19 @@ void ED_asset_shelf_region_draw(const bContext *C, ARegion *region)
|
|||
UI_view2d_scrollers_draw(®ion->v2d, nullptr);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_header_region_listen(const wmRegionListenerParams *params)
|
||||
void header_region_listen(const wmRegionListenerParams *params)
|
||||
{
|
||||
asset_shelf_region_listen(params);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||
void header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||
{
|
||||
ED_region_header_init(region);
|
||||
region->alignment |= RGN_SPLIT_SCALE_PREV;
|
||||
region->flag |= RGN_FLAG_RESIZE_RESPECT_BUTTON_SECTIONS;
|
||||
}
|
||||
|
||||
void ED_asset_shelf_header_region(const bContext *C, ARegion *region)
|
||||
void header_region(const bContext *C, ARegion *region)
|
||||
{
|
||||
const SpaceLink *space = CTX_wm_space_data(C);
|
||||
const SpaceType *space_type = BKE_spacetype_from_id(space->spacetype);
|
||||
|
@ -503,7 +497,7 @@ void ED_asset_shelf_header_region(const bContext *C, ARegion *region)
|
|||
ED_region_header_with_button_sections(C, region, uiButtonSectionsAlign::Bottom);
|
||||
}
|
||||
|
||||
int ED_asset_shelf_header_region_size()
|
||||
int header_region_size()
|
||||
{
|
||||
/* Use a height that lets widgets sit just on top of the separator line drawn at the lower edge
|
||||
* of the region (widgets will be centered).
|
||||
|
@ -513,7 +507,7 @@ int ED_asset_shelf_header_region_size()
|
|||
return UI_UNIT_Y + (UI_BUTTON_SECTION_SEPERATOR_LINE_WITH * 2);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, ARegion *region)
|
||||
void region_blend_read_data(BlendDataReader *reader, ARegion *region)
|
||||
{
|
||||
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
|
||||
if (!shelf_regiondata) {
|
||||
|
@ -523,7 +517,7 @@ void ED_asset_shelf_region_blend_read_data(BlendDataReader *reader, ARegion *reg
|
|||
region->regiondata = shelf_regiondata;
|
||||
}
|
||||
|
||||
void ED_asset_shelf_region_blend_write(BlendWriter *writer, ARegion *region)
|
||||
void region_blend_write(BlendWriter *writer, ARegion *region)
|
||||
{
|
||||
RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
|
||||
if (!shelf_regiondata) {
|
||||
|
@ -561,7 +555,7 @@ static AssetShelf *active_shelf_from_area(const ScrArea *area)
|
|||
return shelf_regiondata->active_shelf;
|
||||
}
|
||||
|
||||
int ED_asset_shelf_context(const bContext *C, const char *member, bContextDataResult *result)
|
||||
int context(const bContext *C, const char *member, bContextDataResult *result)
|
||||
{
|
||||
static const char *context_dir[] = {
|
||||
"asset_shelf",
|
||||
|
@ -626,8 +620,6 @@ int ED_asset_shelf_context(const bContext *C, const char *member, bContextDataRe
|
|||
return CTX_RESULT_MEMBER_NOT_FOUND;
|
||||
}
|
||||
|
||||
namespace blender::ed::asset::shelf {
|
||||
|
||||
static PointerRNA active_shelf_ptr_from_context(const bContext *C)
|
||||
{
|
||||
return CTX_data_pointer_get_type(C, "asset_shelf", &RNA_AssetShelf);
|
||||
|
@ -639,8 +631,6 @@ AssetShelf *active_shelf_from_context(const bContext *C)
|
|||
return static_cast<AssetShelf *>(shelf_settings_ptr.data);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -722,7 +712,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
|
|||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
const AssetLibraryReference *library_ref = CTX_wm_asset_library_ref(C);
|
||||
|
||||
ED_assetlist_storage_fetch(library_ref, C);
|
||||
list::storage_fetch(library_ref, C);
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
uiItemPopoverPanel(layout, C, "ASSETSHELF_PT_catalog_selector", "", ICON_COLLAPSEMENU);
|
||||
|
@ -730,7 +720,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
|
|||
|
||||
uiItemS(layout);
|
||||
|
||||
PointerRNA shelf_ptr = shelf::active_shelf_ptr_from_context(C);
|
||||
PointerRNA shelf_ptr = active_shelf_ptr_from_context(C);
|
||||
AssetShelf *shelf = static_cast<AssetShelf *>(shelf_ptr.data);
|
||||
if (shelf) {
|
||||
add_catalog_tabs(shelf->settings, *layout);
|
||||
|
@ -745,7 +735,7 @@ static void asset_shelf_header_draw(const bContext *C, Header *header)
|
|||
uiItemR(sub, &shelf_ptr, "search_filter", UI_ITEM_NONE, "", ICON_VIEWZOOM);
|
||||
}
|
||||
|
||||
void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const int space_type)
|
||||
void header_regiontype_register(ARegionType *region_type, const int space_type)
|
||||
{
|
||||
HeaderType *ht = MEM_cnew<HeaderType>(__func__);
|
||||
STRNCPY(ht->idname, "ASSETSHELF_HT_settings");
|
||||
|
@ -758,7 +748,7 @@ void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const i
|
|||
|
||||
BLI_addtail(®ion_type->headertypes, ht);
|
||||
|
||||
shelf::catalog_selector_panel_register(region_type);
|
||||
catalog_selector_panel_register(region_type);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -767,7 +757,7 @@ void ED_asset_shelf_header_regiontype_register(ARegionType *region_type, const i
|
|||
/** \name Asset Shelf Type (un)registration
|
||||
* \{ */
|
||||
|
||||
void ED_asset_shelf_type_unlink(const Main &bmain, const AssetShelfType &shelf_type)
|
||||
void type_unlink(const Main &bmain, const AssetShelfType &shelf_type)
|
||||
{
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain.screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
|
@ -798,3 +788,5 @@ void ED_asset_shelf_type_unlink(const Main &bmain, const AssetShelfType &shelf_t
|
|||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "ED_asset_handle.h"
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_handle.hh"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_asset_shelf.h"
|
||||
#include "ED_asset_shelf.hh"
|
||||
|
||||
#include "UI_grid_view.hh"
|
||||
#include "UI_interface.hh"
|
||||
|
@ -97,15 +96,13 @@ AssetView::AssetView(const AssetLibraryReference &library_ref, const AssetShelf
|
|||
|
||||
void AssetView::build_items()
|
||||
{
|
||||
const asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(
|
||||
library_ref_);
|
||||
const asset_system::AssetLibrary *library = list::library_get_once_available(library_ref_);
|
||||
if (!library) {
|
||||
return;
|
||||
}
|
||||
|
||||
ED_assetlist_iterate(library_ref_, [&](AssetHandle asset_handle) {
|
||||
const asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(
|
||||
&asset_handle);
|
||||
list::iterate(library_ref_, [&](AssetHandle asset_handle) {
|
||||
const asset_system::AssetRepresentation *asset = handle_get_representation(&asset_handle);
|
||||
|
||||
if (shelf_.type->asset_poll && !shelf_.type->asset_poll(shelf_.type, asset)) {
|
||||
return true;
|
||||
|
@ -122,10 +119,10 @@ void AssetView::build_items()
|
|||
|
||||
const StringRef identifier = asset->get_identifier().library_relative_identifier();
|
||||
const int preview_id = [&]() -> int {
|
||||
if (ED_assetlist_asset_image_is_loading(&library_ref_, &asset_handle)) {
|
||||
if (list::asset_image_is_loading(&library_ref_, &asset_handle)) {
|
||||
return ICON_TEMP;
|
||||
}
|
||||
return ED_asset_handle_get_preview_or_type_icon_id(&asset_handle);
|
||||
return handle_get_preview_or_type_icon_id(&asset_handle);
|
||||
}();
|
||||
|
||||
AssetViewItem &item = add_item<AssetViewItem>(
|
||||
|
@ -171,7 +168,7 @@ static std::optional<asset_system::AssetCatalogFilter> catalog_filter_from_shelf
|
|||
return {};
|
||||
}
|
||||
|
||||
asset_system ::AssetCatalog *active_catalog = library.catalog_service->find_catalog_by_path(
|
||||
asset_system::AssetCatalog *active_catalog = library.catalog_service->find_catalog_by_path(
|
||||
shelf_settings.active_catalog_path);
|
||||
if (!active_catalog) {
|
||||
return {};
|
||||
|
@ -214,7 +211,7 @@ void AssetViewItem::build_context_menu(bContext &C, uiLayout &column) const
|
|||
const AssetView &asset_view = dynamic_cast<const AssetView &>(get_view());
|
||||
const AssetShelfType &shelf_type = *asset_view.shelf_.type;
|
||||
if (shelf_type.draw_context_menu) {
|
||||
asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(&asset_);
|
||||
asset_system::AssetRepresentation *asset = handle_get_representation(&asset_);
|
||||
shelf_type.draw_context_menu(&C, &shelf_type, asset, &column);
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +223,7 @@ bool AssetViewItem::is_filtered_visible() const
|
|||
return true;
|
||||
}
|
||||
|
||||
const StringRefNull asset_name = ED_asset_handle_get_representation(&asset_)->get_name();
|
||||
const StringRefNull asset_name = handle_get_representation(&asset_)->get_name();
|
||||
return fnmatch(asset_view.search_string, asset_name.c_str(), FNM_CASEFOLD) == 0;
|
||||
}
|
||||
|
||||
|
@ -235,7 +232,7 @@ std::unique_ptr<ui::AbstractViewItemDragController> AssetViewItem::create_drag_c
|
|||
if (!allow_asset_drag_) {
|
||||
return nullptr;
|
||||
}
|
||||
asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(&asset_);
|
||||
asset_system::AssetRepresentation *asset = handle_get_representation(&asset_);
|
||||
return std::make_unique<AssetDragController>(get_view(), *asset);
|
||||
}
|
||||
|
||||
|
@ -247,16 +244,16 @@ void build_asset_view(uiLayout &layout,
|
|||
const bContext &C,
|
||||
ARegion ®ion)
|
||||
{
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
ED_assetlist_ensure_previews_job(&library_ref, &C);
|
||||
list::storage_fetch(&library_ref, &C);
|
||||
list::ensure_previews_job(&library_ref, &C);
|
||||
|
||||
const asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(library_ref);
|
||||
const asset_system::AssetLibrary *library = list::library_get_once_available(library_ref);
|
||||
if (!library) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float tile_width = ED_asset_shelf_tile_width(shelf.settings);
|
||||
const float tile_height = ED_asset_shelf_tile_height(shelf.settings);
|
||||
const float tile_width = shelf::tile_width(shelf.settings);
|
||||
const float tile_height = shelf::tile_height(shelf.settings);
|
||||
BLI_assert(tile_width != 0);
|
||||
BLI_assert(tile_height != 0);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "BLT_translation.h"
|
||||
|
||||
#include "ED_asset_filter.hh"
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_list.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
@ -202,7 +201,7 @@ static void catalog_selector_panel_draw(const bContext *C, Panel *panel)
|
|||
uiItemO(row, "", ICON_FILE_REFRESH, "ASSET_OT_library_refresh");
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *library = ED_assetlist_library_get_once_available(*library_ref);
|
||||
asset_system::AssetLibrary *library = list::library_get_once_available(*library_ref);
|
||||
if (!library) {
|
||||
return;
|
||||
}
|
||||
|
@ -230,7 +229,7 @@ void catalog_selector_panel_register(ARegionType *region_type)
|
|||
pt->description = N_(
|
||||
"Select the asset library and the contained catalogs to display in the asset shelf");
|
||||
pt->draw = catalog_selector_panel_draw;
|
||||
pt->listener = asset::asset_reading_region_listen_fn;
|
||||
pt->listener = asset::list::asset_reading_region_listen_fn;
|
||||
BLI_addtail(®ion_type->paneltypes, pt);
|
||||
WM_paneltype_add(pt);
|
||||
}
|
||||
|
|
|
@ -22,18 +22,16 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "ED_asset_temp_id_consumer.h"
|
||||
#include "ED_asset_temp_id_consumer.hh"
|
||||
|
||||
using namespace blender;
|
||||
namespace blender::ed::asset {
|
||||
|
||||
class AssetTemporaryIDConsumer : NonCopyable, NonMovable {
|
||||
const blender::asset_system::AssetRepresentation *asset_;
|
||||
const asset_system::AssetRepresentation *asset_;
|
||||
TempLibraryContext *temp_lib_context_ = nullptr;
|
||||
|
||||
public:
|
||||
AssetTemporaryIDConsumer(const blender::asset_system::AssetRepresentation *asset) : asset_(asset)
|
||||
{
|
||||
}
|
||||
AssetTemporaryIDConsumer(const asset_system::AssetRepresentation *asset) : asset_(asset) {}
|
||||
~AssetTemporaryIDConsumer()
|
||||
{
|
||||
if (temp_lib_context_) {
|
||||
|
@ -65,8 +63,7 @@ class AssetTemporaryIDConsumer : NonCopyable, NonMovable {
|
|||
}
|
||||
};
|
||||
|
||||
AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
|
||||
const asset_system::AssetRepresentation *asset)
|
||||
AssetTempIDConsumer *temp_id_consumer_create(const asset_system::AssetRepresentation *asset)
|
||||
{
|
||||
if (!asset) {
|
||||
return nullptr;
|
||||
|
@ -75,16 +72,16 @@ AssetTempIDConsumer *ED_asset_temp_id_consumer_create(
|
|||
MEM_new<AssetTemporaryIDConsumer>(__func__, asset));
|
||||
}
|
||||
|
||||
void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer)
|
||||
void temp_id_consumer_free(AssetTempIDConsumer **consumer)
|
||||
{
|
||||
MEM_delete(reinterpret_cast<AssetTemporaryIDConsumer *>(*consumer));
|
||||
*consumer = nullptr;
|
||||
}
|
||||
|
||||
ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
|
||||
ID_Type id_type,
|
||||
Main *bmain,
|
||||
ReportList *reports)
|
||||
ID *temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
|
||||
ID_Type id_type,
|
||||
Main *bmain,
|
||||
ReportList *reports)
|
||||
{
|
||||
if (!(consumer_ && bmain && reports)) {
|
||||
return nullptr;
|
||||
|
@ -96,3 +93,5 @@ ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
|
|||
}
|
||||
return consumer->import_id(id_type, *bmain, *reports);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -12,16 +12,18 @@
|
|||
|
||||
#include "BKE_lib_id.hh"
|
||||
|
||||
#include "ED_asset_type.h"
|
||||
#include "ED_asset_type.hh"
|
||||
|
||||
bool ED_asset_type_id_is_non_experimental(const ID *id)
|
||||
namespace blender::ed::asset {
|
||||
|
||||
bool id_type_is_non_experimental(const ID *id)
|
||||
{
|
||||
/* Remember to update #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_UI_STRING and
|
||||
* #ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS() with this! */
|
||||
return ELEM(GS(id->name), ID_MA, ID_GR, ID_OB, ID_AC, ID_WO, ID_NT);
|
||||
}
|
||||
|
||||
bool ED_asset_type_is_supported(const ID *id)
|
||||
bool id_type_is_supported(const ID *id)
|
||||
{
|
||||
if (!BKE_id_can_be_asset(id)) {
|
||||
return false;
|
||||
|
@ -33,10 +35,10 @@ bool ED_asset_type_is_supported(const ID *id)
|
|||
return true;
|
||||
}
|
||||
|
||||
return ED_asset_type_id_is_non_experimental(id);
|
||||
return id_type_is_non_experimental(id);
|
||||
}
|
||||
|
||||
int64_t ED_asset_types_supported_as_filter_flags()
|
||||
int64_t types_supported_as_filter_flags()
|
||||
{
|
||||
if (U.experimental.use_extended_asset_browser) {
|
||||
return FILTER_ID_ALL;
|
||||
|
@ -44,3 +46,5 @@ int64_t ED_asset_types_supported_as_filter_flags()
|
|||
|
||||
return ED_ASSET_TYPE_IDS_NON_EXPERIMENTAL_FLAGS;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
|
|
@ -904,7 +904,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu)
|
|||
const Set<std::string> builtin_menus = get_builtin_menus(ObjectType(active_object->type),
|
||||
eObjectMode(active_object->mode));
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -929,7 +929,7 @@ MenuType node_group_operator_assets_menu()
|
|||
STRNCPY(type.idname, "GEO_MT_node_operator_catalog_assets");
|
||||
type.poll = asset_menu_poll;
|
||||
type.draw = catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
@ -1028,7 +1028,7 @@ MenuType node_group_operator_assets_menu_unassigned()
|
|||
STRNCPY(type.idname, "GEO_MT_node_operator_unassigned");
|
||||
type.poll = asset_menu_poll;
|
||||
type.draw = catalog_assets_draw_unassigned;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
type.description = N_(
|
||||
"Tool node group assets not assigned to a catalog.\n"
|
||||
|
@ -1053,7 +1053,7 @@ void ui_template_node_operator_asset_menu_items(uiLayout &layout,
|
|||
if (!item) {
|
||||
return;
|
||||
}
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -1082,7 +1082,7 @@ void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext
|
|||
*tree = build_catalog_tree(C, *active_object);
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
|
|
@ -14,17 +14,21 @@
|
|||
/* Barely anything here. Just general editor level functions. Actual asset level code is in
|
||||
* dedicated headers. */
|
||||
|
||||
void ED_operatortypes_asset();
|
||||
|
||||
#include "../asset/ED_asset_catalog.h"
|
||||
#include "../asset/ED_asset_handle.h"
|
||||
#include "../asset/ED_asset_library.h"
|
||||
#include "../asset/ED_asset_list.h"
|
||||
#include "../asset/ED_asset_mark_clear.h"
|
||||
#include "../asset/ED_asset_temp_id_consumer.h"
|
||||
#include "../asset/ED_asset_type.h"
|
||||
#include "../asset/ED_asset_catalog.hh"
|
||||
#include "../asset/ED_asset_handle.hh"
|
||||
#include "../asset/ED_asset_library.hh"
|
||||
#include "../asset/ED_asset_list.hh"
|
||||
#include "../asset/ED_asset_mark_clear.hh"
|
||||
#include "../asset/ED_asset_temp_id_consumer.hh"
|
||||
#include "../asset/ED_asset_type.hh"
|
||||
|
||||
#include "../asset/ED_asset_catalog.hh"
|
||||
#include "../asset/ED_asset_filter.hh"
|
||||
#include "../asset/ED_asset_import.hh"
|
||||
#include "../asset/ED_asset_list.hh"
|
||||
|
||||
namespace blender::ed::asset {
|
||||
|
||||
void operatortypes_asset();
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
struct AssetLibrary;
|
||||
struct bScreen;
|
||||
struct uiLayout;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "DNA_uuid_types.h"
|
||||
|
||||
struct ARegion;
|
||||
struct AssetLibrary;
|
||||
struct FileAssetSelectParams;
|
||||
struct FileDirEntry;
|
||||
struct FileSelectParams;
|
||||
|
@ -28,6 +27,9 @@ struct wmWindow;
|
|||
struct wmWindowManager;
|
||||
struct View2D;
|
||||
struct rcti;
|
||||
namespace blender::asset_system {
|
||||
class AssetLibrary;
|
||||
}
|
||||
|
||||
#define FILE_LAYOUT_HOR 1
|
||||
#define FILE_LAYOUT_VER 2
|
||||
|
@ -140,7 +142,8 @@ void ED_fileselect_exit(wmWindowManager *wm, SpaceFile *sfile);
|
|||
|
||||
bool ED_fileselect_is_file_browser(const SpaceFile *sfile);
|
||||
bool ED_fileselect_is_asset_browser(const SpaceFile *sfile);
|
||||
AssetLibrary *ED_fileselect_active_asset_library_get(const SpaceFile *sfile);
|
||||
blender::asset_system::AssetLibrary *ED_fileselect_active_asset_library_get(
|
||||
const SpaceFile *sfile);
|
||||
ID *ED_fileselect_active_asset_get(const SpaceFile *sfile);
|
||||
|
||||
void ED_fileselect_activate_asset_catalog(const SpaceFile *sfile, bUUID catalog_id);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "DNA_view3d_enums.h"
|
||||
|
||||
enum class PaintMode : int8_t;
|
||||
struct bContext;
|
||||
struct bToolRef;
|
||||
struct PaintModeSettings;
|
||||
|
@ -57,7 +58,7 @@ bool ED_paint_proj_mesh_data_check(Scene *scene,
|
|||
* The caller is responsible for running #ED_image_undo_push_end,
|
||||
* failure to do so causes an invalid state for the undo system.
|
||||
*/
|
||||
void ED_image_undo_push_begin(const char *name, int paint_mode);
|
||||
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode);
|
||||
void ED_image_undo_push_begin_with_image(const char *name,
|
||||
Image *image,
|
||||
ImBuf *ibuf,
|
||||
|
|
|
@ -506,6 +506,7 @@ static void set_layout_context_from_button(bContext *C, uiLayout *layout, uiBut
|
|||
|
||||
bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *event)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
/* ui_but_is_interactive() may let some buttons through that should not get a context menu - it
|
||||
* doesn't make sense for them. */
|
||||
if (ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_IMAGE)) {
|
||||
|
@ -1023,7 +1024,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
}
|
||||
|
||||
/* If the button represents an id, it can set the "id" context pointer. */
|
||||
if (ED_asset_can_mark_single_from_context(C)) {
|
||||
if (asset::can_mark_single_from_context(C)) {
|
||||
const ID *id = static_cast<const ID *>(CTX_data_pointer_get_type(C, "id", &RNA_ID).data);
|
||||
|
||||
/* Gray out items depending on if data-block is an asset. Preferably this could be done via
|
||||
|
|
|
@ -970,7 +970,7 @@ static void ui_apply_but_undo(uiBut *but)
|
|||
/* XXX: disable all undo pushes from UI changes from sculpt mode as they cause memfile undo
|
||||
* steps to be written which cause lag: #71434. */
|
||||
if (BKE_paintmode_get_active_from_context(static_cast<bContext *>(but->block->evil_C)) ==
|
||||
PAINT_MODE_SCULPT)
|
||||
PaintMode::Sculpt)
|
||||
{
|
||||
skip_undo = true;
|
||||
}
|
||||
|
|
|
@ -2105,7 +2105,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
|||
else {
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
const EnumPropertyItem *items = nullptr;
|
||||
ePaintMode paint_mode = PAINT_MODE_INVALID;
|
||||
PaintMode paint_mode = PaintMode::Invalid;
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
char space_type = area->spacetype;
|
||||
/* Fallback to 3D view. */
|
||||
|
@ -2119,26 +2119,26 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
|||
|
||||
if ((space_type == SPACE_VIEW3D) && ob) {
|
||||
if (ob->mode & OB_MODE_SCULPT) {
|
||||
paint_mode = PAINT_MODE_SCULPT;
|
||||
paint_mode = PaintMode::Sculpt;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
|
||||
paint_mode = PAINT_MODE_VERTEX;
|
||||
paint_mode = PaintMode::Vertex;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
|
||||
paint_mode = PAINT_MODE_WEIGHT;
|
||||
paint_mode = PaintMode::Weight;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
||||
paint_mode = PAINT_MODE_TEXTURE_3D;
|
||||
paint_mode = PaintMode::Texture3D;
|
||||
}
|
||||
else if (ob->mode & OB_MODE_SCULPT_CURVES) {
|
||||
paint_mode = PAINT_MODE_SCULPT_CURVES;
|
||||
paint_mode = PaintMode::SculptCurves;
|
||||
}
|
||||
}
|
||||
else if (space_type == SPACE_IMAGE) {
|
||||
if (area->spacetype == space_type) {
|
||||
const SpaceImage *sima = static_cast<const SpaceImage *>(area->spacedata.first);
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
paint_mode = PAINT_MODE_TEXTURE_2D;
|
||||
paint_mode = PaintMode::Texture2D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2248,7 +2248,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
|
|||
return id->icon_id;
|
||||
}
|
||||
|
||||
if (paint_mode != PAINT_MODE_INVALID) {
|
||||
if (paint_mode != PaintMode::Invalid) {
|
||||
items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paintmode(paint_mode);
|
||||
const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
|
||||
|
|
|
@ -576,7 +576,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
|
|||
std::string shortcut = UI_but_string_get_operator_keymap(*C, *but);
|
||||
|
||||
if (shortcut.empty()) {
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
const PaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
const char *tool_attr = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
if (tool_attr != nullptr) {
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "interface_intern.hh"
|
||||
|
||||
using namespace blender;
|
||||
using namespace blender::ed;
|
||||
|
||||
struct AssetViewListData {
|
||||
AssetLibraryReference asset_library_ref;
|
||||
|
@ -45,7 +46,7 @@ struct AssetViewListData {
|
|||
|
||||
static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
|
||||
{
|
||||
blender::asset_system::AssetRepresentation *asset = ED_asset_handle_get_representation(
|
||||
blender::asset_system::AssetRepresentation *asset = asset::handle_get_representation(
|
||||
asset_handle);
|
||||
|
||||
UI_but_dragflag_enable(but, UI_BUT_DRAG_FULL_BUT);
|
||||
|
@ -59,9 +60,9 @@ static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
|
|||
const eAssetImportMethod import_method = asset->get_import_method().value_or(
|
||||
ASSET_IMPORT_APPEND_REUSE);
|
||||
|
||||
ImBuf *imbuf = ED_assetlist_asset_image_get(asset_handle);
|
||||
ImBuf *imbuf = asset::list::asset_image_get(asset_handle);
|
||||
UI_but_drag_set_asset(
|
||||
but, asset, import_method, ED_asset_handle_get_preview_icon_id(asset_handle), imbuf, 1.0f);
|
||||
but, asset, import_method, asset::handle_get_preview_icon_id(asset_handle), imbuf, 1.0f);
|
||||
}
|
||||
|
||||
static void asset_view_draw_item(uiList *ui_list,
|
||||
|
@ -77,7 +78,7 @@ static void asset_view_draw_item(uiList *ui_list,
|
|||
{
|
||||
AssetViewListData *list_data = (AssetViewListData *)ui_list->dyn_data->customdata;
|
||||
|
||||
AssetHandle asset_handle = ED_assetlist_asset_handle_get_by_index(&list_data->asset_library_ref,
|
||||
AssetHandle asset_handle = asset::list::asset_handle_get_by_index(&list_data->asset_library_ref,
|
||||
index);
|
||||
|
||||
PointerRNA file_ptr = RNA_pointer_create(&list_data->screen->id,
|
||||
|
@ -93,8 +94,8 @@ static void asset_view_draw_item(uiList *ui_list,
|
|||
block,
|
||||
UI_BTYPE_PREVIEW_TILE,
|
||||
0,
|
||||
ED_asset_handle_get_preview_icon_id(&asset_handle),
|
||||
show_names ? ED_asset_handle_get_representation(&asset_handle)->get_name().c_str() : "",
|
||||
asset::handle_get_preview_icon_id(&asset_handle),
|
||||
show_names ? asset::handle_get_representation(&asset_handle)->get_name().c_str() : "",
|
||||
0,
|
||||
0,
|
||||
size_x,
|
||||
|
@ -106,7 +107,7 @@ static void asset_view_draw_item(uiList *ui_list,
|
|||
0,
|
||||
"");
|
||||
ui_def_but_icon(but,
|
||||
ED_asset_handle_get_preview_icon_id(&asset_handle),
|
||||
asset::handle_get_preview_icon_id(&asset_handle),
|
||||
/* NOLINTNEXTLINE: bugprone-suspicious-enum-usage */
|
||||
UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
||||
but->emboss = UI_EMBOSS_NONE;
|
||||
|
@ -130,10 +131,10 @@ static void asset_view_filter_items(uiList *ui_list,
|
|||
C,
|
||||
[&name_filter, list_data, &filter_settings](
|
||||
const PointerRNA &itemptr, blender::StringRefNull name, int index) {
|
||||
asset_system::AssetRepresentation *asset = ED_assetlist_asset_get_by_index(
|
||||
asset_system::AssetRepresentation *asset = asset::list::asset_get_by_index(
|
||||
list_data->asset_library_ref, index);
|
||||
|
||||
if (!ED_asset_filter_matches_asset(&filter_settings, *asset)) {
|
||||
if (!asset::filter_matches_asset(&filter_settings, *asset)) {
|
||||
return UI_LIST_ITEM_NEVER_SHOW;
|
||||
}
|
||||
return name_filter(itemptr, name, index);
|
||||
|
@ -141,7 +142,7 @@ static void asset_view_filter_items(uiList *ui_list,
|
|||
dataptr,
|
||||
propname,
|
||||
[list_data](const PointerRNA & /*itemptr*/, int index) -> std::string {
|
||||
asset_system::AssetRepresentation *asset = ED_assetlist_asset_get_by_index(
|
||||
asset_system::AssetRepresentation *asset = asset::list::asset_get_by_index(
|
||||
list_data->asset_library_ref, index);
|
||||
|
||||
return asset->get_name();
|
||||
|
@ -155,13 +156,13 @@ static void asset_view_listener(uiList * /*ui_list*/, wmRegionListenerParams *pa
|
|||
switch (notifier->category) {
|
||||
case NC_ID: {
|
||||
if (ELEM(notifier->action, NA_RENAME)) {
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
asset::list::storage_tag_main_data_dirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ED_assetlist_listen(params->notifier)) {
|
||||
if (asset::list::listen(params->notifier)) {
|
||||
ED_region_tag_redraw(params->region);
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +200,7 @@ static void populate_asset_collection(const AssetLibraryReference &asset_library
|
|||
|
||||
RNA_property_collection_clear(&assets_dataptr, assets_prop);
|
||||
|
||||
ED_assetlist_iterate(asset_library_ref, [&](AssetHandle /*asset*/) {
|
||||
asset::list::iterate(asset_library_ref, [&](AssetHandle /*asset*/) {
|
||||
/* XXX creating a dummy #RNA_AssetHandle collection item. It's #file_data will be null. This is
|
||||
* because the #FileDirEntry may be freed while iterating, there's a cache for them with a
|
||||
* maximum size. Further code will query as needed it using the collection index. */
|
||||
|
@ -238,7 +239,7 @@ void uiTemplateAssetView(uiLayout *layout,
|
|||
|
||||
PropertyRNA *asset_library_prop = RNA_struct_find_property(asset_library_dataptr,
|
||||
asset_library_propname);
|
||||
AssetLibraryReference asset_library_ref = ED_asset_library_reference_from_enum_value(
|
||||
AssetLibraryReference asset_library_ref = asset::library_reference_from_enum_value(
|
||||
RNA_property_enum_get(asset_library_dataptr, asset_library_prop));
|
||||
|
||||
uiLayout *row = uiLayoutRow(col, true);
|
||||
|
@ -256,9 +257,9 @@ void uiTemplateAssetView(uiLayout *layout,
|
|||
}
|
||||
}
|
||||
|
||||
ED_assetlist_storage_fetch(&asset_library_ref, C);
|
||||
ED_assetlist_ensure_previews_job(&asset_library_ref, C);
|
||||
const int tot_items = ED_assetlist_size(&asset_library_ref);
|
||||
asset::list::storage_fetch(&asset_library_ref, C);
|
||||
asset::list::ensure_previews_job(&asset_library_ref, C);
|
||||
const int tot_items = asset::list::size(&asset_library_ref);
|
||||
|
||||
populate_asset_collection(asset_library_ref, *assets_dataptr, assets_propname);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace blender::ed::object {
|
|||
static bool all_loading_finished()
|
||||
{
|
||||
AssetLibraryReference all_library_ref = asset_system::all_library_reference();
|
||||
return ED_assetlist_is_loaded(&all_library_ref);
|
||||
return asset::list::is_loaded(&all_library_ref);
|
||||
}
|
||||
|
||||
static asset::AssetItemTree build_catalog_tree(const bContext &C)
|
||||
|
@ -111,7 +111,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu)
|
|||
asset::operator_asset_reference_props_set(*asset, props_ptr);
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -234,7 +234,7 @@ static void root_catalogs_draw(const bContext *C, Menu *menu)
|
|||
return menus;
|
||||
}();
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -358,7 +358,7 @@ static MenuType modifier_add_unassigned_assets_menu_type()
|
|||
MenuType type{};
|
||||
STRNCPY(type.idname, "OBJECT_MT_add_modifier_unassigned_assets");
|
||||
type.draw = unassigned_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.description = N_(
|
||||
"Modifier node group assets not assigned to a catalog.\n"
|
||||
"Catalogs can be assigned in the Asset Browser");
|
||||
|
@ -370,7 +370,7 @@ static MenuType modifier_add_catalog_assets_menu_type()
|
|||
MenuType type{};
|
||||
STRNCPY(type.idname, "OBJECT_MT_add_modifier_catalog_assets");
|
||||
type.draw = catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ static MenuType modifier_add_root_catalogs_menu_type()
|
|||
MenuType type{};
|
||||
STRNCPY(type.idname, "OBJECT_MT_modifier_add_root_catalogs");
|
||||
type.draw = root_catalogs_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ void ui_template_modifier_asset_menu_items(uiLayout &layout,
|
|||
if (!item) {
|
||||
return;
|
||||
}
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "WM_types.hh"
|
||||
|
||||
#include "ED_asset.hh"
|
||||
#include "ED_asset_shelf.h"
|
||||
#include "ED_asset_shelf.hh"
|
||||
#include "ED_buttons.hh"
|
||||
#include "ED_screen.hh"
|
||||
#include "ED_screen_types.hh"
|
||||
|
@ -1348,6 +1348,7 @@ bool ED_region_is_overlap(int spacetype, int regiontype)
|
|||
static void region_rect_recursive(
|
||||
ScrArea *area, ARegion *region, rcti *remainder, rcti *overlap_remainder, int quad)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
rcti *remainder_prev = remainder;
|
||||
|
||||
if (region == nullptr) {
|
||||
|
@ -1409,10 +1410,10 @@ static void region_rect_recursive(
|
|||
}
|
||||
else if (region->regiontype == RGN_TYPE_ASSET_SHELF) {
|
||||
prefsizey = region->sizey > 1 ? (UI_SCALE_FAC * (region->sizey + 0.5f)) :
|
||||
ED_asset_shelf_region_prefsizey();
|
||||
asset::shelf::region_prefsizey();
|
||||
}
|
||||
else if (region->regiontype == RGN_TYPE_ASSET_SHELF_HEADER) {
|
||||
prefsizey = ED_asset_shelf_header_region_size();
|
||||
prefsizey = asset::shelf::header_region_size();
|
||||
}
|
||||
else if (ED_area_is_global(area)) {
|
||||
prefsizey = ED_region_global_size_y();
|
||||
|
|
|
@ -203,7 +203,7 @@ static void stroke_done(const bContext *C, PaintStroke *stroke)
|
|||
static int sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT_CURVES);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::SculptCurves);
|
||||
const Brush *brush = paint ? BKE_paint_brush_for_read(paint) : nullptr;
|
||||
if (brush == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
|
@ -289,7 +289,7 @@ static void curves_sculptmode_enter(bContext *C)
|
|||
ob->mode = OB_MODE_SCULPT_CURVES;
|
||||
|
||||
/* Setup cursor color. BKE_paint_init() could be used, but creates an additional brush. */
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT_CURVES);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::SculptCurves);
|
||||
copy_v3_v3_uchar(paint->paint_cursor_col, PAINT_CURSOR_SCULPT_CURVES);
|
||||
paint->paint_cursor_col[3] = 128;
|
||||
|
||||
|
|
|
@ -544,7 +544,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
int x,
|
||||
int y,
|
||||
float zoom,
|
||||
const ePaintMode mode,
|
||||
const PaintMode mode,
|
||||
bool col,
|
||||
bool primary)
|
||||
{
|
||||
|
@ -556,7 +556,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
(brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0);
|
||||
int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha;
|
||||
|
||||
if (mode == PAINT_MODE_TEXTURE_3D) {
|
||||
if (mode == PaintMode::Texture3D) {
|
||||
if (primary && brush->imagepaint_tool != PAINT_TOOL_DRAW) {
|
||||
/* All non-draw tools don't use the primary texture (clone, smear, soften.. etc). */
|
||||
return false;
|
||||
|
@ -781,11 +781,11 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
|
|||
int x,
|
||||
int y,
|
||||
float zoom,
|
||||
ePaintMode mode)
|
||||
PaintMode mode)
|
||||
{
|
||||
/* Color means that primary brush texture is colored and
|
||||
* secondary is used for alpha/mask control. */
|
||||
bool col = ELEM(mode, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D, PAINT_MODE_VERTEX);
|
||||
bool col = ELEM(mode, PaintMode::Texture3D, PaintMode::Texture2D, PaintMode::Vertex);
|
||||
|
||||
bool alpha_overlay_active = false;
|
||||
|
||||
|
@ -813,7 +813,7 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT)) {
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PaintMode::Weight)) {
|
||||
alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, mode, false, true);
|
||||
}
|
||||
if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
|
||||
|
@ -1205,23 +1205,23 @@ static void SCULPT_layer_brush_height_preview_draw(const uint gpuattr,
|
|||
GPU_matrix_pop();
|
||||
}
|
||||
|
||||
static bool paint_use_2d_cursor(ePaintMode mode)
|
||||
static bool paint_use_2d_cursor(PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::Vertex:
|
||||
case PaintMode::Weight:
|
||||
return false;
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_SCULPT_UV:
|
||||
case PAINT_MODE_VERTEX_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_GPENCIL:
|
||||
case PAINT_MODE_WEIGHT_GPENCIL:
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::Texture3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::SculptUV:
|
||||
case PaintMode::VertexGPencil:
|
||||
case PaintMode::SculptGPencil:
|
||||
case PaintMode::WeightGPencil:
|
||||
case PaintMode::SculptCurves:
|
||||
case PaintMode::GPencil:
|
||||
return true;
|
||||
case PAINT_MODE_INVALID:
|
||||
case PaintMode::Invalid:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
return true;
|
||||
|
@ -1243,7 +1243,7 @@ struct PaintCursorContext {
|
|||
UnifiedPaintSettings *ups;
|
||||
Brush *brush;
|
||||
Paint *paint;
|
||||
ePaintMode mode;
|
||||
PaintMode mode;
|
||||
ViewContext vc;
|
||||
|
||||
/* Sculpt related data. */
|
||||
|
@ -1389,7 +1389,7 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext)
|
|||
static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext *pcontext)
|
||||
{
|
||||
BLI_assert(pcontext->ss != nullptr);
|
||||
BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
|
||||
BLI_assert(pcontext->mode == PaintMode::Sculpt);
|
||||
|
||||
bContext *C = pcontext->C;
|
||||
SculptSession *ss = pcontext->ss;
|
||||
|
@ -1440,7 +1440,7 @@ static void paint_update_mouse_cursor(PaintCursorContext *pcontext)
|
|||
* with the UI (dragging a number button for e.g.), see: #102792. */
|
||||
return;
|
||||
}
|
||||
if (pcontext->mode == PAINT_MODE_GPENCIL) {
|
||||
if (pcontext->mode == PaintMode::GPencil) {
|
||||
WM_cursor_set(pcontext->win, WM_CURSOR_DOT);
|
||||
}
|
||||
else {
|
||||
|
@ -1523,7 +1523,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
|||
const int y = pcontext->y;
|
||||
|
||||
/* for paint use paint brush size and color */
|
||||
if (pcontext->mode == PAINT_MODE_GPENCIL) {
|
||||
if (pcontext->mode == PaintMode::GPencil) {
|
||||
Paint *paint = pcontext->paint;
|
||||
Brush *brush = pcontext->brush;
|
||||
if ((brush == nullptr) || (brush->gpencil_settings == nullptr)) {
|
||||
|
@ -1602,7 +1602,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
|||
static void paint_draw_2D_view_brush_cursor(PaintCursorContext *pcontext)
|
||||
{
|
||||
switch (pcontext->mode) {
|
||||
case PAINT_MODE_GPENCIL: {
|
||||
case PaintMode::GPencil: {
|
||||
grease_pencil_brush_cursor_draw(pcontext);
|
||||
break;
|
||||
}
|
||||
|
@ -1914,7 +1914,7 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont
|
|||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
BLI_assert(pcontext->ss != nullptr);
|
||||
BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
|
||||
BLI_assert(pcontext->mode == PaintMode::Sculpt);
|
||||
|
||||
SculptSession *ss = pcontext->ss;
|
||||
Brush *brush = pcontext->brush;
|
||||
|
@ -1995,7 +1995,7 @@ static void paint_cursor_draw_3D_view_brush_cursor(PaintCursorContext *pcontext)
|
|||
|
||||
/* These paint tools are not using the SculptSession, so they need to use the default 2D brush
|
||||
* cursor in the 3D view. */
|
||||
if (pcontext->mode != PAINT_MODE_SCULPT || !pcontext->ss) {
|
||||
if (pcontext->mode != PaintMode::Sculpt || !pcontext->ss) {
|
||||
paint_draw_legacy_3D_view_brush_cursor(pcontext);
|
||||
return;
|
||||
}
|
||||
|
@ -2019,7 +2019,7 @@ static bool paint_cursor_is_3d_view_navigating(PaintCursorContext *pcontext)
|
|||
static bool paint_cursor_is_brush_cursor_enabled(PaintCursorContext *pcontext)
|
||||
{
|
||||
if (pcontext->paint->flags & PAINT_SHOW_BRUSH) {
|
||||
if (ELEM(pcontext->mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) &&
|
||||
if (ELEM(pcontext->mode, PaintMode::Texture2D, PaintMode::Texture3D) &&
|
||||
pcontext->brush->imagepaint_tool == PAINT_TOOL_FILL)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -666,27 +666,27 @@ void PAINTCURVE_OT_slide(wmOperatorType *ot)
|
|||
|
||||
static int paintcurve_draw_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const char *name;
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
name = "PAINT_OT_image_paint";
|
||||
break;
|
||||
case PAINT_MODE_WEIGHT:
|
||||
case PaintMode::Weight:
|
||||
name = "PAINT_OT_weight_paint";
|
||||
break;
|
||||
case PAINT_MODE_VERTEX:
|
||||
case PaintMode::Vertex:
|
||||
name = "PAINT_OT_vertex_paint";
|
||||
break;
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
name = "SCULPT_OT_brush_stroke";
|
||||
break;
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
name = "SCULPT_CURVES_OT_brush_stroke";
|
||||
break;
|
||||
case PAINT_MODE_GPENCIL:
|
||||
case PaintMode::GPencil:
|
||||
name = "GREASE_PENCIL_OT_brush_stroke";
|
||||
break;
|
||||
default:
|
||||
|
@ -713,10 +713,10 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
|
|||
|
||||
static int paintcurve_cursor_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_TEXTURE_2D: {
|
||||
case PaintMode::Texture2D: {
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
float location[2];
|
||||
|
|
|
@ -489,7 +489,7 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
|
|||
}
|
||||
|
||||
if (enabled) {
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_TEXTURE_2D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Texture2D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
ED_paint_cursor_start(&imapaint->paint, ED_image_tools_paint_poll);
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
const bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
|
||||
|
@ -655,7 +655,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
|
|||
|
||||
RNA_int_get_array(op->ptr, "location", location);
|
||||
const bool use_palette = RNA_boolean_get(op->ptr, "palette");
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
paint_sample_color(C, region, location[0], location[1], use_sample_texture, use_palette);
|
||||
|
@ -695,8 +695,8 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
|
|||
|
||||
RNA_int_set_array(op->ptr, "location", event->mval);
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
paint_sample_color(C, region, event->mval[0], event->mval[1], use_sample_texture, false);
|
||||
|
@ -730,8 +730,8 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PaintMode::Texture3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
switch (event->type) {
|
||||
|
@ -898,7 +898,7 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain,
|
|||
|
||||
ob->mode |= OB_MODE_TEXTURE_PAINT;
|
||||
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_TEXTURE_3D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Texture3D, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ void ED_imapaint_bucket_fill(bContext *C, float color[3], wmOperator *op, const
|
|||
if (sima && sima->image) {
|
||||
Image *ima = sima->image;
|
||||
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture2D);
|
||||
|
||||
const float mouse_init[2] = {float(mouse[0]), float(mouse[1])};
|
||||
paint_2d_bucket_fill(C, color, nullptr, mouse_init, nullptr, nullptr);
|
||||
|
|
|
@ -319,7 +319,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo
|
|||
}
|
||||
|
||||
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture2D);
|
||||
|
||||
return pop;
|
||||
}
|
||||
|
|
|
@ -6164,7 +6164,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_3D);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Texture3D);
|
||||
|
||||
const float pos[2] = {0.0, 0.0};
|
||||
const float lastpos[2] = {0.0, 0.0};
|
||||
|
|
|
@ -79,17 +79,17 @@ void paint_stroke_free(bContext *C, wmOperator *op, PaintStroke *stroke);
|
|||
/**
|
||||
* Returns zero if the stroke dots should not be spaced, non-zero otherwise.
|
||||
*/
|
||||
bool paint_space_stroke_enabled(Brush *br, enum ePaintMode mode);
|
||||
bool paint_space_stroke_enabled(Brush *br, PaintMode mode);
|
||||
/**
|
||||
* Return true if the brush size can change during paint (normally used for pressure).
|
||||
*/
|
||||
bool paint_supports_dynamic_size(Brush *br, enum ePaintMode mode);
|
||||
bool paint_supports_dynamic_size(Brush *br, PaintMode mode);
|
||||
/**
|
||||
* Return true if the brush size can change during paint (normally used for pressure).
|
||||
*/
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, enum ePaintMode mode);
|
||||
bool paint_supports_smooth_stroke(Brush *br, enum ePaintMode mode);
|
||||
bool paint_supports_texture(enum ePaintMode mode);
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode);
|
||||
bool paint_supports_smooth_stroke(Brush *br, PaintMode mode);
|
||||
bool paint_supports_texture(PaintMode mode);
|
||||
|
||||
/**
|
||||
* Called in paint_ops.cc, on each regeneration of key-maps.
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
#include "BKE_preferences.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "ED_asset_handle.h"
|
||||
#include "ED_asset_list.h"
|
||||
#include "ED_asset_mark_clear.h"
|
||||
#include "ED_asset_handle.hh"
|
||||
#include "ED_asset_list.hh"
|
||||
#include "ED_asset_mark_clear.hh"
|
||||
#include "ED_image.hh"
|
||||
#include "ED_paint.hh"
|
||||
#include "ED_screen.hh"
|
||||
|
@ -56,7 +56,6 @@
|
|||
#include "RNA_access.hh"
|
||||
#include "RNA_define.hh"
|
||||
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
#include "AS_asset_representation.hh"
|
||||
|
||||
|
@ -71,7 +70,7 @@ static int brush_add_exec(bContext *C, wmOperator * /*op*/)
|
|||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *br = BKE_paint_brush(paint);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
if (br) {
|
||||
br = (Brush *)BKE_id_copy(bmain, &br->id);
|
||||
|
@ -392,7 +391,7 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
|||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Palette *palette = paint->palette;
|
||||
PaletteColor *color;
|
||||
|
||||
|
@ -402,15 +401,15 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
|||
if (paint->brush) {
|
||||
const Brush *brush = paint->brush;
|
||||
if (ELEM(mode,
|
||||
PAINT_MODE_TEXTURE_3D,
|
||||
PAINT_MODE_TEXTURE_2D,
|
||||
PAINT_MODE_VERTEX,
|
||||
PAINT_MODE_SCULPT))
|
||||
PaintMode::Texture3D,
|
||||
PaintMode::Texture2D,
|
||||
PaintMode::Vertex,
|
||||
PaintMode::Sculpt))
|
||||
{
|
||||
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
|
||||
color->value = 0.0;
|
||||
}
|
||||
else if (mode == PAINT_MODE_WEIGHT) {
|
||||
else if (mode == PaintMode::Weight) {
|
||||
zero_v3(color->rgb);
|
||||
color->value = brush->weight;
|
||||
}
|
||||
|
@ -901,16 +900,16 @@ static bool brush_generic_tool_set(bContext *C,
|
|||
return false;
|
||||
}
|
||||
|
||||
static const ePaintMode brush_select_paint_modes[] = {
|
||||
PAINT_MODE_SCULPT,
|
||||
PAINT_MODE_VERTEX,
|
||||
PAINT_MODE_WEIGHT,
|
||||
PAINT_MODE_TEXTURE_3D,
|
||||
PAINT_MODE_GPENCIL,
|
||||
PAINT_MODE_VERTEX_GPENCIL,
|
||||
PAINT_MODE_SCULPT_GPENCIL,
|
||||
PAINT_MODE_WEIGHT_GPENCIL,
|
||||
PAINT_MODE_SCULPT_CURVES,
|
||||
static const PaintMode brush_select_paint_modes[] = {
|
||||
PaintMode::Sculpt,
|
||||
PaintMode::Vertex,
|
||||
PaintMode::Weight,
|
||||
PaintMode::Texture3D,
|
||||
PaintMode::GPencil,
|
||||
PaintMode::VertexGPencil,
|
||||
PaintMode::SculptGPencil,
|
||||
PaintMode::WeightGPencil,
|
||||
PaintMode::SculptCurves,
|
||||
};
|
||||
|
||||
static int brush_select_exec(bContext *C, wmOperator *op)
|
||||
|
@ -922,7 +921,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
|||
const char *tool_name = "Brush";
|
||||
int tool = 0;
|
||||
|
||||
ePaintMode paint_mode = PAINT_MODE_INVALID;
|
||||
PaintMode paint_mode = PaintMode::Invalid;
|
||||
for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
|
||||
paint_mode = brush_select_paint_modes[i];
|
||||
const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
|
@ -933,7 +932,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
if (paint_mode == PAINT_MODE_INVALID) {
|
||||
if (paint_mode == PaintMode::Invalid) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -966,7 +965,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
|
|||
/* props */
|
||||
/* All properties are hidden, so as not to show the redo panel. */
|
||||
for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
|
||||
const ePaintMode paint_mode = brush_select_paint_modes[i];
|
||||
const PaintMode paint_mode = brush_select_paint_modes[i];
|
||||
const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
|
||||
prop = RNA_def_enum(
|
||||
ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
|
||||
|
@ -1029,9 +1028,6 @@ static void BRUSH_OT_asset_select(wmOperatorType *ot)
|
|||
|
||||
ot->exec = brush_asset_select_exec;
|
||||
ot->poll = brush_asset_select_poll;
|
||||
|
||||
ot->prop = RNA_def_string(
|
||||
ot->srna, "name", nullptr, MAX_NAME, "Brush Name", "Name of the brush asset to select");
|
||||
}
|
||||
|
||||
/* FIXME Quick dirty hack to generate a weak ref from 'raw' paths.
|
||||
|
@ -1068,7 +1064,7 @@ static void brush_asset_refresh_editable_library(const bContext *C)
|
|||
|
||||
/* TODO: Should the all library reference be automatically cleared? */
|
||||
AssetLibraryReference all_lib_ref = blender::asset_system::all_library_reference();
|
||||
ED_assetlist_clear(&all_lib_ref, C);
|
||||
blender::ed::asset::list::clear(&all_lib_ref, C);
|
||||
|
||||
/* TODO: this is convoluted, can we create a reference from pointer? */
|
||||
for (const AssetLibraryReference &lib_ref :
|
||||
|
@ -1078,7 +1074,7 @@ static void brush_asset_refresh_editable_library(const bContext *C)
|
|||
const bUserAssetLibrary *ref_user_library = BKE_preferences_asset_library_find_index(
|
||||
&U, lib_ref.custom_library_index);
|
||||
if (ref_user_library == user_library) {
|
||||
ED_assetlist_clear(&lib_ref, C);
|
||||
blender::ed::asset::list::clear(&lib_ref, C);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1239,8 +1235,8 @@ static int brush_asset_save_as_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* Turn brush into asset if it isn't yet. */
|
||||
if (!BKE_paint_brush_is_valid_asset(brush)) {
|
||||
ED_asset_mark_id(&brush->id);
|
||||
ED_asset_generate_preview(C, &brush->id);
|
||||
blender::ed::asset::mark_id(&brush->id);
|
||||
blender::ed::asset::generate_preview(C, &brush->id);
|
||||
}
|
||||
BLI_assert(BKE_paint_brush_is_valid_asset(brush));
|
||||
|
||||
|
@ -1720,7 +1716,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
|
|||
|
||||
static bool stencil_control_poll(bContext *C)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
Paint *paint;
|
||||
Brush *br;
|
||||
|
|
|
@ -208,10 +208,10 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
|||
GPU_line_smooth(false);
|
||||
}
|
||||
|
||||
static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
|
||||
static bool paint_tool_require_location(Brush *brush, PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (ELEM(brush->sculpt_tool,
|
||||
SCULPT_TOOL_GRAB,
|
||||
SCULPT_TOOL_ELASTIC_DEFORM,
|
||||
|
@ -236,10 +236,10 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
|
||||
static bool paint_stroke_use_scene_spacing(Brush *brush, PaintMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
return brush->flag & BRUSH_SCENE_SPACING;
|
||||
default:
|
||||
break;
|
||||
|
@ -247,19 +247,19 @@ static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool paint_tool_raycast_original(Brush *brush, ePaintMode /*mode*/)
|
||||
static bool paint_tool_raycast_original(Brush *brush, PaintMode /*mode*/)
|
||||
{
|
||||
return brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT);
|
||||
}
|
||||
|
||||
static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode)
|
||||
static bool paint_tool_require_inbetween_mouse_events(Brush *brush, PaintMode mode)
|
||||
{
|
||||
if (brush->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (ELEM(brush->sculpt_tool,
|
||||
SCULPT_TOOL_GRAB,
|
||||
SCULPT_TOOL_ROTATE,
|
||||
|
@ -285,7 +285,7 @@ static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode m
|
|||
/* Initialize the stroke cache variants from operator properties */
|
||||
static bool paint_brush_update(bContext *C,
|
||||
Brush *brush,
|
||||
ePaintMode mode,
|
||||
PaintMode mode,
|
||||
PaintStroke *stroke,
|
||||
const float mouse_init[2],
|
||||
float mouse[2],
|
||||
|
@ -500,7 +500,7 @@ static bool paint_stroke_use_dash(Brush *brush)
|
|||
return brush->flag & BRUSH_SPACE || brush->flag & BRUSH_LINE || brush->flag & BRUSH_CURVE;
|
||||
}
|
||||
|
||||
static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert)
|
||||
static bool paint_stroke_use_jitter(PaintMode mode, Brush *brush, bool invert)
|
||||
{
|
||||
bool use_jitter = (brush->flag & BRUSH_ABSOLUTE_JITTER) ? (brush->jitter_absolute != 0) :
|
||||
(brush->jitter != 0);
|
||||
|
@ -508,7 +508,7 @@ static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert)
|
|||
/* jitter-ed brush gives weird and unpredictable result for this
|
||||
* kinds of stroke, so manually disable jitter usage (sergey) */
|
||||
use_jitter &= (brush->flag & (BRUSH_DRAG_DOT | BRUSH_ANCHORED)) == 0;
|
||||
use_jitter &= (!ELEM(mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) ||
|
||||
use_jitter &= (!ELEM(mode, PaintMode::Texture2D, PaintMode::Texture3D) ||
|
||||
!(invert && brush->imagepaint_tool == PAINT_TOOL_CLONE));
|
||||
|
||||
return use_jitter;
|
||||
|
@ -520,7 +520,7 @@ static void paint_brush_stroke_add_step(
|
|||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
float mouse_out[2];
|
||||
|
@ -643,7 +643,7 @@ static void paint_brush_stroke_add_step(
|
|||
/* Returns zero if no sculpt changes should be made, non-zero otherwise */
|
||||
static bool paint_smooth_stroke(PaintStroke *stroke,
|
||||
const PaintSample *sample,
|
||||
ePaintMode mode,
|
||||
PaintMode mode,
|
||||
float r_mouse[2],
|
||||
float *r_pressure)
|
||||
{
|
||||
|
@ -676,7 +676,7 @@ static float paint_space_stroke_spacing(bContext *C,
|
|||
float spacing_pressure)
|
||||
{
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
float size_clamp = 0.0f;
|
||||
float size = BKE_brush_size_get(scene, stroke->brush) * size_pressure;
|
||||
|
@ -816,7 +816,7 @@ static int paint_space_stroke(bContext *C,
|
|||
ARegion *region = CTX_wm_region(C);
|
||||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
int count = 0;
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ static bool curves_sculpt_brush_uses_spacing(const eBrushCurvesSculptTool tool)
|
|||
return ELEM(tool, CURVES_SCULPT_TOOL_ADD, CURVES_SCULPT_TOOL_DENSITY);
|
||||
}
|
||||
|
||||
bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
|
||||
bool paint_space_stroke_enabled(Brush *br, PaintMode mode)
|
||||
{
|
||||
if ((br->flag & BRUSH_SPACE) == 0) {
|
||||
return false;
|
||||
|
@ -1036,13 +1036,13 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (mode == PAINT_MODE_SCULPT_CURVES &&
|
||||
if (mode == PaintMode::SculptCurves &&
|
||||
!curves_sculpt_brush_uses_spacing(eBrushCurvesSculptTool(br->curves_sculpt_tool)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode == PAINT_MODE_GPENCIL) {
|
||||
if (mode == PaintMode::GPencil) {
|
||||
/* No spacing needed for now. */
|
||||
return false;
|
||||
}
|
||||
|
@ -1066,21 +1066,21 @@ static bool sculpt_is_grab_tool(Brush *br)
|
|||
SCULPT_TOOL_SNAKE_HOOK);
|
||||
}
|
||||
|
||||
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_dynamic_size(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (br->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case PAINT_MODE_TEXTURE_2D: /* fall through */
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D: /* fall through */
|
||||
case PaintMode::Texture3D:
|
||||
if ((br->imagepaint_tool == PAINT_TOOL_FILL) && (br->flag & BRUSH_USE_GRADIENT)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (!(br->flag & BRUSH_SMOOTH_STROKE) ||
|
||||
(br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE)))
|
||||
|
@ -1101,7 +1101,7 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
|||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1112,21 +1112,21 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool paint_supports_texture(ePaintMode mode)
|
||||
bool paint_supports_texture(PaintMode mode)
|
||||
{
|
||||
/* omit: PAINT_WEIGHT, PAINT_SCULPT_UV, PAINT_INVALID */
|
||||
return ELEM(
|
||||
mode, PAINT_MODE_SCULPT, PAINT_MODE_VERTEX, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D);
|
||||
mode, PaintMode::Sculpt, PaintMode::Vertex, PaintMode::Texture3D, PaintMode::Texture2D);
|
||||
}
|
||||
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
|
||||
bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode)
|
||||
{
|
||||
if (br->flag & BRUSH_ANCHORED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1208,7 +1208,7 @@ static void paint_line_strokes_spacing(bContext *C,
|
|||
UnifiedPaintSettings *ups = stroke->ups;
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
const bool use_scene_spacing = paint_stroke_use_scene_spacing(brush, mode);
|
||||
|
@ -1432,7 +1432,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2])
|
|||
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintStroke **stroke_p)
|
||||
{
|
||||
Paint *p = BKE_paint_get_active_from_context(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintStroke *stroke = *stroke_p;
|
||||
Brush *br = stroke->brush = BKE_paint_brush(p);
|
||||
PaintSample sample_average;
|
||||
|
|
|
@ -315,7 +315,7 @@ void mode_enter_generic(
|
|||
BKE_object_free_derived_caches(ob);
|
||||
|
||||
if (mode_flag == OB_MODE_VERTEX_PAINT) {
|
||||
const ePaintMode paint_mode = PAINT_MODE_VERTEX;
|
||||
const PaintMode paint_mode = PaintMode::Vertex;
|
||||
ED_mesh_color_ensure(mesh, nullptr);
|
||||
|
||||
BKE_paint_ensure(bmain, scene->toolsettings, (Paint **)&scene->toolsettings->vpaint);
|
||||
|
@ -324,7 +324,7 @@ void mode_enter_generic(
|
|||
BKE_paint_init(bmain, scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
|
||||
}
|
||||
else if (mode_flag == OB_MODE_WEIGHT_PAINT) {
|
||||
const ePaintMode paint_mode = PAINT_MODE_WEIGHT;
|
||||
const PaintMode paint_mode = PaintMode::Weight;
|
||||
|
||||
BKE_paint_ensure(bmain, scene->toolsettings, (Paint **)&scene->toolsettings->wpaint);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
|
@ -523,7 +523,7 @@ void update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr)
|
|||
* brush coord/pressure/etc.
|
||||
* It's more an events design issue, which doesn't split coordinate/pressure/angle
|
||||
* changing events. We should avoid this after events system re-design */
|
||||
if (paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT) || cache->first_time) {
|
||||
if (paint_supports_dynamic_size(brush, PaintMode::Sculpt) || cache->first_time) {
|
||||
cache->pressure = RNA_float_get(ptr, "pressure");
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ void update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr)
|
|||
BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius);
|
||||
}
|
||||
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT))
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PaintMode::Sculpt))
|
||||
{
|
||||
cache->radius = cache->initial_radius * cache->pressure;
|
||||
}
|
||||
|
|
|
@ -1177,7 +1177,7 @@ static int sculpt_brush_needs_normal(const SculptSession *ss, Sculpt *sd, const
|
|||
|
||||
(mask_tex->brush_map_mode == MTEX_MAP_MODE_AREA)) ||
|
||||
sculpt_brush_use_topology_rake(ss, brush) ||
|
||||
BKE_brush_has_cube_tip(brush, PAINT_MODE_SCULPT);
|
||||
BKE_brush_has_cube_tip(brush, PaintMode::Sculpt);
|
||||
}
|
||||
|
||||
static bool sculpt_brush_needs_rake_rotation(const Brush *brush)
|
||||
|
@ -3324,7 +3324,7 @@ static void do_brush_action(Sculpt *sd,
|
|||
float radius_scale = 1.0f;
|
||||
|
||||
/* Corners of square brushes can go outside the brush radius. */
|
||||
if (BKE_brush_has_cube_tip(brush, PAINT_MODE_SCULPT)) {
|
||||
if (BKE_brush_has_cube_tip(brush, PaintMode::Sculpt)) {
|
||||
radius_scale = M_SQRT2;
|
||||
}
|
||||
|
||||
|
@ -4628,7 +4628,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
|
|||
* thumb). They depends on initial state and brush coord/pressure/etc.
|
||||
* It's more an events design issue, which doesn't split coordinate/pressure/angle changing
|
||||
* events. We should avoid this after events system re-design. */
|
||||
if (paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT) || cache->first_time) {
|
||||
if (paint_supports_dynamic_size(brush, PaintMode::Sculpt) || cache->first_time) {
|
||||
cache->pressure = RNA_float_get(ptr, "pressure");
|
||||
}
|
||||
|
||||
|
@ -4661,7 +4661,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
|
|||
}
|
||||
}
|
||||
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT))
|
||||
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PaintMode::Sculpt))
|
||||
{
|
||||
cache->radius = sculpt_brush_dynamic_size_get(brush, cache, cache->initial_radius);
|
||||
cache->dyntopo_pixel_radius = sculpt_brush_dynamic_size_get(
|
||||
|
@ -5401,7 +5401,7 @@ static void sculpt_stroke_undo_begin(const bContext *C, wmOperator *op)
|
|||
if (brush && brush->sculpt_tool == SCULPT_TOOL_PAINT &&
|
||||
SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob))
|
||||
{
|
||||
ED_image_undo_push_begin(op->type->name, PAINT_MODE_SCULPT);
|
||||
ED_image_undo_push_begin(op->type->name, PaintMode::Sculpt);
|
||||
}
|
||||
else {
|
||||
undo::push_begin_ex(ob, sculpt_tool_name(sd));
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <queue>
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_paint.hh"
|
||||
#include "BKE_pbvh_api.hh"
|
||||
|
||||
#include "BLI_array.hh"
|
||||
|
|
|
@ -358,8 +358,8 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
|
|||
BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable");
|
||||
}
|
||||
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT);
|
||||
BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::Sculpt);
|
||||
BKE_paint_init(bmain, scene, PaintMode::Sculpt, PAINT_CURSOR_SCULPT);
|
||||
|
||||
ED_paint_cursor_start(paint, SCULPT_mode_poll_view3d);
|
||||
|
||||
|
|
|
@ -1993,7 +1993,7 @@ static UndoSculpt *get_nodes()
|
|||
|
||||
static bool use_multires_mesh(bContext *C)
|
||||
{
|
||||
if (BKE_paintmode_get_active_from_context(C) != PAINT_MODE_SCULPT) {
|
||||
if (BKE_paintmode_get_active_from_context(C) != PaintMode::Sculpt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
void ED_spacetypes_init()
|
||||
{
|
||||
using namespace blender::ed;
|
||||
/* UI unit is a variable, may be used in some space type initialization. */
|
||||
U.widget_unit = 20;
|
||||
|
||||
|
@ -92,7 +93,7 @@ void ED_spacetypes_init()
|
|||
ED_operatortypes_screen();
|
||||
ED_operatortypes_anim();
|
||||
ED_operatortypes_animchannels();
|
||||
ED_operatortypes_asset();
|
||||
asset::operatortypes_asset();
|
||||
ED_operatortypes_gpencil_legacy();
|
||||
ED_operatortypes_grease_pencil();
|
||||
ED_operatortypes_object();
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace blender::ed::asset_browser {
|
|||
class AssetCatalogTreeViewAllItem;
|
||||
|
||||
class AssetCatalogTreeView : public ui::AbstractTreeView {
|
||||
::AssetLibrary *asset_library_;
|
||||
asset_system::AssetLibrary *asset_library_;
|
||||
/** The asset catalog tree this tree-view represents. */
|
||||
asset_system::AssetCatalogTree *catalog_tree_;
|
||||
FileAssetSelectParams *params_;
|
||||
|
@ -55,7 +55,7 @@ class AssetCatalogTreeView : public ui::AbstractTreeView {
|
|||
friend class AssetCatalogTreeViewAllItem;
|
||||
|
||||
public:
|
||||
AssetCatalogTreeView(::AssetLibrary *library,
|
||||
AssetCatalogTreeView(asset_system::AssetLibrary *library,
|
||||
FileAssetSelectParams *params,
|
||||
SpaceFile &space_file);
|
||||
|
||||
|
@ -117,11 +117,12 @@ class AssetCatalogDropTarget : public ui::TreeViewItemDropTarget {
|
|||
std::string drop_tooltip(const ui::DragInfo &drag_info) const override;
|
||||
bool on_drop(bContext *C, const ui::DragInfo &drag_info) const override;
|
||||
|
||||
::AssetLibrary &get_asset_library() const;
|
||||
asset_system::AssetLibrary &get_asset_library() const;
|
||||
|
||||
static AssetCatalog *get_drag_catalog(const wmDrag &drag, const ::AssetLibrary &asset_library);
|
||||
static AssetCatalog *get_drag_catalog(const wmDrag &drag,
|
||||
const asset_system::AssetLibrary &asset_library);
|
||||
static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint);
|
||||
static bool can_modify_catalogs(const ::AssetLibrary &asset_library,
|
||||
static bool can_modify_catalogs(const asset_system::AssetLibrary &asset_library,
|
||||
const char **r_disabled_hint);
|
||||
static bool drop_assets_into_catalog(bContext *C,
|
||||
const AssetCatalogTreeView &tree_view,
|
||||
|
@ -177,7 +178,7 @@ class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem {
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AssetCatalogTreeView::AssetCatalogTreeView(::AssetLibrary *library,
|
||||
AssetCatalogTreeView::AssetCatalogTreeView(asset_system::AssetLibrary *library,
|
||||
FileAssetSelectParams *params,
|
||||
SpaceFile &space_file)
|
||||
: asset_library_(library),
|
||||
|
@ -329,7 +330,7 @@ bool AssetCatalogTreeViewItem::supports_renaming() const
|
|||
{
|
||||
const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
|
||||
get_tree_view());
|
||||
return !ED_asset_catalogs_read_only(*tree_view.asset_library_);
|
||||
return !asset::catalogs_read_only(*tree_view.asset_library_);
|
||||
}
|
||||
|
||||
bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name)
|
||||
|
@ -339,7 +340,7 @@ bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name)
|
|||
|
||||
const AssetCatalogTreeView &tree_view = static_cast<const AssetCatalogTreeView &>(
|
||||
get_tree_view());
|
||||
ED_asset_catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
|
||||
asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -366,7 +367,7 @@ AssetCatalogDropTarget::AssetCatalogDropTarget(AssetCatalogTreeViewItem &item,
|
|||
bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disabled_hint) const
|
||||
{
|
||||
if (drag.type == WM_DRAG_ASSET_CATALOG) {
|
||||
const ::AssetLibrary &library = get_asset_library();
|
||||
const asset_system::AssetLibrary &library = get_asset_library();
|
||||
if (!can_modify_catalogs(library, r_disabled_hint)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -453,7 +454,7 @@ bool AssetCatalogDropTarget::drop_asset_catalog_into_catalog(
|
|||
{
|
||||
BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG);
|
||||
wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
|
||||
ED_asset_catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
|
||||
asset::catalog_move(tree_view.asset_library_, catalog_drag->drag_catalog_id, drop_catalog_id);
|
||||
tree_view.activate_catalog_by_id(catalog_drag->drag_catalog_id);
|
||||
|
||||
WM_main_add_notifier(NC_ASSET | ND_ASSET_CATALOGS, nullptr);
|
||||
|
@ -496,8 +497,8 @@ bool AssetCatalogDropTarget::drop_assets_into_catalog(bContext *C,
|
|||
return true;
|
||||
}
|
||||
|
||||
AssetCatalog *AssetCatalogDropTarget::get_drag_catalog(const wmDrag &drag,
|
||||
const ::AssetLibrary &asset_library)
|
||||
AssetCatalog *AssetCatalogDropTarget::get_drag_catalog(
|
||||
const wmDrag &drag, const asset_system::AssetLibrary &asset_library)
|
||||
{
|
||||
if (drag.type != WM_DRAG_ASSET_CATALOG) {
|
||||
return nullptr;
|
||||
|
@ -525,17 +526,17 @@ bool AssetCatalogDropTarget::has_droppable_asset(const wmDrag &drag, const char
|
|||
return false;
|
||||
}
|
||||
|
||||
bool AssetCatalogDropTarget::can_modify_catalogs(const ::AssetLibrary &library,
|
||||
bool AssetCatalogDropTarget::can_modify_catalogs(const asset_system::AssetLibrary &library,
|
||||
const char **r_disabled_hint)
|
||||
{
|
||||
if (ED_asset_catalogs_read_only(library)) {
|
||||
if (asset::catalogs_read_only(library)) {
|
||||
*r_disabled_hint = RPT_("Catalogs cannot be edited in this asset library");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
::AssetLibrary &AssetCatalogDropTarget::get_asset_library() const
|
||||
asset_system::AssetLibrary &AssetCatalogDropTarget::get_asset_library() const
|
||||
{
|
||||
return *get_view<AssetCatalogTreeView>().asset_library_;
|
||||
}
|
||||
|
@ -600,7 +601,7 @@ bool AssetCatalogTreeViewAllItem::DropTarget::can_drop(const wmDrag &drag,
|
|||
if (drag.type != WM_DRAG_ASSET_CATALOG) {
|
||||
return false;
|
||||
}
|
||||
::AssetLibrary &library = *get_view<AssetCatalogTreeView>().asset_library_;
|
||||
asset_system::AssetLibrary &library = *get_view<AssetCatalogTreeView>().asset_library_;
|
||||
if (!AssetCatalogDropTarget::can_modify_catalogs(library, r_disabled_hint)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -771,7 +772,7 @@ bool file_is_asset_visible_in_catalog_filter_settings(
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void file_create_asset_catalog_tree_view_in_layout(::AssetLibrary *asset_library,
|
||||
void file_create_asset_catalog_tree_view_in_layout(asset_system::AssetLibrary *asset_library,
|
||||
uiLayout *layout,
|
||||
SpaceFile *space_file,
|
||||
FileAssetSelectParams *params)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
struct ARegion;
|
||||
struct ARegionType;
|
||||
struct AssetLibrary;
|
||||
struct bContextDataResult;
|
||||
struct FileAssetSelectParams;
|
||||
struct FileSelectParams;
|
||||
|
@ -228,10 +227,11 @@ void file_path_to_ui_path(const char *path, char *r_pathi, int max_size);
|
|||
/* C-handle for #ed::asset_browser::AssetCatalogFilterSettings. */
|
||||
struct FileAssetCatalogFilterSettingsHandle;
|
||||
|
||||
void file_create_asset_catalog_tree_view_in_layout(::AssetLibrary *asset_library,
|
||||
uiLayout *layout,
|
||||
SpaceFile *space_file,
|
||||
FileAssetSelectParams *params);
|
||||
void file_create_asset_catalog_tree_view_in_layout(
|
||||
blender::asset_system::AssetLibrary *asset_library,
|
||||
uiLayout *layout,
|
||||
SpaceFile *space_file,
|
||||
FileAssetSelectParams *params);
|
||||
|
||||
namespace blender::asset_system {
|
||||
class AssetLibrary;
|
||||
|
|
|
@ -225,7 +225,7 @@ static void file_panel_asset_catalog_buttons_draw(const bContext *C, Panel *pane
|
|||
bScreen *screen = CTX_wm_screen(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
/* May be null if the library wasn't loaded yet. */
|
||||
AssetLibrary *asset_library = filelist_asset_library(sfile->files);
|
||||
blender::asset_system::AssetLibrary *asset_library = filelist_asset_library(sfile->files);
|
||||
FileAssetSelectParams *params = ED_fileselect_get_asset_params(sfile);
|
||||
BLI_assert(params != nullptr);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include "AS_asset_library.h"
|
||||
#include "AS_asset_library.hh"
|
||||
#include "AS_asset_representation.hh"
|
||||
|
||||
|
@ -1948,9 +1947,9 @@ void filelist_free(FileList *filelist)
|
|||
filelist->flags &= ~(FL_NEED_SORTING | FL_NEED_FILTERING);
|
||||
}
|
||||
|
||||
AssetLibrary *filelist_asset_library(FileList *filelist)
|
||||
blender::asset_system::AssetLibrary *filelist_asset_library(FileList *filelist)
|
||||
{
|
||||
return reinterpret_cast<::AssetLibrary *>(filelist->asset_library);
|
||||
return filelist->asset_library;
|
||||
}
|
||||
|
||||
void filelist_freelib(FileList *filelist)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
struct AssetLibrary;
|
||||
struct AssetLibraryReference;
|
||||
struct bContext;
|
||||
struct BlendHandle;
|
||||
|
@ -19,6 +18,9 @@ struct ID;
|
|||
struct ImBuf;
|
||||
struct bUUID;
|
||||
struct wmWindowManager;
|
||||
namespace blender::asset_system {
|
||||
class AssetLibrary;
|
||||
}
|
||||
|
||||
struct FileDirEntry;
|
||||
|
||||
|
@ -197,7 +199,7 @@ void filelist_entry_parent_select_set(FileList *filelist,
|
|||
|
||||
void filelist_setrecursion(FileList *filelist, int recursion_level);
|
||||
|
||||
AssetLibrary *filelist_asset_library(FileList *filelist);
|
||||
blender::asset_system::AssetLibrary *filelist_asset_library(FileList *filelist);
|
||||
|
||||
BlendHandle *filelist_lib(FileList *filelist);
|
||||
/**
|
||||
|
|
|
@ -469,7 +469,7 @@ bool ED_fileselect_is_asset_browser(const SpaceFile *sfile)
|
|||
return (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS);
|
||||
}
|
||||
|
||||
AssetLibrary *ED_fileselect_active_asset_library_get(const SpaceFile *sfile)
|
||||
blender::asset_system::AssetLibrary *ED_fileselect_active_asset_library_get(const SpaceFile *sfile)
|
||||
{
|
||||
if (!ED_fileselect_is_asset_browser(sfile) || !sfile->files) {
|
||||
return nullptr;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "WM_types.hh"
|
||||
|
||||
#include "ED_asset.hh"
|
||||
#include "ED_asset_indexer.h"
|
||||
#include "ED_asset_indexer.hh"
|
||||
#include "ED_fileselect.hh"
|
||||
#include "ED_screen.hh"
|
||||
#include "ED_space_api.hh"
|
||||
|
@ -202,6 +202,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
|
|||
|
||||
static void file_refresh(const bContext *C, ScrArea *area)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
|
@ -231,7 +232,7 @@ static void file_refresh(const bContext *C, ScrArea *area)
|
|||
if (ED_fileselect_is_asset_browser(sfile)) {
|
||||
/* Ask the asset code for appropriate ID filter flags for the supported assets, and mask others
|
||||
* out. */
|
||||
params->filter_id &= ED_asset_types_supported_as_filter_flags();
|
||||
params->filter_id &= asset::types_supported_as_filter_flags();
|
||||
}
|
||||
|
||||
filelist_settype(sfile->files, params->type);
|
||||
|
@ -258,8 +259,8 @@ static void file_refresh(const bContext *C, ScrArea *area)
|
|||
|
||||
if (ED_fileselect_is_asset_browser(sfile)) {
|
||||
const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing);
|
||||
filelist_setindexer(sfile->files,
|
||||
use_asset_indexer ? &file_indexer_asset : &file_indexer_noop);
|
||||
filelist_setindexer(
|
||||
sfile->files, use_asset_indexer ? &asset::index::file_indexer_asset : &file_indexer_noop);
|
||||
}
|
||||
|
||||
/* Update the active indices of bookmarks & co. */
|
||||
|
|
|
@ -756,7 +756,7 @@ struct ImageUndoStep {
|
|||
PaintTileMap *paint_tile_map;
|
||||
|
||||
bool is_encode_init;
|
||||
ePaintMode paint_mode;
|
||||
PaintMode paint_mode;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -943,8 +943,8 @@ static bool image_undosys_step_encode(bContext *C, Main * /*bmain*/, UndoStep *u
|
|||
else {
|
||||
BLI_assert(C != nullptr);
|
||||
/* Happens when switching modes. */
|
||||
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
BLI_assert(ELEM(paint_mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D));
|
||||
PaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
||||
BLI_assert(ELEM(paint_mode, PaintMode::Texture2D, PaintMode::Texture3D));
|
||||
us->paint_mode = paint_mode;
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ static void image_undosys_step_decode(
|
|||
image_undosys_step_decode_redo(us);
|
||||
}
|
||||
|
||||
if (us->paint_mode == PAINT_MODE_TEXTURE_3D) {
|
||||
if (us->paint_mode == PaintMode::Texture3D) {
|
||||
ED_object_mode_set_ex(C, OB_MODE_TEXTURE_PAINT, false, nullptr);
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1093,7 @@ PaintTileMap *ED_image_paint_tile_map_get()
|
|||
BLI_assert(us_p == us_prev);
|
||||
if (us_p != us_prev) {
|
||||
/* Fallback value until we can be sure this never happens. */
|
||||
us->paint_mode = PAINT_MODE_TEXTURE_2D;
|
||||
us->paint_mode = PaintMode::Texture2D;
|
||||
}
|
||||
return us->paint_tile_map;
|
||||
}
|
||||
|
@ -1105,18 +1105,18 @@ void ED_image_undo_restore(UndoStep *us)
|
|||
ptile_invalidate_map(paint_tile_map);
|
||||
}
|
||||
|
||||
static ImageUndoStep *image_undo_push_begin(const char *name, int paint_mode)
|
||||
static ImageUndoStep *image_undo_push_begin(const char *name, PaintMode paint_mode)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = nullptr; /* special case, we never read from this. */
|
||||
UndoStep *us_p = BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
ImageUndoStep *us = reinterpret_cast<ImageUndoStep *>(us_p);
|
||||
BLI_assert(ELEM(paint_mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D, PAINT_MODE_SCULPT));
|
||||
us->paint_mode = (ePaintMode)paint_mode;
|
||||
BLI_assert(ELEM(paint_mode, PaintMode::Texture2D, PaintMode::Texture3D, PaintMode::Sculpt));
|
||||
us->paint_mode = (PaintMode)paint_mode;
|
||||
return us;
|
||||
}
|
||||
|
||||
void ED_image_undo_push_begin(const char *name, int paint_mode)
|
||||
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
|
||||
{
|
||||
image_undo_push_begin(name, paint_mode);
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ void ED_image_undo_push_begin_with_image(const char *name,
|
|||
ImBuf *ibuf,
|
||||
ImageUser *iuser)
|
||||
{
|
||||
ImageUndoStep *us = image_undo_push_begin(name, PAINT_MODE_TEXTURE_2D);
|
||||
ImageUndoStep *us = image_undo_push_begin(name, PaintMode::Texture2D);
|
||||
|
||||
BLI_assert(BKE_image_get_tile(image, iuser->tile));
|
||||
UndoImageHandle *uh = uhandle_ensure(&us->handles, image, iuser);
|
||||
|
|
|
@ -38,7 +38,7 @@ static bool node_add_menu_poll(const bContext *C, MenuType * /*mt*/)
|
|||
static bool all_loading_finished()
|
||||
{
|
||||
AssetLibraryReference all_library_ref = asset_system::all_library_reference();
|
||||
return ED_assetlist_is_loaded(&all_library_ref);
|
||||
return asset::list::is_loaded(&all_library_ref);
|
||||
}
|
||||
|
||||
static asset::AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree &node_tree)
|
||||
|
@ -194,7 +194,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
|
|||
asset::operator_asset_reference_props_set(*asset, op_ptr);
|
||||
}
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -270,7 +270,7 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
|
|||
|
||||
const Set<StringRef> all_builtin_menus = get_builtin_menus(edit_tree->type);
|
||||
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
@ -295,7 +295,7 @@ MenuType add_catalog_assets_menu_type()
|
|||
STRNCPY(type.idname, "NODE_MT_node_add_catalog_assets");
|
||||
type.poll = node_add_menu_poll;
|
||||
type.draw = node_add_catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ MenuType add_unassigned_assets_menu_type()
|
|||
STRNCPY(type.idname, "NODE_MT_node_add_unassigned_assets");
|
||||
type.poll = node_add_menu_poll;
|
||||
type.draw = node_add_unassigned_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
type.description = N_(
|
||||
"Node group assets not assigned to a catalog.\n"
|
||||
|
@ -320,7 +320,7 @@ MenuType add_root_catalogs_menu_type()
|
|||
STRNCPY(type.idname, "NODE_MT_node_add_root_catalogs");
|
||||
type.poll = node_add_menu_poll;
|
||||
type.draw = add_root_catalogs_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.listener = asset::list::asset_reading_region_listen_fn;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ void ui_template_node_asset_menu_items(uiLayout &layout,
|
|||
if (!item) {
|
||||
return;
|
||||
}
|
||||
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
|
||||
asset_system::AssetLibrary *all_library = asset::list::library_get_once_available(
|
||||
asset_system::all_library_reference());
|
||||
if (!all_library) {
|
||||
return;
|
||||
|
|
|
@ -238,9 +238,9 @@ static void gather_search_link_ops_for_asset_library(const bContext &C,
|
|||
AssetFilterSettings filter_settings{};
|
||||
filter_settings.id_types = FILTER_ID_NT;
|
||||
|
||||
ED_assetlist_storage_fetch(&library_ref, &C);
|
||||
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
|
||||
asset::list::storage_fetch(&library_ref, &C);
|
||||
asset::list::iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
|
||||
if (!asset::filter_matches_asset(&filter_settings, asset)) {
|
||||
return true;
|
||||
}
|
||||
if (skip_local && asset.is_local_id()) {
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "BKE_viewer_path.hh"
|
||||
#include "BKE_workspace.h"
|
||||
|
||||
#include "ED_asset_shelf.h"
|
||||
#include "ED_asset_shelf.hh"
|
||||
#include "ED_geometry.hh"
|
||||
#include "ED_object.hh"
|
||||
#include "ED_outliner.hh"
|
||||
|
@ -1937,11 +1937,12 @@ static void view3d_tools_header_region_draw(const bContext *C, ARegion *region)
|
|||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void view3d_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
wmKeyMap *keymap = WM_keymap_ensure(
|
||||
wm->defaultconf, "3D View Generic", SPACE_VIEW3D, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler(®ion->handlers, keymap);
|
||||
|
||||
ED_asset_shelf_region_init(wm, region);
|
||||
asset::shelf::region_init(wm, region);
|
||||
}
|
||||
|
||||
/* area (not region) level listener */
|
||||
|
@ -2104,6 +2105,7 @@ static void view3d_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
|||
|
||||
void ED_spacetype_view3d()
|
||||
{
|
||||
using namespace blender::ed;
|
||||
SpaceType *st = MEM_cnew<SpaceType>("spacetype view3d");
|
||||
ARegionType *art;
|
||||
|
||||
|
@ -2196,29 +2198,29 @@ void ED_spacetype_view3d()
|
|||
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf region");
|
||||
art->regionid = RGN_TYPE_ASSET_SHELF;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES;
|
||||
art->duplicate = ED_asset_shelf_region_duplicate;
|
||||
art->free = ED_asset_shelf_region_free;
|
||||
art->listener = ED_asset_shelf_region_listen;
|
||||
art->poll = ED_asset_shelf_regions_poll;
|
||||
art->snap_size = ED_asset_shelf_region_snap;
|
||||
art->on_user_resize = ED_asset_shelf_region_on_user_resize;
|
||||
art->context = ED_asset_shelf_context;
|
||||
art->duplicate = asset::shelf::region_duplicate;
|
||||
art->free = asset::shelf::region_free;
|
||||
art->listener = asset::shelf::region_listen;
|
||||
art->poll = asset::shelf::regions_poll;
|
||||
art->snap_size = asset::shelf::region_snap;
|
||||
art->on_user_resize = asset::shelf::region_on_user_resize;
|
||||
art->context = asset::shelf::context;
|
||||
art->init = view3d_asset_shelf_region_init;
|
||||
art->layout = ED_asset_shelf_region_layout;
|
||||
art->draw = ED_asset_shelf_region_draw;
|
||||
art->layout = asset::shelf::region_layout;
|
||||
art->draw = asset::shelf::region_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: asset shelf header */
|
||||
art = MEM_cnew<ARegionType>("spacetype view3d asset shelf header region");
|
||||
art->regionid = RGN_TYPE_ASSET_SHELF_HEADER;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
||||
art->init = ED_asset_shelf_header_region_init;
|
||||
art->poll = ED_asset_shelf_regions_poll;
|
||||
art->draw = ED_asset_shelf_header_region;
|
||||
art->listener = ED_asset_shelf_header_region_listen;
|
||||
art->context = ED_asset_shelf_context;
|
||||
art->init = asset::shelf::header_region_init;
|
||||
art->poll = asset::shelf::regions_poll;
|
||||
art->draw = asset::shelf::header_region;
|
||||
art->listener = asset::shelf::header_region_listen;
|
||||
art->context = asset::shelf::context;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
ED_asset_shelf_header_regiontype_register(art, SPACE_VIEW3D);
|
||||
asset::shelf::header_regiontype_register(art, SPACE_VIEW3D);
|
||||
|
||||
/* regions: hud */
|
||||
art = ED_area_type_hud(st->spaceid);
|
||||
|
|
|
@ -205,6 +205,7 @@ static void ed_undo_step_post(bContext *C,
|
|||
const enum eUndoStepDir undo_dir,
|
||||
ReportList *reports)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
|
||||
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
@ -249,7 +250,7 @@ static void ed_undo_step_post(bContext *C,
|
|||
WM_toolsystem_refresh_active(C);
|
||||
WM_toolsystem_refresh_screen_all(bmain);
|
||||
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
asset::list::storage_tag_main_data_dirty();
|
||||
|
||||
if (CLOG_CHECK(&LOG, 1)) {
|
||||
BKE_undosys_print(wm->undo_stack);
|
||||
|
|
|
@ -75,6 +75,7 @@ void ED_editors_init_for_undo(Main *bmain)
|
|||
|
||||
void ED_editors_init(bContext *C)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -205,7 +206,7 @@ void ED_editors_init(bContext *C)
|
|||
}
|
||||
}
|
||||
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
asset::list::storage_tag_main_data_dirty();
|
||||
|
||||
SWAP(int, reports->flag, reports_flag_prev);
|
||||
wm->op_undo_depth--;
|
||||
|
|
|
@ -156,6 +156,7 @@ static bool lib_id_generate_preview_poll(bContext *C)
|
|||
|
||||
static int lib_id_generate_preview_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
PointerRNA idptr = CTX_data_pointer_get(C, "id");
|
||||
ID *id = (ID *)idptr.data;
|
||||
|
||||
|
@ -169,7 +170,7 @@ static int lib_id_generate_preview_exec(bContext *C, wmOperator * /*op*/)
|
|||
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
|
||||
|
||||
WM_event_add_notifier(C, NC_ASSET | NA_EDITED, nullptr);
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
asset::list::storage_tag_main_data_dirty();
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -201,6 +202,7 @@ static bool lib_id_generate_preview_from_object_poll(bContext *C)
|
|||
|
||||
static int lib_id_generate_preview_from_object_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
using namespace blender::ed;
|
||||
PointerRNA idptr = CTX_data_pointer_get(C, "id");
|
||||
ID *id = (ID *)idptr.data;
|
||||
|
||||
|
@ -213,7 +215,7 @@ static int lib_id_generate_preview_from_object_exec(bContext *C, wmOperator * /*
|
|||
UI_icon_render_id_ex(C, nullptr, &object_to_render->id, ICON_SIZE_PREVIEW, true, preview_image);
|
||||
|
||||
WM_event_add_notifier(C, NC_ASSET | NA_EDITED, nullptr);
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
asset::list::storage_tag_main_data_dirty();
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -198,9 +198,9 @@ typedef struct AssetWeakReference {
|
|||
* into a type with PropertyGroup as base, so we can have an RNA collection of #AssetHandle's to
|
||||
* pass to the UI.
|
||||
*
|
||||
* \warning Never store this! When using #ED_assetlist_iterate(), only access it within the
|
||||
* iterator function. The contained file data can be freed since the file cache has a
|
||||
* maximum number of items.
|
||||
* \warning Never store this! When using #blender::ed::asset::list::iterate(), only access it
|
||||
* within the iterator function. The contained file data can be freed since the file cache has a
|
||||
* maximum number of items.
|
||||
*/
|
||||
#
|
||||
#
|
||||
|
|
|
@ -700,7 +700,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
|
|||
|
||||
static void rna_ID_asset_mark(ID *id)
|
||||
{
|
||||
if (ED_asset_mark_id(id)) {
|
||||
if (blender::ed::asset::mark_id(id)) {
|
||||
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
|
||||
WM_main_add_notifier(NC_ASSET | NA_ADDED, nullptr);
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ static void rna_ID_asset_mark(ID *id)
|
|||
|
||||
static void rna_ID_asset_generate_preview(ID *id, bContext *C)
|
||||
{
|
||||
ED_asset_generate_preview(C, id);
|
||||
blender::ed::asset::generate_preview(C, id);
|
||||
|
||||
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
|
||||
WM_main_add_notifier(NC_ASSET | NA_EDITED, nullptr);
|
||||
|
@ -716,7 +716,7 @@ static void rna_ID_asset_generate_preview(ID *id, bContext *C)
|
|||
|
||||
static void rna_ID_asset_clear(ID *id)
|
||||
{
|
||||
if (ED_asset_clear_id(id)) {
|
||||
if (blender::ed::asset::clear_id(id)) {
|
||||
WM_main_add_notifier(NC_ID | NA_EDITED, nullptr);
|
||||
WM_main_add_notifier(NC_ASSET | NA_REMOVED, nullptr);
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ static void rna_ID_asset_data_set(PointerRNA *ptr, PointerRNA value, ReportList
|
|||
return;
|
||||
}
|
||||
|
||||
const bool assigned_ok = ED_asset_copy_to_id(asset_data, destination);
|
||||
const bool assigned_ok = blender::ed::asset::copy_to_id(asset_data, destination);
|
||||
if (!assigned_ok) {
|
||||
BKE_reportf(
|
||||
reports, RPT_ERROR, "'%s' is of a type that cannot be an asset", destination->name + 2);
|
||||
|
|
|
@ -43,7 +43,7 @@ const EnumPropertyItem rna_enum_asset_library_type_items[] = {
|
|||
|
||||
# include <algorithm>
|
||||
|
||||
# include "AS_asset_library.h"
|
||||
# include "AS_asset_library.hh"
|
||||
# include "AS_asset_representation.hh"
|
||||
|
||||
# include "BKE_asset.hh"
|
||||
|
@ -355,7 +355,8 @@ void rna_AssetMetaData_catalog_id_update(bContext *C, PointerRNA *ptr)
|
|||
return;
|
||||
}
|
||||
|
||||
::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile);
|
||||
blender::asset_system::AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(
|
||||
sfile);
|
||||
if (asset_library == nullptr) {
|
||||
/* The SpaceFile may not be an asset browser but a regular file browser. */
|
||||
return;
|
||||
|
@ -458,7 +459,7 @@ const EnumPropertyItem *rna_asset_library_reference_itemf(bContext * /*C*/,
|
|||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(true);
|
||||
const EnumPropertyItem *items = blender::ed::asset::library_reference_to_rna_enum_itemf(true);
|
||||
if (!items) {
|
||||
*r_free = false;
|
||||
}
|
||||
|
|
|
@ -901,7 +901,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
|||
PropertyRNA * /*prop*/,
|
||||
bool * /*r_free*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
/* sculpt mode */
|
||||
static const EnumPropertyItem prop_flatten_contrast_items[] = {
|
||||
|
@ -944,7 +944,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
|||
Brush *me = (Brush *)(ptr->data);
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PaintMode::Sculpt:
|
||||
switch (me->sculpt_tool) {
|
||||
case SCULPT_TOOL_DRAW:
|
||||
case SCULPT_TOOL_DRAW_SHARP:
|
||||
|
@ -987,8 +987,8 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
|||
return rna_enum_dummy_DEFAULT_items;
|
||||
}
|
||||
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
switch (me->imagepaint_tool) {
|
||||
case PAINT_TOOL_SOFTEN:
|
||||
return prop_soften_sharpen_items;
|
||||
|
@ -996,7 +996,7 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C,
|
|||
default:
|
||||
return rna_enum_dummy_DEFAULT_items;
|
||||
}
|
||||
case PAINT_MODE_SCULPT_CURVES:
|
||||
case PaintMode::SculptCurves:
|
||||
switch (me->curves_sculpt_tool) {
|
||||
case CURVES_SCULPT_TOOL_GROW_SHRINK:
|
||||
case CURVES_SCULPT_TOOL_SELECTION_PAINT:
|
||||
|
@ -1015,7 +1015,7 @@ static const EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C,
|
|||
PropertyRNA * /*prop*/,
|
||||
bool * /*r_free*/)
|
||||
{
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
|
||||
static const EnumPropertyItem brush_stroke_method_items[] = {
|
||||
{0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
|
||||
|
@ -1039,9 +1039,9 @@ static const EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C,
|
|||
};
|
||||
|
||||
switch (mode) {
|
||||
case PAINT_MODE_SCULPT:
|
||||
case PAINT_MODE_TEXTURE_2D:
|
||||
case PAINT_MODE_TEXTURE_3D:
|
||||
case PaintMode::Sculpt:
|
||||
case PaintMode::Texture2D:
|
||||
case PaintMode::Texture3D:
|
||||
return sculpt_stroke_method_items;
|
||||
|
||||
default:
|
||||
|
@ -1175,8 +1175,8 @@ static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C,
|
|||
# define rna_enum_brush_texture_slot_map_sculpt_mode_items \
|
||||
rna_enum_brush_texture_slot_map_all_mode_items;
|
||||
|
||||
const ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
if (mode == PAINT_MODE_SCULPT) {
|
||||
const PaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
if (mode == PaintMode::Sculpt) {
|
||||
return rna_enum_brush_texture_slot_map_sculpt_mode_items;
|
||||
}
|
||||
return rna_enum_brush_texture_slot_map_texture_mode_items;
|
||||
|
|
|
@ -240,6 +240,8 @@ bool rna_AnimaData_override_apply(struct Main *bmain,
|
|||
void rna_def_animviz_common(struct StructRNA *srna);
|
||||
void rna_def_motionpath_common(struct StructRNA *srna);
|
||||
|
||||
void api_ui_item_common_translation(FunctionRNA *func);
|
||||
|
||||
/**
|
||||
* Settings for curved bbone settings.
|
||||
*/
|
||||
|
|
|
@ -2822,13 +2822,13 @@ static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr)
|
|||
/* Just an extra sanity check to ensure this isn't somehow called for RNA_FileSelectParams. */
|
||||
BLI_assert(ptr->type == &RNA_FileAssetSelectParams);
|
||||
|
||||
return ED_asset_library_reference_to_enum_value(¶ms->asset_library_ref);
|
||||
return blender::ed::asset::library_reference_to_enum_value(¶ms->asset_library_ref);
|
||||
}
|
||||
|
||||
static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
FileAssetSelectParams *params = static_cast<FileAssetSelectParams *>(ptr->data);
|
||||
params->asset_library_ref = ED_asset_library_reference_from_enum_value(value);
|
||||
params->asset_library_ref = blender::ed::asset::library_reference_from_enum_value(value);
|
||||
}
|
||||
|
||||
static PointerRNA rna_FileAssetSelectParams_filter_id_get(PointerRNA *ptr)
|
||||
|
|
|
@ -66,8 +66,8 @@ const EnumPropertyItem rna_enum_uilist_layout_type_items[] = {
|
|||
# include "BKE_report.h"
|
||||
# include "BKE_screen.hh"
|
||||
|
||||
# include "ED_asset_library.h"
|
||||
# include "ED_asset_shelf.h"
|
||||
# include "ED_asset_library.hh"
|
||||
# include "ED_asset_shelf.hh"
|
||||
|
||||
# include "WM_api.hh"
|
||||
|
||||
|
@ -1180,7 +1180,7 @@ static bool rna_AssetShelf_unregister(Main *bmain, StructRNA *type)
|
|||
return false;
|
||||
}
|
||||
|
||||
ED_asset_shelf_type_unlink(*bmain, *shelf_type);
|
||||
blender::ed::asset::shelf::type_unlink(*bmain, *shelf_type);
|
||||
|
||||
RNA_struct_free_extension(type, &shelf_type->rna_ext);
|
||||
RNA_struct_free(&BLENDER_RNA, type);
|
||||
|
@ -1284,13 +1284,15 @@ static StructRNA *rna_AssetShelf_refine(PointerRNA *shelf_ptr)
|
|||
static int rna_AssetShelf_asset_library_get(PointerRNA *ptr)
|
||||
{
|
||||
AssetShelf *shelf = static_cast<AssetShelf *>(ptr->data);
|
||||
return ED_asset_library_reference_to_enum_value(&shelf->settings.asset_library_reference);
|
||||
return blender::ed::asset::library_reference_to_enum_value(
|
||||
&shelf->settings.asset_library_reference);
|
||||
}
|
||||
|
||||
static void rna_AssetShelf_asset_library_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
AssetShelf *shelf = static_cast<AssetShelf *>(ptr->data);
|
||||
shelf->settings.asset_library_reference = ED_asset_library_reference_from_enum_value(value);
|
||||
shelf->settings.asset_library_reference = blender::ed::asset::library_reference_from_enum_value(
|
||||
value);
|
||||
}
|
||||
|
||||
static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue