Camera tracking: some bug fixes
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Dec 2011 09:21:50 +0000 (09:21 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Dec 2011 09:21:50 +0000 (09:21 +0000)
- Fixed bug with not putting disabled markers properly when doing backwards tracking
- Fixed margin size calculating from pattern size which used to be double-sized
  and prevented to track things on the image edges.

source/blender/blenkernel/intern/tracking.c

index 66c0c0265a1a734cc171e0a9cd6a597ff2ca49fa..043fabcd510e2b8698b211b1ab3cd442865d75c9 100644 (file)
@@ -1158,7 +1158,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
                if(marker && (marker->flag&MARKER_DISABLED)==0) {
 #ifdef WITH_LIBMV
                        int width, height, origin[2], tracked= 0, need_readjust= 0;
-                       float pos[2], margin[2];
+                       float pos[2], margin[2], dim[2];
                        double x1, y1, x2, y2;
                        ImBuf *ibuf= NULL;
                        MovieTrackingMarker marker_new, *marker_keyed;
@@ -1174,7 +1174,8 @@ int BKE_tracking_next(MovieTrackingContext *context)
                        else nextfra= curfra+1;
 
                        /* margin from frame boundaries */
-                       sub_v2_v2v2(margin, track->pat_max, track->pat_min);
+                       sub_v2_v2v2(dim, track->pat_max, track->pat_min);
+                       margin[0]= margin[1]= MAX2(dim[0], dim[1]) / 2.0f;
 
                        margin[0]= MAX2(margin[0], (float)track->margin / ibuf_new->x);
                        margin[1]= MAX2(margin[1], (float)track->margin / ibuf_new->y);
@@ -1287,7 +1288,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
                                        {
                                                /* check if there's no keyframe/tracked markers before tracking marker.
                                                   if so -- create disabled marker before currently tracking "segment" */
-                                               put_disabled_marker(track, marker, 1, 0);
+                                               put_disabled_marker(track, marker, !context->backwards, 0);
                                        }
                                }
 
@@ -1311,7 +1312,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
                                /* make currently tracked segment be finished with disabled marker */
                                #pragma omp critical
                                {
-                                       put_disabled_marker(track, &marker_new, 0, 0);
+                                       put_disabled_marker(track, &marker_new, context->backwards, 0);
                                }
                        } else {
                                marker_new= *marker;