From ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Mar 2012 06:38:07 +0000 Subject: style cleanup: follow style guide for formatting of if/for/while loops, and else if's --- source/blender/editors/space_clip/clip_buttons.c | 53 +- source/blender/editors/space_clip/clip_draw.c | 430 +++++++------- source/blender/editors/space_clip/clip_editor.c | 57 +- .../blender/editors/space_clip/clip_graph_draw.c | 27 +- source/blender/editors/space_clip/clip_graph_ops.c | 44 +- source/blender/editors/space_clip/clip_ops.c | 89 +-- source/blender/editors/space_clip/clip_toolbar.c | 32 +- source/blender/editors/space_clip/clip_utils.c | 46 +- source/blender/editors/space_clip/space_clip.c | 44 +- source/blender/editors/space_clip/tracking_ops.c | 625 +++++++++++---------- 10 files changed, 744 insertions(+), 703 deletions(-) (limited to 'source/blender/editors/space_clip') diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 0b191b7e1a5..bb816d1b8b2 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -85,17 +85,17 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayout *row, *split; uiBlock *block; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -106,10 +106,10 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr); - if(!compact) + if (!compact) uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); - if(clip) { + if (clip) { row= uiLayoutRow(layout, 0); block= uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); @@ -133,17 +133,17 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) rctf rect; MovieClipScopes *scopes; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -198,7 +198,7 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb; MovieTrackingMarker *marker; - if(!cb->compact) + if (!cb->compact) return; marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); @@ -218,7 +218,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); - if(event==B_MARKER_POS) { + if (event==B_MARKER_POS) { marker->pos[0]= cb->marker_pos[0]/width; marker->pos[1]= cb->marker_pos[1]/height; @@ -228,7 +228,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_PAT_DIM) { + else if (event==B_MARKER_PAT_DIM) { float dim[2], pat_dim[2]; sub_v2_v2v2(pat_dim, cb->track->pat_max, cb->track->pat_min); @@ -249,7 +249,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_SEARCH_POS) { + else if (event==B_MARKER_SEARCH_POS) { float delta[2], side[2]; sub_v2_v2v2(side, cb->track->search_max, cb->track->search_min); @@ -265,7 +265,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_SEARCH_DIM) { + else if (event==B_MARKER_SEARCH_DIM) { float dim[2], search_dim[2]; sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min); @@ -285,11 +285,13 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); ok= 1; - } else if(event==B_MARKER_FLAG) { + } + else if (event==B_MARKER_FLAG) { marker->flag= cb->marker_flag; ok= 1; - } else if(event==B_MARKER_OFFSET) { + } + else if (event==B_MARKER_OFFSET) { float offset[2], delta[2]; int i; @@ -299,7 +301,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(delta, offset, cb->track->offset); copy_v2_v2(cb->track->offset, offset); - for(i=0; itrack->markersnr; i++) + for (i=0; itrack->markersnr; i++) sub_v2_v2(cb->track->markers[i].pos, delta); /* to update position of "parented" objects */ @@ -309,7 +311,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - if(ok) + if (ok) WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, cb->clip); } @@ -326,17 +328,17 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P MarkerUpdateCb *cb; const char *tip; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -357,24 +359,25 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P cb->marker_flag= marker->flag; cb->framenr= user->framenr; - if(compact) { + if (compact) { block= uiLayoutGetBlock(layout); - if(cb->marker_flag&MARKER_DISABLED) + if (cb->marker_flag&MARKER_DISABLED) tip= "Marker is disabled at current frame"; else tip= "Marker is enabled at current frame"; bt= uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip); uiButSetNFunc(bt, marker_update_cb, cb, NULL); - } else { + } + else { int width, height, step, digits; float pat_dim[2], pat_pos[2], search_dim[2], search_pos[2]; uiLayout *col; BKE_movieclip_get_size(clip, user, &width, &height); - if(track->flag&TRACK_LOCKED) { + if (track->flag&TRACK_LOCKED) { uiLayoutSetActive(layout, 0); block= uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); @@ -406,7 +409,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiBlockSetHandleFunc(block, marker_block_handler, cb); uiBlockSetNFunc(block, marker_update_cb, cb, NULL); - if(cb->marker_flag&MARKER_DISABLED) + if (cb->marker_flag&MARKER_DISABLED) tip= "Marker is disabled at current frame"; else tip= "Marker is enabled at current frame"; diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 920b8dc3ccb..ef83a62c290 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -107,10 +107,10 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc /* cached segments -- could be usefu lto debug caching strategies */ BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points); - if(totseg) { + if (totseg) { glColor4ub(128, 128, 255, 128); - for(a= 0; awinx; @@ -121,31 +121,31 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } /* track */ - if(act_track) { + if (act_track) { MovieTrackingTrack *track= act_track; - for(i= sfra, a= 0; i <= efra; i++) { + for (i= sfra, a= 0; i <= efra; i++) { int framenr; MovieTrackingMarker *marker; - while(amarkersnr) { - if(track->markers[a].framenr>=i) + while (amarkersnr) { + if (track->markers[a].framenr>=i) break; - if(amarkersnr-1 && track->markers[a+1].framenr>i) + if (amarkersnr-1 && track->markers[a+1].framenr>i) break; a++; } - if(amarkersnr) marker= &track->markers[a]; + if (amarkersnr) marker= &track->markers[a]; else marker= &track->markers[track->markersnr-1]; - if((marker->flag&MARKER_DISABLED)==0) { + if ((marker->flag&MARKER_DISABLED)==0) { framenr= marker->framenr; - if(framenr!=i) glColor4ub(128, 128, 0, 96); - else if((marker->flag&MARKER_TRACKED)==0) glColor4ub(255, 255, 0, 196); + if (framenr!=i) glColor4ub(128, 128, 0, 96); + else if ((marker->flag&MARKER_TRACKED)==0) glColor4ub(255, 255, 0, 196); else glColor4ub(255, 255, 0, 96); glRecti((i-sfra)*framelen, 0, (i-sfra+1)*framelen, 4); @@ -154,28 +154,28 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } /* failed frames */ - if(reconstruction->flag&TRACKING_RECONSTRUCTED) { + if (reconstruction->flag&TRACKING_RECONSTRUCTED) { int n= reconstruction->camnr; MovieReconstructedCamera *cameras= reconstruction->cameras; glColor4ub(255, 0, 0, 96); - for(i= sfra, a= 0; i <= efra; i++) { + for (i= sfra, a= 0; i <= efra; i++) { int ok= 0; - while(ai) { + else if (cameras[a].framenr>i) { break; } a++; } - if(!ok) + if (!ok) glRecti((i-sfra)*framelen, 0, (i-sfra+1)*framelen, 8); } } @@ -198,15 +198,16 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) char str[256]= {0}; int block= 0; - if(tracking->stats) { + if (tracking->stats) { BLI_strncpy(str, tracking->stats->message, sizeof(str)); block= 1; - } else { - if(sc->flag&SC_LOCK_SELECTION) + } + else { + if (sc->flag&SC_LOCK_SELECTION) strcpy(str, "Locked"); } - if(str[0]) + if (str[0]) ED_region_info_draw(ar, str, block, 0.6f); } @@ -222,20 +223,21 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - if(sc->flag&SC_MUTE_FOOTAGE) { + if (sc->flag&SC_MUTE_FOOTAGE) { glColor3f(0.0f, 0.0f, 0.0f); glRectf(x, y, x+zoomx*width, y+zoomy*height); - } else { - if(ibuf->rect_float && !ibuf->rect) { + } + else { + if (ibuf->rect_float && !ibuf->rect) { IMB_rect_from_float(ibuf); } - if(ibuf->rect) + if (ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); } /* draw boundary border for frame if stabilization is enabled */ - if(sc->flag&SC_SHOW_STABLE && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { + if (sc->flag&SC_SHOW_STABLE && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { glColor3f(0.0f, 0.0f, 0.0f); glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); @@ -274,63 +276,66 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin int tiny= sc->flag&SC_SHOW_TINY_MARKER, framenr; MovieTrackingMarker *marker; - if(count==0) + if (count==0) return; marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED) + if (marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED) return; framenr= marker->framenr; a= count; i= framenr-1; - while(i>=framenr-count) { + while (i>=framenr-count) { marker= BKE_tracking_get_marker(track, i); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; - if(marker->framenr==i) { + if (marker->framenr==i) { add_v2_v2v2(path[--a], marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, path[a], path[a]); - if(marker->framenr==sc->user.framenr) + if (marker->framenr==sc->user.framenr) curindex= a; - } else + } + else { break; + } i--; } b= count; i= framenr; - while(i<=framenr+count) { + while (i<=framenr+count) { marker= BKE_tracking_get_marker(track, i); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; - if(marker->framenr==i) { - if(marker->framenr==sc->user.framenr) + if (marker->framenr==i) { + if (marker->framenr==sc->user.framenr) curindex= b; add_v2_v2v2(path[b++], marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); - } else + } + else break; i++; } - if(!tiny) { + if (!tiny) { UI_ThemeColor(TH_MARKER_OUTLINE); - if(TRACK_VIEW_SELECTED(sc, track)) { + if (TRACK_VIEW_SELECTED(sc, track)) { glPointSize(5.0f); glBegin(GL_POINTS); - for(i= a; izoom; px[1]= 1.0f/height/sc->zoom; - if((marker->flag&MARKER_DISABLED)==0) { + if ((marker->flag&MARKER_DISABLED)==0) { float pos[2]; rctf r; @@ -392,15 +397,16 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT ED_clip_point_undistorted_pos(sc, pos, pos); - if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { - if(tiny) glPointSize(3.0f); + if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (tiny) glPointSize(3.0f); else glPointSize(4.0f); glBegin(GL_POINTS); glVertex2f(pos[0], pos[1]); glEnd(); glPointSize(1.0f); - } else { - if(!tiny) glLineWidth(3.0f); + } + else { + if (!tiny) glLineWidth(3.0f); glBegin(GL_LINES); glVertex2f(pos[0] + px[0]*2, pos[1]); glVertex2f(pos[0] + px[0]*8, pos[1]); @@ -414,7 +420,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT glVertex2f(pos[0], pos[1] + px[1]*2); glVertex2f(pos[0], pos[1] + px[1]*8); glEnd(); - if(!tiny) glLineWidth(1.0f); + if (!tiny) glLineWidth(1.0f); } } @@ -422,9 +428,9 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT glPushMatrix(); glTranslatef(marker_pos[0], marker_pos[1], 0); - if(!tiny) glLineWidth(3.0f); + if (!tiny) glLineWidth(3.0f); - if(sc->flag&SC_SHOW_MARKER_PATTERN) { + if (sc->flag&SC_SHOW_MARKER_PATTERN) { glBegin(GL_LINE_LOOP); glVertex2f(track->pat_min[0], track->pat_min[1]); glVertex2f(track->pat_max[0], track->pat_min[1]); @@ -434,7 +440,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT } show_search= TRACK_VIEW_SELECTED(sc, track) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0); - if(sc->flag&SC_SHOW_MARKER_SEARCH && show_search) { + if (sc->flag&SC_SHOW_MARKER_SEARCH && show_search) { glBegin(GL_LINE_LOOP); glVertex2f(track->search_min[0], track->search_min[1]); glVertex2f(track->search_max[0], track->search_min[1]); @@ -444,20 +450,21 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT } glPopMatrix(); - if(!tiny) glLineWidth(1.0f); + if (!tiny) glLineWidth(1.0f); } static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3]) { - if(track->flag&TRACK_CUSTOMCOLOR) { - if(act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); + if (track->flag&TRACK_CUSTOMCOLOR) { + if (act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); else copy_v3_v3(scol, track->color); mul_v3_v3fl(col, track->color, 0.5f); - } else { + } + else { UI_GetThemeColor3fv(TH_MARKER, col); - if(act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); + if (act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); else UI_GetThemeColor3fv(TH_SEL_MARKER, scol); } } @@ -474,16 +481,17 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra px[1]= 1.0f/height/sc->zoom; /* marker position and offset position */ - if((track->flag&SELECT)==sel && (marker->flag&MARKER_DISABLED)==0) { + if ((track->flag&SELECT)==sel && (marker->flag&MARKER_DISABLED)==0) { float pos[2]; rctf r; - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); - } else { - if(track->flag&SELECT) glColor3fv(scol); + } + else { + if (track->flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -491,13 +499,14 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra add_v2_v2v2(pos, marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, pos, pos); - if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { - if(!tiny) glPointSize(2.0f); + if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (!tiny) glPointSize(2.0f); glBegin(GL_POINTS); glVertex2f(pos[0], pos[1]); glEnd(); - if(!tiny) glPointSize(1.0f); - } else { + if (!tiny) glPointSize(1.0f); + } + else { glBegin(GL_LINES); glVertex2f(pos[0] + px[0]*3, pos[1]); glVertex2f(pos[0] + px[0]*7, pos[1]); @@ -532,23 +541,24 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra glPushMatrix(); glTranslatef(marker_pos[0], marker_pos[1], 0); - if(tiny) { + if (tiny) { glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); } - if((track->pat_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_PATTERN)) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if ((track->pat_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_PATTERN)) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->pat_flag&SELECT) glColor3fv(scol); + } + else { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -562,18 +572,19 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra /* search */ show_search= TRACK_VIEW_SELECTED(sc, track) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0); - if((track->search_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_SEARCH) && show_search) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->search_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if ((track->search_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_SEARCH) && show_search) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->search_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->search_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->search_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->search_flag&SELECT) glColor3fv(scol); + } + else { + if (track->search_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -586,18 +597,19 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } /* pyramid */ - if(sel && TRACK_VIEW_SELECTED(sc, track) && (track->tracker==TRACKER_KLT) && (marker->flag&MARKER_DISABLED)==0) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if (sel && TRACK_VIEW_SELECTED(sc, track) && (track->tracker==TRACKER_KLT) && (marker->flag&MARKER_DISABLED)==0) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->pat_flag&SELECT) glColor3fv(scol); + } + else { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -620,7 +632,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } } - if(tiny) + if (tiny) glDisable(GL_LINE_STIPPLE); glPopMatrix(); @@ -633,15 +645,15 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo int tiny= sc->flag&SC_SHOW_TINY_MARKER; float col[3], scol[3], px[2]; - if((tiny && outline) || (marker->flag&MARKER_DISABLED)) + if ((tiny && outline) || (marker->flag&MARKER_DISABLED)) return; - if(!TRACK_VIEW_SELECTED(sc, track) || track->flag&TRACK_LOCKED) + if (!TRACK_VIEW_SELECTED(sc, track) || track->flag&TRACK_LOCKED) return; track_colors(track, act, col, scol); - if(outline) { + if (outline) { glLineWidth(3.0f); UI_ThemeColor(TH_MARKER_OUTLINE); } @@ -661,9 +673,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo px[0]= 1.0f/sc->zoom/width/sc->scale; px[1]= 1.0f/sc->zoom/height/sc->scale; - if((sc->flag&SC_SHOW_MARKER_SEARCH) && ((track->search_flag&SELECT)==sel || outline)) { - if(!outline) { - if(track->search_flag&SELECT) glColor3fv(scol); + if ((sc->flag&SC_SHOW_MARKER_SEARCH) && ((track->search_flag&SELECT)==sel || outline)) { + if (!outline) { + if (track->search_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -674,7 +686,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= searchdx; tdy= searchdy; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -693,7 +705,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= searchdx*2.0f; tdy= searchdy*2.0f; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -705,9 +717,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnd(); } - if((sc->flag&SC_SHOW_MARKER_PATTERN) && ((track->pat_flag&SELECT)==sel || outline)) { - if(!outline) { - if(track->pat_flag&SELECT) glColor3fv(scol); + if ((sc->flag&SC_SHOW_MARKER_PATTERN) && ((track->pat_flag&SELECT)==sel || outline)) { + if (!outline) { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -718,7 +730,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= patdx; tdy= patdy; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -737,7 +749,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= patdx*2.0f; tdy= patdy*2.0f; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -751,7 +763,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glPopMatrix(); - if(outline) + if (outline) glLineWidth(1.0f); } @@ -763,26 +775,28 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra uiStyle *style= U.uistyles.first; int fontid= style->widget.uifont_id; - if(!TRACK_VIEW_SELECTED(sc, track)) + if (!TRACK_VIEW_SELECTED(sc, track)) return; BLF_size(fontid, 11.0f, U.dpi); fontsize= BLF_height_max(fontid); - if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); + if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); else UI_ThemeColorShade(TH_DIS_MARKER, 128); - } else { - if(act) UI_ThemeColor(TH_ACT_MARKER); + } + else { + if (act) UI_ThemeColor(TH_ACT_MARKER); else UI_ThemeColor(TH_SEL_MARKER); } - if((sc->flag&SC_SHOW_MARKER_SEARCH) && + if ((sc->flag&SC_SHOW_MARKER_SEARCH) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0)) { dx= track->search_min[0]; dy= track->search_min[1]; - } else if(sc->flag&SC_SHOW_MARKER_PATTERN) { + } + else if (sc->flag&SC_SHOW_MARKER_PATTERN) { dx= track->pat_min[0]; dy= track->pat_min[1]; } @@ -796,12 +810,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra pos[0]= pos[0]*zoomx; pos[1]= pos[1]*zoomy - fontsize; - if(marker->flag&MARKER_DISABLED) strcpy(state, "disabled"); - else if(marker->framenr!=sc->user.framenr) strcpy(state, "estimated"); - else if(marker->flag&MARKER_TRACKED) strcpy(state, "tracked"); + if (marker->flag&MARKER_DISABLED) strcpy(state, "disabled"); + else if (marker->framenr!=sc->user.framenr) strcpy(state, "estimated"); + else if (marker->flag&MARKER_TRACKED) strcpy(state, "tracked"); else strcpy(state, "keyframed"); - if(state[0]) + if (state[0]) BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state); else BLI_snprintf(str, sizeof(str), "%s", track->name); @@ -810,14 +824,14 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra BLF_draw(fontid, str, sizeof(str)); pos[1]-= fontsize; - if(track->flag&TRACK_HAS_BUNDLE) { + if (track->flag&TRACK_HAS_BUNDLE) { BLI_snprintf(str, sizeof(str), "Average error: %.3f", track->error); BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, str, sizeof(str)); pos[1]-= fontsize; } - if(track->flag&TRACK_LOCKED) { + if (track->flag&TRACK_LOCKED) { BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, "locked", 6); } @@ -865,16 +879,16 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, act_track= BKE_tracking_active_track(tracking); - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { int count= 0; /* count */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) + if (MARKER_VISIBLE(sc, marker)) count++; } @@ -882,19 +896,19 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } /* undistort */ - if(count) { + if (count) { marker_pos= MEM_callocN(2*sizeof(float)*count, "draw_tracking_tracks marker_pos"); track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { ED_clip_point_undistorted_pos(sc, marker->pos, fp); - if(track==act_track) + if (track==act_track) active_pos= fp; fp+= 2; @@ -906,10 +920,10 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } - if(sc->flag&SC_SHOW_TRACK_PATH) { + if (sc->flag&SC_SHOW_TRACK_PATH) { track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) draw_track_path(sc, clip, track); track= track->next; @@ -919,11 +933,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* markers outline and non-selected areas */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_outline(sc, track, marker, cur_pos, width, height); @@ -931,7 +945,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height); draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height); - if(fp) + if (fp) fp+= 2; } } @@ -943,20 +957,20 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, * non-selected areas */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { int act= track==act_track; marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { - if(!act) { + if (MARKER_VISIBLE(sc, marker)) { + if (!act) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 1); draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height); } - if(fp) + if (fp) fp+= 2; } } @@ -965,11 +979,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } /* active marker would be displayed on top of everything else */ - if(act_track) { - if((act_track->flag&TRACK_HIDDEN)==0) { + if (act_track) { + if ((act_track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(act_track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos); draw_marker_areas(sc, act_track, marker, cur_pos, width, height, 1, 1); @@ -978,7 +992,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } - if(sc->flag&SC_SHOW_BUNDLES) { + if (sc->flag&SC_SHOW_BUNDLES) { MovieTrackingObject *object= BKE_tracking_active_object(tracking); float pos[4], vec[4], mat[4][4], aspy; @@ -989,11 +1003,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, BKE_tracking_projection_matrix(tracking, object, framenr, width, height, mat); track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0 && track->flag&TRACK_HAS_BUNDLE) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0 && track->flag&TRACK_HAS_BUNDLE) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); vec[3]=1; @@ -1005,17 +1019,17 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, BKE_tracking_apply_intrinsics(tracking, pos, npos); - if(npos[0]>=0.0f && npos[1]>=0.0f && npos[0]<=width && npos[1]<=height*aspy) { + if (npos[0]>=0.0f && npos[1]>=0.0f && npos[0]<=width && npos[1]<=height*aspy) { vec[0]= (marker->pos[0]+track->offset[0])*width; vec[1]= (marker->pos[1]+track->offset[1])*height*aspy; sub_v2_v2(vec, npos); - if(len_v2(vec)<3) glColor3f(0.0f, 1.0f, 0.0f); + if (len_v2(vec)<3) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_POINTS); - if(undistort) glVertex3f(pos[0]/width, pos[1]/(height*aspy), 0); + if (undistort) glVertex3f(pos[0]/width, pos[1]/(height*aspy), 0); else glVertex3f(npos[0]/width, npos[1]/(height*aspy), 0); glEnd(); } @@ -1031,22 +1045,22 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); - if(sc->flag&SC_SHOW_NAMES) { + if (sc->flag&SC_SHOW_NAMES) { /* scaling should be cleared before drawing texts, otherwise font would also be scaled */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { int act= track==act_track; copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy); - if(fp) fp+= 2; + if (fp) fp+= 2; } } @@ -1056,7 +1070,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); - if(marker_pos) + if (marker_pos) MEM_freeN(marker_pos); } @@ -1070,13 +1084,13 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid float aspy= 1.0f/tracking->camera.pixel_aspect; float dx= (float)width/n, dy= (float)height/n*aspy; - if(sc->mode!=SC_MODE_DISTORTION) + if (sc->mode!=SC_MODE_DISTORTION) return; - if(!tracking->camera.focal) + if (!tracking->camera.focal) return; - if((sc->flag&SC_SHOW_GRID)==0 && (sc->flag&SC_MANUAL_CALIBRATION)==0) + if ((sc->flag&SC_SHOW_GRID)==0 && (sc->flag&SC_MANUAL_CALIBRATION)==0) return; view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y); @@ -1088,28 +1102,28 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glScalef(width, height, 0); /* grid */ - if(sc->flag&SC_SHOW_GRID) { + if (sc->flag&SC_SHOW_GRID) { float val[4][2], idx[4][2]; float min[2], max[2]; - for(a=0; a<4; a++) { - if(a<2) val[a][a%2]= FLT_MAX; + for (a=0; a<4; a++) { + if (a<2) val[a][a%2]= FLT_MAX; else val[a][a%2]= -FLT_MAX; } zero_v2(pos); - for(i= 0; i<=n; i++) { - for(j= 0; j<=n; j++) { - if(i==0 || j==0 || i==n || j==n) { + for (i= 0; i<=n; i++) { + for (j= 0; j<=n; j++) { + if (i==0 || j==0 || i==n || j==n) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); - for(a=0; a<4; a++) { + for (a=0; a<4; a++) { int ok; - if(a<2) ok= tpos[a%2] < val[a][a%2]; + if (a<2) ok= tpos[a%2] < val[a][a%2]; else ok= tpos[a%2] > val[a][a%2]; - if(ok) { + if (ok) { copy_v2_v2(val[a], tpos); idx[a][0]= j; idx[a][1]= i; @@ -1126,7 +1140,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid INIT_MINMAX2(min, max); - for(a= 0; a<4; a++) { + for (a= 0; a<4; a++) { pos[0]= idx[a][0]*dx; pos[1]= idx[a][1]*dy; @@ -1139,8 +1153,8 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid dx= (max[0]-min[0])/n; dy= (max[1]-min[1])/n; - for(i= 0; i<=n; i++) { - for(j= 0; j<=n; j++) { + for (i= 0; i<=n; i++) { + for (j= 0; j<=n; j++) { BKE_tracking_apply_intrinsics(tracking, pos, grid[i][j]); grid[i][j][0]/= width; @@ -1155,30 +1169,30 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glColor3f(1.0f, 0.0f, 0.0f); - for(i= 0; i<=n; i++) { + for (i= 0; i<=n; i++) { glBegin(GL_LINE_STRIP); - for(j= 0; j<=n; j++) { + for (j= 0; j<=n; j++) { glVertex2fv(grid[i][j]); } glEnd(); } - for(j= 0; j<=n; j++) { + for (j= 0; j<=n; j++) { glBegin(GL_LINE_STRIP); - for(i= 0; i<=n; i++) { + for (i= 0; i<=n; i++) { glVertex2fv(grid[i][j]); } glEnd(); } } - if(sc->flag&SC_MANUAL_CALIBRATION && clip->gpd) { + if (sc->flag&SC_MANUAL_CALIBRATION && clip->gpd) { bGPDlayer *layer= clip->gpd->layers.first; - while(layer) { + while (layer) { bGPDframe *frame= layer->frames.first; - if(layer->flag & GP_LAYER_HIDE) { + if (layer->flag & GP_LAYER_HIDE) { layer= layer->next; continue; } @@ -1187,14 +1201,14 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glLineWidth(layer->thickness); glPointSize((float)(layer->thickness + 2)); - while(frame) { + while (frame) { bGPDstroke *stroke= frame->strokes.first; - while(stroke) { - if(stroke->flag&GP_STROKE_2DSPACE) { - if(stroke->totpoints>1) { + while (stroke) { + if (stroke->flag&GP_STROKE_2DSPACE) { + if (stroke->totpoints>1) { glBegin(GL_LINE_STRIP); - for(i= 0; itotpoints-1; i++) { + for (i= 0; itotpoints-1; i++) { float npos[2], dpos[2], len; int steps; @@ -1208,7 +1222,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid steps= ceil(len/5.0f); /* we want to distort only long straight lines */ - if(stroke->totpoints==2) { + if (stroke->totpoints==2) { BKE_tracking_invert_intrinsics(tracking, pos, pos); BKE_tracking_invert_intrinsics(tracking, npos, npos); } @@ -1216,7 +1230,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid sub_v2_v2v2(dpos, npos, pos); mul_v2_fl(dpos, 1.0f/steps); - for(j= 0; j<=steps; j++) { + for (j= 0; j<=steps; j++) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); glVertex2f(tpos[0]/width, tpos[1]/(height*aspy)); @@ -1225,7 +1239,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } glEnd(); } - else if(stroke->totpoints==1) { + else if (stroke->totpoints==1) { glBegin(GL_POINTS); glVertex2f(stroke->points[0].x, stroke->points[0].y); glEnd(); @@ -1256,22 +1270,22 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) float zoomx, zoomy; /* if no clip, nothing to do */ - if(!clip) + if (!clip) return; ED_space_clip_size(sc, &width, &height); ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - if(sc->flag&SC_SHOW_STABLE) { + if (sc->flag&SC_SHOW_STABLE) { float smat[4][4], ismat[4][4]; ibuf= ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle); - if(ibuf) { + if (ibuf) { float loc[2]; float aspect= clip->tracking.camera.pixel_aspect; - if(width != ibuf->x) + if (width != ibuf->x) mul_v2_v2fl(loc, sc->loc, (float)width / ibuf->x); else copy_v2_v2(loc, sc->loc); @@ -1285,7 +1299,8 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) mul_serie_m4(sc->unistabmat, smat, sc->stabmat, ismat, NULL, NULL, NULL, NULL, NULL); } - } else { + } + else { ibuf= ED_space_clip_get_buffer(sc); zero_v2(sc->loc); @@ -1294,7 +1309,7 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) unit_m4(sc->unistabmat); } - if(ibuf) { + if (ibuf) { draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); @@ -1313,16 +1328,16 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) MovieClip *clip= ED_space_clip(sc); ImBuf *ibuf; - if(!clip) + if (!clip) return; - if(onlyv2d) { + if (onlyv2d) { /* if manual calibration is used then grease pencil data is already * drawed in draw_distortion */ - if((sc->flag&SC_MANUAL_CALIBRATION)==0 || sc->mode!=SC_MODE_DISTORTION) { + if ((sc->flag&SC_MANUAL_CALIBRATION)==0 || sc->mode!=SC_MODE_DISTORTION) { ibuf= ED_space_clip_get_buffer(sc); - if(ibuf) { + if (ibuf) { glPushMatrix(); glMultMatrixf(sc->unistabmat); draw_gpencil_2dimage(C, ibuf); @@ -1331,7 +1346,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) glPopMatrix(); } } - } else { + } + else { draw_gpencil_view2d(C, 0); } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 35d870022a4..87b0ac1aac1 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -59,7 +59,7 @@ int ED_space_clip_poll(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - if(sc && sc->clip) + if (sc && sc->clip) return 1; return 0; @@ -69,10 +69,10 @@ void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip) { sc->clip= clip; - if(sc->clip && sc->clip->id.us==0) + if (sc->clip && sc->clip->id.us==0) sc->clip->id.us= 1; - if(C) + if (C) WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); } @@ -83,15 +83,15 @@ MovieClip *ED_space_clip(SpaceClip *sc) ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) { - if(sc->clip) { + if (sc->clip) { ImBuf *ibuf; ibuf= BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; - if(ibuf) + if (ibuf) IMB_freeImBuf(ibuf); } @@ -100,15 +100,15 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) { - if(sc->clip) { + if (sc->clip) { ImBuf *ibuf; ibuf= BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; - if(ibuf) + if (ibuf) IMB_freeImBuf(ibuf); } @@ -117,11 +117,12 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale void ED_space_clip_size(SpaceClip *sc, int *width, int *height) { - if(!sc->clip) { - *width= 0; - *height= 0; - } else + if (!sc->clip) { + *width = *height = 0; + } + else { BKE_movieclip_get_size(sc->clip, &sc->user, width, height); + } } void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) @@ -138,7 +139,7 @@ void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) { MovieClip *clip= ED_space_clip(sc); - if(clip) + if (clip) BKE_movieclip_aspect(clip, aspx, aspy); else *aspx= *aspy= 1.0f; @@ -150,11 +151,11 @@ void ED_clip_update_frame(const Main *mainp, int cfra) wmWindow *win; /* image window, compo node users */ - for(wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ - for(win= wm->windows.first; win; win= win->next) { + for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ + for (win= wm->windows.first; win; win= win->next) { ScrArea *sa; - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_CLIP) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_CLIP) { SpaceClip *sc= sa->spacedata.first; sc->scopes.ok= 0; @@ -178,11 +179,11 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) ED_space_clip_size(sc, &width, &height); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(marker) { + if (marker) { float pos[3]; pos[0]= marker->pos[0]+track->offset[0]; @@ -190,7 +191,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) pos[2]= 0.0f; /* undistortion happens for normalized coords */ - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) /* undistortion happens for normalized coords */ ED_clip_point_undistorted_pos(sc, pos, pos); @@ -218,9 +219,9 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) ED_space_clip_size(sc, &frame_width, &frame_height); - if(frame_width==0 || frame_height==0) return 0; + if (frame_width==0 || frame_height==0) return 0; - if(!selected_boundbox(sc, min, max)) + if (!selected_boundbox(sc, min, max)) return 0; /* center view */ @@ -230,7 +231,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) h= max[1]-min[1]; /* set zoom to see all selection */ - if(w>0 && h>0) { + if (w>0 && h>0) { int width, height; float zoomx, zoomy, newzoom, aspx, aspy; @@ -244,7 +245,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) newzoom= 1.0f/power_of_2(1/MIN2(zoomx, zoomy)); - if(fit || sc->zoom>newzoom) + if (fit || sc->zoom>newzoom) sc->zoom= newzoom; } @@ -255,7 +256,7 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]) { copy_v2_v2(nco, co); - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { MovieClip *clip= ED_space_clip(sc); float aspy= 1.0f/clip->tracking.camera.pixel_aspect; int width, height; @@ -292,7 +293,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y *xr= pos[0]/width; *yr= pos[1]/height; - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; float aspy= 1.0f/tracking->camera.pixel_aspect; diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 1e21d0e5120..c1089d2bbcf 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -155,10 +155,11 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co copy_v3_v3(col, colors[coord]); - if(track==userdata) { + if (track==userdata) { col[3]= 1.0f; glLineWidth(2.0f); - } else { + } + else { col[3]= 0.5f; glLineWidth(1.0f); } @@ -181,14 +182,14 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata; int sel= 0, sel_flag; - if(track!=data->act_track) + if (track!=data->act_track) return; sel_flag= coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y; sel= (marker->flag & sel_flag) ? 1 : 0; - if(sel == data->sel) { - if(sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); + if (sel == data->sel) { + if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); else UI_ThemeColor(TH_HANDLE_VERTEX); draw_curve_knot(marker->framenr, val, data->xscale, data->yscale, data->hsize); @@ -205,7 +206,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if(!width || !height) + if (!width || !height) return; /* non-selected knot handles */ @@ -234,15 +235,15 @@ static void draw_frame_curves(SpaceClip *sc) glColor3f(0.0f, 0.0f, 1.0f); - for(i= 0; icamnr; i++) { + for (i= 0; icamnr; i++) { MovieReconstructedCamera *camera= &reconstruction->cameras[i]; - if(lines && camera->framenr!=prevfra+1) { + if (lines && camera->framenr!=prevfra+1) { glEnd(); lines= 0; } - if(!lines) { + if (!lines) { glBegin(GL_LINE_STRIP); lines= 1; } @@ -252,7 +253,7 @@ static void draw_frame_curves(SpaceClip *sc) prevfra= camera->framenr; } - if(lines) + if (lines) glEnd(); } @@ -268,11 +269,11 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - if(clip) { - if(sc->flag&SC_SHOW_GRAPH_TRACKS) + if (clip) { + if (sc->flag&SC_SHOW_GRAPH_TRACKS) draw_tracks_curves(v2d, sc); - if(sc->flag&SC_SHOW_GRAPH_FRAMES) + if (sc->flag&SC_SHOW_GRAPH_FRAMES) draw_frame_curves(sc); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 0b8b4724062..4a1f2c56ee0 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -65,7 +65,7 @@ static int ED_space_clip_graph_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); - if(sc && sc->clip) { + if (sc && sc->clip) { ARegion *ar = CTX_wm_region(C); return ar->regiontype == RGN_TYPE_PREVIEW; @@ -116,10 +116,10 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack MouseSelectUserData *data= userdata; float co[2]= {marker->framenr, val}; - if(data->has_prev) { + if (data->has_prev) { float d= dist_to_line_segment_v2(data->mouse_co, data->prev_co, co); - if(data->track==NULL || dmin_dist) { + if (data->track==NULL || dmin_dist) { data->track= track; data->min_dist= d; data->coord= coord; @@ -145,7 +145,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr float dx= marker->framenr-data->mouse_co[0], dy= val-data->mouse_co[1]; float d= dx*dx+dy*dy; - if(data->marker==NULL || dmin_dist) { + if (data->marker==NULL || dmin_dist) { float co[2]= {marker->framenr, val}; data->track= track; @@ -174,26 +174,26 @@ static int mouse_select_knot(bContext *C, float co[2], int extend) MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); static const int delta= 6; - if(act_track) { + if (act_track) { MouseSelectUserData userdata; mouse_select_init_data(&userdata, co); clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, find_nearest_tracking_knot_cb, NULL, NULL); - if(userdata.marker) { + if (userdata.marker) { int x1, y1, x2, y2; UI_view2d_view_to_region(v2d, co[0], co[1], &x1, &y1); UI_view2d_view_to_region(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2); - if(abs(x2-x1)<=delta && abs(y2-y1)<=delta) { - if(!extend) { + if (abs(x2-x1)<=delta && abs(y2-y1)<=delta) { + if (!extend) { SelectUserData selectdata = {SEL_DESELECT}; clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb); } - if(userdata.coord==0) + if (userdata.coord==0) userdata.marker->flag|= MARKER_GRAPH_SEL_X; else userdata.marker->flag|= MARKER_GRAPH_SEL_Y; @@ -217,14 +217,14 @@ static int mouse_select_curve(bContext *C, float co[2], int extend) mouse_select_init_data(&userdata, co); clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb, NULL, find_nearest_tracking_segment_end_cb); - if(userdata.track) { - if(extend) { - if(act_track==userdata.track) { + if (userdata.track) { + if (extend) { + if (act_track==userdata.track) { /* currently only single curve can be selected (selected curve represents active track) */ act_track= NULL; } } - else if(act_track!=userdata.track) { + else if (act_track!=userdata.track) { MovieTrackingMarker *marker; SelectUserData selectdata = {SEL_DESELECT}; @@ -252,12 +252,12 @@ static int mouse_select(bContext *C, float co[2], int extend) /* first try to select knot on selected curves */ sel= mouse_select_knot(C, co, extend); - if(!sel) { + if (!sel) { /* if there's no close enough knot to mouse osition, select nearest curve */ sel= mouse_select_curve(C, co, extend); } - if(sel) + if (sel) WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -468,7 +468,7 @@ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) + if (act_track) clip_delete_track(C, clip, tracksbase, act_track); return OPERATOR_FINISHED; @@ -500,13 +500,13 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { int a= 0; - while(amarkersnr) { + while (amarkersnr) { MovieTrackingMarker *marker= &act_track->markers[a]; - if(marker->flag & MARKER_GRAPH_SEL) + if (marker->flag & MARKER_GRAPH_SEL) clip_delete_marker(C, clip, tracksbase, act_track, marker); else a++; @@ -542,8 +542,8 @@ static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), Movie { ViewAllUserData *data = (ViewAllUserData *)userdata; - if(val < data->min) data->min = val; - if(val > data->max) data->max = val; + if (val < data->min) data->min = val; + if (val > data->max) data->max = val; } static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) @@ -656,7 +656,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) if (marker->flag & MARKER_GRAPH_SEL) { if (action==0) marker->flag |= MARKER_DISABLED; - else if(action==1) + else if (action==1) marker->flag &= ~MARKER_DISABLED; else marker->flag ^= MARKER_DISABLED; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 6be1a83d7d9..2fa7f447f38 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -82,15 +82,15 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio width*= sc->zoom; height*= sc->zoom; - if((width < 4) && (height < 4)) + if ((width < 4) && (height < 4)) sc->zoom= oldzoom; - else if((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) + else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) sc->zoom= oldzoom; - else if((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) + else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) sc->zoom= oldzoom; } - if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { + if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { ED_space_clip_size(sc, &width, &height); sc->xof+= ((location[0]-0.5f)*width-sc->xof)*(sc->zoom-oldzoom)/sc->zoom; @@ -158,8 +158,8 @@ static int open_exec(bContext *C, wmOperator *op) clip= BKE_add_movieclip_file(str); - if(!clip) { - if(op->customdata) + if (!clip) { + if (op->customdata) MEM_freeN(op->customdata); BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported movie clip format"); @@ -167,13 +167,13 @@ static int open_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) open_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ clip->id.us--; @@ -182,7 +182,7 @@ static int open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(sc) { + else if (sc) { ED_space_clip_set(C, sc, clip); } @@ -199,16 +199,16 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) char *path= U.textudir; MovieClip *clip= NULL; - if(sc) + if (sc) clip= ED_space_clip(sc); - if(clip) + if (clip) path= clip->name; - if(!RNA_struct_property_is_set(op->ptr, "relative_path")) + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return open_exec(C, op); open_init(C, op); @@ -243,7 +243,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) { MovieClip *clip= CTX_data_edit_movieclip(C); - if(!clip) + if (!clip) return OPERATOR_CANCELLED; BKE_movieclip_reload(clip); @@ -284,7 +284,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) vpd->x= event->x; vpd->y= event->y; - if(sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof; + if (sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof; else vpd->vec= &sc->xof; copy_v2_v2(&vpd->xof, vpd->vec); @@ -299,7 +299,7 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel) { ViewPanData *vpd= op->customdata; - if(cancel) { + if (cancel) { copy_v2_v2(vpd->vec, &vpd->xorig); ED_region_tag_redraw(CTX_wm_region(C)); @@ -316,10 +316,11 @@ static int view_pan_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "offset", offset); - if(sc->flag&SC_LOCK_SELECTION) { + if (sc->flag&SC_LOCK_SELECTION) { sc->xlockof+= offset[0]; sc->ylockof+= offset[1]; - } else { + } + else { sc->xof+= offset[0]; sc->yof+= offset[1]; } @@ -370,7 +371,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) view_pan_exit(C, op, 0); return OPERATOR_FINISHED; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { view_pan_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -440,7 +441,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) SpaceClip *sc= CTX_wm_space_clip(C); ViewZoomData *vpd= op->customdata; - if(cancel) { + if (cancel) { sc->zoom= vpd->zoom; ED_region_tag_redraw(CTX_wm_region(C)); } @@ -495,7 +496,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { view_zoom_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -672,7 +673,7 @@ static int view_all_exec(bContext *C, wmOperator *op) width= ar->winrct.xmax - ar->winrct.xmin + 1; height= ar->winrct.ymax - ar->winrct.ymin + 1; - if(fit_view) { + if (fit_view) { const int margin = 5; /* margin from border */ zoomx= (float)width / (w + 2*margin); @@ -681,7 +682,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); } else { - if((w >= width || h >= height) && (width > 0 && height > 0)) { + if ((w >= width || h >= height) && (width > 0 && height > 0)) { zoomx= (float)width/w; zoomy= (float)height/h; @@ -745,7 +746,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot) static int change_frame_poll(bContext *C) { /* prevent changes during render */ - if(G.rendering) + if (G.rendering) return 0; return ED_space_clip_poll(C); @@ -778,11 +779,12 @@ static int frame_from_event(bContext *C, wmEvent *event) Scene *scene= CTX_data_scene(C); int framenr= 0; - if(ar->regiontype == RGN_TYPE_WINDOW) { + if (ar->regiontype == RGN_TYPE_WINDOW) { float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); framenr= sfra+event->mval[0]/framelen; - } else { + } + else { float viewx, viewy; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); @@ -797,8 +799,8 @@ static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype == RGN_TYPE_WINDOW) { - if(event->mval[1]>16) + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (event->mval[1]>16) return OPERATOR_PASS_THROUGH; } @@ -883,10 +885,10 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto MCLIP_PROXY_UNDISTORTED_SIZE_100}}; int size_nr = undistort ? 1 : 0; - if(size_flag & size_flags[size_nr][0]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; - if(size_flag & size_flags[size_nr][1]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; - if(size_flag & size_flags[size_nr][2]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; - if(size_flag & size_flags[size_nr][3]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; + if (size_flag & size_flags[size_nr][0]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; + if (size_flag & size_flags[size_nr][1]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; + if (size_flag & size_flags[size_nr][2]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; + if (size_flag & size_flags[size_nr][3]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; return build_count; } @@ -908,11 +910,11 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog build_count= proxy_bitflag_to_array(size_flag, build_sizes, 0); build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1); - if(clip->source == MCLIP_SRC_MOVIE) { + if (clip->source == MCLIP_SRC_MOVIE) { if (pj->index_context) IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress); - if(!build_undistort_count) { + if (!build_undistort_count) { if (*stop) pj->stop = 1; @@ -924,23 +926,23 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog } } - if(build_undistort_count) + if (build_undistort_count) distortion= BKE_tracking_distortion_create(); - for(cfra= sfra; cfra<=efra; cfra++) { - if(clip->source != MCLIP_SRC_MOVIE) + for (cfra= sfra; cfra<=efra; cfra++) { + if (clip->source != MCLIP_SRC_MOVIE) BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0); BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1); - if(*stop || G.afbreek) + if (*stop || G.afbreek) break; *do_update= 1; *progress= ((float)cfra)/(efra-sfra); } - if(distortion) + if (distortion) BKE_tracking_distortion_destroy(distortion); if (*stop) @@ -971,7 +973,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if((clip->flag&MCLIP_USE_PROXY)==0) + if ((clip->flag&MCLIP_USE_PROXY)==0) return OPERATOR_CANCELLED; steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); @@ -1022,10 +1024,11 @@ static int mode_set_exec(bContext *C, wmOperator *op) int mode= RNA_enum_get(op->ptr, "mode"); int toggle= RNA_boolean_get(op->ptr, "toggle"); - if(sc->mode==mode) { - if(toggle) + if (sc->mode==mode) { + if (toggle) sc->mode= SC_MODE_TRACKING; - } else { + } + else { sc->mode= mode; } diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index 287edfa3f1c..b42b4137ea0 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -61,14 +61,14 @@ static ARegion *clip_has_properties_region(ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); - if(ar) + if (ar) return ar; /* add subdiv level; after header */ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if(ar==NULL) + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "clip properties region"); @@ -92,7 +92,7 @@ static int properties_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= clip_has_properties_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -116,23 +116,23 @@ static ARegion *clip_has_tools_region(ScrArea *sa) { ARegion *ar, *artool=NULL, *arprops=NULL, *arhead; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_TOOLS) + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_TOOLS) artool= ar; - if(ar->regiontype==RGN_TYPE_TOOL_PROPS) + if (ar->regiontype==RGN_TYPE_TOOL_PROPS) arprops= ar; } /* tool region hide/unhide also hides props */ - if(arprops && artool) + if (arprops && artool) return artool; - if(artool==NULL) { + if (artool==NULL) { /* add subdiv level; after header */ arhead= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if(arhead==NULL) + if (arhead==NULL) return NULL; artool= MEM_callocN(sizeof(ARegion), "clip tools region"); @@ -144,7 +144,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) artool->flag= RGN_FLAG_HIDDEN; } - if(arprops==NULL) { + if (arprops==NULL) { /* add extra subdivided region for tool properties */ arprops= MEM_callocN(sizeof(ARegion), "tool props for clip"); @@ -166,7 +166,7 @@ static int tools_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= clip_has_tools_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -195,14 +195,14 @@ static void clip_panel_operator_redo_header(const bContext *C, Panel *pa) { wmOperator *op= WM_operator_last_redo(C); - if(op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); + if (op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOperator *op) { - if(op->type->flag & OPTYPE_MACRO) { - for(op= op->macro.first; op; op= op->next) { + if (op->type->flag & OPTYPE_MACRO) { + for (op= op->macro.first; op; op= op->next) { uiItemL(pa->layout, op->type->name, ICON_NONE); clip_panel_operator_redo_operator(C, pa, op); } @@ -218,9 +218,9 @@ static void clip_panel_operator_redo(const bContext *C, Panel *pa) wmOperator *op= WM_operator_last_redo(C); uiBlock *block; - if(op==NULL) + if (op==NULL) return; - if(WM_operator_poll((bContext*)C, op->type) == 0) + if (WM_operator_poll((bContext*)C, op->type) == 0) return; block= uiLayoutGetBlock(pa->layout); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 46442d39a7b..c637bffe3ad 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -67,17 +67,17 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack BKE_movieclip_get_size(clip, &sc->user, &width, &height); - for(coord= 0; coord<2; coord++) { + for (coord= 0; coord<2; coord++) { int i, open= 0, prevfra= 0; float prevval= 0.0f; - for(i= 0; imarkersnr; i++) { + for (i= 0; imarkersnr; i++) { MovieTrackingMarker *marker= &track->markers[i]; float val; - if(marker->flag&MARKER_DISABLED) { - if(open) { - if(segment_end) + if (marker->flag&MARKER_DISABLED) { + if (open) { + if (segment_end) segment_end(userdata); open= 0; @@ -86,8 +86,8 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack continue; } - if(!open) { - if(segment_start) + if (!open) { + if (segment_start) segment_start(userdata, track, coord); open= 1; @@ -98,15 +98,15 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack val= (marker->pos[coord] - prevval) * ((coord==0) ? (width) : (height)); val/= marker->framenr-prevfra; - if(func) + if (func) func(userdata, track, marker, coord, val); prevval= marker->pos[coord]; prevfra= marker->framenr; } - if(open) { - if(segment_end) + if (open) { + if (segment_end) segment_end(userdata); } } @@ -123,8 +123,8 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata, MovieTrackingTrack *track; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end); } @@ -141,17 +141,17 @@ void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata, MovieTrackingTrack *track; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { int i; - for(i= 0; imarkersnr; i++) { + for (i= 0; imarkersnr; i++) { MovieTrackingMarker *marker= &track->markers[i]; - if(marker->flag&MARKER_DISABLED) + if (marker->flag&MARKER_DISABLED) continue; - if(func) + if (func) func(userdata, marker); } } @@ -168,17 +168,17 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie int has_bundle= 0, update_stab= 0; - if(track==act_track) + if (track==act_track) tracking->act_track= NULL; - if(track==stab->rot_track) { + if (track==stab->rot_track) { stab->rot_track= NULL; update_stab= 1; } /* handle reconstruction display in 3d viewport */ - if(track->flag&TRACK_HAS_BUNDLE) + if (track->flag&TRACK_HAS_BUNDLE) has_bundle= 1; BKE_tracking_free_track(track); @@ -186,20 +186,20 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); - if(update_stab) { + if (update_stab) { tracking->stabilization.ok= 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); } - if(has_bundle) + if (has_bundle) WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); } void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker) { - if(track->markersnr==1) { + if (track->markersnr==1) { clip_delete_track(C, clip, tracksbase, track); } else { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 96c348fb6e2..ca66248682c 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -101,14 +101,14 @@ static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - if(ar) + if (ar) return ar; /* add subdiv level; after header */ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if(ar==NULL) + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "clip preview region"); @@ -124,7 +124,7 @@ static void clip_scopes_tag_refresh(ScrArea *sa) SpaceClip *sc= (SpaceClip *)sa->spacedata.first; ARegion *ar; - if(sc->mode!=SC_MODE_TRACKING) + if (sc->mode!=SC_MODE_TRACKING) return; /* only while proeprties are visible */ @@ -141,7 +141,7 @@ static void clip_stabilization_tag_refresh(ScrArea *sa) SpaceClip *sc= (SpaceClip *)sa->spacedata.first; MovieClip *clip= ED_space_clip(sc); - if(clip) { + if (clip) { MovieTrackingStabilization *stab= &clip->tracking.stabilization; stab->ok= 0; @@ -212,7 +212,7 @@ static void clip_free(SpaceLink *sl) sc->clip= NULL; - if(sc->scopes.track_preview) + if (sc->scopes.track_preview) IMB_freeImBuf(sc->scopes.track_preview); } @@ -278,12 +278,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SCREEN: - if(wmn->data==ND_ANIMPLAY) { + if (wmn->data==ND_ANIMPLAY) { ED_area_tag_redraw(sa); } break; case NC_SPACE: - if(wmn->data==ND_SPACE_CLIP) { + if (wmn->data==ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -617,11 +617,11 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul { SpaceClip *sc= CTX_wm_space_clip(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, clip_context_dir); return 1; } - else if(CTX_data_equals(member, "edit_movieclip")) { + else if (CTX_data_equals(member, "edit_movieclip")) { CTX_data_id_pointer_set(result, &sc->clip->id); return 1; } @@ -684,7 +684,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) break; } - if(view_changed) { + if (view_changed) { ED_area_initialize(wm, window, sa); ED_area_tag_redraw(sa); } @@ -706,7 +706,7 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) w= width; h= height; - if(clip) + if (clip) h*= clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect; winx= ar->winrct.xmax - ar->winrct.xmin + 1; @@ -767,22 +767,22 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) /* if tracking is in progress, we should synchronize framenr from clipuser * so latest tracked frame would be shown */ - if(clip && clip->tracking_context) + if (clip && clip->tracking_context) BKE_tracking_sync_user(&sc->user, clip->tracking_context); - if(sc->flag&SC_LOCK_SELECTION) { + if (sc->flag&SC_LOCK_SELECTION) { ImBuf *tmpibuf= NULL; - if(clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { + if (clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { tmpibuf= ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - if(ED_clip_view_selection(sc, ar, 0)) { + if (ED_clip_view_selection(sc, ar, 0)) { sc->xof+= sc->xlockof; sc->yof+= sc->ylockof; } - if(tmpibuf) + if (tmpibuf) IMB_freeImBuf(tmpibuf); } @@ -840,7 +840,7 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar) Scene *scene= CTX_data_scene(C); short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; - if(sc->flag & SC_LOCK_TIMECURSOR) + if (sc->flag & SC_LOCK_TIMECURSOR) ED_clip_graph_center_current_frame(scene, ar); /* clear and setup matrix */ @@ -898,19 +898,19 @@ static void clip_props_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_WM: - if(wmn->data == ND_HISTORY) + if (wmn->data == ND_HISTORY) ED_region_tag_redraw(ar); break; case NC_SCENE: - if(wmn->data == ND_MODE) + if (wmn->data == ND_MODE) ED_region_tag_redraw(ar); break; case NC_SPACE: - if(wmn->data == ND_SPACE_CLIP) + if (wmn->data == ND_SPACE_CLIP) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if(wmn->data == ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; } @@ -947,7 +947,7 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if(wmn->action==NA_EDITED) + if (wmn->action==NA_EDITED) ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index f1ce73a8ab0..6cb7536b1ae 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -82,10 +82,10 @@ static int space_clip_frame_poll(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - if(sc) { + if (sc) { MovieClip *clip= ED_space_clip(sc); - if(clip) + if (clip) return BKE_movieclip_has_frame(clip, &sc->user); } @@ -119,7 +119,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) int width, height; ED_space_clip_size(sc, &width, &height); - if(!width || !height) + if (!width || !height) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", pos); @@ -176,10 +176,10 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track= tracksbase->first, *next; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track)) + if (TRACK_VIEW_SELECTED(sc, track)) clip_delete_track(C, clip, tracksbase, track); track= next; @@ -218,13 +218,13 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) int framenr= sc->user.framenr; int has_selection= 0; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track)) { + if (TRACK_VIEW_SELECTED(sc, track)) { MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, framenr); - if(marker) { + if (marker) { has_selection|= track->markersnr>1; clip_delete_marker(C, clip, tracksbase, track, marker); @@ -234,7 +234,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) track= next; } - if(!has_selection) { + if (!has_selection) { /* nothing selected now, unlock view so it can be scrolled nice again */ sc->flag&= ~SC_LOCK_SELECTION; } @@ -290,16 +290,18 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra data->track= track; data->marker= marker; - if(area==TRACK_AREA_POINT) { + if (area==TRACK_AREA_POINT) { data->pos= marker->pos; data->offset= track->offset; copy_v2_v2(data->spos, marker->pos); copy_v2_v2(data->soff, track->offset); - } else if(area==TRACK_AREA_PAT) { - if(action==SLIDE_ACTION_SIZE) { + } + else if (area==TRACK_AREA_PAT) { + if (action==SLIDE_ACTION_SIZE) { data->min= track->pat_min; data->max= track->pat_max; - } else { + } + else { int a; data->pos= marker->pos; @@ -308,15 +310,16 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra copy_v2_v2(data->soff, track->offset); data->smarkers= MEM_callocN(sizeof(*data->smarkers)*track->markersnr, "slide marekrs"); - for(a= 0; amarkersnr; a++) + for (a= 0; amarkersnr; a++) copy_v2_v2(data->smarkers[a], track->markers[a].pos); } - } else if(area==TRACK_AREA_SEARCH) { + } + else if (area==TRACK_AREA_SEARCH) { data->min= track->search_min; data->max= track->search_max; } - if(area==TRACK_AREA_SEARCH || (area==TRACK_AREA_PAT && action!=SLIDE_ACTION_OFFSET)) { + if (area==TRACK_AREA_SEARCH || (area==TRACK_AREA_PAT && action!=SLIDE_ACTION_OFFSET)) { copy_v2_v2(data->smin, data->min); copy_v2_v2(data->smax, data->max); } @@ -327,7 +330,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra data->width= width; data->height= height; - if(action==SLIDE_ACTION_SIZE) + if (action==SLIDE_ACTION_SIZE) data->lock= 1; return data; @@ -343,10 +346,11 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki float min[2], max[2]; float crn[2], dx, dy, tdx, tdy; - if(area==TRACK_AREA_SEARCH) { + if (area==TRACK_AREA_SEARCH) { copy_v2_v2(min, track->search_min); copy_v2_v2(max, track->search_max); - } else { + } + else { copy_v2_v2(min, track->pat_min); copy_v2_v2(max, track->pat_max); } @@ -360,12 +364,13 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki dx= MIN2(dx, (max[0]-min[0])/6.0f) + tdx; dy= MIN2(dy, (max[1]-min[1])/6.0f) + tdy; - if(corner==0) { + if (corner==0) { crn[0]= marker->pos[0]+max[0]; crn[1]= marker->pos[1]+min[1]; inside= co[0]>=crn[0]-dx && co[0]<=crn[0]+tdx && co[1]>=crn[1]-tdy && co[1]<=crn[1]+dy; - } else { + } + else { crn[0]= marker->pos[0]+min[0]; crn[1]= marker->pos[1]+max[1]; @@ -417,37 +422,37 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) ED_space_clip_size(sc, &width, &height); - if(width==0 || height==0) + if (width==0 || height==0) return NULL; ED_clip_mouse_pos(C, event, co); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if((marker->flag&MARKER_DISABLED)==0) { - if(!customdata) - if(mouse_on_offset(sc, track, marker, co, width, height)) + if ((marker->flag&MARKER_DISABLED)==0) { + if (!customdata) + if (mouse_on_offset(sc, track, marker, co, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height); - if(sc->flag&SC_SHOW_MARKER_SEARCH) { - if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) + if (sc->flag&SC_SHOW_MARKER_SEARCH) { + if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height); - else if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) + else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height); } - if(!customdata && sc->flag&SC_SHOW_MARKER_PATTERN) { - if(mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) + if (!customdata && sc->flag&SC_SHOW_MARKER_PATTERN) { + if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height); - if(!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) + if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); } - if(customdata) + if (customdata) break; } } @@ -462,7 +467,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) { SlideMarkerData *slidedata= slide_marker_customdata(C, event); - if(slidedata) { + if (slidedata) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; @@ -485,19 +490,21 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) static void cancel_mouse_slide(SlideMarkerData *data) { /* cancel sliding */ - if(data->area == TRACK_AREA_POINT) { - if(data->action==SLIDE_ACTION_OFFSET) + if (data->area == TRACK_AREA_POINT) { + if (data->action==SLIDE_ACTION_OFFSET) copy_v2_v2(data->offset, data->soff); else copy_v2_v2(data->pos, data->spos); - } else { - if(data->action==SLIDE_ACTION_SIZE) { + } + else { + if (data->action==SLIDE_ACTION_SIZE) { copy_v2_v2(data->min, data->smin); copy_v2_v2(data->max, data->smax); - } else { + } + else { int a; - for(a= 0; atrack->markersnr; a++) + for (a= 0; atrack->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -507,7 +514,7 @@ static void cancel_mouse_slide(SlideMarkerData *data) static void free_slide_data(SlideMarkerData *data) { - if(data->smarkers) MEM_freeN(data->smarkers); + if (data->smarkers) MEM_freeN(data->smarkers); MEM_freeN(data); } @@ -522,11 +529,11 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTCTRLKEY: case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - if(data->action==SLIDE_ACTION_SIZE) - if(ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) + if (data->action==SLIDE_ACTION_SIZE) + if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) data->lock= event->val==KM_RELEASE; - if(ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) + if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) data->accurate= event->val==KM_PRESS; /* no break! update area size */ @@ -537,19 +544,20 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) dx= mdelta[0]/data->width/sc->zoom; - if(data->lock) dy= -dx/data->height*data->width; + if (data->lock) dy= -dx/data->height*data->width; else dy= mdelta[1]/data->height/sc->zoom; - if(data->accurate) { + if (data->accurate) { dx/= 5; dy/= 5; } - if(data->area==TRACK_AREA_POINT) { - if(data->action==SLIDE_ACTION_OFFSET) { + if (data->area==TRACK_AREA_POINT) { + if (data->action==SLIDE_ACTION_OFFSET) { data->offset[0]= data->soff[0]+dx; data->offset[1]= data->soff[1]+dy; - } else { + } + else { data->pos[0]= data->spos[0]+dx; data->pos[1]= data->spos[1]+dy; @@ -558,32 +566,35 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); DAG_id_tag_update(&sc->clip->id, 0); - } else { - if(data->action==SLIDE_ACTION_SIZE) { + } + else { + if (data->action==SLIDE_ACTION_SIZE) { data->min[0]= data->smin[0]-dx; data->max[0]= data->smax[0]+dx; data->min[1]= data->smin[1]+dy; data->max[1]= data->smax[1]-dy; - if(data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM); + if (data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM); else BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM); - } else { + } + else { float d[2]={dx, dy}; - if(data->area==TRACK_AREA_SEARCH) { + if (data->area==TRACK_AREA_SEARCH) { add_v2_v2v2(data->min, data->smin, d); add_v2_v2v2(data->max, data->smax, d); - } else { + } + else { int a; - for(a= 0; atrack->markersnr; a++) + for (a= 0; atrack->markersnr; a++) add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d); sub_v2_v2v2(data->offset, data->soff, d); } - if(data->area==TRACK_AREA_SEARCH) + if (data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_POS); } } @@ -593,7 +604,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: - if(event->val==KM_RELEASE) { + if (event->val==KM_RELEASE) { free_slide_data(op->customdata); show_cursor(C); @@ -642,8 +653,8 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy) { - if(x1>x2) SWAP(float, x1, x2); - if(y1>y2) SWAP(float, y1, y2); + if (x1>x2) SWAP(float, x1, x2); + if (y1>y2) SWAP(float, y1, y2); return (co[0]>=x1-epsx && co[0]<=x2+epsx) && (co[1]>=y1-epsy && co[1]<=y2+epsy); } @@ -672,19 +683,19 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac epsx= MAX2(epsx, 2.0f / width); epsy= MAX2(epsy, 2.0f / height); - if(sc->flag&SC_SHOW_MARKER_SEARCH) - if(mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy)) + if (sc->flag&SC_SHOW_MARKER_SEARCH) + if (mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy)) return TRACK_AREA_SEARCH; - if((marker->flag&MARKER_DISABLED)==0) { - if(sc->flag&SC_SHOW_MARKER_PATTERN) - if(mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) + if ((marker->flag&MARKER_DISABLED)==0) { + if (sc->flag&SC_SHOW_MARKER_PATTERN) + if (mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) return TRACK_AREA_PAT; epsx= 12.0f/width; epsy= 12.0f/height; - if(fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) + if (fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) return TRACK_AREA_POINT; } @@ -712,27 +723,27 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas float mindist= 0.0f; cur= tracksbase->first; - while(cur) { + while (cur) { MovieTrackingMarker *marker= BKE_tracking_get_marker(cur, sc->user.framenr); - if(((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) { + if (((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) { float dist, d1, d2=FLT_MAX, d3=FLT_MAX; d1= sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ /* distance to pattern boundbox */ - if(sc->flag&SC_SHOW_MARKER_PATTERN) + if (sc->flag&SC_SHOW_MARKER_PATTERN) d2= dist_to_rect(co, marker->pos, cur->pat_min, cur->pat_max); /* distance to search boundbox */ - if(sc->flag&SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) + if (sc->flag&SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) d3= dist_to_rect(co, marker->pos, cur->search_min, cur->search_max); /* choose minimal distance. useful for cases of overlapped markers. */ dist= MIN3(d1, d2, d3); - if(track==NULL || disttracking.act_track= track; - } else { - if(area==TRACK_AREA_POINT) + } + else { + if (area==TRACK_AREA_POINT) area= TRACK_AREA_ALL; BKE_tracking_select_track(tracksbase, track, area, extend); @@ -775,7 +787,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } } - if(!extend) { + if (!extend) { sc->xlockof= 0.0f; sc->ylockof= 0.0f; } @@ -801,10 +813,10 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) float co[2]; int extend= RNA_boolean_get(op->ptr, "extend"); - if(!extend) { + if (!extend) { SlideMarkerData *slidedata= slide_marker_customdata(C, event); - if(slidedata) { + if (slidedata) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); @@ -872,15 +884,15 @@ static int border_select_exec(bContext *C, wmOperator *op) /* do actual selection */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(MARKER_VISIBLE(sc, marker)) { - if(BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { + if (MARKER_VISIBLE(sc, marker)) { + if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); } - else if(!extend) { + else if (!extend) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); } @@ -891,7 +903,7 @@ static int border_select_exec(bContext *C, wmOperator *op) track= track->next; } - if(change) { + if (change) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -961,11 +973,11 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* do selection */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(MARKER_VISIBLE(sc, marker) && marker_inside_ellipse(marker, offset, ellipse)) { + if (MARKER_VISIBLE(sc, marker) && marker_inside_ellipse(marker, offset, ellipse)) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); change= 1; @@ -975,7 +987,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) track= track->next; } - if(change) { + if (change) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -1020,14 +1032,14 @@ static int select_all_exec(bContext *C, wmOperator *op) int framenr= sc->user.framenr; int has_selection= 0; - if(action == SEL_TOGGLE){ + if (action == SEL_TOGGLE) { action= SEL_SELECT; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { action= SEL_DESELECT; break; } @@ -1038,11 +1050,11 @@ static int select_all_exec(bContext *C, wmOperator *op) } track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { switch (action) { case SEL_SELECT: track->flag|= SELECT; @@ -1063,13 +1075,13 @@ static int select_all_exec(bContext *C, wmOperator *op) } } - if(TRACK_VIEW_SELECTED(sc, track)) + if (TRACK_VIEW_SELECTED(sc, track)) has_selection= 1; track= track->next; } - if(!has_selection) + if (!has_selection) sc->flag&= ~SC_LOCK_SELECTION; WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -1107,44 +1119,44 @@ static int select_groped_exec(bContext *C, wmOperator *op) int group= RNA_enum_get(op->ptr, "group"); track= tracksbase->first; - while(track) { + while (track) { int ok= 0; marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(group==0) { /* Keyframed */ + if (group==0) { /* Keyframed */ ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED)==0; } - else if(group==1) { /* Estimated */ + else if (group==1) { /* Estimated */ ok= marker->framenr!=sc->user.framenr; } - else if(group==2) { /* tracked */ + else if (group==2) { /* tracked */ ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED); } - else if(group==3) { /* locked */ + else if (group==3) { /* locked */ ok= track->flag&TRACK_LOCKED; } - else if(group==4) { /* disabled */ + else if (group==4) { /* disabled */ ok= marker->flag&MARKER_DISABLED; } - else if(group==5) { /* color */ + else if (group==5) { /* color */ MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { ok= (track->flag&TRACK_CUSTOMCOLOR) == (act_track->flag&TRACK_CUSTOMCOLOR); - if(ok && track->flag&TRACK_CUSTOMCOLOR) + if (ok && track->flag&TRACK_CUSTOMCOLOR) ok= equals_v3v3(track->color, act_track->color); } } - else if(group==6) { /* failed */ + else if (group==6) { /* failed */ ok= (track->flag&TRACK_HAS_BUNDLE) == 0; } - if(ok) { + if (ok) { track->flag|= SELECT; - if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT; - if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT; + if (sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT; + if (sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT; } track= track->next; @@ -1211,8 +1223,8 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) int framenr= sc->user.framenr; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); if (!marker || (marker->flag&MARKER_DISABLED) == 0) @@ -1239,7 +1251,7 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) if (hidden) { MovieTrackingTrack *track = tracksbase->first; - while(track) { + while (track) { if ((track->flag & TRACK_HIDDEN) == 0) BKE_tracking_track_flag(track, hidden, SELECT, 1); @@ -1258,13 +1270,13 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit clear_invisible_track_selection(sc, clip); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { - if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { + if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { BKE_tracking_ensure_marker(track, framenr); - if(track->frames_limit) { - if(frames_limit==0) + if (track->frames_limit) { + if (frames_limit==0) frames_limit= track->frames_limit; else frames_limit= MIN2(frames_limit, track->frames_limit); @@ -1280,11 +1292,11 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit static int track_markers_check_direction(int backwards, int curfra, int efra) { - if(backwards) { - if(curfraefra) return 0; + if (curfra>efra) return 0; } return 1; @@ -1304,21 +1316,21 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward tmj->clip= clip; tmj->backwards= backwards; - if(backwards) tmj->efra= SFRA; + if (backwards) tmj->efra= SFRA; else tmj->efra= EFRA; /* limit frames to be tracked by user setting */ - if(frames_limit) { - if(backwards) tmj->efra= MAX2(tmj->efra, tmj->sfra-frames_limit); + if (frames_limit) { + if (backwards) tmj->efra= MAX2(tmj->efra, tmj->sfra-frames_limit); else tmj->efra= MIN2(tmj->efra, tmj->sfra+frames_limit); } - if(settings->speed!=TRACKING_SPEED_FASTEST) { + if (settings->speed!=TRACKING_SPEED_FASTEST) { tmj->delay= 1.0f/scene->r.frs_sec*1000.0f; - if(settings->speed==TRACKING_SPEED_HALF) tmj->delay*= 2; - else if(settings->speed==TRACKING_SPEED_QUARTER) tmj->delay*= 4; - else if(settings->speed==TRACKING_SPEED_DOUBLE) tmj->delay/= 2; + if (settings->speed==TRACKING_SPEED_HALF) tmj->delay*= 2; + else if (settings->speed==TRACKING_SPEED_QUARTER) tmj->delay*= 4; + else if (settings->speed==TRACKING_SPEED_DOUBLE) tmj->delay/= 2; } tmj->context= BKE_tracking_context_new(clip, &sc->user, backwards, 1); @@ -1345,8 +1357,8 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo int framenr= tmj->sfra; //double t= PIL_check_seconds_timer(); - while(framenr != tmj->efra) { - if(tmj->delay>0) { + while (framenr != tmj->efra) { + if (tmj->delay>0) { /* tracking should happen with fixed fps. Calculate time * using current timer value before tracking frame and after. * @@ -1355,24 +1367,25 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo double start_time= PIL_check_seconds_timer(), exec_time; - if(!BKE_tracking_next(tmj->context)) + if (!BKE_tracking_next(tmj->context)) break; exec_time= PIL_check_seconds_timer()-start_time; - if(tmj->delay > (float)exec_time) + if (tmj->delay > (float)exec_time) PIL_sleep_ms(tmj->delay-(float)exec_time); - } else if(!BKE_tracking_next(tmj->context)) + } + else if (!BKE_tracking_next(tmj->context)) break; *do_update= 1; *progress=(float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); - if(tmj->backwards) framenr--; + if (tmj->backwards) framenr--; else framenr++; tmj->lastfra= framenr; - if(*stop || track_markers_testbreak()) + if (*stop || track_markers_testbreak()) break; } @@ -1414,34 +1427,34 @@ static int track_markers_exec(bContext *C, wmOperator *op) int sequence= RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if(track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip)==0) return OPERATOR_CANCELLED; track_init_markers(sc, clip, &frames_limit); - if(backwards) efra= SFRA; + if (backwards) efra= SFRA; else efra= EFRA; /* limit frames to be tracked by user setting */ - if(frames_limit) { - if(backwards) efra= MAX2(efra, sfra-frames_limit); + if (frames_limit) { + if (backwards) efra= MAX2(efra, sfra-frames_limit); else efra= MIN2(efra, sfra+frames_limit); } - if(!track_markers_check_direction(backwards, framenr, efra)) + if (!track_markers_check_direction(backwards, framenr, efra)) return OPERATOR_CANCELLED; /* do not disable tracks due to threshold when tracking frame-by-frame */ context= BKE_tracking_context_new(clip, &sc->user, backwards, sequence); - while(framenr != efra) { - if(!BKE_tracking_next(context)) + while (framenr != efra) { + if (!BKE_tracking_next(context)) break; - if(backwards) framenr--; + if (backwards) framenr--; else framenr++; - if(!sequence) + if (!sequence) break; } @@ -1467,22 +1480,22 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve int backwards= RNA_boolean_get(op->ptr, "backwards"); int sequence= RNA_boolean_get(op->ptr, "sequence"); - if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { /* only one tracking is allowed at a time */ return OPERATOR_CANCELLED; } - if(clip->tracking_context) + if (clip->tracking_context) return OPERATOR_CANCELLED; - if(track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip)==0) return OPERATOR_CANCELLED; - if(!sequence) + if (!sequence) return track_markers_exec(C, op); tmj= MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); - if(!track_markers_initjob(C, tmj, backwards)) { + if (!track_markers_initjob(C, tmj, backwards)) { track_markers_freejob(tmj); return OPERATOR_CANCELLED; @@ -1496,7 +1509,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ - if(tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); + if (tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); else WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0); WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); @@ -1515,7 +1528,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running tracking, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running tracking */ @@ -1573,7 +1586,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op MovieTrackingObject *object= BKE_tracking_active_object(tracking); int width, height; - if(!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error)) + if (!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error)) return 0; /* could fail if footage uses images with different sizes */ @@ -1616,7 +1629,7 @@ static void solve_camera_freejob(void *scv) MovieClip *clip= scj->clip; int solved; - if(!scj->context) { + if (!scj->context) { /* job weren't fully initialized due to some error */ MEM_freeN(scj); return; @@ -1624,20 +1637,20 @@ static void solve_camera_freejob(void *scv) solved= BKE_tracking_finish_reconstruction(scj->context, tracking); - if(!solved) + if (!solved) BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details"); else BKE_reportf(scj->reports, RPT_INFO, "Average re-projection error %.3f", tracking->reconstruction.error); /* set currently solved clip as active for scene */ - if(scene->clip) + if (scene->clip) id_us_min(&clip->id); scene->clip= clip; id_us_plus(&clip->id); /* set blender camera focal length so result would look fine there */ - if(scene->camera) { + if (scene->camera) { Camera *camera= (Camera*)scene->camera->data; int width, height; @@ -1669,8 +1682,8 @@ static int solve_camera_exec(bContext *C, wmOperator *op) char error_msg[256]= "\0"; scj= MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); - if(!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { - if(error_msg[0]) + if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { + if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); solve_camera_freejob(scj); @@ -1696,14 +1709,14 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even wmJob *steve; char error_msg[256]= "\0"; - if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { /* only one solve is allowed at a time */ return OPERATOR_CANCELLED; } scj= MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); - if(!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { - if(error_msg[0]) + if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { + if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); solve_camera_freejob(scj); @@ -1737,7 +1750,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running solver, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running tracking */ @@ -1778,13 +1791,13 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking); MovieTrackingTrack *track= tracksbase->first; - while(track) { + while (track) { track->flag&= ~TRACK_HAS_BUNDLE; track= track->next; } - if(reconstruction->cameras) + if (reconstruction->cameras) MEM_freeN(reconstruction->cameras); reconstruction->cameras= NULL; @@ -1832,8 +1845,8 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } else { track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) BKE_tracking_clear_path(track, sc->user.framenr, action); track= track->next; @@ -1882,12 +1895,12 @@ static int disable_markers_exec(bContext *C, wmOperator *op) MovieTrackingTrack *track= tracksbase->first; int action= RNA_enum_get(op->ptr, "action"); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr); - if(action==0) marker->flag|= MARKER_DISABLED; - else if(action==1) marker->flag&= ~MARKER_DISABLED; + if (action==0) marker->flag|= MARKER_DISABLED; + else if (action==1) marker->flag&= ~MARKER_DISABLED; else marker->flag^= MARKER_DISABLED; } @@ -1933,13 +1946,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera= scene->camera; Base *base; - if(camera && object_get_movieclip(scene, camera, 0)==clip) + if (camera && object_get_movieclip(scene, camera, 0)==clip) return camera; base= scene->base.first; - while(base) { - if(base->object->type == OB_CAMERA) { - if(object_get_movieclip(scene, base->object, 0)==clip) { + while (base) { + if (base->object->type == OB_CAMERA) { + if (object_get_movieclip(scene, base->object, 0)==clip) { camera= base->object; break; } @@ -1960,14 +1973,14 @@ static Object *get_orientation_object(bContext *C) MovieTrackingObject *tracking_object= BKE_tracking_active_object(tracking); Object *object= NULL; - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { object= get_camera_with_movieclip(scene, clip); } else { object= OBACT; } - if(object && object->parent) + if (object && object->parent) object= object->parent; return object; @@ -1975,14 +1988,14 @@ static Object *get_orientation_object(bContext *C) static int set_orientation_poll(bContext *C) { - if(space_clip_frame_poll(C)) { + if (space_clip_frame_poll(C)) { Scene *scene= CTX_data_scene(C); SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; MovieTrackingObject *tracking_object= BKE_tracking_active_object(tracking); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { return 1; } else { @@ -2002,8 +2015,8 @@ static int count_selected_bundles(bContext *C) int tot= 0; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) tot++; track= track->next; @@ -2020,13 +2033,13 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat for (con= ob->constraints.first; con; con=con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - if(!cti) + if (!cti) continue; - if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { + if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; - if(!found) { + if (!found) { Object *cam= data->camera ? data->camera : scene->camera; where_is_object_mat(scene, cam, invmat); @@ -2038,7 +2051,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat } } - if(found) + if (found) invert_m4(invmat); else unit_m4(invmat); @@ -2051,10 +2064,10 @@ static Object *object_solver_camera(Scene *scene, Object *ob) for (con= ob->constraints.first; con; con=con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - if(!cti) + if (!cti) continue; - if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { + if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; return data->camera ? data->camera : scene->camera; @@ -2078,14 +2091,14 @@ static int set_origin_exec(bContext *C, wmOperator *op) float mat[4][4], vec[3], median[3]; int selected_count= count_selected_bundles(C); - if(selected_count==0) { + if (selected_count==0) { BKE_report(op->reports, RPT_ERROR, "At least one track with bundle should be selected to define origin position"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2097,8 +2110,8 @@ static int set_origin_exec(bContext *C, wmOperator *op) track= tracksbase->first; zero_v3(median); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) { add_v3_v3(median, track->bundle_pos); } @@ -2110,7 +2123,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) mul_v3_m4v3(vec, mat, median); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { sub_v3_v3(object->loc, vec); } else { @@ -2162,7 +2175,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb mul_v3_m4v3(vec, mat, track->bundle_pos); copy_v3_v3(dvec, vec); - if(!is_camera) { + if (!is_camera) { float imat[4][4]; object_solver_inverted_matrix(scene, ob, imat); @@ -2174,22 +2187,23 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb sub_v3_v3(vec, obmat[3]); } - if(len_v2(vec) < 1e-3f) + if (len_v2(vec) < 1e-3f) return; unit_m4(mat); - if(axis=='X') { - if(fabsf(dvec[1])<1e-3f) { + if (axis=='X') { + if (fabsf(dvec[1])<1e-3f) { flip= 1; mat[0][0]= -1.0f; mat[0][1]= 0.0f; mat[0][2]= 0.0f; mat[1][0]= 0.0f; mat[1][1]= -1.0f; mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; - } else { + } + else { copy_v3_v3(mat[0], vec); - if(is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2])<1e-3f) { mat[0][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; cross_v3_v3v3(mat[1], mat[2], mat[0]); @@ -2201,17 +2215,19 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb cross_v3_v3v3(mat[2], mat[0], mat[1]); } } - } else { - if(fabsf(dvec[0])<1e-3f) { + } + else { + if (fabsf(dvec[0])<1e-3f) { flip= 1; mat[0][0]= -1.0f; mat[0][1]= 0.0f; mat[0][2]= 0.0f; mat[1][0]= 0.0f; mat[1][1]= -1.0f; mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; - } else { + } + else { copy_v3_v3(mat[1], vec); - if(is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2])<1e-3f) { mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; cross_v3_v3v3(mat[0], mat[1], mat[2]); @@ -2229,13 +2245,13 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb normalize_v3(mat[1]); normalize_v3(mat[2]); - if(is_camera) { + if (is_camera) { invert_m4(mat); mult_m4_m4m4(mat, mat, obmat); } else { - if(!flip) { + if (!flip) { float lmat[4][4], ilmat[4][4], rmat[3][3]; object_rot_to_mat3(ob, rmat); @@ -2275,7 +2291,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ - if(count_selected_bundles(C)!=3) { + if (count_selected_bundles(C)!=3) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); return OPERATOR_CANCELLED; @@ -2286,7 +2302,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) act_track= BKE_tracking_active_track(tracking); object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2296,11 +2312,11 @@ static int set_plane_exec(bContext *C, wmOperator *op) /* get 3 bundles to use as reference */ track= tracksbase->first; - while(track && tot<3) { - if(track->flag&TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { + while (track && tot<3) { + if (track->flag&TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); - if(tot==0 || track==act_track) + if (tot==0 || track==act_track) copy_v3_v3(orig, vec[tot]); else axis_track= track; @@ -2337,7 +2353,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) mat[3][1]= orig[1]; mat[3][2]= orig[2]; - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { invert_m4(mat); object_to_mat4(object, obmat); @@ -2346,7 +2362,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ - if(object->loc[2]<0) { + if (object->loc[2]<0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); object_apply_mat4(object, newmat, 0, 0); @@ -2406,14 +2422,14 @@ static int set_axis_exec(bContext *C, wmOperator *op) ListBase *tracksbase; int axis= RNA_enum_get(op->ptr, "axis"); - if(count_selected_bundles(C)!=1) { + if (count_selected_bundles(C)!=1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2422,8 +2438,8 @@ static int set_axis_exec(bContext *C, wmOperator *op) tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); track=tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) break; track= track->next; @@ -2481,14 +2497,14 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) float vec[2][3], mat[4][4], scale; float dist= RNA_float_get(op->ptr, "distance"); - if(count_selected_bundles(C)!=2) { + if (count_selected_bundles(C)!=2) { BKE_report(op->reports, RPT_ERROR, "Two tracks with bundles should be selected to set scale"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2497,8 +2513,8 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) BKE_get_tracking_mat(scene, camera, mat); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); tot++; } @@ -2508,19 +2524,19 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) sub_v3_v3(vec[0], vec[1]); - if(len_v3(vec[0])>1e-5f) { + if (len_v3(vec[0])>1e-5f) { scale= dist / len_v3(vec[0]); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { mul_v3_fl(object->size, scale); mul_v3_fl(object->loc, scale); } - else if(!scale_solution){ + else if (!scale_solution) { Object *solver_camera= object_solver_camera(scene, object); object->size[0]= object->size[1]= object->size[2]= 1.0f/scale; - if(solver_camera) { + if (solver_camera) { object->size[0]/= solver_camera->size[0]; object->size[1]/= solver_camera->size[1]; object->size[2]/= solver_camera->size[2]; @@ -2532,7 +2548,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) DAG_id_tag_update(&clip->id, 0); - if(object) + if (object) DAG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); @@ -2552,7 +2568,7 @@ static int set_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "distance")) + if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist); return set_scale_exec(C, op); @@ -2582,7 +2598,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) static int set_solution_scale_poll(bContext *C) { - if(space_clip_frame_poll(C)) { + if (space_clip_frame_poll(C)) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; @@ -2604,7 +2620,7 @@ static int set_solution_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "distance")) + if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.object_distance); return set_solution_scale_exec(C, op); @@ -2640,7 +2656,7 @@ static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if(width==0 || height==0) + if (width==0 || height==0) return OPERATOR_CANCELLED; clip->tracking.camera.principal[0]= ((float)width)/2.0f; @@ -2681,20 +2697,21 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) unselected= RNA_boolean_get(op->ptr, "unselected"); track= tracksbase->first; - while(track) { - if(unselected==0 && TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (unselected==0 && TRACK_VIEW_SELECTED(sc, track)) { track->flag|= TRACK_HIDDEN; - } else if(unselected==1 && !TRACK_VIEW_SELECTED(sc, track)) { + } + else if (unselected==1 && !TRACK_VIEW_SELECTED(sc, track)) { track->flag|= TRACK_HIDDEN; } track= track->next; } - if(act_track && act_track->flag&TRACK_HIDDEN) + if (act_track && act_track->flag&TRACK_HIDDEN) clip->tracking.act_track= NULL; - if(unselected==0) { + if (unselected==0) { /* no selection on screen now, unlock view so it can be scrolled nice again */ sc->flag&= ~SC_LOCK_SELECTION; } @@ -2732,7 +2749,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingTrack *track; track= tracksbase->first; - while(track) { + while (track) { track->flag&= ~TRACK_HIDDEN; track= track->next; @@ -2764,12 +2781,12 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) { bGPDlayer *layer; - if(!clip->gpd) + if (!clip->gpd) return NULL; layer= clip->gpd->layers.first; - while(layer) { - if(layer->flag&GP_LAYER_ACTIVE) + while (layer) { + if (layer->flag&GP_LAYER_ACTIVE) return layer; layer= layer->next; @@ -2794,13 +2811,13 @@ static int detect_features_exec(bContext *C, wmOperator *op) int place_outside_layer= 0; bGPDlayer *layer= NULL; - if(placement!=0) { + if (placement!=0) { layer= detect_get_layer(clip); place_outside_layer= placement==2; } /* deselect existing tracks */ - while(track) { + while (track) { track->flag&= ~SELECT; track->pat_flag&= ~SELECT; track->search_flag&= ~SELECT; @@ -2857,25 +2874,25 @@ static int frame_jump_exec(bContext *C, wmOperator *op) int pos= RNA_enum_get(op->ptr, "position"); int delta; - if(pos<=1) { /* jump to path */ + if (pos<=1) { /* jump to path */ track= BKE_tracking_active_track(&clip->tracking); - if(!track) + if (!track) return OPERATOR_CANCELLED; delta= pos == 1 ? 1 : -1; - while(sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { + while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, sc->user.framenr+delta); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; sc->user.framenr+= delta; } } else { /* to to failed frame */ - if(clip->tracking.reconstruction.flag&TRACKING_RECONSTRUCTED) { + if (clip->tracking.reconstruction.flag&TRACKING_RECONSTRUCTED) { int a= sc->user.framenr; MovieTracking *tracking= &clip->tracking; MovieTrackingObject *object= BKE_tracking_active_object(tracking); @@ -2884,12 +2901,12 @@ static int frame_jump_exec(bContext *C, wmOperator *op) a+= delta; - while(a+delta >= SFRA && a+delta <= EFRA) { + while (a+delta >= SFRA && a+delta <= EFRA) { MovieReconstructedCamera *cam; cam= BKE_tracking_get_reconstructed_camera(tracking, object, a); - if(!cam) { + if (!cam) { sc->user.framenr= a; break; @@ -2900,7 +2917,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) } } - if(CFRA!=sc->user.framenr) { + if (CFRA!=sc->user.framenr) { CFRA= sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); @@ -2950,19 +2967,19 @@ static int join_tracks_exec(bContext *C, wmOperator *op) act_track= BKE_tracking_active_track(tracking); - if(!act_track) { + if (!act_track) { BKE_report(op->reports, RPT_ERROR, "No active track to join to"); return OPERATOR_CANCELLED; } track= tracksbase->first; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { + if (TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { BKE_tracking_join_tracks(act_track, track); - if(tracking->stabilization.rot_track == track) + if (tracking->stabilization.rot_track == track) tracking->stabilization.rot_track= act_track; BKE_tracking_free_track(track); @@ -3003,10 +3020,10 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) MovieTrackingTrack *track= tracksbase->first; int action= RNA_enum_get(op->ptr, "action"); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { - if(action==0) track->flag|= TRACK_LOCKED; - else if(action==1) track->flag&= ~TRACK_LOCKED; + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { + if (action==0) track->flag|= TRACK_LOCKED; + else if (action==1) track->flag&= ~TRACK_LOCKED; else track->flag^= TRACK_LOCKED; } @@ -3053,15 +3070,15 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track, *act_track= BKE_tracking_active_track(tracking); - if(!act_track) + if (!act_track) return OPERATOR_CANCELLED; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { track->flag&= ~TRACK_CUSTOMCOLOR; - if(act_track->flag&TRACK_CUSTOMCOLOR) { + if (act_track->flag&TRACK_CUSTOMCOLOR) { copy_v3_v3(track->color, act_track->color); track->flag|= TRACK_CUSTOMCOLOR; } @@ -3103,8 +3120,8 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) int update= 0; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_USE_2D_STAB)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_USE_2D_STAB)==0) { track->flag|= TRACK_USE_2D_STAB; stab->tot_track++; @@ -3114,7 +3131,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) { + if (update) { stab->ok= 0; DAG_id_tag_update(&clip->id, 0); @@ -3152,15 +3169,15 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) int a= 0, update= 0; track= tracksbase->first; - while(track) { - if(track->flag&TRACK_USE_2D_STAB) { - if(a==stab->act_track) { + while (track) { + if (track->flag&TRACK_USE_2D_STAB) { + if (a==stab->act_track) { track->flag&= ~TRACK_USE_2D_STAB; stab->act_track--; stab->tot_track--; - if(stab->act_track<0) + if (stab->act_track<0) stab->act_track= 0; update= 1; @@ -3174,7 +3191,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) { + if (update) { stab->ok= 0; DAG_id_tag_update(&clip->id, 0); @@ -3211,8 +3228,8 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) int update= 0; track= tracksbase->first; - while(track) { - if(track->flag&TRACK_USE_2D_STAB) { + while (track) { + if (track->flag&TRACK_USE_2D_STAB) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0); update= 1; @@ -3221,7 +3238,7 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) + if (update) WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); return OPERATOR_FINISHED; @@ -3251,7 +3268,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) MovieTracking *tracking= &clip->tracking; MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { MovieTrackingStabilization *stab= &tracking->stabilization; stab->rot_track= act_track; @@ -3288,53 +3305,53 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) int start_disabled= 0; int markersnr= track->markersnr; - if(del) + if (del) new_markers= MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for(a= 0; a= 0) { + if (prev >= 0) { end= a == markersnr-1; end|= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || markers[a].flag&MARKER_DISABLED); } - if(end) { + if (end) { int segok= 1, len= 0; - if(a != prev && markers[a].framenr != markers[a-1].framenr+1) + if (a != prev && markers[a].framenr != markers[a-1].framenr+1) len= a-prev; - else if(markers[a].flag&MARKER_DISABLED) + else if (markers[a].flag&MARKER_DISABLED) len= a-prev; else len= a-prev+1; - if(frames) { - if(len < frames) { + if (frames) { + if (len < frames) { segok= 0; ok= 0; - if(!del) + if (!del) break; } } - if(del) { - if(segok) { + if (del) { + if (segok) { int t= len; - if(markers[a].flag&MARKER_DISABLED) + if (markers[a].flag&MARKER_DISABLED) t++; /* place disabled marker in front of current segment */ - if(start_disabled) { + if (start_disabled) { memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; new_markers[count].flag|= MARKER_DISABLED; @@ -3346,7 +3363,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); count+= t; } - else if(markers[a].flag&MARKER_DISABLED) { + else if (markers[a].flag&MARKER_DISABLED) { /* current segment which would be deleted was finished by disabled marker, * so next segment should be started from disabled marker */ start_disabled= 1; @@ -3357,10 +3374,10 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) } } - if(del) { + if (del) { MEM_freeN(track->markers); - if(count) { + if (count) { track->markers= new_markers; } else { @@ -3385,25 +3402,25 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) int action= RNA_enum_get(op->ptr, "action"); float error= RNA_float_get(op->ptr, "error"); - if(error && action==TRACKING_CLEAN_DELETE_SEGMENT) + if (error && action==TRACKING_CLEAN_DELETE_SEGMENT) action= TRACKING_CLEAN_DELETE_TRACK; track= tracksbase->first; - while(track) { + while (track) { next= track->next; - if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { + if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { int ok= 1; ok= (is_track_clean(track, frames, action==TRACKING_CLEAN_DELETE_SEGMENT)) && (error == 0.0f || (track->flag&TRACK_HAS_BUNDLE)==0 || track->error < error); - if(!ok) { - if(action==TRACKING_CLEAN_SELECT) { + if (!ok) { + if (action==TRACKING_CLEAN_SELECT) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0); } - else if(action==TRACKING_CLEAN_DELETE_TRACK) { - if(track==act_track) + else if (action==TRACKING_CLEAN_DELETE_TRACK) { + if (track==act_track) clip->tracking.act_track= NULL; BKE_tracking_free_track(track); @@ -3412,8 +3429,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) } /* happens when all tracking segments are not long enough */ - if(track && track->markersnr==0) { - if(track==act_track) + if (track && track->markersnr==0) { + if (track==act_track) clip->tracking.act_track= NULL; BKE_tracking_free_track(track); @@ -3435,13 +3452,13 @@ static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "frames")) + if (!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); - if(!RNA_struct_property_is_set(op->ptr, "error")) + if (!RNA_struct_property_is_set(op->ptr, "error")) RNA_float_set(op->ptr, "error", clip->tracking.settings.clean_error); - if(!RNA_struct_property_is_set(op->ptr, "action")) + if (!RNA_struct_property_is_set(op->ptr, "action")) RNA_enum_set(op->ptr, "action", clip->tracking.settings.clean_action); return clean_tracks_exec(C, op); @@ -3516,7 +3533,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) object= BKE_tracking_active_object(tracking); - if(object->flag&TRACKING_OBJECT_CAMERA) { + if (object->flag&TRACKING_OBJECT_CAMERA) { BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking can't be deleted"); return OPERATOR_CANCELLED; } -- cgit v1.2.3