diff options
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 0f04c03688c..2dc615c19f9 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1558,9 +1558,23 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name) KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const bool do_force) { KeyBlock *kb = BKE_keyblock_add(key, name); + const float cpos = key->ctime / 100.0f; + /* In case of absolute keys, there is no point in adding more than one key with the same pos. + * Hence only set new keybloc pos to current time if none previous one already use it. + * Now at least people just adding absolute keys without touching to ctime + * won't have to systematically use retiming func (and have ordering issues, too). See T39897. + */ + if (!do_force && (key->type != KEY_RELATIVE)) { + KeyBlock *it_kb; + for (it_kb = key->block.first; it_kb; it_kb = it_kb->next) { + if (it_kb->pos == cpos) { + return kb; + } + } + } if (do_force || (key->type != KEY_RELATIVE)) { - kb->pos = key->ctime / 100.0f; + kb->pos = cpos; BKE_key_sort(key); } |