diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-19 17:54:10 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-19 17:54:10 +0300 |
commit | 436a7ee65176090ee44de6dbf38d4eb512ffaf9e (patch) | |
tree | 9a92fa46080e44dee8447abd54aa2dd9d057f9b3 /source | |
parent | eb13072399559de0a5b38b874b3a00850e1bf483 (diff) | |
parent | 2d5b91d6a0f7470dd475721ea038c061513090d7 (diff) |
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 11 | ||||
-rw-r--r-- | source/blender/editors/object/object_collection.c | 18 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 5 |
3 files changed, 30 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 0edc16e822c..76c6dc1d5e7 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1172,14 +1172,21 @@ static bool scene_collections_object_remove( { bool removed = false; + /* If given object is removed from all collections in given scene, then it can also be safely + * removed from rigidbody world for given scene. */ if (collection_skip == NULL) { BKE_scene_remove_rigidbody_object(bmain, scene, ob, free_us); } FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { - if (collection != collection_skip) { - removed |= collection_object_remove(bmain, collection, ob, free_us); + if (ID_IS_LINKED(collection) || ID_IS_OVERRIDE_LIBRARY(collection)) { + continue; + } + if (collection == collection_skip) { + continue; } + + removed |= collection_object_remove(bmain, collection, ob, free_us); } FOREACH_SCENE_COLLECTION_END; diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c index 054c9e1de46..39951c2ab6e 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.c @@ -526,7 +526,7 @@ void OBJECT_OT_collection_link(wmOperatorType *ot) ot->prop = prop; } -static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int collection_remove_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Object *ob = ED_object_context(C); @@ -535,6 +535,12 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op)) if (!ob || !collection) { return OPERATOR_CANCELLED; } + if (ID_IS_LINKED(collection) || ID_IS_OVERRIDE_LIBRARY(collection)) { + BKE_report(op->reports, + RPT_ERROR, + "Cannot remove an object from a linked or library override collection"); + return OPERATOR_CANCELLED; + } BKE_collection_object_remove(bmain, collection, ob, false); @@ -561,7 +567,7 @@ void OBJECT_OT_collection_remove(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op)) +static int collection_unlink_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data; @@ -569,6 +575,14 @@ static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op)) if (!collection) { return OPERATOR_CANCELLED; } + if (ID_IS_OVERRIDE_LIBRARY(collection) && + collection->id.override_library->hierarchy_root != &collection->id) { + BKE_report(op->reports, + RPT_ERROR, + "Cannot unlink a library override collection which is not the root of its override " + "hierarchy"); + return OPERATOR_CANCELLED; + } BKE_id_delete(bmain, collection); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c9626e674f2..adac1479c7e 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1835,6 +1835,11 @@ static int move_to_collection_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + if (ID_IS_OVERRIDE_LIBRARY(collection)) { + BKE_report(op->reports, RPT_ERROR, "Cannot add objects to a library override collection"); + return OPERATOR_CANCELLED; + } + ListBase objects = selected_objects_get(C); if (is_new) { |