Tracking: Cleanup, de-duplicate implementation of marker lookup

The logic was duplicated.

Should be no functional changes. The modified function is expected
to give same exact results for all inputs.

On the "caching last-used track" topic. The code was using last_marker
to allow faster lookup of marker closest to the frame. With this
change it is still the case since the BKE_tracking_marker_get() does
cache last used marker.
This commit is contained in:
Sergey Sharybin 2020-11-24 16:29:41 +01:00
parent e922dd7d8a
commit b1533f8fa4
1 changed files with 2 additions and 15 deletions

View File

@ -270,21 +270,8 @@ static bool is_effectively_disabled(StabContext *ctx,
static int search_closest_marker_index(MovieTrackingTrack *track, int ref_frame)
{
MovieTrackingMarker *markers = track->markers;
int end = track->markersnr;
int i = track->last_marker;
i = MAX2(0, i);
i = MIN2(i, end - 1);
for (; i < end - 1 && markers[i].framenr <= ref_frame; i++) {
/* pass */
}
for (; 0 < i && markers[i].framenr > ref_frame; i--) {
/* pass */
}
track->last_marker = i;
return i;
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, ref_frame);
return marker - track->markers;
}
static void retrieve_next_higher_usable_frame(