addKey and setValuesAtTimes calculation time
Posted: December 15th, 2013, 10:55 pm
I'm trying to add keys on layers that already have a large amount of keys, and I'm having some trouble getting the processing time down to an acceptable length.
Here's what I've found so far.
Adding keys with setValueAtKey or setValueAtTime takes massively longer than putting all the times and values in two arrays and running setValuesAtTimes.
However, setValuesAtTimes (and the rest of the setValue methods) don't return the key indexes of the newly created keys.
So, if I want to edit the new keys later, I need to do one of the following:
a) run nearestKeyIndex for each of my times to get the index of each new keyframe
2) run addKey to create a blank keyframes at the time I want which returns the key index I want, and then overwrite the value when running setValuesAtTimes
Now, neither of these are optimal since running addKey or nearestKeyIndex takes an exceptional amount of time if a property has a lot of keyframes
So, any suggestions on how to speed up getting all the indexes of newly created keys?
Or is there maybe some undocumented way to get the list of indexes back from setValuesAtTimes()?
Here's what I've found so far.
Adding keys with setValueAtKey or setValueAtTime takes massively longer than putting all the times and values in two arrays and running setValuesAtTimes.
However, setValuesAtTimes (and the rest of the setValue methods) don't return the key indexes of the newly created keys.
So, if I want to edit the new keys later, I need to do one of the following:
a) run nearestKeyIndex for each of my times to get the index of each new keyframe
Code: Select all
setValuesAtTimes(times, values);
for (i=0;i<times.length-1;i++) {
indexes.push(nearestKeyIndex(times[i]);
}
Code: Select all
for (i=0;i<times.length-1;i++) {
indexes.push(addKey(time));
}
setValuesAtTimes(times, values);
So, any suggestions on how to speed up getting all the indexes of newly created keys?
Or is there maybe some undocumented way to get the list of indexes back from setValuesAtTimes()?