Merge pull request #25012 from avencherus/prevent-duplicate-keyframes
Do precision comparison to prevent the creation of keyframes with a time that already exists
This commit is contained in:
commit
c11bf884e0
1 changed files with 8 additions and 6 deletions
|
@ -819,15 +819,17 @@ int Animation::_insert(float p_time, T &p_keys, const V &p_value) {
|
|||
|
||||
while (true) {
|
||||
|
||||
if (idx == 0 || p_keys[idx - 1].time < p_time) {
|
||||
//condition for insertion.
|
||||
p_keys.insert(idx, p_value);
|
||||
return idx;
|
||||
} else if (p_keys[idx - 1].time == p_time) {
|
||||
// Condition for replacement.
|
||||
if (idx > 0 && Math::is_equal_approx(p_keys[idx - 1].time, p_time)) {
|
||||
|
||||
// condition for replacing.
|
||||
p_keys.write[idx - 1] = p_value;
|
||||
return idx - 1;
|
||||
|
||||
// Condition for insert.
|
||||
} else if (idx == 0 || p_keys[idx - 1].time < p_time) {
|
||||
|
||||
p_keys.insert(idx, p_value);
|
||||
return idx;
|
||||
}
|
||||
|
||||
idx--;
|
||||
|
|
Loading…
Reference in a new issue