diff options
author | Bastien Montagne <bastien@blender.org> | 2020-07-01 18:10:30 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-07-01 18:12:12 +0300 |
commit | f4f00661a51a7fab89c1ade40d6195522d6e2f63 (patch) | |
tree | b61ddd0dfd2bdcda282f435a8e124a9a63b04c21 /source/blender | |
parent | 42be3964eb201180f6b0fa1ff6ce43b8c3845bc2 (diff) |
Fix T78330: Duplicating parented objects does not preserve relationships.
Caused by refactor of duplicate code in rBad6cccf058d0, we need to take
into account the duplication of groups of objects here too...
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_add.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8073d87080f..4850764eecd 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1772,6 +1772,21 @@ static void copy_object_set_idnew(bContext *C) } CTX_DATA_END; +#ifndef NDEBUG + /* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those flags. */ + ID *id_iter; + FOREACH_MAIN_ID_BEGIN (bmain, id_iter) { + if (GS(id_iter->name) == ID_OB) { + /* Not all duplicated objects would be used by other newly duplicated data, so their flag + * will not always be cleared. */ + continue; + } + BLI_assert((id_iter->tag & LIB_TAG_NEW) == 0); + } + FOREACH_MAIN_ID_END; +#endif + + BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); } @@ -2907,9 +2922,14 @@ static int duplicate_exec(bContext *C, wmOperator *op) const bool linked = RNA_boolean_get(op->ptr, "linked"); const eDupli_ID_Flags dupflag = (linked) ? 0 : (eDupli_ID_Flags)U.dupflag; + /* We need to handle that here ourselves, because we may duplicate several objects, in which case + * we also want to remap pointers between those... */ + BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); + BKE_main_id_clear_newpoins(bmain); + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { Base *basen = object_add_duplicate_internal( - bmain, scene, view_layer, base->object, dupflag, 0); + bmain, scene, view_layer, base->object, dupflag, LIB_ID_DUPLICATE_IS_SUBPROCESS); /* note that this is safe to do with this context iterator, * the list is made in advance */ @@ -2931,6 +2951,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) } CTX_DATA_END; + /* Note that this will also clear newid pointers and tags. */ copy_object_set_idnew(C); ED_outliner_select_sync_from_object_tag(C); |