Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/key.c
| Context not available. | |||||
| return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0); | return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0); | ||||
| } | } | ||||
| int BKE_key_count_keyblocks_elements_shapenr(Key *key, int shapenr) | |||||
| { | |||||
| int result = 0; | |||||
| int index = 0; | |||||
| LISTBASE_FOREACH (KeyBlock *, block, &key->block) { | |||||
| if (shapenr < 0 || index == shapenr) { | |||||
| result += block->totelem; | |||||
| } | |||||
| ++index; | |||||
| } | |||||
| return result; | |||||
| } | |||||
| int BKE_key_count_keyblocks_elements(Key *key) | |||||
| { | |||||
| return BKE_key_count_keyblocks_elements_shapenr(key, -1); | |||||
| } | |||||
| void BKE_key_copy_keyblocks_data_shapenr(Key *key, float (*arr)[3], int shapenr) | |||||
| { | |||||
| uint8_t *elements = (uint8_t *)arr; | |||||
| int index = 0; | |||||
| LISTBASE_FOREACH (KeyBlock *, block, &key->block) { | |||||
| if (shapenr < 0 || index == shapenr) { | |||||
| const int block_elem_len = block->totelem * key->elemsize; | |||||
| memcpy(elements, block->data, block_elem_len); | |||||
| elements += block_elem_len; | |||||
| } | |||||
| ++index; | |||||
| } | |||||
| } | |||||
| void BKE_key_copy_keyblocks_data(Key *key, float (*arr)[3]) | |||||
| { | |||||
| BKE_key_copy_keyblocks_data_shapenr(key, arr, -1); | |||||
| } | |||||
| void BKE_key_set_keyblocks_data_with_mat(Key *key, | |||||
campbellbarton: Follow naming conventions of similar functions, use `_with_mat4` suffix. | |||||
campbellbartonUnsubmitted Done Inline ActionsThis only works for elemsize 3 shape-keys, so it wont work for curves. Remaining TODO's should be noted in comments. campbellbarton: This only works for elemsize 3 shape-keys, so it wont work for curves.
Remaining TODO's should… | |||||
| int shapenr, | |||||
| float (*vertices)[3], | |||||
campbellbartonUnsubmitted Done Inline ActionsUse const for source data. campbellbarton: Use const for source data. | |||||
| const float mat[4][4]) | |||||
| { | |||||
| if (key->elemsize != 3 * sizeof(float)) { | |||||
| // ERROR | |||||
campbellbartonUnsubmitted Done Inline ActionsUse an BLI_assert(0) here if it should be unreachable. campbellbarton: Use an `BLI_assert(0)` here if it should be unreachable. | |||||
| return; | |||||
| } | |||||
| int index = 0; | |||||
| float(*elements)[3] = vertices; | |||||
| LISTBASE_FOREACH (KeyBlock *, block, &key->block) { | |||||
| if (shapenr < 0 || index == shapenr) { | |||||
| const int block_elem_len = block->totelem; | |||||
| float(*block_data)[3] = (float(*)[3])block->data; | |||||
| for (int data_offset = 0; data_offset < block_elem_len; ++data_offset) { | |||||
| float *srcdata = (float *)(elements + data_offset); | |||||
campbellbartonUnsubmitted Done Inline ActionsUse const for source data. campbellbarton: Use const for source data. | |||||
| float *dstdata = (float *)(block_data + data_offset); | |||||
| mul_v3_m4v3(dstdata, mat, srcdata); | |||||
| } | |||||
| elements += block_elem_len; | |||||
| } | |||||
| ++index; | |||||
| } | |||||
| } | |||||
| void BKE_key_set_keyblocks_data(Key *key, int shapenr, void *data) | |||||
| { | |||||
| int index = 0; | |||||
| uint8_t *elements = data; | |||||
| LISTBASE_FOREACH (KeyBlock *, block, &key->block) { | |||||
| if (shapenr < 0 || index == shapenr) { | |||||
| const int block_elem_size = block->totelem * key->elemsize; | |||||
| memcpy(block->data, elements, block_elem_size); | |||||
| elements += block_elem_size; | |||||
| } | |||||
| ++index; | |||||
| } | |||||
| } | |||||
| bool BKE_key_idtype_support(const short id_type) | bool BKE_key_idtype_support(const short id_type) | ||||
| { | { | ||||
| switch (id_type) { | switch (id_type) { | ||||
| Context not available. | |||||
Follow naming conventions of similar functions, use _with_mat4 suffix.