Internal refactoring of tracking module, should be no functional changes
[blender.git] / source / blender / editors / space_clip / clip_editor.c
index b24ff58e590d818f909723095061c069ac6d4afe..275cb782bbd321c2738c17928d6c4b507b809b65 100644 (file)
@@ -342,7 +342,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
        MovieClip *clip = ED_space_clip(sc);
        MovieTrackingTrack *track;
        int width, height, ok = FALSE;
-       ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
+       ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
 
        INIT_MINMAX2(min, max);
 
@@ -351,7 +351,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2])
        track = tracksbase->first;
        while (track) {
                if (TRACK_VIEW_SELECTED(sc, track)) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_marker_get(track, sc->user.framenr);
 
                        if (marker) {
                                float pos[3];
@@ -439,7 +439,7 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[
                r_co[0] *= width;
                r_co[1] *= height * aspy;
 
-               BKE_tracking_invert_intrinsics(&clip->tracking, r_co, r_co);
+               BKE_tracking_undistort_v2(&clip->tracking, r_co, r_co);
 
                r_co[0] /= width;
                r_co[1] /= height * aspy;
@@ -474,7 +474,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y
                float aspy = 1.0f / tracking->camera.pixel_aspect;
                float tmp[2] = {*xr * width, *yr * height * aspy};
 
-               BKE_tracking_apply_intrinsics(tracking, tmp, tmp);
+               BKE_tracking_distort_v2(tracking, tmp, tmp);
 
                *xr = tmp[0] / width;
                *yr = tmp[1] / (height * aspy);
@@ -523,7 +523,7 @@ typedef struct SpaceClipDrawContext {
        unsigned last_texture;          /* ID of previously used texture, so it'll be restored after clip drawing */
 
        /* fields to check if cache is still valid */
-       int framenr, start_frame;
+       int framenr, start_frame, frame_offset;
        short render_size, render_flag;
 } SpaceClipDrawContext;
 
@@ -565,6 +565,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
        need_rebind |= context->render_size != sc->user.render_size;
        need_rebind |= context->render_flag != sc->user.render_flag;
        need_rebind |= context->start_frame != clip->start_frame;
+       need_rebind |= context->frame_offset != clip->frame_offset;
 
        if (need_rebind) {
                int width = ibuf->x, height = ibuf->y;
@@ -622,6 +623,7 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
                context->render_size = sc->user.render_size;
                context->render_flag = sc->user.render_flag;
                context->start_frame = clip->start_frame;
+               context->frame_offset = clip->frame_offset;
        }
        else {
                /* displaying exactly the same image which was loaded t oa texture,