forked from blender/blender
WIP: uv-simple-select #1
@ -67,6 +67,9 @@ class AssetLibrary {
|
|||||||
|
|
||||||
std::unique_ptr<AssetCatalogService> catalog_service;
|
std::unique_ptr<AssetCatalogService> catalog_service;
|
||||||
|
|
||||||
|
/** Assets owned by this library should never be linked. */
|
||||||
|
bool never_link = false;
|
||||||
|
|
||||||
friend class AssetLibraryService;
|
friend class AssetLibraryService;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -22,6 +22,8 @@ const char *AS_asset_representation_name_get(const AssetRepresentation *asset)
|
|||||||
AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset)
|
AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset)
|
||||||
ATTR_WARN_UNUSED_RESULT;
|
ATTR_WARN_UNUSED_RESULT;
|
||||||
bool AS_asset_representation_is_local_id(const AssetRepresentation *asset) ATTR_WARN_UNUSED_RESULT;
|
bool AS_asset_representation_is_local_id(const AssetRepresentation *asset) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
bool AS_asset_representation_is_never_link(const AssetRepresentation *asset)
|
||||||
|
ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
15
source/blender/asset_system/AS_essentials_library.hh
Normal file
15
source/blender/asset_system/AS_essentials_library.hh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup asset_system
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BLI_string_ref.hh"
|
||||||
|
|
||||||
|
namespace blender::asset_system {
|
||||||
|
|
||||||
|
StringRefNull essentials_directory_path();
|
||||||
|
|
||||||
|
}
|
@ -17,6 +17,7 @@ set(SRC
|
|||||||
intern/asset_catalog.cc
|
intern/asset_catalog.cc
|
||||||
intern/asset_catalog_path.cc
|
intern/asset_catalog_path.cc
|
||||||
intern/asset_catalog_tree.cc
|
intern/asset_catalog_tree.cc
|
||||||
|
intern/asset_essentials_library.cc
|
||||||
intern/asset_identifier.cc
|
intern/asset_identifier.cc
|
||||||
intern/asset_library.cc
|
intern/asset_library.cc
|
||||||
intern/asset_library_service.cc
|
intern/asset_library_service.cc
|
||||||
@ -30,6 +31,7 @@ set(SRC
|
|||||||
AS_asset_identifier.hh
|
AS_asset_identifier.hh
|
||||||
AS_asset_library.hh
|
AS_asset_library.hh
|
||||||
AS_asset_representation.hh
|
AS_asset_representation.hh
|
||||||
|
AS_essentials_library.hh
|
||||||
intern/asset_library_service.hh
|
intern/asset_library_service.hh
|
||||||
intern/asset_storage.hh
|
intern/asset_storage.hh
|
||||||
intern/utils.hh
|
intern/utils.hh
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup asset_system
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BLI_path_util.h"
|
||||||
|
|
||||||
|
#include "BKE_appdir.h"
|
||||||
|
|
||||||
|
#include "AS_essentials_library.hh"
|
||||||
|
|
||||||
|
namespace blender::asset_system {
|
||||||
|
|
||||||
|
StringRefNull essentials_directory_path()
|
||||||
|
{
|
||||||
|
static std::string path = []() {
|
||||||
|
const char *datafiles_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "assets");
|
||||||
|
return datafiles_path;
|
||||||
|
}();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::asset_system
|
@ -260,6 +260,12 @@ StringRefNull AssetLibrary::root_path() const
|
|||||||
Vector<AssetLibraryReference> all_valid_asset_library_refs()
|
Vector<AssetLibraryReference> all_valid_asset_library_refs()
|
||||||
{
|
{
|
||||||
Vector<AssetLibraryReference> result;
|
Vector<AssetLibraryReference> result;
|
||||||
|
{
|
||||||
|
AssetLibraryReference library_ref{};
|
||||||
|
library_ref.custom_library_index = -1;
|
||||||
|
library_ref.type = ASSET_LIBRARY_ESSENTIALS;
|
||||||
|
result.append(library_ref);
|
||||||
|
}
|
||||||
int i;
|
int i;
|
||||||
LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
|
LISTBASE_FOREACH_INDEX (const bUserAssetLibrary *, asset_library, &U.asset_libraries, i) {
|
||||||
if (!BLI_is_dir(asset_library->path)) {
|
if (!BLI_is_dir(asset_library->path)) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "AS_asset_catalog_tree.hh"
|
#include "AS_asset_catalog_tree.hh"
|
||||||
#include "AS_asset_library.hh"
|
#include "AS_asset_library.hh"
|
||||||
|
#include "AS_essentials_library.hh"
|
||||||
#include "asset_library_service.hh"
|
#include "asset_library_service.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
|
||||||
@ -60,6 +61,12 @@ AssetLibrary *AssetLibraryService::get_asset_library(
|
|||||||
const eAssetLibraryType type = eAssetLibraryType(library_reference.type);
|
const eAssetLibraryType type = eAssetLibraryType(library_reference.type);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case ASSET_LIBRARY_ESSENTIALS: {
|
||||||
|
const StringRefNull root_path = essentials_directory_path();
|
||||||
|
AssetLibrary *asset_library = get_asset_library_on_disk(root_path);
|
||||||
|
asset_library->never_link = true;
|
||||||
|
return asset_library;
|
||||||
|
}
|
||||||
case ASSET_LIBRARY_LOCAL: {
|
case ASSET_LIBRARY_LOCAL: {
|
||||||
/* For the "Current File" library we get the asset library root path based on main. */
|
/* For the "Current File" library we get the asset library root path based on main. */
|
||||||
std::string root_path = bmain ? AS_asset_library_find_suitable_root_path_from_main(bmain) :
|
std::string root_path = bmain ? AS_asset_library_find_suitable_root_path_from_main(bmain) :
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "DNA_asset_types.h"
|
#include "DNA_asset_types.h"
|
||||||
|
|
||||||
#include "AS_asset_identifier.hh"
|
#include "AS_asset_identifier.hh"
|
||||||
|
#include "AS_asset_library.hh"
|
||||||
#include "AS_asset_representation.h"
|
#include "AS_asset_representation.h"
|
||||||
#include "AS_asset_representation.hh"
|
#include "AS_asset_representation.hh"
|
||||||
|
|
||||||
@ -126,4 +127,11 @@ bool AS_asset_representation_is_local_id(const AssetRepresentation *asset_handle
|
|||||||
return asset->is_local_id();
|
return asset->is_local_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AS_asset_representation_is_never_link(const AssetRepresentation *asset_handle)
|
||||||
|
{
|
||||||
|
const asset_system::AssetRepresentation *asset =
|
||||||
|
reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle);
|
||||||
|
return asset->owner_asset_library().never_link;
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -47,7 +47,7 @@ AssetLibraryReference ED_asset_library_reference_from_enum_value(int value)
|
|||||||
if (value < ASSET_LIBRARY_CUSTOM) {
|
if (value < ASSET_LIBRARY_CUSTOM) {
|
||||||
library.type = value;
|
library.type = value;
|
||||||
library.custom_library_index = -1;
|
library.custom_library_index = -1;
|
||||||
BLI_assert(ELEM(value, ASSET_LIBRARY_ALL, ASSET_LIBRARY_LOCAL));
|
BLI_assert(ELEM(value, ASSET_LIBRARY_ALL, ASSET_LIBRARY_LOCAL, ASSET_LIBRARY_ESSENTIALS));
|
||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +87,11 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
|
|||||||
ICON_CURRENT_FILE,
|
ICON_CURRENT_FILE,
|
||||||
"Current File",
|
"Current File",
|
||||||
"Show the assets currently available in this Blender session"},
|
"Show the assets currently available in this Blender session"},
|
||||||
|
{ASSET_LIBRARY_ESSENTIALS,
|
||||||
|
"ESSENTIALS",
|
||||||
|
ICON_NONE,
|
||||||
|
"Essentials",
|
||||||
|
"Show the basic building blocks and utilities coming with Blender"},
|
||||||
{0, nullptr, 0, nullptr, nullptr},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -372,6 +372,7 @@ std::optional<eFileSelectType> AssetListStorage::asset_library_reference_to_file
|
|||||||
switch (eAssetLibraryType(library_reference.type)) {
|
switch (eAssetLibraryType(library_reference.type)) {
|
||||||
case ASSET_LIBRARY_ALL:
|
case ASSET_LIBRARY_ALL:
|
||||||
return FILE_ASSET_LIBRARY_ALL;
|
return FILE_ASSET_LIBRARY_ALL;
|
||||||
|
case ASSET_LIBRARY_ESSENTIALS:
|
||||||
case ASSET_LIBRARY_CUSTOM:
|
case ASSET_LIBRARY_CUSTOM:
|
||||||
return FILE_ASSET_LIBRARY;
|
return FILE_ASSET_LIBRARY;
|
||||||
case ASSET_LIBRARY_LOCAL:
|
case ASSET_LIBRARY_LOCAL:
|
||||||
|
@ -55,6 +55,8 @@
|
|||||||
#include "GPU_immediate_util.h"
|
#include "GPU_immediate_util.h"
|
||||||
#include "GPU_state.h"
|
#include "GPU_state.h"
|
||||||
|
|
||||||
|
#include "AS_asset_representation.h"
|
||||||
|
|
||||||
#include "filelist.h"
|
#include "filelist.h"
|
||||||
|
|
||||||
#include "file_intern.h" /* own include */
|
#include "file_intern.h" /* own include */
|
||||||
@ -126,6 +128,19 @@ static void draw_tile_background(const rcti *draw_rect, int colorid, int shade)
|
|||||||
UI_draw_roundbox_aa(&draw_rect_fl, true, 5.0f, color);
|
UI_draw_roundbox_aa(&draw_rect_fl, true, 5.0f, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static eFileAssetImportType get_asset_import_type(const SpaceFile *sfile, const FileDirEntry *file)
|
||||||
|
{
|
||||||
|
const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile);
|
||||||
|
BLI_assert(asset_params != NULL);
|
||||||
|
if (asset_params->import_type != FILE_ASSET_IMPORT_LINK) {
|
||||||
|
return asset_params->import_type;
|
||||||
|
}
|
||||||
|
if (AS_asset_representation_is_never_link(file->asset)) {
|
||||||
|
return FILE_ASSET_IMPORT_APPEND_REUSE;
|
||||||
|
}
|
||||||
|
return FILE_ASSET_IMPORT_LINK;
|
||||||
|
}
|
||||||
|
|
||||||
static void file_draw_icon(const SpaceFile *sfile,
|
static void file_draw_icon(const SpaceFile *sfile,
|
||||||
uiBlock *block,
|
uiBlock *block,
|
||||||
const FileDirEntry *file,
|
const FileDirEntry *file,
|
||||||
@ -165,13 +180,10 @@ static void file_draw_icon(const SpaceFile *sfile,
|
|||||||
ImBuf *preview_image = filelist_file_getimage(file);
|
ImBuf *preview_image = filelist_file_getimage(file);
|
||||||
char blend_path[FILE_MAX_LIBEXTRA];
|
char blend_path[FILE_MAX_LIBEXTRA];
|
||||||
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
|
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
|
||||||
const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile);
|
|
||||||
BLI_assert(asset_params != NULL);
|
|
||||||
|
|
||||||
UI_but_drag_set_asset(but,
|
UI_but_drag_set_asset(but,
|
||||||
&(AssetHandle){.file_data = file},
|
&(AssetHandle){.file_data = file},
|
||||||
BLI_strdup(blend_path),
|
BLI_strdup(blend_path),
|
||||||
asset_params->import_type,
|
get_asset_import_type(sfile, file),
|
||||||
icon,
|
icon,
|
||||||
preview_image,
|
preview_image,
|
||||||
UI_DPI_FAC);
|
UI_DPI_FAC);
|
||||||
@ -558,13 +570,10 @@ static void file_draw_preview(const SpaceFile *sfile,
|
|||||||
char blend_path[FILE_MAX_LIBEXTRA];
|
char blend_path[FILE_MAX_LIBEXTRA];
|
||||||
|
|
||||||
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
|
if (BLO_library_path_explode(path, blend_path, NULL, NULL)) {
|
||||||
const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile);
|
|
||||||
BLI_assert(asset_params != NULL);
|
|
||||||
|
|
||||||
UI_but_drag_set_asset(but,
|
UI_but_drag_set_asset(but,
|
||||||
&(AssetHandle){.file_data = file},
|
&(AssetHandle){.file_data = file},
|
||||||
BLI_strdup(blend_path),
|
BLI_strdup(blend_path),
|
||||||
asset_params->import_type,
|
get_asset_import_type(sfile, file),
|
||||||
icon,
|
icon,
|
||||||
imb,
|
imb,
|
||||||
scale);
|
scale);
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
#include "UI_interface_icons.h"
|
#include "UI_interface_icons.h"
|
||||||
#include "UI_view2d.h"
|
#include "UI_view2d.h"
|
||||||
|
|
||||||
|
#include "AS_essentials_library.hh"
|
||||||
|
|
||||||
#include "file_intern.h"
|
#include "file_intern.h"
|
||||||
#include "filelist.h"
|
#include "filelist.h"
|
||||||
|
|
||||||
@ -424,7 +426,13 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (library->type) {
|
switch (eAssetLibraryType(library->type)) {
|
||||||
|
case ASSET_LIBRARY_ESSENTIALS:
|
||||||
|
BLI_strncpy(base_params->dir,
|
||||||
|
blender::asset_system::essentials_directory_path().c_str(),
|
||||||
|
sizeof(base_params->dir));
|
||||||
|
base_params->type = FILE_ASSET_LIBRARY;
|
||||||
|
break;
|
||||||
case ASSET_LIBRARY_ALL:
|
case ASSET_LIBRARY_ALL:
|
||||||
base_params->dir[0] = '\0';
|
base_params->dir[0] = '\0';
|
||||||
base_params->type = FILE_ASSET_LIBRARY_ALL;
|
base_params->type = FILE_ASSET_LIBRARY_ALL;
|
||||||
|
@ -85,11 +85,11 @@ typedef struct AssetMetaData {
|
|||||||
} AssetMetaData;
|
} AssetMetaData;
|
||||||
|
|
||||||
typedef enum eAssetLibraryType {
|
typedef enum eAssetLibraryType {
|
||||||
/* For the future. Display assets bundled with Blender by default. */
|
|
||||||
// ASSET_LIBRARY_BUNDLED = 0,
|
|
||||||
/** Display assets from the current session (current "Main"). */
|
/** Display assets from the current session (current "Main"). */
|
||||||
ASSET_LIBRARY_LOCAL = 1,
|
ASSET_LIBRARY_LOCAL = 1,
|
||||||
ASSET_LIBRARY_ALL = 2,
|
ASSET_LIBRARY_ALL = 2,
|
||||||
|
/** Display assets bundled with Blender by default. */
|
||||||
|
ASSET_LIBRARY_ESSENTIALS = 3,
|
||||||
|
|
||||||
/** Display assets from custom asset libraries, as defined in the preferences
|
/** Display assets from custom asset libraries, as defined in the preferences
|
||||||
* (#bUserAssetLibrary). The name will be taken from #FileSelectParams.asset_library_ref.idname
|
* (#bUserAssetLibrary). The name will be taken from #FileSelectParams.asset_library_ref.idname
|
||||||
|
@ -1481,6 +1481,20 @@ install(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Bundle assets
|
||||||
|
|
||||||
|
set(ASSET_BUNDLE_DIR ${CMAKE_SOURCE_DIR}/../lib/assets/publish/)
|
||||||
|
|
||||||
|
if(EXISTS "${ASSET_BUNDLE_DIR}")
|
||||||
|
install(
|
||||||
|
DIRECTORY ${ASSET_BUNDLE_DIR}
|
||||||
|
DESTINATION ${TARGETDIR_VER}/datafiles/assets
|
||||||
|
PATTERN ".svn" EXCLUDE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Setup link libraries
|
# Setup link libraries
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user