-----------------------------------------------------------------------
| 675 | } |
| 676 | //----------------------------------------------------------------------- |
| 677 | TimeIndex Animation::_getTimeIndex( Real timePos ) const |
| 678 | { |
| 679 | // Uncomment following statement for work as previous |
| 680 | // return timePos; |
| 681 | |
| 682 | // Build keyframe time list on demand |
| 683 | if( mKeyFrameTimesDirty ) |
| 684 | { |
| 685 | buildKeyFrameTimeList(); |
| 686 | } |
| 687 | |
| 688 | // Wrap time |
| 689 | Real totalAnimationLength = mLength; |
| 690 | |
| 691 | if( timePos > totalAnimationLength && totalAnimationLength > 0.0f ) |
| 692 | timePos = std::fmod( timePos, totalAnimationLength ); |
| 693 | |
| 694 | // Search for global index |
| 695 | KeyFrameTimeList::iterator it = |
| 696 | std::lower_bound( mKeyFrameTimes.begin(), mKeyFrameTimes.end(), timePos ); |
| 697 | |
| 698 | return TimeIndex( timePos, |
| 699 | static_cast<uint>( std::distance( mKeyFrameTimes.begin(), it ) ) ); |
| 700 | } |
| 701 | //----------------------------------------------------------------------- |
| 702 | void Animation::buildKeyFrameTimeList() const |
| 703 | { |