Faster sampling
The current animation-clip sampling code performs well, so long as each animation lasts under 1 second. With multiple minute-long animation clips, such as a cutscene, the animation system's performance starts to suffer. Why does the performance worsen with longer animations? The culprit is the following bit of code in the Track::FrameIndex
function:
for (int i = (int)size - 1; i >= 0; --i) { if (time >= mFrames[i].mTime) { return i; } }
The presented loop goes through every frame in the track. If an animation has a lot of frames, the performance starts to get worse. Remember, this bit of code is executed for each animated component of each animated bone in an animation clip.
This function currently does a linear search, but it can be...