Fix T69931: Materials with keyframes duplicated by 'make single user' are linked.
Another sneaky bite from the infamous private ID data: While those monsters are not in bmain, the actions used by their animdata are regular cute little ID's, living with the herd in the safe and sound Main DB... So we have to be careful not to propagate the nasty black magic required to handle the formers when we duplicate their animdata. Saying it again: private ID datablocks should never have had their own animdata & actions, this is endless issue also with RNA paths... And makes copying of animation between materials and such needlessly complicated.
This commit is contained in:
parent
7a0ca9f98f
commit
76650402f3
Notes:
blender-bot
2023-06-26 11:58:59 +02:00
Referenced by issue #70208, Viewport, EEVEE, Look Dev breaks mesh. Referenced by issue #70045, EEVEE viewport error when using volume and lights (with animation) Referenced by issue #69993, instanceing does not work on the vertex made of subdivision Referenced by issue #69984, Sculpt Mode: Display ➔ Curve Alpha doesn't display curves other than Custom Referenced by issue #69931, Materials with keyframes duplicated by 'make single user' are linked Referenced by issue #69728, Sculpt Mode Grab Active Vertex and Dynamic Mesh Preview Bug.
|
@ -114,7 +114,10 @@ enum {
|
|||
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_CACHES,
|
||||
};
|
||||
|
||||
void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag);
|
||||
void BKE_libblock_copy_ex(struct Main *bmain,
|
||||
const struct ID *id,
|
||||
struct ID **r_newid,
|
||||
const int orig_flag);
|
||||
void *BKE_libblock_copy(struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL();
|
||||
/* Special version. sued by datablock localization. */
|
||||
|
|
|
@ -1407,9 +1407,10 @@ void *BKE_id_new_nomain(const short type, const char *name)
|
|||
return id;
|
||||
}
|
||||
|
||||
void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag)
|
||||
void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int orig_flag)
|
||||
{
|
||||
ID *new_id = *r_newid;
|
||||
int flag = orig_flag;
|
||||
|
||||
const bool is_private_id_data = (id->flag & LIB_PRIVATE_DATA) != 0;
|
||||
|
||||
|
@ -1430,7 +1431,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag)
|
|||
}
|
||||
|
||||
/* The id->flag bits to copy over. */
|
||||
const int copy_flag_mask = LIB_PRIVATE_DATA;
|
||||
const int copy_idflag_mask = LIB_PRIVATE_DATA;
|
||||
|
||||
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
|
||||
/* r_newid already contains pointer to allocated memory. */
|
||||
|
@ -1454,7 +1455,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag)
|
|||
memcpy(cpn + id_offset, cp + id_offset, id_len - id_offset);
|
||||
}
|
||||
|
||||
new_id->flag = (new_id->flag & ~copy_flag_mask) | (id->flag & copy_flag_mask);
|
||||
new_id->flag = (new_id->flag & ~copy_idflag_mask) | (id->flag & copy_idflag_mask);
|
||||
|
||||
if (id->properties) {
|
||||
new_id->properties = IDP_CopyProperty_ex(id->properties, flag);
|
||||
|
@ -1474,9 +1475,12 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag)
|
|||
|
||||
/* the duplicate should get a copy of the animdata */
|
||||
if ((flag & LIB_ID_COPY_NO_ANIMDATA) == 0) {
|
||||
BLI_assert((flag & LIB_ID_COPY_ACTIONS) == 0 || (flag & LIB_ID_CREATE_NO_MAIN) == 0 ||
|
||||
is_private_id_data);
|
||||
iat->adt = BKE_animdata_copy(bmain, iat->adt, flag);
|
||||
/* Note that even though horrors like root nodetrees are not in bmain, the actions they use
|
||||
* in their anim data *are* in bmain... super-mega-hurra. */
|
||||
int animdata_flag = orig_flag;
|
||||
BLI_assert((animdata_flag & LIB_ID_COPY_ACTIONS) == 0 ||
|
||||
(animdata_flag & LIB_ID_CREATE_NO_MAIN) == 0);
|
||||
iat->adt = BKE_animdata_copy(bmain, iat->adt, animdata_flag);
|
||||
}
|
||||
else {
|
||||
iat->adt = NULL;
|
||||
|
|
Loading…
Reference in New Issue