From dc81327f751edc5b18c81f2e2c0a43e63dcd1335 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 2 Jul 2011 16:03:47 +0000 Subject: [PATCH] Camera tracking integration =========================== - Removed TRACK_PROCESSED flag which is actually unneeded now. - When libmv fails to track marker for next frame, add marker for new frame with old position and set it up as Disabled. - "Break" track path when markers sequence is "broken". This means path wouldn't be drawed over frames, during which racking object was lost. - Update Properties Editor for SpaceClip during playback. Track preview button should now update nicely. --- source/blender/blenkernel/intern/tracking.c | 19 +++++++++++-------- source/blender/editors/screen/screen_ops.c | 9 +++++++++ source/blender/editors/space_clip/clip_draw.c | 12 +++++------- source/blender/makesdna/DNA_tracking_types.h | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index da104af9df5..d3c65167d1e 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -553,7 +553,7 @@ void BKE_tracking_sync(MovieTrackingContext *context) if(sel_type==MCLIP_SEL_TRACK && sel==cur) replace_sel= 1; - track->flag= cur->flag | (track->flag&TRACK_PROCESSED); + track->flag= cur->flag; track->pat_flag= cur->pat_flag; track->search_flag= cur->search_flag; @@ -635,6 +635,7 @@ int BKE_tracking_next(MovieTrackingContext *context) double x1= pos[0], y1= pos[1]; double x2= x1, y2= y1; int wndx, wndy; + MovieTrackingMarker marker_new; wndx= (int)((track->pat_max[0]-track->pat_min[0])*ibuf->x)/2; wndy= (int)((track->pat_max[1]-track->pat_min[1])*ibuf->y)/2; @@ -642,8 +643,6 @@ int BKE_tracking_next(MovieTrackingContext *context) if(libmv_regionTrackerTrack(context->region_tracker, patch, patch_new, width, height, MAX2(wndx, wndy), x1, y1, &x2, &y2)) { - MovieTrackingMarker marker_new; - memset(&marker_new, 0, sizeof(marker_new)); marker_new.pos[0]= (origin[0]+x2)/ibuf_new->x; marker_new.pos[1]= (origin[1]+y2)/ibuf_new->y; @@ -651,18 +650,22 @@ int BKE_tracking_next(MovieTrackingContext *context) if(context->backwards) marker_new.framenr= curfra-1; else marker_new.framenr= curfra+1; - track->flag|= TRACK_PROCESSED; - BKE_tracking_insert_marker(track, &marker_new); - ok= 1; + } else { + marker_new= *marker; + marker_new.framenr++; + marker_new.flag|= MARKER_DISABLED; + + BKE_tracking_insert_marker(track, &marker_new); } + ok= 1; + MEM_freeN(patch); MEM_freeN(patch_new); #endif - } else - track->flag|= TRACK_PROCESSED; + } track= track->next; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 7fdb2bddb5b..03a5ea24ec9 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2778,6 +2778,15 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) } } else if(regiontype==RGN_TYPE_UI) { + if(spacetype==SPACE_CLIP) { + /* Track Preview button is on Properties Editor in SpaceClip, + and it's very common case when users want it be refreshing + during playback, so asking people to enable special option + for this is a bit ticky, so add exception here for refreshing + Properties Editor for SpaceClip always */ + return 1; + } + if(redraws & TIME_ALL_BUTS_WIN) return 1; } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index b143de1f223..b09229946cb 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -175,12 +175,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack * BKE_movieclip_last_selection(clip, &sel_type, &sel); - /* non-tracked tracks shouldn't display path */ - if((track->flag&TRACK_PROCESSED)==0) - return; - marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(marker->flag&MARKER_DISABLED) + if(marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED) return; framenr= marker->framenr; @@ -198,7 +194,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack * if(marker->framenr==sc->user.framenr) curindex= a; - } + } else + break; i--; } @@ -216,7 +213,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *clip, MovieTrackingTrack * curindex= b; copy_v2_v2(path[b++], marker->pos); - } + } else + break; i++; } diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 7abb521554c..3aa12885004 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -109,7 +109,7 @@ typedef struct MovieTracking { #define MARKER_DISABLED 1 /* MovieTrackingTrack->flag */ -#define TRACK_PROCESSED (1<<1) +#define TRACK_UNUSED (1<<1) #define TRACK_DISABLE_RED (1<<2) #define TRACK_DISABLE_GREEN (1<<3) #define TRACK_DISABLE_BLUE (1<<4)