Commit: a01fcfcc6aa684f075faee9a5cde13ece0ace381
Author: Julian Eisel
Date: Fri Aug 28 16:00:14 2020 +0200
Branches: asset-metadata
https://developer.blender.org/rBa01fcfcc6aa684f075faee9a5cde13ece0ace381
Keep assets local to the file, don't copy them
Previously my idea was that when creating an asset for the user
repository, we'd always create a deep copy of the data-block for storage
in the repository.
However for the initial design, we decided to not let Blender
automatically save things into a repository. The user has to mark a
data-block as asset and save the file, so the asset is stored as part of
that file. By adding a path to the Preferences, all .blend files in that
path become part of a repository and users can then access their assets
in different projects through the Asset Browser (not done yet).
Because of this, the operator is now called "Make Asset" again, not
"Create Asset". We don't create a new asset, we just add asset data to
an existing data-block.
===================================================================
M source/blender/editors/asset/asset_ops.c
M source/blender/editors/space_outliner/outliner_tools.c
===================================================================
diff --git a/source/blender/editors/asset/asset_ops.c
b/source/blender/editors/asset/asset_ops.c
index dee23e3f30d..52515d1ea6a 100644
--- a/source/blender/editors/asset/asset_ops.c
+++ b/source/blender/editors/asset/asset_ops.c
@@ -36,7 +36,7 @@
#include "WM_api.h"
#include "WM_types.h"
-static int asset_create_exec(bContext *C, wmOperator *op)
+static int asset_make_exec(bContext *C, wmOperator *op)
{
PointerRNA idptr = RNA_pointer_get(op->ptr, "id");
ID *id = idptr.data;
@@ -50,43 +50,30 @@ static int asset_create_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- struct Main *bmain = CTX_data_main(C);
- ID *copied_id = NULL;
+ /* TODO this should probably be somewhere in BKE and/or ED. */
- /* TODO this should probably be somewhere in BKE. */
- /* TODO this is not a deep copy... */
- if (!BKE_id_copy(bmain, id, &copied_id)) {
- BKE_reportf(op->reports,
- RPT_ERROR,
- "Data-block '%s' could not be copied into an asset data-block",
- id->name);
- return OPERATOR_CANCELLED;
- }
- id_fake_user_set(copied_id);
+ id_fake_user_set(id);
- copied_id->asset_data = BKE_asset_data_create();
+ id->asset_data = BKE_asset_data_create();
- UI_id_icon_render(C, NULL, copied_id, true, false);
+ UI_id_icon_render(C, NULL, id, true, false);
/* Store reference to the ID's preview. */
- copied_id->asset_data->preview = BKE_previewimg_id_get(copied_id);
-
- /* TODO generate more default meta-data */
- /* TODO create asset in the asset DB, not in the local file. */
+ id->asset_data->preview = BKE_previewimg_id_get(id);
- BKE_reportf(op->reports, RPT_INFO, "Asset '%s' created", copied_id->name +
2);
+ BKE_reportf(op->reports, RPT_INFO, "Data-block '%s' is now an asset",
id->name + 2);
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
-static void ASSET_OT_create(wmOperatorType *ot)
+static void ASSET_OT_make(wmOperatorType *ot)
{
- ot->name = "Create Asset";
+ ot->name = "Make Asset";
ot->description = "Enable asset management for a data-block";
- ot->idname = "ASSET_OT_create";
+ ot->idname = "ASSET_OT_make";
- ot->exec = asset_create_exec;
+ ot->exec = asset_make_exec;
RNA_def_pointer_runtime(
ot->srna, "id", &RNA_ID, "Data-block", "Data-block to enable asset
management for");
@@ -96,5 +83,5 @@ static void ASSET_OT_create(wmOperatorType *ot)
void ED_operatortypes_asset(void)
{
- WM_operatortype_append(ASSET_OT_create);
+ WM_operatortype_append(ASSET_OT_make);
}
diff --git a/source/blender/editors/space_outliner/outliner_tools.c
b/source/blender/editors/space_outliner/outliner_tools.c
index 20a5476ea6d..b6f1a79f1e9 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -735,9 +735,9 @@ static void id_make_asset_cb(bContext *C,
RNA_id_pointer_create(id, &id_ptr);
- WM_operator_properties_create(&op_ptr, "ASSET_OT_create");
+ WM_operator_properties_create(&op_ptr, "ASSET_OT_make");
RNA_pointer_set(&op_ptr, "id", id_ptr);
- WM_operator_name_call(C, "ASSET_OT_create", WM_OP_EXEC_DEFAULT, &op_ptr);
+ WM_operator_name_call(C, "ASSET_OT_make", WM_OP_EXEC_DEFAULT, &op_ptr);
WM_operator_properties_free(&op_ptr);
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs