| 272 | |
| 273 | |
| 274 | F32 CameraSpline::getTime(F32 d) |
| 275 | { |
| 276 | if (mSize <= 1) |
| 277 | return 0; |
| 278 | |
| 279 | // Find nodes spanning the distance |
| 280 | Vector<TimeMap>::iterator end = mTimeMap.begin() + 1, start; |
| 281 | for (; end < (mTimeMap.end() - 1) && end->mDistance < d; end++) { } |
| 282 | start = end - 1; |
| 283 | |
| 284 | // Check for duplicate points.. |
| 285 | F32 seg = end->mDistance - start->mDistance; |
| 286 | if (!seg) |
| 287 | return end->mTime; |
| 288 | |
| 289 | // Interpolate between the two nodes |
| 290 | F32 i = (d - start->mDistance) / (end->mDistance - start->mDistance); |
| 291 | return start->mTime + (end->mTime - start->mTime) * i; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | //----------------------------------------------------------------------------- |
no test coverage detected