Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/anim_sys.c
| Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | if (adt) { | ||||
| iat->adt = NULL; | iat->adt = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Copying -------------------------------------------- */ | /* Copying -------------------------------------------- */ | ||||
| /* Make a copy of the given AnimData - to be used when copying datablocks */ | /* Make a copy of the given AnimData - to be used when copying datablocks */ | ||||
| AnimData *BKE_animdata_copy(AnimData *adt, const bool do_action) | AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action) | ||||
| { | { | ||||
| AnimData *dadt; | AnimData *dadt; | ||||
| /* sanity check before duplicating struct */ | /* sanity check before duplicating struct */ | ||||
| if (adt == NULL) | if (adt == NULL) | ||||
| return NULL; | return NULL; | ||||
| dadt = MEM_dupallocN(adt); | dadt = MEM_dupallocN(adt); | ||||
| /* make a copy of action - at worst, user has to delete copies... */ | /* make a copy of action - at worst, user has to delete copies... */ | ||||
| if (do_action) { | if (do_action) { | ||||
| dadt->action = BKE_action_copy(G.main, adt->action); | BLI_assert(bmain != NULL); | ||||
| dadt->tmpact = BKE_action_copy(G.main, adt->tmpact); | 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 { | ||||
| id_us_plus((ID *)dadt->action); | id_us_plus((ID *)dadt->action); | ||||
| id_us_plus((ID *)dadt->tmpact); | id_us_plus((ID *)dadt->tmpact); | ||||
| } | } | ||||
| /* duplicate NLA data */ | /* duplicate NLA data */ | ||||
| copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); | copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); | ||||
| /* duplicate drivers (F-Curves) */ | /* duplicate drivers (F-Curves) */ | ||||
| copy_fcurves(&dadt->drivers, &adt->drivers); | copy_fcurves(&dadt->drivers, &adt->drivers); | ||||
| /* don't copy overrides */ | /* don't copy overrides */ | ||||
| BLI_listbase_clear(&dadt->overrides); | BLI_listbase_clear(&dadt->overrides); | ||||
| /* return */ | /* return */ | ||||
| return dadt; | return dadt; | ||||
| } | } | ||||
| bool BKE_animdata_copy_id(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) | ||||
| { | { | ||||
| AnimData *adt; | AnimData *adt; | ||||
| if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) | if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) | ||||
| return false; | return false; | ||||
| BKE_animdata_free(id_to, true); | BKE_animdata_free(id_to, true); | ||||
| adt = BKE_animdata_from_id(id_from); | adt = BKE_animdata_from_id(id_from); | ||||
| if (adt) { | if (adt) { | ||||
| IdAdtTemplate *iat = (IdAdtTemplate *)id_to; | IdAdtTemplate *iat = (IdAdtTemplate *)id_to; | ||||
| iat->adt = BKE_animdata_copy(adt, do_action); | iat->adt = BKE_animdata_copy(bmain, adt, do_action); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| void BKE_animdata_copy_id_action(ID *id, const bool set_newid) | void BKE_animdata_copy_id_action(ID *id, const bool set_newid) | ||||
| { | { | ||||
| AnimData *adt = BKE_animdata_from_id(id); | AnimData *adt = BKE_animdata_from_id(id); | ||||
| ▲ Show 20 Lines • Show All 1,027 Lines • ▼ Show 20 Lines | void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp) | ||||
| if (ksp->rna_path) | if (ksp->rna_path) | ||||
| MEM_freeN(ksp->rna_path); | MEM_freeN(ksp->rna_path); | ||||
| /* free path itself */ | /* free path itself */ | ||||
| BLI_freelinkN(&ks->paths, ksp); | BLI_freelinkN(&ks->paths, ksp); | ||||
| } | } | ||||
| /* Copy all KeyingSets in the given list */ | /* Copy all KeyingSets in the given list */ | ||||
| void BKE_keyingsets_copy(ListBase *newlist, ListBase *list) | void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list) | ||||
| { | { | ||||
| KeyingSet *ksn; | KeyingSet *ksn; | ||||
| KS_Path *kspn; | KS_Path *kspn; | ||||
| BLI_duplicatelist(newlist, list); | BLI_duplicatelist(newlist, list); | ||||
| for (ksn = newlist->first; ksn; ksn = ksn->next) { | for (ksn = newlist->first; ksn; ksn = ksn->next) { | ||||
| BLI_duplicatelist(&ksn->paths, &ksn->paths); | BLI_duplicatelist(&ksn->paths, &ksn->paths); | ||||
| ▲ Show 20 Lines • Show All 1,549 Lines • Show Last 20 Lines | |||||