diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-12 15:05:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-12 15:05:16 +0400 |
commit | 4c9486f13d40cb066ad4643537d926559c6ea481 (patch) | |
tree | 62ef92d3d84b3675a7f2167fb589de5fb3cdcde6 /source/blender/blenkernel/intern/key.c | |
parent | 4b8ab31d81e335a1d5e45dc950ea1350dc1ca1c4 (diff) |
change add_keyblock() not to sort keyblocks by time since this can be a problem when using the function in lower level parts of the code, instead add add_keyblock_ctime() which sets time and sorts on absolute shape keys.
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 62701f4e98e..74d56a82c75 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1472,15 +1472,30 @@ KeyBlock *add_keyblock(Key *key, const char *name) kb->slidermin= 0.0f; kb->slidermax= 1.0f; - - // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor... - if (key->type == KEY_RELATIVE) { - kb->pos= curpos + 0.1f; - } - else { + + /** + * \note caller may want to set this to current time, but don't do it here since we need to sort + * which could cause problems in some cases, see #add_keyblock_ctime */ + kb->pos = curpos + 0.1f; /* only used for absolute shape keys */ + + return kb; +} + +/** + * \note sorting is a problematic side effect in some cases, + * better only do this explicitly by having its own function, + * + * \param do_force always use ctime even for relative keys. + */ +KeyBlock *add_keyblock_ctime(Key *key, const char *name, const short do_force) +{ + KeyBlock *kb = add_keyblock(key, name); + + if (do_force || (key->type != KEY_RELATIVE)) { kb->pos = key->ctime / 100.0f; sort_keys(key); } + return kb; } |