MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / getReferenceFrame

Method getReferenceFrame

Engine/TrackMarker.cpp:701–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701int
702TrackMarker::getReferenceFrame(int time,
703 int frameStep) const
704{
705 QMutexLocker k(&_imp->trackMutex);
706 std::set<int>::iterator upper = _imp->userKeyframes.upper_bound(time);
707
708 if ( upper == _imp->userKeyframes.end() ) {
709 //all keys are lower than time, pick the last one
710 if ( !_imp->userKeyframes.empty() ) {
711 return *_imp->userKeyframes.rbegin();
712 }
713
714 // no keyframe - use the previous/next as reference
715 return time - frameStep;
716 } else {
717 if ( upper == _imp->userKeyframes.begin() ) {
718 ///all keys are greater than time
719 return *upper;
720 }
721
722 int upperKeyFrame = *upper;
723 ///If we find "time" as a keyframe, then use it
724 --upper;
725
726 int lowerKeyFrame = *upper;
727
728 if (lowerKeyFrame == time) {
729 return time;
730 }
731
732 /// return the nearest from time
733 return (time - lowerKeyFrame) < (upperKeyFrame - time) ? lowerKeyFrame : upperKeyFrame;
734 }
735}
736
737void
738TrackMarker::resetCenter()

Callers 2

trackStepTrackerPMMethod · 0.80

Calls 3

emptyMethod · 0.80
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected