Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/key.c
| Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | case ID_CU: | ||||
| key->elemsize = 16; | key->elemsize = 16; | ||||
| break; | break; | ||||
| } | } | ||||
| return key; | return key; | ||||
| } | } | ||||
| Key *BKE_key_copy(Main *bmain, const Key *key) | /** | ||||
| * Only copy internal data of ShapeKey ID from source to already allocated/initialized destination. | |||||
| * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs. | |||||
| * | |||||
| * WARNING! This function will not handle ID user count! | |||||
| * | |||||
| * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). | |||||
| */ | |||||
| void BKE_key_copy_data(Main *UNUSED(bmain), Key *key_dst, const Key *key_src, const int UNUSED(flag)) | |||||
| { | { | ||||
| Key *keyn; | BLI_duplicatelist(&key_dst->block, &key_src->block); | ||||
| KeyBlock *kbn, *kb; | |||||
| keyn = BKE_libblock_copy(bmain, &key->id); | |||||
| BLI_duplicatelist(&keyn->block, &key->block); | |||||
| kb = key->block.first; | |||||
| kbn = keyn->block.first; | |||||
| while (kbn) { | |||||
| if (kbn->data) kbn->data = MEM_dupallocN(kbn->data); | KeyBlock *kb_dst, *kb_src; | ||||
| if (kb == key->refkey) keyn->refkey = kbn; | for (kb_src = key_src->block.first, kb_dst = key_dst->block.first; | ||||
| kb_dst; | |||||
| kbn = kbn->next; | kb_src = kb_src->next, kb_dst = kb_dst->next) | ||||
| kb = kb->next; | { | ||||
| if (kb_dst->data) { | |||||
| kb_dst->data = MEM_dupallocN(kb_dst->data); | |||||
| } | |||||
| if (kb_src == key_src->refkey) { | |||||
| key_dst->refkey = kb_dst; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| BKE_id_copy_ensure_local(bmain, &key->id, &keyn->id); | Key *BKE_key_copy(Main *bmain, const Key *key) | ||||
| { | |||||
| return keyn; | Key *key_copy; | ||||
| BKE_id_copy_ex(bmain, &key->id, (ID **)&key_copy, 0, false); | |||||
| return key_copy; | |||||
| } | } | ||||
| /* XXX TODO get rid of this! */ | |||||
| Key *BKE_key_copy_nolib(Key *key) | Key *BKE_key_copy_nolib(Key *key) | ||||
| { | { | ||||
| Key *keyn; | Key *keyn; | ||||
| KeyBlock *kbn, *kb; | KeyBlock *kbn, *kb; | ||||
| keyn = MEM_dupallocN(key); | keyn = MEM_dupallocN(key); | ||||
| keyn->adt = NULL; | keyn->adt = NULL; | ||||
| ▲ Show 20 Lines • Show All 1,951 Lines • Show Last 20 Lines | |||||