diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-19 17:30:54 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-19 17:30:54 +0300 |
commit | d7aaa145c609776cf3ef8b495f22ff18ef7ea296 (patch) | |
tree | 1d13156c7f8aa6146be773d1e53611f8831881b0 /source/blender/editors/object/object_add.c | |
parent | 0852805ed771043f43752658bb763983a8aae408 (diff) | |
parent | 04ec36f677d47e3a70baa944bb26fc03d5e8d52e (diff) |
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r-- | source/blender/editors/object/object_add.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8b5894923ad..c77db10d74b 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1657,12 +1657,25 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) PropertyRNA *prop_name = RNA_struct_find_property(op->ptr, "name"); PropertyRNA *prop_location = RNA_struct_find_property(op->ptr, "location"); + PropertyRNA *prop_session_uuid = RNA_struct_find_property(op->ptr, "session_uuid"); + bool update_location_if_necessary = false; if (RNA_property_is_set(op->ptr, prop_name)) { char name[MAX_ID_NAME - 2]; RNA_property_string_get(op->ptr, prop_name, name); collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, name); + update_location_if_necessary = true; + } + else if (RNA_property_is_set(op->ptr, prop_session_uuid)) { + const uint32_t session_uuid = (uint32_t)RNA_property_int_get(op->ptr, prop_session_uuid); + collection = (Collection *)BKE_libblock_find_session_uuid(bmain, ID_GR, session_uuid); + update_location_if_necessary = true; + } + else { + collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection")); + } + if (update_location_if_necessary) { int mval[2]; if (!RNA_property_is_set(op->ptr, prop_location) && object_add_drop_xy_get(C, op, &mval)) { ED_object_location_from_view(C, loc); @@ -1670,9 +1683,6 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) RNA_property_float_set_array(op->ptr, prop_location, loc); } } - else { - collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection")); - } if (collection == NULL) { return OPERATOR_CANCELLED; @@ -1707,7 +1717,8 @@ static int object_instance_add_invoke(bContext *C, wmOperator *op, const wmEvent RNA_int_set(op->ptr, "drop_y", event->xy[1]); } - if (!RNA_struct_property_is_set(op->ptr, "name")) { + if (!RNA_struct_property_is_set(op->ptr, "name") && + !RNA_struct_property_is_set(op->ptr, "session_uuid")) { return WM_enum_search_invoke(C, op, event); } return op->type->exec(C, op); @@ -1740,6 +1751,16 @@ void OBJECT_OT_collection_instance_add(wmOperatorType *ot) ot->prop = prop; ED_object_add_generic_props(ot, false); + RNA_def_int(ot->srna, + "session_uuid", + 0, + INT32_MIN, + INT32_MAX, + "Session UUID", + "Session UUID of the collection to add", + INT32_MIN, + INT32_MAX); + object_add_drop_xy_props(ot); } |