diff options
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 1b63aa1a8af..7468112b40e 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -183,14 +183,14 @@ static void shapekey_blend_read_lib(BlendLibReader *reader, ID *id) Key *key = (Key *)id; BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0); - BLO_read_id_address(reader, key->id.lib, &key->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, key->id.lib, &key->ipo); /* XXX deprecated - old animation system */ BLO_read_id_address(reader, key->id.lib, &key->from); } static void shapekey_blend_read_expand(BlendExpander *expander, ID *id) { Key *key = (Key *)id; - BLO_expand(expander, key->ipo); // XXX deprecated - old animation system + BLO_expand(expander, key->ipo); /* XXX deprecated - old animation system */ } IDTypeInfo IDType_ID_KE = { @@ -214,6 +214,8 @@ IDTypeInfo IDType_ID_KE = { .blend_read_data = shapekey_blend_read_data, .blend_read_lib = shapekey_blend_read_lib, .blend_read_expand = shapekey_blend_read_expand, + + .blend_read_undo_preserve = NULL, }; #define KEY_MODE_DUMMY 0 /* use where mode isn't checked for */ @@ -249,7 +251,7 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */ Key *key; char *el; - key = BKE_libblock_alloc(bmain, ID_KE, "Key", 0); + key = BKE_id_new(bmain, ID_KE, "Key"); key->type = KEY_NORMAL; key->from = id; @@ -296,43 +298,6 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */ return key; } -Key *BKE_key_copy(Main *bmain, const Key *key) -{ - Key *key_copy; - BKE_id_copy(bmain, &key->id, (ID **)&key_copy); - return key_copy; -} - -/* XXX TODO get rid of this! */ -Key *BKE_key_copy_nolib(Key *key) -{ - Key *keyn; - KeyBlock *kbn, *kb; - - keyn = MEM_dupallocN(key); - - keyn->adt = NULL; - - 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); - } - if (kb == key->refkey) { - keyn->refkey = kbn; - } - - kbn = kbn->next; - kb = kb->next; - } - - return keyn; -} - /* Sort shape keys and Ipo curves after a change. This assumes that at most * one key was moved, which is a valid assumption for the places it's * currently being called. @@ -959,7 +924,7 @@ static void key_evaluate_relative(const int start, reffrom = refb->data; poin += start * poinsize; - reffrom += key->elemsize * start; // key elemsize yes! + reffrom += key->elemsize * start; /* key elemsize yes! */ from += key->elemsize * start; for (b = start; b < end; b += step) { @@ -1651,7 +1616,7 @@ int BKE_keyblock_element_count_from_shape(const Key *key, const int shape_index) int result = 0; int index = 0; for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { result += kb->totelem; } } @@ -1691,7 +1656,7 @@ void BKE_keyblock_data_get_from_shape(const Key *key, float (*arr)[3], const int uint8_t *elements = (uint8_t *)arr; int index = 0; for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_len = kb->totelem * key->elemsize; memcpy(elements, kb->data, block_elem_len); elements += block_elem_len; @@ -1721,7 +1686,7 @@ void BKE_keyblock_data_set_with_mat4(Key *key, int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_len = kb->totelem; float(*block_data)[3] = (float(*)[3])kb->data; for (int data_offset = 0; data_offset < block_elem_len; ++data_offset) { @@ -1745,7 +1710,7 @@ void BKE_keyblock_curve_data_set_with_mat4( int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_size = kb->totelem * key->elemsize; BKE_keyblock_curve_data_transform(nurb, mat, elements, kb->data); elements += block_elem_size; @@ -1761,7 +1726,7 @@ void BKE_keyblock_data_set(Key *key, const int shape_index, const void *data) const uint8_t *elements = data; int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_size = kb->totelem * key->elemsize; memcpy(kb->data, elements, block_elem_size); elements += block_elem_size; |