diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-05-13 01:57:57 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-05-13 01:57:57 +0400 |
commit | 33651da150b6085ddf1e3973fcac5eda8f7e91ec (patch) | |
tree | 1cac858af22f20d612d92a203cc4ac8802b67900 | |
parent | df746390020f4484c76d95e094f2533a84bf436c (diff) |
Fix for keyed marker search not happening correct in some cases
Was an heuristic failure writen for cases when there's no keyframe
in desired direction. Shall all be fine now.
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index ded7a1941f1..71a7697bfc2 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2488,8 +2488,9 @@ static ImBuf *tracking_context_get_frame_ibuf(MovieClip *clip, MovieClipUser *us static MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingTrack *track, int curfra, bool backwards) { - MovieTrackingMarker *marker_keyed = BKE_tracking_marker_get(track, curfra); - int a = marker_keyed - track->markers; + MovieTrackingMarker *marker_keyed = NULL; + MovieTrackingMarker *marker_keyed_fallback = NULL; + int a = BKE_tracking_marker_get(track, curfra) - track->markers; while (a >= 0 && a < track->markersnr) { int next = backwards ? a + 1 : a - 1; @@ -2500,11 +2501,18 @@ static MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingT if (next >= 0 && next < track->markersnr) next_marker = &track->markers[next]; - /* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */ - if (next_marker && next_marker->flag & MARKER_DISABLED) - is_keyframed = true; + if ((cur_marker->flag & MARKER_DISABLED) == 0) { + /* If it'll happen so we didn't find a real keyframe marker, + * fallback to the first marker in current tracked segment + * as a keyframe. + */ + if (next_marker && next_marker->flag & MARKER_DISABLED) { + if (marker_keyed_fallback == NULL) + marker_keyed_fallback = cur_marker; + } - is_keyframed |= (cur_marker->flag & MARKER_TRACKED) == 0; + is_keyframed |= (cur_marker->flag & MARKER_TRACKED) == 0; + } if (is_keyframed) { marker_keyed = cur_marker; @@ -2515,6 +2523,9 @@ static MovieTrackingMarker *tracking_context_get_keyframed_marker(MovieTrackingT a = next; } + if (marker_keyed == NULL) + marker_keyed = marker_keyed_fallback; + return marker_keyed; } |