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
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-09-23 11:47:27 +0300
committerBastien Montagne <bastien@blender.org>2020-09-23 12:07:03 +0300
commitc3a0618fbffffffcf5abbeed8de3f19d8a401db1 (patch)
treef3e607810277449efa988354c815260b7938e413 /source/blender/editors/space_outliner/outliner_tools.c
parent6fde0050c45af994d7f0de16622037bf28c938c8 (diff)
LibOverride: Add operator to convert a proxy object into an override.
In the end the process is surpringly simple, we only need to manually convert the proxy itself into an override (which is trivial), and then run common code with the default 'make override' operation. Fix T81059: Add operator to convert proxies to library overrides.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tools.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 8fe4c364aa6..eb2969aa15d 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -737,6 +737,31 @@ static void id_local_fn(bContext *C,
}
}
+static void object_proxy_to_override_convert_fn(bContext *C,
+ ReportList *UNUSED(reports),
+ Scene *UNUSED(scene),
+ TreeElement *UNUSED(te),
+ TreeStoreElem *UNUSED(tsep),
+ TreeStoreElem *tselem,
+ void *UNUSED(user_data))
+{
+ BLI_assert(TSE_IS_REAL_ID(tselem));
+ ID *id_proxy = tselem->id;
+ BLI_assert(GS(id_proxy->name) == ID_OB);
+ Object *ob_proxy = (Object *)id_proxy;
+ Scene *scene = CTX_data_scene(C);
+
+ if (ob_proxy->proxy == NULL) {
+ return;
+ }
+
+ BKE_lib_override_library_proxy_convert(
+ CTX_data_main(C), scene, CTX_data_view_layer(C), ob_proxy);
+
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+}
+
typedef struct OutlinerLibOverrideData {
bool do_hierarchy;
} OutlinerLibOverrideData;
@@ -1404,6 +1429,7 @@ enum {
OL_OP_RENAME,
OL_OP_OBJECT_MODE_ENTER,
OL_OP_OBJECT_MODE_EXIT,
+ OL_OP_PROXY_TO_OVERRIDE_CONVERT,
};
static const EnumPropertyItem prop_object_op_types[] = {
@@ -1418,6 +1444,11 @@ static const EnumPropertyItem prop_object_op_types[] = {
{OL_OP_RENAME, "RENAME", 0, "Rename", ""},
{OL_OP_OBJECT_MODE_ENTER, "OBJECT_MODE_ENTER", 0, "Enter Mode", ""},
{OL_OP_OBJECT_MODE_EXIT, "OBJECT_MODE_EXIT", 0, "Exit Mode", ""},
+ {OL_OP_PROXY_TO_OVERRIDE_CONVERT,
+ "OBJECT_PROXY_TO_OVERRIDE",
+ 0,
+ "Convert Proxy to Override",
+ "Convert a Proxy object to a full library override, inclduing all its dependencies"},
{0, NULL, 0, NULL, NULL},
};
@@ -1487,6 +1518,15 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
C, op->reports, scene, space_outliner, &space_outliner->tree, item_rename_fn);
str = "Rename Object";
}
+ else if (event == OL_OP_PROXY_TO_OVERRIDE_CONVERT) {
+ outliner_do_object_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ object_proxy_to_override_convert_fn);
+ str = "Convert Proxy to Override";
+ }
else {
BLI_assert(0);
return OPERATOR_CANCELLED;
@@ -1654,6 +1694,7 @@ typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_LOCAL,
OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE,
OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE_HIERARCHY,
+ OUTLINER_IDOP_OVERRIDE_LIBRARY_PROXY_CONVERT,
OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET,
OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET_HIERARCHY,
OUTLINER_IDOP_OVERRIDE_LIBRARY_RESYNC_HIERARCHY,
@@ -1694,6 +1735,11 @@ static const EnumPropertyItem prop_id_op_types[] = {
0,
"Add Library Override Hierarchy",
"Add a local override of this linked data-block, and its hierarchy of dependencies"},
+ {OUTLINER_IDOP_OVERRIDE_LIBRARY_PROXY_CONVERT,
+ "OVERRIDE_LIBRARY_PROXY_CONVERT",
+ 0,
+ "Convert Proxy to Override",
+ "Convert a Proxy object to a full library override, inclduing all its dependencies"},
{OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET,
"OVERRIDE_LIBRARY_RESET",
0,
@@ -1904,6 +1950,16 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
ED_undo_push(C, "Overridden Data Hierarchy");
break;
}
+ case OUTLINER_IDOP_OVERRIDE_LIBRARY_PROXY_CONVERT: {
+ outliner_do_object_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ object_proxy_to_override_convert_fn);
+ ED_undo_push(C, "Convert Proxy to Override");
+ break;
+ }
case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET: {
outliner_do_libdata_operation(C,
op->reports,