Function addKeyframe
Synopsis
#include <Source/Falcor/Scene/Animation/Animation.h>
void addKeyframe(const Keyframe &keyframe)
Description
Add a keyframe. If there's already a keyframe at the requested time, this call will override the existing frame.
- Parameters
[ in ]
keyframe
- Keyframe.
Mentioned in
- Usage / Scripting / Animation
Source
Lines 260-296 in Source/Falcor/Scene/Animation/Animation.cpp. Line 118 in Source/Falcor/Scene/Animation/Animation.h.
void Animation::addKeyframe(const Keyframe& keyframe)
{
assert(keyframe.time <= mDuration);
if (mKeyframes.size() == 0 || mKeyframes[0].time > keyframe.time)
{
mKeyframes.insert(mKeyframes.begin(), keyframe);
return;
}
else
{
for (size_t i = 0; i < mKeyframes.size(); i++)
{
auto& current = mKeyframes[i];
// If we already have a key-frame at the same time, replace it
if (current.time == keyframe.time)
{
current = keyframe;
return;
}
// If this is not the last frame, Check if we are in between frames
if (i < mKeyframes.size() - 1)
{
auto& Next = mKeyframes[i + 1];
if (current.time < keyframe.time && Next.time > keyframe.time)
{
mKeyframes.insert(mKeyframes.begin() + i + 1, keyframe);
return;
}
}
}
// If we got here, need to push it to the end of the list
mKeyframes.push_back(keyframe);
}
}