Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-09-29 16:01:36 +0300
committerJulian Eisel <julian@blender.org>2021-09-29 16:02:38 +0300
commitef29bf9023f54667db7a0c2898d12a3bce0873ed (patch)
tree91a5dfcd0cc0d46b33dae9e3a6b674dd08f7b877 /source
parent5cebcb415e76aaff74bc03c66414aa93b5c90e70 (diff)
Assets: Expose option to reuse data-block data when appending
With 794c2828af60 & f48a4aa0f915 it's possible to reuse possibly expensive, nested data of a data-block when appending. E.g. the texture of a material, or the mesh of an object. Without this it's easy to bloat memory and the file size. Duplicated textures also cause unnecessary shader recompilations. The feature was intended to be the new default behavior for the Asset Browser, but it wasn't actually added to the UI yet. This patch adds a new import type option to the Asset Browser. So from the menu in the header, you can now choose between: * Link * Append * Append (Reuse Data) The latter is the new default. Maniphest Task: https://developer.blender.org/T91741 Differential Revision: https://developer.blender.org/D12647 Reviewed by: Sybren Stüvel, Bastien Montagne
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/versioning_300.c5
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/makesdna/DNA_space_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_space.c8
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c10
5 files changed, 30 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 8b8b7218c0e..e65fd3e6754 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1554,6 +1554,11 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
sfile->params->flag &= ~(FILE_PARAMS_FLAG_UNUSED_1 | FILE_PARAMS_FLAG_UNUSED_2 |
FILE_PARAMS_FLAG_UNUSED_3 | FILE_PARAMS_FLAG_UNUSED_4);
}
+
+ /* New default import type: Append with reuse. */
+ if (sfile->asset_params) {
+ sfile->asset_params->import_type = FILE_ASSET_IMPORT_APPEND_REUSE;
+ }
break;
}
default:
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index a741f2582ee..2ca08a3105c 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -120,7 +120,7 @@ static void fileselect_ensure_updated_asset_params(SpaceFile *sfile)
asset_params->base_params.details_flags = U_default.file_space_data.details_flags;
asset_params->asset_library_ref.type = ASSET_LIBRARY_LOCAL;
asset_params->asset_library_ref.custom_library_index = -1;
- asset_params->import_type = FILE_ASSET_IMPORT_APPEND;
+ asset_params->import_type = FILE_ASSET_IMPORT_APPEND_REUSE;
}
FileSelectParams *base_params = &asset_params->base_params;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index a7fcf2cfb89..2f3f52a6b82 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -812,8 +812,14 @@ typedef struct FileAssetSelectParams {
} FileAssetSelectParams;
typedef enum eFileAssetImportType {
+ /** Regular data-block linking. */
FILE_ASSET_IMPORT_LINK = 0,
+ /** Regular data-block appending (basically linking + "Make Local"). */
FILE_ASSET_IMPORT_APPEND = 1,
+ /** Append data-block with the #BLO_LIBLINK_APPEND_LOCAL_ID_REUSE flag enabled. Some typically
+ * heavy data dependencies (e.g. the image data-blocks of a material, the mesh of an object) may
+ * be reused from an earlier append. */
+ FILE_ASSET_IMPORT_APPEND_REUSE = 2,
} eFileAssetImportType;
/**
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index a4f79696276..9e06533d41b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -6643,6 +6643,14 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
0,
"Append",
"Import the assets as copied data-block, with no link to the original asset data-block"},
+ {FILE_ASSET_IMPORT_APPEND_REUSE,
+ "APPEND_REUSE",
+ 0,
+ "Append (Reuse Data)",
+ "Import the assets as copied data-block while avoiding multiple copies of nested, "
+ "typically heavy data. For example the textures of a material asset, or the mesh of an "
+ "object asset, don't have to be copied every time this asset is imported. The instances of "
+ "the asset share the data instead"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index f3a57b72095..93038b5709c 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -398,6 +398,16 @@ static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag)
case FILE_ASSET_IMPORT_APPEND:
return WM_file_append_datablock(
G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name, BLO_LIBLINK_APPEND_RECURSIVE);
+ case FILE_ASSET_IMPORT_APPEND_REUSE:
+ return WM_file_append_datablock(G_MAIN,
+ NULL,
+ NULL,
+ NULL,
+ asset_drag->path,
+ idtype,
+ name,
+ BLO_LIBLINK_APPEND_RECURSIVE |
+ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE);
}
BLI_assert_unreachable();