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>2022-08-16 16:43:24 +0300
committerBastien Montagne <bastien@blender.org>2022-08-16 16:43:24 +0300
commit850126ab44310881efc37204a10acf4b606af34a (patch)
treee66616b338e19b2a978497135e195facffe217d4 /source/blender/editors/object
parent8af983ba78ecc28e35bcccbb9095526c1165f41c (diff)
parenta42896a8a14212fc568fbb147e02dfacb8822f11 (diff)
Merge branch 'blender-v3.3-release'
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_intern.h6
-rw-r--r--source/blender/editors/object/object_ops.c5
-rw-r--r--source/blender/editors/object/object_relations.c111
3 files changed, 115 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 229f8aace5a..63f010cd526 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -49,10 +49,14 @@ void OBJECT_OT_vertex_parent_set(struct wmOperatorType *ot);
void OBJECT_OT_track_set(struct wmOperatorType *ot);
void OBJECT_OT_track_clear(struct wmOperatorType *ot);
void OBJECT_OT_make_local(struct wmOperatorType *ot);
-void OBJECT_OT_make_override_library(struct wmOperatorType *ot);
void OBJECT_OT_make_single_user(struct wmOperatorType *ot);
void OBJECT_OT_make_links_scene(struct wmOperatorType *ot);
void OBJECT_OT_make_links_data(struct wmOperatorType *ot);
+
+void OBJECT_OT_make_override_library(struct wmOperatorType *ot);
+void OBJECT_OT_reset_override_library(struct wmOperatorType *ot);
+void OBJECT_OT_clear_override_library(struct wmOperatorType *ot);
+
/**
* Used for drop-box.
* Assigns to object under cursor, only first material slot.
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 8a0d380ff2f..24a4556b075 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -58,11 +58,14 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_track_set);
WM_operatortype_append(OBJECT_OT_track_clear);
WM_operatortype_append(OBJECT_OT_make_local);
- WM_operatortype_append(OBJECT_OT_make_override_library);
WM_operatortype_append(OBJECT_OT_make_single_user);
WM_operatortype_append(OBJECT_OT_make_links_scene);
WM_operatortype_append(OBJECT_OT_make_links_data);
+ WM_operatortype_append(OBJECT_OT_make_override_library);
+ WM_operatortype_append(OBJECT_OT_reset_override_library);
+ WM_operatortype_append(OBJECT_OT_clear_override_library);
+
WM_operatortype_append(OBJECT_OT_select_random);
WM_operatortype_append(OBJECT_OT_select_all);
WM_operatortype_append(OBJECT_OT_select_same_collection);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index f136d3302df..052b243d893 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2325,6 +2325,14 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
user_overrides_from_selected_objects = true;
}
+ /* Make already existing selected liboverrides editable. */
+ FOREACH_SELECTED_OBJECT_BEGIN (view_layer, CTX_wm_view3d(C), ob_iter) {
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(ob_iter) && !ID_IS_LINKED(ob_iter)) {
+ ob_iter->id.override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+
if (do_fully_editable) {
/* Pass. */
}
@@ -2435,6 +2443,9 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve
}
if (!ID_IS_LINKED(obact)) {
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(obact)) {
+ return make_override_library_exec(C, op);
+ }
BKE_report(op->reports, RPT_ERROR, "Cannot make library override from a local object");
return OPERATOR_CANCELLED;
}
@@ -2473,17 +2484,20 @@ static bool make_override_library_poll(bContext *C)
Object *obact = CTX_data_active_object(C);
/* Object must be directly linked to be overridable. */
- return (ED_operator_objectmode(C) && obact != NULL &&
- (ID_IS_LINKED(obact) || (obact->instance_collection != NULL &&
- ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection) &&
- !ID_IS_OVERRIDE_LIBRARY(obact))));
+ return (
+ ED_operator_objectmode(C) && obact != NULL &&
+ (ID_IS_LINKED(obact) || ID_IS_OVERRIDE_LIBRARY(obact) ||
+ (obact->instance_collection != NULL &&
+ ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection) && !ID_IS_OVERRIDE_LIBRARY(obact))));
}
void OBJECT_OT_make_override_library(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Make Library Override";
- ot->description = "Make a local override of this library linked data-block";
+ ot->description =
+ "Create a local override of the selected linked objects, and their hierarchy of "
+ "dependencies";
ot->idname = "OBJECT_OT_make_override_library";
/* api callbacks */
@@ -2510,6 +2524,93 @@ void OBJECT_OT_make_override_library(wmOperatorType *ot)
ot->prop = prop;
}
+static bool reset_clear_override_library_poll(bContext *C)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ /* Object must be local and an override. */
+ return (ED_operator_objectmode(C) && obact != NULL && !ID_IS_LINKED(obact) &&
+ ID_IS_OVERRIDE_LIBRARY(obact));
+}
+
+static int reset_override_library_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+
+ /* Make already existing selected liboverrides editable. */
+ FOREACH_SELECTED_OBJECT_BEGIN (CTX_data_view_layer(C), CTX_wm_view3d(C), ob_iter) {
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(ob_iter) && !ID_IS_LINKED(ob_iter)) {
+ BKE_lib_override_library_id_reset(bmain, &ob_iter->id, false);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+
+ WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_reset_override_library(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Reset Library Override";
+ ot->description = "Reset the selected local overrides to their linked references values";
+ ot->idname = "OBJECT_OT_reset_override_library";
+
+ /* api callbacks */
+ ot->exec = reset_override_library_exec;
+ ot->poll = reset_clear_override_library_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int clear_override_library_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+
+ /* Make already existing selected liboverrides editable. */
+ FOREACH_SELECTED_OBJECT_BEGIN (CTX_data_view_layer(C), CTX_wm_view3d(C), ob_iter) {
+ if (ID_IS_LINKED(ob_iter)) {
+ continue;
+ }
+ if (BKE_lib_override_library_is_hierarchy_leaf(bmain, &ob_iter->id)) {
+ BKE_libblock_remap(bmain,
+ &ob_iter->id,
+ ob_iter->id.override_library->reference,
+ ID_REMAP_SKIP_INDIRECT_USAGE);
+ BKE_id_delete(bmain, &ob_iter->id);
+ }
+ else {
+ BKE_lib_override_library_id_reset(bmain, &ob_iter->id, true);
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+
+ WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_clear_override_library(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Clear Library Override";
+ ot->description =
+ "Delete the selected local overrides and relink their usages to the linked data-blocks if "
+ "possible, else reset them and mark them as non editable";
+ ot->idname = "OBJECT_OT_clear_override_library";
+
+ /* api callbacks */
+ ot->exec = clear_override_library_exec;
+ ot->poll = reset_clear_override_library_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/** \} */
/* ------------------------------------------------------------------- */