diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-11-16 23:45:40 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-11-17 13:19:54 +0300 |
commit | b7f5ab0cd33bc7632bd71af5f883745e340d6e18 (patch) | |
tree | 44319a121504220313b7af8bf63eec659034985d /source/blender/blenkernel/intern/key.c | |
parent | d526ef607d0a8741799ede335c2c64dc87e4f094 (diff) |
ShapeKeys: Add `BKE_keyblock_is_basis` to check whether a given keyblock is used a basis by others.
Also fix stupid debug-only error in previous commit.
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index d4266022d2f..b98213918bf 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1890,9 +1890,23 @@ void BKE_keyblock_update_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos) float *fp = kb->data; int tot, a; - BLI_assert(((ob->type == OB_MESH) ? me->totvert : - (ob->type == OB_LATTICE) ? lt->pntsu * lt->pntsv * lt->pntsw : - ELEM(ob->type, OB_CURVE, OB_SURF) ? BKE_nurbList_verts_count(&cu->nurb) : 0) == kb->totelem); +#ifndef NDEBUG + if (ob->type == OB_LATTICE) { + Lattice *lt = ob->data; + BLI_assert((lt->pntsu * lt->pntsv * lt->pntsw) == kb->totelem); + } + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { + Curve *cu = ob->data; + BLI_assert(BKE_nurbList_verts_count(&cu->nurb) == kb->totelem); + } + else if (ob->type == OB_MESH) { + Mesh *me = ob->data; + BLI_assert(me->totvert == kb->totelem); + } + else { + BLI_assert(0 == kb->totelem); + } +#endif tot = kb->totelem; if (tot == 0) return; @@ -2192,3 +2206,22 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index) return true; } + +/** + * Check if given keyblock (as index) is used as basis by others in given key. + */ +bool BKE_keyblock_is_basis(struct Key *key, const int index) +{ + KeyBlock *kb; + int i; + + if (key->type == KEY_RELATIVE) { + for (i = 0, kb = key->block.first; kb; i++, kb = kb->next) { + if ((i != index) && (kb->relative == index)) { + return true; + } + } + } + + return false; +} |