Get the value at a specific index
| 256 | |
| 257 | // Get the value at a specific index |
| 258 | double Keyframe::GetValue(int64_t index) const { |
| 259 | if (Points.empty()) { |
| 260 | return 0; |
| 261 | } |
| 262 | std::vector<Point>::const_iterator candidate = |
| 263 | std::lower_bound(begin(Points), end(Points), static_cast<double>(index), IsPointBeforeX); |
| 264 | |
| 265 | if (candidate == end(Points)) { |
| 266 | // index is behind last point |
| 267 | return Points.back().co.Y; |
| 268 | } |
| 269 | if (candidate == begin(Points)) { |
| 270 | // index is at or before first point |
| 271 | return Points.front().co.Y; |
| 272 | } |
| 273 | if (candidate->co.X == index) { |
| 274 | // index is directly on a point |
| 275 | return candidate->co.Y; |
| 276 | } |
| 277 | std::vector<Point>::const_iterator predecessor = candidate - 1; |
| 278 | return InterpolateBetween(*predecessor, *candidate, index, 0.01); |
| 279 | } |
| 280 | |
| 281 | // Get the rounded INT value at a specific index |
| 282 | int Keyframe::GetInt(int64_t index) const { |
no test coverage detected