20 #ifndef ANTKEEPER_ANIMATION_CHANNEL_HPP
21 #define ANTKEEPER_ANIMATION_CHANNEL_HPP
97 struct keyframe_compare
101 return std::get<0>(lhs) < std::get<0>(rhs);
106 std::set<keyframe, keyframe_compare> keyframes;
109 template <
typename T>
112 keyframes(keyframe_compare())
115 template <
typename T>
120 template <
typename T>
123 keyframes(other.keyframes)
126 template <
typename T>
130 keyframes = other.keyframes;
134 template <
typename T>
137 keyframes.emplace(k);
140 template <
typename T>
143 auto lower_bound = keyframes.lower_bound({start, T()});
144 auto upper_bound = keyframes.upper_bound({end, T()});
145 keyframes.erase(lower_bound, upper_bound);
148 template <
typename T>
154 template <
typename T>
158 auto upper_bound = keyframes.upper_bound({
position, T()});
161 auto lower_bound = upper_bound;
164 std::array<const keyframe*, 2> frames;
165 frames[0] = (lower_bound != keyframes.end()) ? &(*lower_bound) :
nullptr;
166 frames[1] = (upper_bound != keyframes.end()) ? &(*upper_bound) :
nullptr;
171 template <
typename T>
174 std::list<keyframe> keyframe_list;
176 auto lower_bound = keyframes.lower_bound({start, T()});
177 auto upper_bound = keyframes.upper_bound({end, T()});
178 for (
auto iterator = lower_bound; iterator != upper_bound; ++iterator)
180 keyframe_list.push_back(*iterator);
183 return keyframe_list;
186 template <
typename T>
192 template <
typename T>
195 if (keyframes.empty())
200 return std::get<0>(*keyframes.rbegin());
Single channel in a keyframe animation.
int get_id() const
Returns the ID of the animation channel.
float get_duration() const
Returns the duration of the animation channel.
std::tuple< float, T > keyframe
Keyframe consisting of a time and a value.
animation_channel()
Creates an animation channel.
std::array< const keyframe *, 2 > find_keyframes(float position) const
Finds the keyframes to the left and right of position.
animation_channel & operator=(const animation_channel &other)
Assigns the contents of another channel to this channel.
void insert_keyframe(const keyframe &k)
Adds a keyframe to the animation.
void remove_keyframes()
Removes all keyframes from the animation.
entt::entity id
Entity ID type.
@ position
Vertex position (vec3)