Animation: Don't user-copunter copy-on-written action block
This commit is contained in:
@@ -69,10 +69,10 @@ bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct b
|
||||
void BKE_animdata_free(struct ID *id, const bool do_id_user);
|
||||
|
||||
/* Copy AnimData */
|
||||
struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const bool do_action);
|
||||
struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const bool do_action, const bool do_id_user);
|
||||
|
||||
/* Copy AnimData */
|
||||
bool BKE_animdata_copy_id(struct Main *bmain, struct ID *id_to, struct ID *id_from, const bool do_action);
|
||||
bool BKE_animdata_copy_id(struct Main *bmain, struct ID *id_to, struct ID *id_from, const bool do_action, const bool do_id_user);
|
||||
|
||||
/* Copy AnimData Actions */
|
||||
void BKE_animdata_copy_id_action(struct ID *id, const bool set_newid);
|
||||
|
||||
@@ -264,7 +264,7 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
|
||||
/* Copying -------------------------------------------- */
|
||||
|
||||
/* Make a copy of the given AnimData - to be used when copying datablocks */
|
||||
AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action)
|
||||
AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action, const bool do_id_user)
|
||||
{
|
||||
AnimData *dadt;
|
||||
|
||||
@@ -279,7 +279,7 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action)
|
||||
BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, 0, false);
|
||||
BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, 0, false);
|
||||
}
|
||||
else {
|
||||
else if (do_id_user) {
|
||||
id_us_plus((ID *)dadt->action);
|
||||
id_us_plus((ID *)dadt->tmpact);
|
||||
}
|
||||
@@ -297,19 +297,19 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action)
|
||||
return dadt;
|
||||
}
|
||||
|
||||
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const bool do_action)
|
||||
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const bool do_action, const bool do_id_user)
|
||||
{
|
||||
AnimData *adt;
|
||||
|
||||
if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name)))
|
||||
return false;
|
||||
|
||||
BKE_animdata_free(id_to, true);
|
||||
BKE_animdata_free(id_to, do_id_user);
|
||||
|
||||
adt = BKE_animdata_from_id(id_from);
|
||||
if (adt) {
|
||||
IdAdtTemplate *iat = (IdAdtTemplate *)id_to;
|
||||
iat->adt = BKE_animdata_copy(bmain, adt, do_action);
|
||||
iat->adt = BKE_animdata_copy(bmain, adt, do_action, do_id_user);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1376,7 +1376,7 @@ static void id_copy_animdata(Main *bmain, ID *id, const bool do_action)
|
||||
|
||||
if (adt) {
|
||||
IdAdtTemplate *iat = (IdAdtTemplate *)id;
|
||||
iat->adt = BKE_animdata_copy(bmain, iat->adt, do_action); /* could be set to false, need to investigate */
|
||||
iat->adt = BKE_animdata_copy(bmain, iat->adt, do_action, true); /* could be set to false, need to investigate */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -608,7 +608,7 @@ static void deg_update_copy_on_write_animation(const Depsgraph * /*depsgraph*/,
|
||||
const IDDepsNode *id_node)
|
||||
{
|
||||
DEG_debug_print_eval(__func__, id_node->id_orig->name, id_node->id_cow);
|
||||
BKE_animdata_copy_id(NULL, id_node->id_cow, id_node->id_orig, false);
|
||||
BKE_animdata_copy_id(NULL, id_node->id_cow, id_node->id_orig, false, false);
|
||||
}
|
||||
|
||||
ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
|
||||
|
||||
@@ -373,7 +373,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
|
||||
if (base->object->adt) {
|
||||
if (ob->adt == NULL) {
|
||||
/* no animdata, so just use a copy of the whole thing */
|
||||
ob->adt = BKE_animdata_copy(bmain, base->object->adt, false);
|
||||
ob->adt = BKE_animdata_copy(bmain, base->object->adt, false, true);
|
||||
}
|
||||
else {
|
||||
/* merge in data - we'll fix the drivers manually */
|
||||
@@ -384,7 +384,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
|
||||
if (curarm->adt) {
|
||||
if (arm->adt == NULL) {
|
||||
/* no animdata, so just use a copy of the whole thing */
|
||||
arm->adt = BKE_animdata_copy(bmain, curarm->adt, false);
|
||||
arm->adt = BKE_animdata_copy(bmain, curarm->adt, false, true);
|
||||
}
|
||||
else {
|
||||
/* merge in data - we'll fix the drivers manually */
|
||||
|
||||
@@ -1466,13 +1466,13 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
|
||||
DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
|
||||
break;
|
||||
case MAKE_LINKS_ANIMDATA:
|
||||
BKE_animdata_copy_id(bmain, (ID *)ob_dst, (ID *)ob_src, false);
|
||||
BKE_animdata_copy_id(bmain, (ID *)ob_dst, (ID *)ob_src, false, true);
|
||||
if (ob_dst->data && ob_src->data) {
|
||||
if (ID_IS_LINKED(obdata_id)) {
|
||||
is_lib = true;
|
||||
break;
|
||||
}
|
||||
BKE_animdata_copy_id(bmain, (ID *)ob_dst->data, (ID *)ob_src->data, false);
|
||||
BKE_animdata_copy_id(bmain, (ID *)ob_dst->data, (ID *)ob_src->data, false, true);
|
||||
}
|
||||
DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
||||
break;
|
||||
|
||||
@@ -601,7 +601,7 @@ bool rna_AnimaData_override_apply(
|
||||
|
||||
if (adt_dst == NULL && adt_src != NULL) {
|
||||
/* Copy anim data from reference into final local ID. */
|
||||
BKE_animdata_copy_id(NULL, ptr_dst->id.data, ptr_src->id.data, false);
|
||||
BKE_animdata_copy_id(NULL, ptr_dst->id.data, ptr_src->id.data, false, true);
|
||||
return true;
|
||||
}
|
||||
else if (adt_dst != NULL && adt_src == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user