Camera tracking integration
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 22 Jul 2011 21:52:17 +0000 (21:52 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 22 Jul 2011 21:52:17 +0000 (21:52 +0000)
===========================

Fixed bug in Join Tracks operator: if there are two keyframes for
the same frame but one of makers is disabled then there's no error.

source/blender/blenkernel/intern/tracking.c

index 54af98b92a2e5258d6a05a37c006a282d1fd9d61..763a60e822c69420f7d185a0f68b68a3ed68340b 100644 (file)
@@ -378,27 +378,43 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio
 int BKE_tracking_test_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
 {
        int i, a= 0, b= 0, tot= dst_track->markersnr+src_track->markersnr;
+       int count= 0;
 
        for(i= 0; i<tot; i++) {
-               if(b>=dst_track->markersnr || a>=src_track->markersnr)
-                       break;
+               if(a>=src_track->markersnr) {
+                       b++;
+                       count++;
+               }
+               else if(b>=dst_track->markersnr) {
+                       a++;
+                       count++;
+               }
+               else if(src_track->markers[a].framenr<dst_track->markers[b].framenr) {
+                       a++;
+                       count++;
+               } else if(src_track->markers[a].framenr>dst_track->markers[b].framenr) {
+                       b++;
+                       count++;
+               } else {
+                       if((src_track->markers[a].flag&MARKER_DISABLED)==0 && (dst_track->markers[b].flag&MARKER_DISABLED)==0)
+                               return 0;
 
-               if(src_track->markers[a].framenr<dst_track->markers[b].framenr)
                        a++;
-               else if(src_track->markers[a].framenr>dst_track->markers[b].framenr)
                        b++;
-               else
-                       return 0;
+                       count++;
+               }
        }
 
-       return 1;
+       return count;
 }
 
 void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
 {
-       int i, a= 0, b= 0, tot= dst_track->markersnr+src_track->markersnr;
+       int i, a= 0, b= 0, tot;
        MovieTrackingMarker *markers;
 
+       tot= BKE_tracking_test_join_tracks(dst_track, src_track);
+
        markers= MEM_callocN(tot*sizeof(MovieTrackingMarker), "tracking joined tracks");
 
        for(i= 0; i<tot; i++) {
@@ -408,10 +424,17 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack
                else if(a>=src_track->markersnr) {
                        markers[i]= dst_track->markers[b++];
                }
-               else if(src_track->markers[a].framenr<dst_track->markers[b].framenr)
+               else if(src_track->markers[a].framenr<dst_track->markers[b].framenr) {
                        markers[i]= src_track->markers[a++];
-               else
+               } else if(src_track->markers[a].framenr>dst_track->markers[b].framenr) {
                        markers[i]= dst_track->markers[b++];
+               } else {
+                       if((src_track->markers[a].flag&MARKER_DISABLED)) markers[i]= dst_track->markers[b];
+                       else markers[i]= src_track->markers[a++];
+
+                       a++;
+                       b++;
+               }
        }
 
        MEM_freeN(dst_track->markers);