diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-26 03:19:21 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-26 03:19:21 +0400 |
commit | 1ce2c73816be97f72484ffa40a3187b24968c6b3 (patch) | |
tree | ea78a78c854a20a6a959ba979c29a6f3823f1955 /source/blender/editors | |
parent | 4457e85442eea30bc6166e15da040188e77b5be7 (diff) |
Code style cleaup for motion-tracking modules.
Should be no functional changes.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_clip/clip_buttons.c | 148 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 727 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 128 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_draw.c | 72 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 161 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 291 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_toolbar.c | 80 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_utils.c | 82 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 308 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 1604 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 137 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 10 |
14 files changed, 1953 insertions, 1805 deletions
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index bb816d1b8b2..eabd64bdc4f 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -67,11 +67,11 @@ void ED_clip_buttons_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil"); + pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil"); strcpy(pt->idname, "CLIP_PT_gpencil"); strcpy(pt->label, "Grease Pencil"); - pt->draw= gpencil_panel_standard; - pt->flag|= PNL_DEFAULT_CLOSED; + pt->draw = gpencil_panel_standard; + pt->flag |= PNL_DEFAULT_CLOSED; BLI_addtail(&art->paneltypes, pt); } @@ -88,7 +88,7 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c if (!ptr->data) return; - prop= RNA_struct_find_property(ptr, propname); + prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); @@ -101,8 +101,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c return; } - clipptr= RNA_property_pointer_get(ptr, prop); - clip= clipptr.data; + clipptr = RNA_property_pointer_get(ptr, prop); + clip = clipptr.data; uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr); @@ -110,13 +110,13 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, 0); split = uiLayoutSplit(row, 0.0, 0); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, 1); uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); @@ -136,7 +136,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) if (!ptr->data) return; - prop= RNA_struct_find_property(ptr, propname); + prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); @@ -149,15 +149,15 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) return; } - scopesptr= RNA_property_pointer_get(ptr, prop); - scopes= (MovieClipScopes *)scopesptr.data; + scopesptr = RNA_property_pointer_get(ptr, prop); + scopes = (MovieClipScopes *)scopesptr.data; rect.xmin = 0; rect.xmax = 200; rect.ymin = 0; rect.ymax = 120; - block= uiLayoutAbsoluteBlock(layout); + block = uiLayoutAbsoluteBlock(layout); - scopes->track_preview_height= (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height; + scopes->track_preview_height = (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height; uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } @@ -189,89 +189,89 @@ typedef struct { static void to_pixel_space(float r[2], float a[2], int width, int height) { copy_v2_v2(r, a); - r[0]*= width; - r[1]*= height; + r[0] *= width; + r[1] *= height; } static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) { - MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb; + MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb; MovieTrackingMarker *marker; if (!cb->compact) return; - marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); + marker = BKE_tracking_ensure_marker(cb->track, cb->framenr); - marker->flag= cb->marker_flag; + marker->flag = cb->marker_flag; WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); } static void marker_block_handler(bContext *C, void *arg_cb, int event) { - MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb; + MarkerUpdateCb *cb = (MarkerUpdateCb*) arg_cb; MovieTrackingMarker *marker; - int width, height, ok= 0; + int width, height, ok = FALSE; BKE_movieclip_get_size(cb->clip, cb->user, &width, &height); - marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); + marker = BKE_tracking_ensure_marker(cb->track, cb->framenr); - if (event==B_MARKER_POS) { - marker->pos[0]= cb->marker_pos[0]/width; - marker->pos[1]= cb->marker_pos[1]/height; + if (event == B_MARKER_POS) { + marker->pos[0] = cb->marker_pos[0]/width; + marker->pos[1] = cb->marker_pos[1]/height; /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); - ok= 1; + ok = TRUE; } - 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); - dim[0]= cb->track_pat[0]/width; - dim[1]= cb->track_pat[1]/height; + dim[0] = cb->track_pat[0] / width; + dim[1] = cb->track_pat[1] / height; sub_v2_v2(dim, pat_dim); mul_v2_fl(dim, 0.5f); - cb->track->pat_min[0]-= dim[0]; - cb->track->pat_min[1]-= dim[1]; + cb->track->pat_min[0] -= dim[0]; + cb->track->pat_min[1] -= dim[1]; - cb->track->pat_max[0]+= dim[0]; - cb->track->pat_max[1]+= dim[1]; + cb->track->pat_max[0] += dim[0]; + cb->track->pat_max[1] += dim[1]; BKE_tracking_clamp_track(cb->track, CLAMP_PAT_DIM); - ok= 1; + ok = TRUE; } - 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); mul_v2_fl(side, 0.5f); - delta[0]= cb->track_search_pos[0]/width; - delta[1]= cb->track_search_pos[1]/height; + delta[0] = cb->track_search_pos[0] / width; + delta[1] = cb->track_search_pos[1] / height; sub_v2_v2v2(cb->track->search_min, delta, side); add_v2_v2v2(cb->track->search_max, delta, side); BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_POS); - ok= 1; + ok = TRUE; } - 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); - dim[0]= cb->track_search[0]/width; - dim[1]= cb->track_search[1]/height; + dim[0] = cb->track_search[0]/width; + dim[1] = cb->track_search[1]/height; sub_v2_v2(dim, search_dim); mul_v2_fl(dim, 0.5f); @@ -284,31 +284,31 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); - ok= 1; + ok = TRUE; } - else if (event==B_MARKER_FLAG) { - marker->flag= cb->marker_flag; + else if (event == B_MARKER_FLAG) { + marker->flag = cb->marker_flag; - ok= 1; + ok = TRUE; } - else if (event==B_MARKER_OFFSET) { + else if (event == B_MARKER_OFFSET) { float offset[2], delta[2]; int i; - offset[0]= cb->track_offset[0]/width; - offset[1]= cb->track_offset[1]/height; + offset[0] = cb->track_offset[0] / width; + offset[1] = cb->track_offset[1] / height; sub_v2_v2v2(delta, offset, cb->track->offset); copy_v2_v2(cb->track->offset, offset); - for (i=0; i<cb->track->markersnr; i++) + for (i = 0; i < cb->track->markersnr; i++) sub_v2_v2(cb->track->markers[i].pos, delta); /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); - ok= 1; + ok = TRUE; } if (ok) @@ -331,7 +331,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P if (!ptr->data) return; - prop= RNA_struct_find_property(ptr, propname); + prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); @@ -344,30 +344,30 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P return; } - clipptr= RNA_property_pointer_get(ptr, prop); - clip= (MovieClip *)clipptr.data; - user= userptr->data; - track= trackptr->data; + clipptr = RNA_property_pointer_get(ptr, prop); + clip = (MovieClip *)clipptr.data; + user = userptr->data; + track = trackptr->data; - marker= BKE_tracking_get_marker(track, user->framenr); + marker = BKE_tracking_get_marker(track, user->framenr); - cb= MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb"); - cb->compact= compact; - cb->clip= clip; - cb->user= user; - cb->track= track; - cb->marker_flag= marker->flag; - cb->framenr= user->framenr; + cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb"); + cb->compact = compact; + cb->clip = clip; + cb->user = user; + cb->track = track; + cb->marker_flag = marker->flag; + cb->framenr = user->framenr; if (compact) { - block= uiLayoutGetBlock(layout); + 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); + 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 { @@ -377,16 +377,16 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P BKE_movieclip_get_size(clip, user, &width, &height); - if (track->flag&TRACK_LOCKED) { + if (track->flag & TRACK_LOCKED) { uiLayoutSetActive(layout, 0); - block= uiLayoutAbsoluteBlock(layout); + block = uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); return; } step= 100; - digits= 2; + digits = 2; sub_v2_v2v2(pat_dim, track->pat_max, track->pat_min); sub_v2_v2v2(search_dim, track->search_max, track->search_min); @@ -403,13 +403,13 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P to_pixel_space(cb->track_search_pos, search_pos, width, height); to_pixel_space(cb->track_offset, track->offset, width, height); - cb->marker_flag= marker->flag; + cb->marker_flag = marker->flag; block= uiLayoutAbsoluteBlock(layout); 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"; @@ -417,10 +417,10 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag, 0, 0, 0, 0, tip); - col= uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, 1); uiLayoutSetActive(col, (cb->marker_flag&MARKER_DISABLED)==0); - block= uiLayoutAbsoluteBlock(col); + block = uiLayoutAbsoluteBlock(col); uiBlockBeginAlign(block); uiDefBut(block, LABEL, 0, "Position:", 0, 190, 300, 19, NULL, 0, 0, 0, 0, ""); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index ef83a62c290..019b23c231b 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -73,8 +73,8 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) { - uiStyle *style= UI_GetStyle(); - int fontid= style->widget.uifont_id; + uiStyle *style = UI_GetStyle(); + int fontid = style->widget.uifont_id; char numstr[32]; float font_dims[2] = {0.0f, 0.0f}; @@ -95,9 +95,9 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc { float x; int *points, totseg, i, a; - float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); - MovieTrackingTrack *act_track= BKE_tracking_active_track(&clip->tracking); - MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(&clip->tracking); + float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); + MovieTrackingTrack *act_track = BKE_tracking_active_track(&clip->tracking); + MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(&clip->tracking); glEnable(GL_BLEND); @@ -110,11 +110,11 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc if (totseg) { glColor4ub(128, 128, 255, 128); - for (a= 0; a<totseg; a++) { + for (a = 0; a < totseg; a++) { float x1, x2; - x1= (points[a*2]-sfra)/(efra-sfra+1)*ar->winx; - x2= (points[a*2+1]-sfra+1)/(efra-sfra+1)*ar->winx; + x1 = (points[a * 2] - sfra) / (efra - sfra + 1) * ar->winx; + x2 = (points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * ar->winx; glRecti(x1, 0, x2, 8); } @@ -122,53 +122,58 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc /* track */ if (act_track) { - MovieTrackingTrack *track= 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 (a<track->markersnr) { - if (track->markers[a].framenr>=i) + if (track->markers[a].framenr >= i) break; - if (a<track->markersnr-1 && track->markers[a+1].framenr>i) + if (a < track->markersnr - 1 && track->markers[a + 1].framenr > i) break; a++; } - if (a<track->markersnr) marker= &track->markers[a]; - else marker= &track->markers[track->markersnr-1]; + if (a < track->markersnr) + marker = &track->markers[a]; + else + marker = &track->markers[track->markersnr - 1]; - if ((marker->flag&MARKER_DISABLED)==0) { - framenr= marker->framenr; + 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); - else glColor4ub(255, 255, 0, 96); + 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); + glRecti((i - sfra) * framelen, 0, (i - sfra + 1)*framelen, 4); } } } /* failed frames */ - if (reconstruction->flag&TRACKING_RECONSTRUCTED) { - int n= reconstruction->camnr; - MovieReconstructedCamera *cameras= reconstruction->cameras; + 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++) { - int ok= 0; + for (i = sfra, a = 0; i <= efra; i++) { + int ok = FALSE; - while (a<n) { - if (cameras[a].framenr==i) { - ok= 1; + while (a < n) { + if (cameras[a].framenr == i) { + ok = TRUE; break; } - else if (cameras[a].framenr>i) { + else if (cameras[a].framenr > i) { break; } @@ -176,14 +181,14 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } if (!ok) - glRecti((i-sfra)*framelen, 0, (i-sfra+1)*framelen, 8); + glRecti((i - sfra) * framelen, 0, (i - sfra + 1) * framelen, 8); } } glDisable(GL_BLEND); /* current frame */ - x= (sc->user.framenr-sfra)/(efra-sfra+1)*ar->winx; + x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx; UI_ThemeColor(TH_CFRAME); glRecti(x, 0, x+framelen, 8); @@ -193,17 +198,17 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - char str[256]= {0}; - int block= 0; + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + char str[256] = {0}; + int block = FALSE; if (tracking->stats) { BLI_strncpy(str, tracking->stats->message, sizeof(str)); - block= 1; + block = TRUE; } else { - if (sc->flag&SC_LOCK_SELECTION) + if (sc->flag & SC_LOCK_SELECTION) strcpy(str, "Locked"); } @@ -212,10 +217,10 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) } static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, - int width, int height, float zoomx, float zoomy) + int width, int height, float zoomx, float zoomy) { int x, y; - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); /* set zoom */ glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y); @@ -223,9 +228,9 @@ 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); + glRectf(x, y, x + zoomx * width, y + zoomy * height); } else { if (ibuf->rect_float && !ibuf->rect) { @@ -237,7 +242,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, } /* 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); @@ -270,35 +275,35 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackingTrack *track) { - int count= sc->path_length; - int i, a, b, curindex= -1; + int count = sc->path_length; + int i, a, b, curindex = -1; float path[102][2]; - int tiny= sc->flag&SC_SHOW_TINY_MARKER, framenr; + 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) + marker = BKE_tracking_get_marker(track, sc->user.framenr); + if (marker->framenr != sc->user.framenr || marker->flag & MARKER_DISABLED) return; - framenr= marker->framenr; + framenr = marker->framenr; - a= count; - i= framenr-1; - while (i>=framenr-count) { - marker= BKE_tracking_get_marker(track, i); + a = count; + i = framenr - 1; + 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) - curindex= a; + if (marker->framenr == sc->user.framenr) + curindex = a; } else { break; @@ -307,16 +312,16 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin i--; } - b= count; - i= framenr; - while (i<=framenr+count) { - marker= BKE_tracking_get_marker(track, i); + b = count; + i = framenr; + 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); @@ -334,8 +339,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (TRACK_VIEW_SELECTED(sc, track)) { glPointSize(5.0f); glBegin(GL_POINTS); - for (i= a; i<b; i++) { - if (i!=curindex) + for (i = a; i < b; i++) { + if (i != curindex) glVertex2f(path[i][0], path[i][1]); } glEnd(); @@ -343,7 +348,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin glLineWidth(3.0f); glBegin(GL_LINE_STRIP); - for (i= a; i<b; i++) + for (i = a; i < b; i++) glVertex2f(path[i][0], path[i][1]); glEnd(); glLineWidth(1.0f); @@ -354,11 +359,11 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (TRACK_VIEW_SELECTED(sc, track)) { glPointSize(3.0f); glBegin(GL_POINTS); - for (i= a; i<b; i++) { - if (i==count+1) + for (i = a; i < b; i++) { + if (i == count + 1) UI_ThemeColor(TH_PATH_AFTER); - if (i!=curindex) + if (i != curindex) glVertex2f(path[i][0], path[i][1]); } glEnd(); @@ -367,8 +372,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin UI_ThemeColor(TH_PATH_BEFORE); glBegin(GL_LINE_STRIP); - for (i= a; i<b; i++) { - if (i==count+1) + for (i = a; i < b; i++) { + if (i == count + 1) UI_ThemeColor(TH_PATH_AFTER); glVertex2f(path[i][0], path[i][1]); @@ -379,16 +384,16 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height) { - int tiny= sc->flag&SC_SHOW_TINY_MARKER; - int show_search= 0; + int tiny = sc->flag&SC_SHOW_TINY_MARKER; + int show_search = FALSE; float px[2]; UI_ThemeColor(TH_MARKER_OUTLINE); - px[0]= 1.0f/width/sc->zoom; - px[1]= 1.0f/height/sc->zoom; + px[0] = 1.0f / width / sc->zoom; + px[1] = 1.0f / height / sc->zoom; - if ((marker->flag&MARKER_DISABLED)==0) { + if ((marker->flag & MARKER_DISABLED) == 0) { float pos[2]; rctf r; @@ -428,9 +433,10 @@ 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]); @@ -439,8 +445,9 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT glEnd(); } - 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) { + 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) { glBegin(GL_LINE_LOOP); glVertex2f(track->search_min[0], track->search_min[1]); glVertex2f(track->search_max[0], track->search_min[1]); @@ -450,22 +457,27 @@ 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); - else copy_v3_v3(scol, track->color); + 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 { UI_GetThemeColor3fv(TH_MARKER, col); - if (act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); - else UI_GetThemeColor3fv(TH_SEL_MARKER, scol); + if (act) + UI_GetThemeColor3fv(TH_ACT_MARKER, scol); + else + UI_GetThemeColor3fv(TH_SEL_MARKER, scol); } } @@ -477,22 +489,27 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra track_colors(track, act, col, scol); - px[0]= 1.0f/width/sc->zoom; - px[1]= 1.0f/height/sc->zoom; + px[0]= 1.0f / width / sc->zoom; + 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); - else UI_ThemeColor(TH_LOCK_MARKER); + 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 glColor3fv(col); + if (track->flag & SELECT) + glColor3fv(scol); + else + glColor3fv(col); } BLI_init_rctf(&r, track->pat_min[0], track->pat_max[0], track->pat_min[1], track->pat_max[1]); @@ -500,11 +517,15 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra 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 (!tiny) + glPointSize(2.0f); + glBegin(GL_POINTS); glVertex2f(pos[0], pos[1]); glEnd(); - if (!tiny) glPointSize(1.0f); + + if (!tiny) + glPointSize(1.0f); } else { glBegin(GL_LINES); @@ -546,19 +567,24 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra 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); + if (track->pat_flag & SELECT) + glColor3fv(scol); else glColor3fv(col); } @@ -571,21 +597,28 @@ 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); + 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); 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 glColor3fv(col); + if (track->search_flag & SELECT) + glColor3fv(scol); + else + glColor3fv(col); } glBegin(GL_LINE_LOOP); @@ -597,20 +630,29 @@ 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 glColor3fv(col); + if (track->pat_flag & SELECT) + glColor3fv(scol); + else + glColor3fv(col); } { @@ -639,16 +681,16 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, - float marker_pos[2], int outline, int sel, int act, int width, int height) + float marker_pos[2], int outline, int sel, int act, int width, int height) { float x, y, dx, dy, patdx, patdy, searchdx, searchdy, tdx, tdy; - int tiny= sc->flag&SC_SHOW_TINY_MARKER; + 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); @@ -661,34 +703,36 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glPushMatrix(); glTranslatef(marker_pos[0], marker_pos[1], 0); - dx= 6.0f/width/sc->zoom; - dy= 6.0f/height/sc->zoom; + dx = 6.0f / width / sc->zoom; + dy = 6.0f / height / sc->zoom; - patdx= MIN2(dx*2.0f/3.0f, (track->pat_max[0]-track->pat_min[0])/6.0f); - patdy= MIN2(dy*2.0f/3.0f, (track->pat_max[1]-track->pat_min[1])/6.0f); + patdx = MIN2(dx * 2.0f / 3.0f, (track->pat_max[0] - track->pat_min[0]) / 6.0f); + patdy = MIN2(dy * 2.0f / 3.0f, (track->pat_max[1] - track->pat_min[1]) / 6.0f); - searchdx= MIN2(dx, (track->search_max[0]-track->search_min[0])/6.0f); - searchdy= MIN2(dy, (track->search_max[1]-track->search_min[1])/6.0f); + searchdx = MIN2(dx, (track->search_max[0] - track->search_min[0]) / 6.0f); + searchdy = MIN2(dy, (track->search_max[1] - track->search_min[1]) / 6.0f); - px[0]= 1.0f/sc->zoom/width/sc->scale; - px[1]= 1.0f/sc->zoom/height/sc->scale; + 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 ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) { if (!outline) { - if (track->search_flag&SELECT) glColor3fv(scol); - else glColor3fv(col); + if (track->search_flag & SELECT) + glColor3fv(scol); + else + glColor3fv(col); } /* search offset square */ - x= track->search_min[0]; - y= track->search_max[1]; + x = track->search_min[0]; + y = track->search_max[1]; - tdx= searchdx; - tdy= searchdy; + tdx = searchdx; + tdy = searchdy; if (outline) { - tdx+= px[0]; - tdy+= px[1]; + tdx += px[0]; + tdy += px[1]; } glBegin(GL_QUADS); @@ -699,15 +743,15 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnd(); /* search re-sizing triangle */ - x= track->search_max[0]; - y= track->search_min[1]; + x = track->search_max[0]; + y = track->search_min[1]; - tdx= searchdx*2.0f; - tdy= searchdy*2.0f; + tdx = searchdx*2.0f; + tdy = searchdy*2.0f; if (outline) { - tdx+= px[0]; - tdy+= px[1]; + tdx += px[0]; + tdy += px[1]; } glBegin(GL_TRIANGLES); @@ -717,22 +761,24 @@ 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 ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT)==sel || outline)) { if (!outline) { - if (track->pat_flag&SELECT) glColor3fv(scol); - else glColor3fv(col); + if (track->pat_flag & SELECT) + glColor3fv(scol); + else + glColor3fv(col); } /* pattern offset square */ - x= track->pat_min[0]; - y= track->pat_max[1]; + x = track->pat_min[0]; + y = track->pat_max[1]; - tdx= patdx; - tdy= patdy; + tdx = patdx; + tdy = patdy; if (outline) { - tdx+= px[0]; - tdy+= px[1]; + tdx += px[0]; + tdy += px[1]; } glBegin(GL_QUADS); @@ -743,15 +789,15 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnd(); /* pattern re-sizing triangle */ - x= track->pat_max[0]; - y= track->pat_min[1]; + x = track->pat_max[0]; + y = track->pat_min[1]; - tdx= patdx*2.0f; - tdy= patdy*2.0f; + tdx = patdx*2.0f; + tdy = patdy*2.0f; if (outline) { - tdx+= px[0]; - tdy+= px[1]; + tdx += px[0]; + tdy += px[1]; } glBegin(GL_TRIANGLES); @@ -768,52 +814,60 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int act, - int width, int height, float zoomx, float zoomy) + int width, int height, float zoomx, float zoomy) { - char str[128]= {0}, state[64]= {0}; - float dx= 0.0f, dy= 0.0f, fontsize, pos[3]; - uiStyle *style= U.uistyles.first; - int fontid= style->widget.uifont_id; + char str[128] = {0}, state[64] = {0}; + float dx= 0.0f, dy = 0.0f, fontsize, pos[3]; + uiStyle *style = U.uistyles.first; + int fontid = style->widget.uifont_id; if (!TRACK_VIEW_SELECTED(sc, track)) return; BLF_size(fontid, 11.0f, U.dpi); - fontsize= BLF_height_max(fontid); + fontsize = BLF_height_max(fontid); - if (marker->flag&MARKER_DISABLED) { - if (act) UI_ThemeColor(TH_ACT_MARKER); - else UI_ThemeColorShade(TH_DIS_MARKER, 128); + 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 UI_ThemeColor(TH_SEL_MARKER); + if (act) + UI_ThemeColor(TH_ACT_MARKER); + else + UI_ThemeColor(TH_SEL_MARKER); } - if ((sc->flag&SC_SHOW_MARKER_SEARCH) && - ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0)) + 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]; + dx = track->search_min[0]; + dy = track->search_min[1]; } - else if (sc->flag&SC_SHOW_MARKER_PATTERN) { - dx= track->pat_min[0]; - dy= track->pat_min[1]; + else if (sc->flag & SC_SHOW_MARKER_PATTERN) { + dx = track->pat_min[0]; + dy = track->pat_min[1]; } - pos[0]= (marker_pos[0]+dx)*width; - pos[1]= (marker_pos[1]+dy)*height; - pos[2]= 0.0f; + pos[0] = (marker_pos[0] + dx) * width; + pos[1] = (marker_pos[1] + dy) * height; + pos[2] = 0.0f; mul_m4_v3(sc->stabmat, pos); - pos[0]= pos[0]*zoomx; - pos[1]= pos[1]*zoomy - fontsize; + 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"); - else strcpy(state, "keyframed"); + 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]) BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state); @@ -822,16 +876,16 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, str, sizeof(str)); - pos[1]-= fontsize; + 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; + 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); } @@ -840,25 +894,25 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony) { /* express given coordinates as proportional values */ - x= -v2d->cur.xmin / (v2d->cur.xmax-v2d->cur.xmin); - y= -v2d->cur.ymin / (v2d->cur.ymax-v2d->cur.ymin); + x = -v2d->cur.xmin / (v2d->cur.xmax - v2d->cur.xmin); + y = -v2d->cur.ymin / (v2d->cur.ymax - v2d->cur.ymin); /* convert proportional distances to screen coordinates */ - *regionx= v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin); - *regiony= v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin); + *regionx = v2d->mask.xmin + x*(v2d->mask.xmax - v2d->mask.xmin); + *regiony = v2d->mask.ymin + y*(v2d->mask.ymax - v2d->mask.ymin); } static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, - int width, int height, float zoomx, float zoomy) + int width, int height, float zoomx, float zoomy) { float x, y; - MovieTracking* tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track, *act_track; MovieTrackingMarker *marker; - int framenr= sc->user.framenr; - int undistort= sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT; - float *marker_pos= NULL, *fp, *active_pos= NULL, cur_pos[2]; + int framenr = sc->user.framenr; + int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT; + float *marker_pos = NULL, *fp, *active_pos = NULL, cur_pos[2]; /* ** find window pixel coordinates of origin ** */ @@ -877,65 +931,65 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, glMultMatrixf(sc->stabmat); glScalef(width, height, 0); - act_track= BKE_tracking_active_track(tracking); + act_track = BKE_tracking_active_track(tracking); - if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { - int count= 0; + if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { + int count = 0; /* count */ - track= tracksbase->first; + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if ((track->flag & TRACK_HIDDEN)==0) { + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) count++; } - track= track->next; + track = track->next; } /* undistort */ if (count) { - marker_pos= MEM_callocN(2*sizeof(float)*count, "draw_tracking_tracks marker_pos"); + marker_pos = MEM_callocN(2*sizeof(float)*count, "draw_tracking_tracks marker_pos"); - track= tracksbase->first; - fp= marker_pos; + track = tracksbase->first; + fp = marker_pos; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if ((track->flag & TRACK_HIDDEN)==0) { + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { ED_clip_point_undistorted_pos(sc, marker->pos, fp); - if (track==act_track) - active_pos= fp; + if (track == act_track) + active_pos = fp; - fp+= 2; + fp += 2; } } - track= track->next; + track = track->next; } } } - if (sc->flag&SC_SHOW_TRACK_PATH) { - track= tracksbase->first; + if (sc->flag & SC_SHOW_TRACK_PATH) { + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) + if ((track->flag & TRACK_HIDDEN)==0) draw_track_path(sc, clip, track); - track= track->next; + track = track->next; } } /* markers outline and non-selected areas */ - track= tracksbase->first; - fp= marker_pos; + track = tracksbase->first; + fp = marker_pos; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if ((track->flag & TRACK_HIDDEN)==0) { + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); @@ -946,21 +1000,21 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height); if (fp) - fp+= 2; + fp += 2; } } - track= track->next; + track = track->next; } /* selected areas only, so selection wouldn't be overlapped by * non-selected areas */ - track= tracksbase->first; - fp= marker_pos; + track = tracksbase->first; + fp = marker_pos; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - int act= track==act_track; - marker= BKE_tracking_get_marker(track, framenr); + 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) { @@ -971,17 +1025,17 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } if (fp) - fp+= 2; + fp += 2; } } - track= track->next; + track = track->next; } /* active marker would be displayed on top of everything else */ if (act_track) { - if ((act_track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(act_track, framenr); + if ((act_track->flag & TRACK_HIDDEN)==0) { + marker = BKE_tracking_get_marker(act_track, framenr); if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos); @@ -992,19 +1046,19 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } - if (sc->flag&SC_SHOW_BUNDLES) { - MovieTrackingObject *object= BKE_tracking_active_object(tracking); + if (sc->flag & SC_SHOW_BUNDLES) { + MovieTrackingObject *object = BKE_tracking_active_object(tracking); float pos[4], vec[4], mat[4][4], aspy; glEnable(GL_POINT_SMOOTH); glPointSize(3.0f); - aspy= 1.0f/clip->tracking.camera.pixel_aspect; + aspy = 1.0f / clip->tracking.camera.pixel_aspect; BKE_tracking_projection_matrix(tracking, object, framenr, width, height, mat); - track= tracksbase->first; + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0 && track->flag&TRACK_HAS_BUNDLE) { + if ((track->flag & TRACK_HIDDEN) == 0 && track->flag & TRACK_HAS_BUNDLE) { marker= BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { @@ -1014,29 +1068,33 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, mul_v4_m4v4(pos, mat, vec); - pos[0]= (pos[0]/(pos[3]*2.0f)+0.5f)*width; - pos[1]= (pos[1]/(pos[3]*2.0f)+0.5f)*height*aspy; + pos[0] = (pos[0] / (pos[3] * 2.0f) + 0.5f) * width; + pos[1] = (pos[1] / (pos[3] * 2.0f) + 0.5f) * height * aspy; BKE_tracking_apply_intrinsics(tracking, pos, npos); - 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; + 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); - else glColor3f(1.0f, 0.0f, 0.0f); + if (len_v2(vec)< 3.0f) + 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); - else glVertex3f(npos[0]/width, npos[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(); } } } - track= track->next; + track = track->next; } glPointSize(1.0f); @@ -1045,26 +1103,27 @@ 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; + track = tracksbase->first; + fp = marker_pos; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if ((track->flag & TRACK_HIDDEN) == 0) { + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { - int act= track==act_track; + 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; } } - track= track->next; + track = track->next; } } @@ -1077,20 +1136,20 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int width, int height, float zoomx, float zoomy) { float x, y; - const int n= 10; + const int n = 10; int i, j, a; float pos[2], tpos[2], grid[11][11][2]; - MovieTracking *tracking= &clip->tracking; - float aspy= 1.0f/tracking->camera.pixel_aspect; - float dx= (float)width/n, dy= (float)height/n*aspy; + MovieTracking *tracking = &clip->tracking; + 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) 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); @@ -1102,47 +1161,51 @@ 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; - else 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]; - else 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) { copy_v2_v2(val[a], tpos); - idx[a][0]= j; - idx[a][1]= i; + idx[a][0] = j; + idx[a][1] = i; } } } - pos[0]+= dx; + pos[0] += dx; } - pos[0]= 0.0f; - pos[1]+= dy; + pos[0] = 0.0f; + pos[1] += dy; } INIT_MINMAX2(min, max); - for (a= 0; a<4; a++) { - pos[0]= idx[a][0]*dx; - pos[1]= idx[a][1]*dy; + for (a = 0; a < 4; a++) { + pos[0] = idx[a][0] * dx; + pos[1] = idx[a][1] * dy; BKE_tracking_invert_intrinsics(tracking, pos, tpos); @@ -1150,50 +1213,50 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } copy_v2_v2(pos, min); - dx= (max[0]-min[0])/n; - dy= (max[1]-min[1])/n; + 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; - grid[i][j][1]/= height*aspy; + grid[i][j][0] /= width; + grid[i][j][1] /= height*aspy; - pos[0]+= dx; + pos[0] += dx; } - pos[0]= min[0]; - pos[1]+= dy; + pos[0] = min[0]; + pos[1] += dy; } 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) { - bGPDframe *frame= layer->frames.first; + bGPDframe *frame = layer->frames.first; if (layer->flag & GP_LAYER_HIDE) { - layer= layer->next; + layer = layer->next; continue; } @@ -1202,27 +1265,27 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glPointSize((float)(layer->thickness + 2)); while (frame) { - bGPDstroke *stroke= frame->strokes.first; + bGPDstroke *stroke = frame->strokes.first; while (stroke) { - if (stroke->flag&GP_STROKE_2DSPACE) { - if (stroke->totpoints>1) { + if (stroke->flag & GP_STROKE_2DSPACE) { + if (stroke->totpoints > 1) { glBegin(GL_LINE_STRIP); - for (i= 0; i<stroke->totpoints-1; i++) { + for (i = 0; i < stroke->totpoints - 1; i++) { float npos[2], dpos[2], len; int steps; - pos[0]= stroke->points[i].x*width; - pos[1]= stroke->points[i].y*height*aspy; + pos[0] = stroke->points[i].x * width; + pos[1] = stroke->points[i].y * height * aspy; - npos[0]= stroke->points[i+1].x*width; - npos[1]= stroke->points[i+1].y*height*aspy; + npos[0] = stroke->points[i+1].x * width; + npos[1] = stroke->points[i+1].y * height * aspy; - len= len_v2v2(pos, npos); + len = len_v2v2(pos, npos); 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); } @@ -1230,7 +1293,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)); @@ -1239,20 +1302,20 @@ 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(); } } - stroke= stroke->next; + stroke = stroke->next; } - frame= frame->next; + frame = frame->next; } - layer= layer->next; + layer = layer->next; } glLineWidth(1.0f); @@ -1276,14 +1339,14 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) 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); + ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle); if (ibuf) { float loc[2]; - float aspect= clip->tracking.camera.pixel_aspect; + float aspect = clip->tracking.camera.pixel_aspect; if (width != ibuf->x) mul_v2_v2fl(loc, sc->loc, (float)width / ibuf->x); @@ -1293,18 +1356,18 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) BKE_tracking_stabdata_to_mat4(width, height, aspect, loc, sc->scale, sc->angle, sc->stabmat); unit_m4(smat); - smat[0][0]= 1.0f/width; - smat[1][1]= 1.0f/height; + smat[0][0] = 1.0f / width; + smat[1][1] = 1.0f / height; invert_m4_m4(ismat, smat); mul_serie_m4(sc->unistabmat, smat, sc->stabmat, ismat, NULL, NULL, NULL, NULL, NULL); } } else { - ibuf= ED_space_clip_get_buffer(sc); + ibuf = ED_space_clip_get_buffer(sc); zero_v2(sc->loc); - sc->scale= 1.0f; + sc->scale = 1.0f; unit_m4(sc->stabmat); unit_m4(sc->unistabmat); } @@ -1324,8 +1387,8 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) /* draw grease pencil */ void clip_draw_grease_pencil(bContext *C, int onlyv2d) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); ImBuf *ibuf; if (!clip) @@ -1334,8 +1397,8 @@ void clip_draw_grease_pencil(bContext *C, int 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) { - ibuf= ED_space_clip_get_buffer(sc); + if ((sc->flag & SC_MANUAL_CALIBRATION)==0 || sc->mode != SC_MODE_DISTORTION) { + ibuf = ED_space_clip_get_buffer(sc); if (ibuf) { glPushMatrix(); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 87b0ac1aac1..3946d4cc36d 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -57,20 +57,20 @@ int ED_space_clip_poll(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) - return 1; + return TRUE; - return 0; + return FALSE; } void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip) { - sc->clip= clip; + sc->clip = clip; if (sc->clip && sc->clip->id.us==0) - sc->clip->id.us= 1; + sc->clip->id.us = 1; if (C) WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); @@ -86,7 +86,7 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) if (sc->clip) { ImBuf *ibuf; - ibuf= BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); + ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; @@ -103,7 +103,7 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale if (sc->clip) { ImBuf *ibuf; - ibuf= BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); + ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; @@ -131,18 +131,18 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) ED_space_clip_size(sc, &width, &height); - *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); - *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); } void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); if (clip) BKE_movieclip_aspect(clip, aspx, aspy); else - *aspx= *aspy= 1.0f; + *aspx = *aspy = 1.0f; } void ED_clip_update_frame(const Main *mainp, int cfra) @@ -151,14 +151,15 @@ 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) { - SpaceClip *sc= sa->spacedata.first; - sc->scopes.ok= 0; + for (sa = win->screen->areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_CLIP) { + SpaceClip *sc = sa->spacedata.first; + + sc->scopes.ok = FALSE; BKE_movieclip_user_set_frame(&sc->user, cfra); } @@ -169,44 +170,45 @@ void ED_clip_update_frame(const Main *mainp, int cfra) static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; - int width, height, ok= 0; + int width, height, ok = FALSE; ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); INIT_MINMAX2(min, max); ED_space_clip_size(sc, &width, &height); - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); if (marker) { float pos[3]; - pos[0]= marker->pos[0]+track->offset[0]; - pos[1]= marker->pos[1]+track->offset[1]; - pos[2]= 0.0f; + pos[0] = marker->pos[0] + track->offset[0]; + pos[1] = marker->pos[1] + track->offset[1]; + 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); + } - pos[0]*= width; - pos[1]*= height; + pos[0] *= width; + pos[1] *= height; mul_v3_m4v3(pos, sc->stabmat, pos); DO_MINMAX2(pos, min, max); - ok= 1; + ok = TRUE; } } - track= track->next; + track = track->next; } return ok; @@ -219,90 +221,92 @@ 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 FALSE; if (!selected_boundbox(sc, min, max)) - return 0; + return FALSE; /* center view */ clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height)); - w= max[0]-min[0]; - h= max[1]-min[1]; + w = max[0] - min[0]; + 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; ED_space_clip_aspect(sc, &aspx, &aspy); - width= ar->winrct.xmax - ar->winrct.xmin + 1; - height= ar->winrct.ymax - ar->winrct.ymin + 1; + width = ar->winrct.xmax - ar->winrct.xmin + 1; + height = ar->winrct.ymax - ar->winrct.ymin + 1; - zoomx= (float)width/w/aspx; - zoomy= (float)height/h/aspy; + zoomx = (float)width / w / aspx; + zoomy = (float)height / h / aspy; - newzoom= 1.0f/power_of_2(1/MIN2(zoomx, zoomy)); + newzoom = 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)); if (fit || sc->zoom>newzoom) - sc->zoom= newzoom; + sc->zoom = newzoom; } - return 1; + return TRUE; } 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) { - MovieClip *clip= ED_space_clip(sc); - float aspy= 1.0f/clip->tracking.camera.pixel_aspect; + 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; ED_space_clip_size(sc, &width, &height); - nco[0]*= width; - nco[1]*= height*aspy; + nco[0] *= width; + nco[1] *= height * aspy; BKE_tracking_invert_intrinsics(&clip->tracking, nco, nco); - nco[0]/= width; - nco[1]/= height*aspy; + + nco[0] /= width; + nco[1] /= height * aspy; } } void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *yr) { - ARegion *ar= CTX_wm_region(C); - SpaceClip *sc= CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); int sx, sy, width, height; - float zoomx, zoomy, pos[3]={0.0f, 0.0f, 0.0f}, imat[4][4]; + float zoomx, zoomy, pos[3] = {0.0f, 0.0f, 0.0f}, imat[4][4]; ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); ED_space_clip_size(sc, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - pos[0]= (x-sx)/zoomx; - pos[1]= (y-sy)/zoomy; + pos[0] = (x - sx) / zoomx; + pos[1] = (y - sy) / zoomy; invert_m4_m4(imat, sc->stabmat); mul_v3_m4v3(pos, imat, pos); - *xr= pos[0]/width; - *yr= pos[1]/height; + *xr = pos[0] / width; + *yr = pos[1] / height; - 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; - float tmp[2]= {*xr*width, *yr*height*aspy}; + 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; + float tmp[2] = {*xr * width, *yr * height * aspy}; BKE_tracking_apply_intrinsics(tracking, tmp, tmp); - *xr= tmp[0]/width; - *yr= tmp[1]/(height*aspy); + *xr = tmp[0] / width; + *yr = tmp[1] / (height * aspy); } } diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index c1089d2bbcf..df14491c9c9 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -67,10 +67,10 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float if (displist == 0) { GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - qobj= gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0, 0.7, 8, 1); gluDeleteQuadric(qobj); @@ -89,21 +89,21 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; float xscale, yscale; float vec[2]; /* Draw a light green line to indicate current frame */ - vec[0]= (float)(sc->user.framenr * scene->r.framelen); + vec[0] = (float)(sc->user.framenr * scene->r.framelen); UI_ThemeColor(TH_CFRAME); glLineWidth(2.0); glBegin(GL_LINE_STRIP); - vec[1]= v2d->cur.ymin; + vec[1] = v2d->cur.ymin; glVertex2fv(vec); - vec[1]= v2d->cur.ymax; + vec[1] = v2d->cur.ymax; glVertex2fv(vec); glEnd(); @@ -156,11 +156,11 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co copy_v3_v3(col, colors[coord]); if (track==userdata) { - col[3]= 1.0f; + col[3] = 1.0f; glLineWidth(2.0f); } else { - col[3]= 0.5f; + col[3] = 0.5f; glLineWidth(1.0f); } @@ -182,15 +182,17 @@ 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; + 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); - else UI_ThemeColor(TH_HANDLE_VERTEX); + 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); } @@ -198,9 +200,9 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); int width, height; struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } userdata; @@ -210,9 +212,9 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) return; /* non-selected knot handles */ - userdata.hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); - userdata.sel= 0; - userdata.act_track= act_track; + userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); + userdata.sel = FALSE; + userdata.act_track = act_track; UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale); clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL); @@ -222,35 +224,35 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) glDisable(GL_BLEND); /* selected knot handles on top of curves */ - userdata.sel= 1; + userdata.sel= TRUE; clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL); } static void draw_frame_curves(SpaceClip *sc) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking); - int i, lines= 0, prevfra= 0; + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking); + int i, lines = 0, prevfra = 0; glColor3f(0.0f, 0.0f, 1.0f); - for (i= 0; i<reconstruction->camnr; i++) { - MovieReconstructedCamera *camera= &reconstruction->cameras[i]; + for (i = 0; i<reconstruction->camnr; i++) { + MovieReconstructedCamera *camera = &reconstruction->cameras[i]; if (lines && camera->framenr!=prevfra+1) { glEnd(); - lines= 0; + lines = 0; } if (!lines) { glBegin(GL_LINE_STRIP); - lines= 1; + lines = 1; } glVertex2f(camera->framenr, camera->error); - prevfra= camera->framenr; + prevfra = camera->framenr; } if (lines) @@ -259,21 +261,21 @@ static void draw_frame_curves(SpaceClip *sc) void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip= ED_space_clip(sc); - View2D *v2d= &ar->v2d; + MovieClip *clip = ED_space_clip(sc); + View2D *v2d = &ar->v2d; View2DGrid *grid; - short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; + short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; /* grid */ - grid= UI_view2d_grid_calc(scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); + grid = UI_view2d_grid_calc(scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); if (clip) { - if (sc->flag&SC_SHOW_GRAPH_TRACKS) + 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 4a1f2c56ee0..f8c81c2944a 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -80,17 +80,17 @@ typedef struct { static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker) { - SelectUserData *data= (SelectUserData *)userdata; + SelectUserData *data = (SelectUserData *)userdata; switch(data->action) { case SEL_SELECT: - marker->flag|= MARKER_GRAPH_SEL; + marker->flag |= MARKER_GRAPH_SEL; break; case SEL_DESELECT: - marker->flag&= ~MARKER_GRAPH_SEL; + marker->flag &= ~MARKER_GRAPH_SEL; break; case SEL_INVERT: - marker->flag^= MARKER_GRAPH_SEL; + marker->flag ^= MARKER_GRAPH_SEL; break; } } @@ -111,47 +111,47 @@ typedef struct { } MouseSelectUserData; static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack *track, - MovieTrackingMarker *marker, int coord, float val) + MovieTrackingMarker *marker, int coord, float val) { - MouseSelectUserData *data= userdata; - float co[2]= {marker->framenr, val}; + MouseSelectUserData *data = userdata; + float co[2] = {marker->framenr, val}; if (data->has_prev) { - float d= dist_to_line_segment_v2(data->mouse_co, data->prev_co, co); + float d = dist_to_line_segment_v2(data->mouse_co, data->prev_co, co); - if (data->track==NULL || d<data->min_dist) { - data->track= track; - data->min_dist= d; - data->coord= coord; + if (data->track == NULL || d < data->min_dist) { + data->track = track; + data->min_dist = d; + data->coord = coord; copy_v2_v2(data->min_co, co); } } - data->has_prev= 1; + data->has_prev = TRUE; copy_v2_v2(data->prev_co, co); } void find_nearest_tracking_segment_end_cb(void *userdata) { - MouseSelectUserData *data= userdata; + MouseSelectUserData *data = userdata; - data->has_prev= 0; + data->has_prev = FALSE; } static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *track, - MovieTrackingMarker *marker, int coord, float val) + MovieTrackingMarker *marker, int coord, float val) { - MouseSelectUserData *data= userdata; - float dx= marker->framenr-data->mouse_co[0], dy= val-data->mouse_co[1]; - float d= dx*dx+dy*dy; + MouseSelectUserData *data = userdata; + float dx = marker->framenr - data->mouse_co[0], dy = val - data->mouse_co[1]; + float d = dx * dx + dy * dy; - if (data->marker==NULL || d<data->min_dist) { + if (data->marker == NULL || d < data->min_dist) { float co[2]= {marker->framenr, val}; - data->track= track; - data->marker= marker; - data->min_dist= d; - data->coord= coord; + data->track = track; + data->marker = marker; + data->min_dist = d; + data->coord = coord; copy_v2_v2(data->min_co, co); } @@ -160,26 +160,26 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr static void mouse_select_init_data(MouseSelectUserData *userdata, float *co) { memset(userdata, 0, sizeof(MouseSelectUserData)); - userdata->min_dist= FLT_MAX; + userdata->min_dist = FLT_MAX; copy_v2_v2(userdata->mouse_co, co); } static int mouse_select_knot(bContext *C, float co[2], int extend) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - MovieTracking *tracking= &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - static const int delta= 6; + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); + static const int delta = 6; 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); + clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, + find_nearest_tracking_knot_cb, NULL, NULL); if (userdata.marker) { int x1, y1, x2, y2; @@ -187,51 +187,53 @@ static int mouse_select_knot(bContext *C, float co[2], int extend) 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 (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) - userdata.marker->flag|= MARKER_GRAPH_SEL_X; + if (userdata.coord == 0) + userdata.marker->flag |= MARKER_GRAPH_SEL_X; else - userdata.marker->flag|= MARKER_GRAPH_SEL_Y; + userdata.marker->flag |= MARKER_GRAPH_SEL_Y; - return 1; + return TRUE; } } } - return 0; + return FALSE; } static int mouse_select_curve(bContext *C, float co[2], int extend) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); MouseSelectUserData userdata; 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); + 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 (act_track == userdata.track) { /* currently only single curve can be selected (selected curve represents active track) */ - act_track= NULL; + act_track = NULL; } } - else if (act_track!=userdata.track) { + else if (act_track != userdata.track) { MovieTrackingMarker *marker; SelectUserData selectdata = {SEL_DESELECT}; - tracking->act_track= userdata.track; + tracking->act_track = userdata.track; /* make active track be centered to screen */ - marker= BKE_tracking_get_marker(userdata.track, sc->user.framenr); + marker = BKE_tracking_get_marker(userdata.track, sc->user.framenr); clip_view_center_to_point(sc, marker->pos[0], marker->pos[1]); @@ -239,22 +241,22 @@ static int mouse_select_curve(bContext *C, float co[2], int extend) clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb); } - return 1; + return TRUE; } - return 0; + return FALSE; } static int mouse_select(bContext *C, float co[2], int extend) { - int sel= 0; + int sel = FALSE; /* first try to select knot on selected curves */ - sel= mouse_select_knot(C, co, extend); + sel = mouse_select_knot(C, co, extend); if (!sel) { /* if there's no close enough knot to mouse osition, select nearest curve */ - sel= mouse_select_curve(C, co, extend); + sel = mouse_select_curve(C, co, extend); } if (sel) @@ -266,7 +268,7 @@ static int mouse_select(bContext *C, float co[2], int extend) static int select_exec(bContext *C, wmOperator *op) { float co[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); + int extend = RNA_boolean_get(op->ptr, "extend"); RNA_float_get_array(op->ptr, "location", co); @@ -275,7 +277,7 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); float co[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); @@ -343,8 +345,8 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); MovieClip *clip = ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); BorderSelectuserData userdata; rcti rect; @@ -399,7 +401,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking = &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); MovieTrackingMarker *marker; int action = RNA_enum_get(op->ptr, "action"); int a; @@ -462,11 +464,11 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); if (act_track) clip_delete_track(C, clip, tracksbase, act_track); @@ -494,17 +496,17 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); if (act_track) { - int a= 0; + int a = 0; - while (a<act_track->markersnr) { - MovieTrackingMarker *marker= &act_track->markers[a]; + while (a < act_track->markersnr) { + MovieTrackingMarker *marker = &act_track->markers[a]; if (marker->flag & MARKER_GRAPH_SEL) clip_delete_marker(C, clip, tracksbase, act_track, marker); @@ -540,10 +542,13 @@ typedef struct { static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *UNUSED(marker), int UNUSED(coord), float val) { - ViewAllUserData *data = (ViewAllUserData *)userdata; + ViewAllUserData *data = (ViewAllUserData *) userdata; + + if (val < data->min) + data->min = val; - if (val < data->min) data->min = val; - if (val > data->max) data->max = val; + if (val > data->max) + data->max = val; } static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) @@ -561,8 +566,8 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL); /* set extents of view to start/end frames */ - v2d->cur.xmin = (float)SFRA; - v2d->cur.xmax = (float)EFRA; + v2d->cur.xmin = (float) SFRA; + v2d->cur.xmax = (float) EFRA; if (userdata.min < userdata.max) { v2d->cur.ymin = userdata.min; @@ -574,11 +579,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) } /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra= 0.01f * (v2d->cur.ymax - v2d->cur.ymin); + extra = 0.01f * (v2d->cur.ymax - v2d->cur.ymin); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 8d4da7e995c..425a1da9ec5 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -97,7 +97,7 @@ void clip_graph_tracking_values_iterate(struct SpaceClip *sc, void *userdata, void (*segment_end) (void *userdata)); void clip_graph_tracking_iterate(struct SpaceClip *sc, void *userdata, - void (*func) (void *userdata, struct MovieTrackingMarker *marker)); + void (*func) (void *userdata, struct MovieTrackingMarker *marker)); void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index ff8feb69bd9..7e1bbc254e9 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -70,31 +70,31 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float location[2]) { - float oldzoom= sc->zoom; + float oldzoom = sc->zoom; int width, height; - sc->zoom= zoom; + sc->zoom = zoom; if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ ED_space_clip_size(sc, &width, &height); - width*= sc->zoom; - height*= sc->zoom; + width *= sc->zoom; + height *= sc->zoom; if ((width < 4) && (height < 4)) - sc->zoom= oldzoom; + sc->zoom = oldzoom; else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) - sc->zoom= oldzoom; + sc->zoom = oldzoom; else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) - sc->zoom= oldzoom; + sc->zoom = oldzoom; } 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; - sc->yof+= ((location[1]-0.5f)*height-sc->yof)*(sc->zoom-oldzoom)/sc->zoom; + sc->xof += ((location[0] - 0.5f) * width-sc->xof) * (sc->zoom-oldzoom) / sc->zoom; + sc->yof += ((location[1] - 0.5f) * height-sc->yof) * (sc->zoom-oldzoom) / sc->zoom; } } @@ -105,8 +105,8 @@ static void sclip_zoom_set_factor(SpaceClip *sc, ARegion *ar, float zoomfac, flo static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float location[2], *mpos = NULL; if (event) { @@ -124,6 +124,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor static void clip_filesel(bContext *C, wmOperator *op, const char *path) { RNA_string_set(op->ptr, "filepath", path); + WM_event_add_fileselect(C, op); } @@ -131,32 +132,32 @@ static void open_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } static int open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } static int open_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); PropertyPointerRNA *pprop; PointerRNA idptr; - MovieClip *clip= NULL; + MovieClip *clip = NULL; char str[FILE_MAX]; RNA_string_get(op->ptr, "filepath", str); /* default to frame 1 if there's no scene in context */ - errno= 0; + errno = 0; - clip= BKE_add_movieclip_file(str); + clip = BKE_add_movieclip_file(str); if (!clip) { if (op->customdata) @@ -171,7 +172,7 @@ static int open_exec(bContext *C, wmOperator *op) open_init(C, op); /* hook into UI */ - pprop= op->customdata; + pprop = op->customdata; if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA @@ -195,15 +196,15 @@ static int open_exec(bContext *C, wmOperator *op) static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceClip *sc= CTX_wm_space_clip(C); - char *path= U.textudir; - MovieClip *clip= NULL; + SpaceClip *sc = CTX_wm_space_clip(C); + char *path = U.textudir; + MovieClip *clip = NULL; if (sc) - clip= ED_space_clip(sc); + clip = ED_space_clip(sc); if (clip) - path= clip->name; + path = clip->name; if (!RNA_struct_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); @@ -241,7 +242,7 @@ void CLIP_OT_open(wmOperatorType *ot) static int reload_exec(bContext *C, wmOperator *UNUSED(op)) { - MovieClip *clip= CTX_data_edit_movieclip(C); + MovieClip *clip = CTX_data_edit_movieclip(C); if (!clip) return OPERATOR_CANCELLED; @@ -275,17 +276,19 @@ typedef struct ViewPanData { static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); ViewPanData *vpd; - op->customdata= vpd= MEM_callocN(sizeof(ViewPanData), "ClipViewPanData"); + op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ClipViewPanData"); WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); - vpd->x= event->x; - vpd->y= event->y; + vpd->x = event->x; + vpd->y = event->y; - if (sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof; - else vpd->vec= &sc->xof; + if (sc->flag & SC_LOCK_SELECTION) + vpd->vec= &sc->xlockof; + else + vpd->vec= &sc->xof; copy_v2_v2(&vpd->xof, vpd->vec); copy_v2_v2(&vpd->xorig, &vpd->xof); @@ -297,7 +300,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) static void view_pan_exit(bContext *C, wmOperator *op, int cancel) { - ViewPanData *vpd= op->customdata; + ViewPanData *vpd = op->customdata; if (cancel) { copy_v2_v2(vpd->vec, &vpd->xorig); @@ -311,18 +314,18 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel) static int view_pan_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); float offset[2]; RNA_float_get_array(op->ptr, "offset", offset); - if (sc->flag&SC_LOCK_SELECTION) { - sc->xlockof+= offset[0]; - sc->ylockof+= offset[1]; + if (sc->flag & SC_LOCK_SELECTION) { + sc->xlockof += offset[0]; + sc->ylockof += offset[1]; } else { - sc->xof+= offset[0]; - sc->yof+= offset[1]; + sc->xof += offset[0]; + sc->yof += offset[1]; } ED_region_tag_redraw(CTX_wm_region(C)); @@ -332,47 +335,52 @@ static int view_pan_exec(bContext *C, wmOperator *op) static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if (event->type==MOUSEPAN) { - SpaceClip *sc= CTX_wm_space_clip(C); + if (event->type == MOUSEPAN) { + SpaceClip *sc = CTX_wm_space_clip(C); float offset[2]; - offset[0]= (event->x - event->prevx)/sc->zoom; - offset[1]= (event->y - event->prevy)/sc->zoom; + offset[0] = (event->x - event->prevx) / sc->zoom; + offset[1] = (event->y - event->prevy) / sc->zoom; RNA_float_set_array(op->ptr, "offset", offset); view_pan_exec(C, op); + return OPERATOR_FINISHED; } else { view_pan_init(C, op, event); + return OPERATOR_RUNNING_MODAL; } } static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); - ViewPanData *vpd= op->customdata; + SpaceClip *sc = CTX_wm_space_clip(C); + ViewPanData *vpd = op->customdata; float offset[2]; switch(event->type) { case MOUSEMOVE: copy_v2_v2(vpd->vec, &vpd->xorig); - offset[0]= (vpd->x - event->x)/sc->zoom; - offset[1]= (vpd->y - event->y)/sc->zoom; + offset[0] = (vpd->x - event->x) / sc->zoom; + offset[1] = (vpd->y - event->y) / sc->zoom; RNA_float_set_array(op->ptr, "offset", offset); view_pan_exec(C, op); break; case ESCKEY: view_pan_exit(C, op, 1); + return OPERATOR_CANCELLED; case SPACEKEY: 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; } break; @@ -420,16 +428,16 @@ typedef struct ViewZoomData { static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); ViewZoomData *vpd; op->customdata= vpd= MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); - vpd->x= event->x; - vpd->y= event->y; - vpd->zoom= sc->zoom; - vpd->event_type= event->type; + vpd->x = event->x; + vpd->y = event->y; + vpd->zoom = sc->zoom; + vpd->event_type = event->type; ED_clip_mouse_pos(C, event, vpd->location); @@ -438,11 +446,11 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) { - SpaceClip *sc= CTX_wm_space_clip(C); - ViewZoomData *vpd= op->customdata; + SpaceClip *sc = CTX_wm_space_clip(C); + ViewZoomData *vpd = op->customdata; if (cancel) { - sc->zoom= vpd->zoom; + sc->zoom = vpd->zoom; ED_region_tag_redraw(CTX_wm_region(C)); } @@ -452,8 +460,8 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) static int view_zoom_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); sclip_zoom_set_factor(sc, ar, RNA_float_get(op->ptr, "factor"), NULL); @@ -464,10 +472,10 @@ static int view_zoom_exec(bContext *C, wmOperator *op) static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if (event->type==MOUSEZOOM) { + if (event->type == MOUSEZOOM) { float factor; - factor= 1.0f + (event->x-event->prevx+event->y-event->prevy)/300.0f; + factor = 1.0f + (event->x - event->prevx + event->y - event->prevy) / 300.0f; RNA_float_set(op->ptr, "factor", factor); sclip_zoom_set_factor_exec(C, event, factor); @@ -483,21 +491,22 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); - ViewZoomData *vpd= op->customdata; + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + ViewZoomData *vpd = op->customdata; float factor; switch(event->type) { case MOUSEMOVE: - factor= 1.0f + (vpd->x-event->x+vpd->y-event->y)/300.0f; + factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); - sclip_zoom_set(sc, ar, vpd->zoom*factor, vpd->location); + sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); 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; } break; @@ -509,6 +518,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) static int view_zoom_cancel(bContext *C, wmOperator *op) { view_zoom_exit(C, op, 1); + return OPERATOR_CANCELLED; } @@ -537,8 +547,8 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) static int view_zoom_in_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); @@ -577,8 +587,8 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) static int view_zoom_out_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); @@ -619,14 +629,14 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) static int view_zoom_ratio_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ - sc->xof= (int)sc->xof; - sc->yof= (int)sc->yof; + sc->xof= (int) sc->xof; + sc->yof= (int) sc->yof; ED_region_tag_redraw(CTX_wm_region(C)); @@ -660,31 +670,31 @@ static int view_all_exec(bContext *C, wmOperator *op) float zoomx, zoomy; /* retrieve state */ - sc= CTX_wm_space_clip(C); - ar= CTX_wm_region(C); + sc = CTX_wm_space_clip(C); + ar = CTX_wm_region(C); ED_space_clip_size(sc, &w, &h); ED_space_clip_aspect(sc, &aspx, &aspy); - w= w*aspx; - h= h*aspy; + w = w * aspx; + h = h * aspy; /* check if the image will fit in the image with zoom==1 */ - width= ar->winrct.xmax - ar->winrct.xmin + 1; - height= ar->winrct.ymax - ar->winrct.ymin + 1; + width = ar->winrct.xmax - ar->winrct.xmin + 1; + height = ar->winrct.ymax - ar->winrct.ymin + 1; if (fit_view) { const int margin = 5; /* margin from border */ - zoomx= (float)width / (w + 2*margin); - zoomy= (float)height / (h + 2*margin); + zoomx= (float) width / (w + 2 * margin); + zoomy= (float) height / (h + 2 * margin); sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { - zoomx= (float)width/w; - zoomy= (float)height/h; + zoomx= (float) width / w; + zoomy= (float) height / h; /* find the zoom value that will fit the image in the image space */ sclip_zoom_set(sc, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL); @@ -693,7 +703,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sclip_zoom_set(sc, ar, 1.0f, NULL); } - sc->xof= sc->yof= 0.0f; + sc->xof = sc->yof = 0.0f; ED_region_tag_redraw(CTX_wm_region(C)); @@ -718,11 +728,11 @@ void CLIP_OT_view_all(wmOperatorType *ot) static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); - sc->xlockof= 0.0f; - sc->ylockof= 0.0f; + sc->xlockof = 0.0f; + sc->ylockof = 0.0f; ED_clip_view_selection(sc, ar, 1); ED_region_tag_redraw(CTX_wm_region(C)); @@ -754,10 +764,10 @@ static int change_frame_poll(bContext *C) static void change_frame_apply(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* set the new frame number */ - CFRA= RNA_int_get(op->ptr, "frame"); + CFRA = RNA_int_get(op->ptr, "frame"); FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.0f; @@ -775,21 +785,21 @@ static int change_frame_exec(bContext *C, wmOperator *op) static int frame_from_event(bContext *C, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - int framenr= 0; + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + int framenr = 0; if (ar->regiontype == RGN_TYPE_WINDOW) { - float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); + float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); - framenr= sfra+event->mval[0]/framelen; + framenr = sfra + event->mval[0] / framelen; } else { float viewx, viewy; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); - framenr= (int)floor(viewx+0.5f); + framenr= (int) floor(viewx + 0.5f); } return framenr; @@ -797,10 +807,10 @@ static int frame_from_event(bContext *C, wmEvent *event) static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1]>16) + if (event->mval[1] > 16) return OPERATOR_PASS_THROUGH; } @@ -827,7 +837,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: - if (event->val==KM_RELEASE) + if (event->val == KM_RELEASE) return OPERATOR_FINISHED; break; } @@ -885,10 +895,17 @@ 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; } @@ -896,19 +913,19 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto /* only this runs inside thread */ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) { - ProxyJob *pj= pjv; - Scene *scene=pj->scene; - MovieClip *clip= pj->clip; - struct MovieDistortion *distortion= NULL; + ProxyJob *pj = pjv; + Scene *scene = pj->scene; + MovieClip *clip = pj->clip; + struct MovieDistortion *distortion = NULL; short size_flag; - int cfra, sfra= SFRA, efra= EFRA; - int build_sizes[4], build_count= 0; - int build_undistort_sizes[4], build_undistort_count= 0; + int cfra, sfra = SFRA, efra = EFRA; + int build_sizes[4], build_count = 0; + int build_undistort_sizes[4], build_undistort_count = 0; - size_flag= clip->proxy.build_size_flag; + size_flag = clip->proxy.build_size_flag; - build_count= proxy_bitflag_to_array(size_flag, build_sizes, 0); - build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1); + 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 (pj->index_context) @@ -921,15 +938,15 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog return; } else { - sfra= 1; - efra= IMB_anim_get_duration(clip->anim, IMB_TC_NONE); + sfra = 1; + efra = IMB_anim_get_duration(clip->anim, IMB_TC_NONE); } } if (build_undistort_count) - distortion= BKE_tracking_distortion_create(); + distortion = BKE_tracking_distortion_create(); - for (cfra= sfra; cfra<=efra; cfra++) { + 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); @@ -938,8 +955,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if (*stop || G.afbreek) break; - *do_update= 1; - *progress= ((float)cfra)/(efra-sfra); + *do_update = TRUE; + *progress= ((float) cfra) / (efra - sfra); } if (distortion) @@ -968,21 +985,21 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { wmJob * steve; ProxyJob *pj; - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + 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); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); - pj= MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); - pj->scene= scene; - pj->main= CTX_data_main(C); - pj->clip= clip; - pj->clip_flag= clip->flag&MCLIP_TIMECODE_FLAGS; + pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); + pj->scene = scene; + pj->main = CTX_data_main(C); + pj->clip = clip; + pj->clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; if (clip->anim) { pj->index_context = IMB_anim_index_rebuild_context(clip->anim, clip->proxy.build_tc_flag, @@ -993,7 +1010,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); - G.afbreek= 0; + G.afbreek = 0; WM_jobs_start(CTX_wm_manager(C), steve); ED_area_tag_redraw(CTX_wm_area(C)); @@ -1020,16 +1037,16 @@ void CLIP_OT_rebuild_proxy(wmOperatorType *ot) static int mode_set_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - int mode= RNA_enum_get(op->ptr, "mode"); - int toggle= RNA_boolean_get(op->ptr, "toggle"); + SpaceClip *sc = CTX_wm_space_clip(C); + int mode = RNA_enum_get(op->ptr, "mode"); + int toggle = RNA_boolean_get(op->ptr, "toggle"); - if (sc->mode==mode) { + if (sc->mode == mode) { if (toggle) - sc->mode= SC_MODE_TRACKING; + sc->mode = SC_MODE_TRACKING; } else { - sc->mode= mode; + sc->mode = mode; } WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CLIP, NULL); diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index b42b4137ea0..b80deb8260a 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -60,24 +60,24 @@ static ARegion *clip_has_properties_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_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"); + arnew = MEM_callocN(sizeof(ARegion), "clip properties region"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; - arnew->flag= RGN_FLAG_HIDDEN; + arnew->flag = RGN_FLAG_HIDDEN; return arnew; } @@ -89,8 +89,8 @@ static int properties_poll(bContext *C) static int properties_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= clip_has_properties_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = clip_has_properties_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -114,43 +114,44 @@ void CLIP_OT_properties(wmOperatorType *ot) static ARegion *clip_has_tools_region(ScrArea *sa) { - ARegion *ar, *artool=NULL, *arprops=NULL, *arhead; + ARegion *ar, *artool = NULL, *arprops = NULL, *arhead; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_TOOLS) - artool= ar; - if (ar->regiontype==RGN_TYPE_TOOL_PROPS) - arprops= ar; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_TOOLS) + artool = ar; + + if (ar->regiontype == RGN_TYPE_TOOL_PROPS) + arprops = ar; } /* tool region hide/unhide also hides props */ 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); + 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"); + artool = MEM_callocN(sizeof(ARegion), "clip tools region"); BLI_insertlinkafter(&sa->regionbase, arhead, artool); - artool->regiontype= RGN_TYPE_TOOLS; - artool->alignment= RGN_ALIGN_LEFT; + artool->regiontype = RGN_TYPE_TOOLS; + artool->alignment = RGN_ALIGN_LEFT; - artool->flag= RGN_FLAG_HIDDEN; + 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"); + arprops = MEM_callocN(sizeof(ARegion), "tool props for clip"); BLI_insertlinkafter(&sa->regionbase, artool, arprops); - arprops->regiontype= RGN_TYPE_TOOL_PROPS; - arprops->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + arprops->regiontype = RGN_TYPE_TOOL_PROPS; + arprops->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; } return artool; @@ -163,8 +164,8 @@ static int tools_poll(bContext *C) static int tools_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= clip_has_tools_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = clip_has_tools_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -193,16 +194,18 @@ static void clip_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperat static void clip_panel_operator_redo_header(const bContext *C, Panel *pa) { - wmOperator *op= WM_operator_last_redo(C); + wmOperator *op = WM_operator_last_redo(C); - if (op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); - else BLI_strncpy(pa->drawname, "Operator", 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) { + 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); } @@ -215,15 +218,16 @@ static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOp /* TODO de-duplicate redo panel functions - campbell */ static void clip_panel_operator_redo(const bContext *C, Panel *pa) { - wmOperator *op= WM_operator_last_redo(C); + 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) return; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); if (!WM_operator_check_ui_enabled(C, op->type->name)) uiLayoutSetEnabled(pa->layout, 0); @@ -238,10 +242,10 @@ void ED_clip_tool_props_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel last operator"); + pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel last operator"); strcpy(pt->idname, "CLIP_PT_last_operator"); strcpy(pt->label, "Operator"); - pt->draw_header= clip_panel_operator_redo_header; - pt->draw= clip_panel_operator_redo; + pt->draw_header = clip_panel_operator_redo_header; + pt->draw = clip_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index c637bffe3ad..443a1d0cdd3 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -62,25 +62,25 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end) (void *userdata)) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); int width, height, coord; BKE_movieclip_get_size(clip, &sc->user, &width, &height); - for (coord= 0; coord<2; coord++) { - int i, open= 0, prevfra= 0; - float prevval= 0.0f; + for (coord = 0; coord < 2; coord++) { + int i, open = FALSE, prevfra = 0; + float prevval = 0.0f; - for (i= 0; i<track->markersnr; i++) { - MovieTrackingMarker *marker= &track->markers[i]; + for (i = 0; i < track->markersnr; i++) { + MovieTrackingMarker *marker = &track->markers[i]; float val; - if (marker->flag&MARKER_DISABLED) { + if (marker->flag & MARKER_DISABLED) { if (open) { if (segment_end) segment_end(userdata); - open= 0; + open = FALSE; } continue; @@ -90,19 +90,19 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack if (segment_start) segment_start(userdata, track, coord); - open= 1; - prevval= marker->pos[coord]; + open = TRUE; + prevval = marker->pos[coord]; } /* value is a pixels per frame speed */ - val= (marker->pos[coord] - prevval) * ((coord==0) ? (width) : (height)); - val/= marker->framenr-prevfra; + val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height)); + val /= marker->framenr - prevfra; if (func) func(userdata, track, marker, coord, val); - prevval= marker->pos[coord]; - prevfra= marker->framenr; + prevval = marker->pos[coord]; + prevfra = marker->framenr; } if (open) { @@ -117,38 +117,38 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata, void (*segment_start) (void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end) (void *userdata)) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end); } - track= track->next; + track = track->next; } } void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata, void (*func) (void *userdata, MovieTrackingMarker *marker)) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { int i; - for (i= 0; i<track->markersnr; i++) { - MovieTrackingMarker *marker= &track->markers[i]; + for (i = 0; i < track->markersnr; i++) { + MovieTrackingMarker *marker = &track->markers[i]; - if (marker->flag&MARKER_DISABLED) + if (marker->flag & MARKER_DISABLED) continue; if (func) @@ -156,30 +156,30 @@ void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata, } } - track= track->next; + track = track->next; } } void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track) { - MovieTracking *tracking= &clip->tracking; - MovieTrackingStabilization *stab= &tracking->stabilization; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTracking *tracking = &clip->tracking; + MovieTrackingStabilization *stab = &tracking->stabilization; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); - int has_bundle= 0, update_stab= 0; + int has_bundle = FALSE, update_stab = FALSE; if (track==act_track) - tracking->act_track= NULL; + tracking->act_track = NULL; - if (track==stab->rot_track) { - stab->rot_track= NULL; + if (track == stab->rot_track) { + stab->rot_track = NULL; - update_stab= 1; + update_stab = TRUE; } /* handle reconstruction display in 3d viewport */ - if (track->flag&TRACK_HAS_BUNDLE) - has_bundle= 1; + if (track->flag & TRACK_HAS_BUNDLE) + has_bundle = TRUE; BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); @@ -187,7 +187,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); if (update_stab) { - tracking->stabilization.ok= 0; + tracking->stabilization.ok = FALSE; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -199,7 +199,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie 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 { @@ -217,6 +217,6 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y) ED_space_clip_size(sc, &width, &height); ED_space_clip_aspect(sc, &aspx, &aspy); - sc->xof= (x-0.5f)*width*aspx; - sc->yof= (y-0.5f)*height*aspy; + sc->xof = (x - 0.5f) * width * aspx; + sc->yof = (y - 0.5f) * height * aspy; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index ca66248682c..228c716e3b6 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -71,47 +71,47 @@ static void init_preview_region(const bContext *C, ARegion *ar) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); - ar->regiontype= RGN_TYPE_PREVIEW; - ar->alignment= RGN_ALIGN_TOP; - ar->flag|= RGN_FLAG_HIDDEN; + ar->regiontype = RGN_TYPE_PREVIEW; + ar->alignment = RGN_ALIGN_TOP; + ar->flag |= RGN_FLAG_HIDDEN; ar->v2d.tot.xmin = 0.0f; ar->v2d.tot.ymin = -10.0f; ar->v2d.tot.xmax = (float)scene->r.efra; ar->v2d.tot.ymax = 10.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= FLT_MIN; - ar->v2d.min[1]= FLT_MIN; + ar->v2d.min[0] = FLT_MIN; + ar->v2d.min[1] = FLT_MIN; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); - ar->v2d.keeptot= 0; + ar->v2d.keeptot = 0; } static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); if (ar) return ar; /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + 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"); + arnew = MEM_callocN(sizeof(ARegion), "clip preview region"); BLI_insertlinkbefore(&sa->regionbase, ar, arnew); init_preview_region(C, arnew); @@ -121,30 +121,30 @@ static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) static void clip_scopes_tag_refresh(ScrArea *sa) { - SpaceClip *sc= (SpaceClip *)sa->spacedata.first; + 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 */ - for (ar=sa->regionbase.first; ar; ar=ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN) return; } - sc->scopes.ok= 0; + sc->scopes.ok = FALSE; } static void clip_stabilization_tag_refresh(ScrArea *sa) { - SpaceClip *sc= (SpaceClip *)sa->spacedata.first; - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = (SpaceClip *) sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); if (clip) { - MovieTrackingStabilization *stab= &clip->tracking.stabilization; + MovieTrackingStabilization *stab = &clip->tracking.stabilization; - stab->ok= 0; + stab->ok = FALSE; } } @@ -155,62 +155,62 @@ static SpaceLink *clip_new(const bContext *C) ARegion *ar; SpaceClip *sc; - sc= MEM_callocN(sizeof(SpaceClip), "initclip"); - sc->spacetype= SPACE_CLIP; - sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; - sc->zoom= 1.0f; - sc->path_length= 20; - sc->scopes.track_preview_height= 120; + sc = MEM_callocN(sizeof(SpaceClip), "initclip"); + sc->spacetype = SPACE_CLIP; + sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; + sc->zoom = 1.0f; + sc->path_length = 20; + sc->scopes.track_preview_height = 120; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for clip"); + ar = MEM_callocN(sizeof(ARegion), "header for clip"); BLI_addtail(&sc->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* tools view */ - ar= MEM_callocN(sizeof(ARegion), "tools for clip"); + ar = MEM_callocN(sizeof(ARegion), "tools for clip"); BLI_addtail(&sc->regionbase, ar); - ar->regiontype= RGN_TYPE_TOOLS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_TOOLS; + ar->alignment = RGN_ALIGN_LEFT; /* tool properties */ - ar= MEM_callocN(sizeof(ARegion), "tool properties for clip"); + ar = MEM_callocN(sizeof(ARegion), "tool properties for clip"); BLI_addtail(&sc->regionbase, ar); - ar->regiontype= RGN_TYPE_TOOL_PROPS; - ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->regiontype = RGN_TYPE_TOOL_PROPS; + ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; /* properties view */ - ar= MEM_callocN(sizeof(ARegion), "properties for clip"); + ar = MEM_callocN(sizeof(ARegion), "properties for clip"); BLI_addtail(&sc->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; /* preview view */ - ar= MEM_callocN(sizeof(ARegion), "preview for clip"); + ar = MEM_callocN(sizeof(ARegion), "preview for clip"); BLI_addtail(&sc->regionbase, ar); init_preview_region(C, ar); /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for clip"); + ar = MEM_callocN(sizeof(ARegion), "main area for clip"); BLI_addtail(&sc->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - return (SpaceLink *)sc; + return (SpaceLink *) sc; } /* not spacelink itself */ static void clip_free(SpaceLink *sl) { - SpaceClip *sc= (SpaceClip*) sl; + SpaceClip *sc = (SpaceClip*) sl; - sc->clip= NULL; + sc->clip = NULL; if (sc->scopes.track_preview) IMB_freeImBuf(sc->scopes.track_preview); @@ -224,11 +224,11 @@ static void clip_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *clip_duplicate(SpaceLink *sl) { - SpaceClip *scn= MEM_dupallocN(sl); + SpaceClip *scn = MEM_dupallocN(sl); /* clear or remove stuff from old */ - scn->scopes.track_preview= NULL; - scn->scopes.ok= 0; + scn->scopes.track_preview = NULL; + scn->scopes.ok = FALSE; return (SpaceLink *)scn; } @@ -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); @@ -615,29 +615,29 @@ const char *clip_context_dir[]= {"edit_movieclip", NULL}; static int clip_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); if (CTX_data_dir(member)) { CTX_data_dir_set(result, clip_context_dir); - return 1; + return TRUE; } else if (CTX_data_equals(member, "edit_movieclip")) { CTX_data_id_pointer_set(result, &sc->clip->id); - return 1; + return TRUE; } - return 0; + return FALSE; } static void clip_refresh(const bContext *C, ScrArea *sa) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *window= CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *window = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); - SpaceClip *sc= (SpaceClip *)sa->spacedata.first; - ARegion *ar_main= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - ARegion *ar_preview= clip_has_preview_region(C, sa); - int view_changed= 0; + SpaceClip *sc = (SpaceClip *)sa->spacedata.first; + ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar_preview = clip_has_preview_region(C, sa); + int view_changed = FALSE; switch (sc->view) { case SC_VIEW_CLIP: @@ -645,11 +645,11 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_preview->flag |= RGN_FLAG_HIDDEN; ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; WM_event_remove_handlers((bContext*)C, &ar_preview->handlers); - view_changed= 1; + view_changed = TRUE; } if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment= RGN_ALIGN_NONE; - view_changed= 1; + ar_main->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; } if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { /* store graph region align */ @@ -658,8 +658,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa) else sc->runtime_flag |= SC_GRAPH_BOTTOM; - ar_preview->alignment= RGN_ALIGN_NONE; - view_changed= 1; + ar_preview->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; } break; case SC_VIEW_GRAPH: @@ -667,19 +667,19 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_preview->flag &= ~RGN_FLAG_HIDDEN; ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; ar_preview->v2d.cur = ar_preview->v2d.tot; - view_changed= 1; + view_changed = TRUE; } if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment= RGN_ALIGN_NONE; - view_changed= 1; + ar_main->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; } if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { if (sc->runtime_flag & SC_GRAPH_BOTTOM) - ar_preview->alignment= RGN_ALIGN_BOTTOM; + ar_preview->alignment = RGN_ALIGN_BOTTOM; else - ar_preview->alignment= RGN_ALIGN_TOP; + ar_preview->alignment = RGN_ALIGN_TOP; - view_changed= 1; + view_changed = TRUE; } break; } @@ -697,20 +697,20 @@ static void clip_refresh(const bContext *C, ScrArea *sa) /* sets up the fields of the View2D from zoom and offset */ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); float x1, y1, w, h; int width, height, winx, winy; ED_space_clip_size(sc, &width, &height); - w= width; - h= height; + w = width; + h = height; if (clip) - h*= clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect; + h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect; - winx= ar->winrct.xmax - ar->winrct.xmin + 1; - winy= ar->winrct.ymax - ar->winrct.ymin + 1; + winx = ar->winrct.xmax - ar->winrct.xmin + 1; + winy = ar->winrct.ymax - ar->winrct.ymin + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; @@ -722,19 +722,19 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) ar->v2d.mask.ymax = winy; /* which part of the image space do we see? */ - x1= ar->winrct.xmin+(winx-sc->zoom*w)/2.0f; - y1= ar->winrct.ymin+(winy-sc->zoom*h)/2.0f; + x1= ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f; + y1= ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f; - x1-= sc->zoom*sc->xof; - y1-= sc->zoom*sc->yof; + x1-= sc->zoom * sc->xof; + y1-= sc->zoom * sc->yof; /* relative display right */ - ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1)/sc->zoom); - ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx/sc->zoom); + ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / sc->zoom; + ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sc->zoom); /* relative display left */ - ar->v2d.cur.ymin = ((ar->winrct.ymin-(float)y1)/sc->zoom); - ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy/sc->zoom); + ar->v2d.cur.ymin = (ar->winrct.ymin - (float)y1) / sc->zoom; + ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sc->zoom); /* normalize 0.0..1.0 */ ar->v2d.cur.xmin /= w; @@ -761,25 +761,25 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) static void clip_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceClip *sc= CTX_wm_space_clip(C); - Scene *scene= CTX_data_scene(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + Scene *scene = CTX_data_scene(C); + MovieClip *clip = ED_space_clip(sc); /* if tracking is in progress, we should synchronize framenr from clipuser * so latest tracked frame would be shown */ if (clip && clip->tracking_context) BKE_tracking_sync_user(&sc->user, clip->tracking_context); - if (sc->flag&SC_LOCK_SELECTION) { - ImBuf *tmpibuf= NULL; + if (sc->flag & SC_LOCK_SELECTION) { + ImBuf *tmpibuf = NULL; - if (clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { - tmpibuf= ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); + 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)) { - sc->xof+= sc->xlockof; - sc->yof+= sc->ylockof; + sc->xof += sc->xlockof; + sc->yof += sc->ylockof; } if (tmpibuf) @@ -810,7 +810,7 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCREEN: - if (wmn->data==ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; } @@ -834,11 +834,11 @@ static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar) static void clip_preview_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - SpaceClip *sc= CTX_wm_space_clip(C); - Scene *scene= CTX_data_scene(C); - short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; + SpaceClip *sc = CTX_wm_space_clip(C); + Scene *scene = CTX_data_scene(C); + short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; if (sc->flag & SC_LOCK_TIMECURSOR) ED_clip_graph_center_current_frame(scene, ar); @@ -856,7 +856,7 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -931,7 +931,7 @@ static void clip_properties_area_init(wmWindowManager *wm, ARegion *ar) static void clip_properties_area_draw(const bContext *C, ARegion *ar) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); BKE_movieclip_update_scopes(sc->clip, &sc->user, &sc->scopes); @@ -943,11 +943,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCREEN: - if (wmn->data==ND_GPENCIL) + if (wmn->data ==ND_GPENCIL) 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; } @@ -958,86 +958,86 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_clip(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype clip"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype clip"); ARegionType *art; - st->spaceid= SPACE_CLIP; + st->spaceid = SPACE_CLIP; strncpy(st->name, "Clip", BKE_ST_MAXNAME); - st->new= clip_new; - st->free= clip_free; - st->init= clip_init; - st->duplicate= clip_duplicate; - st->operatortypes= clip_operatortypes; - st->keymap= clip_keymap; - st->listener= clip_listener; - st->context= clip_context; - st->refresh= clip_refresh; + st->new = clip_new; + st->free = clip_free; + st->init = clip_init; + st->duplicate = clip_duplicate; + st->operatortypes = clip_operatortypes; + st->keymap = clip_keymap; + st->listener = clip_listener; + st->context = clip_context; + st->refresh = clip_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip region"); - art->regionid= RGN_TYPE_WINDOW; - art->init= clip_main_area_init; - art->draw= clip_main_area_draw; - art->listener= clip_main_area_listener; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL; + art = MEM_callocN(sizeof(ARegionType), "spacetype clip region"); + art->regionid = RGN_TYPE_WINDOW; + art->init = clip_main_area_init; + art->draw = clip_main_area_draw; + art->listener = clip_main_area_listener; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); /* preview */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip region preview"); + art = MEM_callocN(sizeof(ARegionType), "spacetype clip region preview"); art->regionid = RGN_TYPE_PREVIEW; art->prefsizey = 240; - art->init= clip_preview_area_init; - art->draw= clip_preview_area_draw; - art->listener= clip_preview_area_listener; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->init = clip_preview_area_init; + art->draw = clip_preview_area_draw; + art->listener = clip_preview_area_listener; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); /* regions: properties */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); - art->regionid= RGN_TYPE_UI; - art->prefsizex= UI_COMPACT_PANEL_WIDTH; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI; - art->init= clip_properties_area_init; - art->draw= clip_properties_area_draw; - art->listener= clip_properties_area_listener; + art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); + art->regionid = RGN_TYPE_UI; + art->prefsizex = UI_COMPACT_PANEL_WIDTH; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->init = clip_properties_area_init; + art->draw = clip_properties_area_draw; + art->listener = clip_properties_area_listener; BLI_addhead(&st->regiontypes, art); ED_clip_buttons_register(art); /* regions: tools */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip region tools"); - art->regionid= RGN_TYPE_TOOLS; - art->prefsizex= UI_COMPACT_PANEL_WIDTH; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI; - art->listener= clip_props_area_listener; - art->init= clip_tools_area_init; - art->draw= clip_tools_area_draw; + art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools"); + art->regionid = RGN_TYPE_TOOLS; + art->prefsizex = UI_COMPACT_PANEL_WIDTH; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->listener = clip_props_area_listener; + art->init = clip_tools_area_init; + art->draw = clip_tools_area_draw; BLI_addhead(&st->regiontypes, art); /* tool properties */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region"); art->regionid = RGN_TYPE_TOOL_PROPS; - art->prefsizex= 0; - art->prefsizey= 120; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI; - art->listener= clip_props_area_listener; - art->init= clip_tools_area_init; - art->draw= clip_tools_area_draw; + art->prefsizex = 0; + art->prefsizey = 120; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->listener = clip_props_area_listener; + art->init = clip_tools_area_init; + art->draw = clip_tools_area_draw; ED_clip_tool_props_register(art); BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype clip region"); - art->regionid= RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art = MEM_callocN(sizeof(ARegionType), "spacetype clip region"); + art->regionid = RGN_TYPE_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->init= clip_header_area_init; - art->draw= clip_header_area_draw; + art->init = clip_header_area_init; + art->draw = clip_header_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 6cb7536b1ae..79569b82476 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -80,41 +80,41 @@ static int space_clip_frame_poll(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); if (clip) return BKE_movieclip_has_frame(clip, &sc->user); } - return 0; + return FALSE; } /********************** add marker operator *********************/ static void add_marker(SpaceClip *sc, float x, float y) { - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; int width, height; - + ED_space_clip_size(sc, &width, &height); - track= BKE_tracking_add_track(tracking, tracksbase, x, y, sc->user.framenr, width, height); + track = BKE_tracking_add_track(tracking, tracksbase, x, y, sc->user.framenr, width, height); BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0); - clip->tracking.act_track= track; + clip->tracking.act_track = track; } static int add_marker_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); float pos[2]; int width, height; @@ -127,8 +127,8 @@ static int add_marker_exec(bContext *C, wmOperator *op) add_marker(sc, pos[0], pos[1]); /* reset offset from locked position, so frame jumping wouldn't be so confusing */ - sc->xlockof= 0; - sc->ylockof= 0; + sc->xlockof = 0; + sc->ylockof = 0; WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); @@ -170,23 +170,23 @@ void CLIP_OT_add_marker(wmOperatorType *ot) static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track= tracksbase->first, *next; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *track = tracksbase->first, *next; while (track) { - next= track->next; + next = track->next; if (TRACK_VIEW_SELECTED(sc, track)) clip_delete_track(C, clip, tracksbase, track); - track= next; + track = next; } /* nothing selected now, unlock view so it can be scrolled nice again */ - sc->flag&= ~SC_LOCK_SELECTION; + sc->flag &= ~SC_LOCK_SELECTION; return OPERATOR_FINISHED; } @@ -211,32 +211,32 @@ void CLIP_OT_delete_track(wmOperatorType *ot) static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); - MovieTrackingTrack *track= tracksbase->first, *next; - int framenr= sc->user.framenr; - int has_selection= 0; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + MovieTrackingTrack *track = tracksbase->first, *next; + int framenr = sc->user.framenr; + int has_selection = 0; while (track) { - next= track->next; + next = track->next; if (TRACK_VIEW_SELECTED(sc, track)) { - MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, framenr); + MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); if (marker) { - has_selection|= track->markersnr>1; + has_selection |= track->markersnr>1; clip_delete_marker(C, clip, tracksbase, track, marker); } } - track= next; + track = next; } if (!has_selection) { /* nothing selected now, unlock view so it can be scrolled nice again */ - sc->flag&= ~SC_LOCK_SELECTION; + sc->flag &= ~SC_LOCK_SELECTION; } return OPERATOR_FINISHED; @@ -281,57 +281,57 @@ typedef struct { static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, wmEvent *event, int area, int action, int width, int height) { - SlideMarkerData *data= MEM_callocN(sizeof(SlideMarkerData), "slide marker data"); + SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data"); - marker= BKE_tracking_ensure_marker(track, sc->user.framenr); + marker = BKE_tracking_ensure_marker(track, sc->user.framenr); - data->area= area; - data->action= action; - data->track= track; - data->marker= marker; + data->area = area; + data->action = action; + data->track = track; + data->marker = marker; - if (area==TRACK_AREA_POINT) { - data->pos= marker->pos; - data->offset= track->offset; + 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) { - data->min= track->pat_min; - data->max= track->pat_max; + else if (area == TRACK_AREA_PAT) { + if (action == SLIDE_ACTION_SIZE) { + data->min = track->pat_min; + data->max = track->pat_max; } else { int a; - data->pos= marker->pos; - data->offset= track->offset; + data->pos = marker->pos; + data->offset = track->offset; copy_v2_v2(data->soff, track->offset); - data->smarkers= MEM_callocN(sizeof(*data->smarkers)*track->markersnr, "slide marekrs"); - for (a= 0; a<track->markersnr; a++) + data->smarkers = MEM_callocN(sizeof(*data->smarkers)*track->markersnr, "slide marekrs"); + for (a = 0; a < track->markersnr; a++) copy_v2_v2(data->smarkers[a], track->markers[a].pos); } } - else if (area==TRACK_AREA_SEARCH) { - data->min= track->search_min; - data->max= track->search_max; + 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); } - data->mval[0]= event->mval[0]; - data->mval[1]= event->mval[1]; + data->mval[0] = event->mval[0]; + data->mval[1] = event->mval[1]; - data->width= width; - data->height= height; + data->width = width; + data->height = height; - if (action==SLIDE_ACTION_SIZE) - data->lock= 1; + if (action == SLIDE_ACTION_SIZE) + data->lock = 1; return data; } @@ -339,14 +339,14 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra /* corner = 0: right-bottom corner, * corner = 1: left-top corner */ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, - int area, float co[2], int corner, int width, int height) + int area, float co[2], int corner, int width, int height) { - int inside= 0; - float size= 12.0f; + int inside = 0; + float size = 12.0f; 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); } @@ -355,26 +355,26 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki copy_v2_v2(max, track->pat_max); } - dx= size/width/sc->zoom; - dy= size/height/sc->zoom; + dx = size / width / sc->zoom; + dy = size / height / sc->zoom; - tdx= 5.0f/width/sc->zoom; - tdy= 5.0f/height/sc->zoom; + tdx = 5.0f / width / sc->zoom; + tdy = 5.0f / height / sc->zoom; - dx= MIN2(dx, (max[0]-min[0])/6.0f) + tdx; - dy= MIN2(dy, (max[1]-min[1])/6.0f) + tdy; + dx = MIN2(dx, (max[0] - min[0]) / 6.0f) + tdx; + dy = MIN2(dy, (max[1] - min[1]) / 6.0f) + tdy; - if (corner==0) { - crn[0]= marker->pos[0]+max[0]; - crn[1]= marker->pos[1]+min[1]; + 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; + inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + tdx && co[1] >= crn[1] - tdy && co[1] <= crn[1] + dy; } else { - crn[0]= marker->pos[0]+min[0]; - crn[1]= marker->pos[1]+max[1]; + crn[0] = marker->pos[0]+min[0]; + crn[1] = marker->pos[1]+max[1]; - inside= co[0]>=crn[0]-dx && co[0]<=crn[0]+dx && co[1]>=crn[1]-dy && co[1]<=crn[1]+dy; + inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + dx && co[1] >= crn[1] - dy && co[1] <= crn[1] + dy; } return inside; @@ -387,69 +387,69 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki add_v2_v2v2(pos, marker->pos, track->offset); - dx= 12.0f/width/sc->zoom; - dy= 12.0f/height/sc->zoom; + dx = 12.0f / width / sc->zoom; + dy = 12.0f / height /sc->zoom; - dx=MIN2(dx, (track->pat_max[0]-track->pat_min[0])/2.0f); - dy=MIN2(dy, (track->pat_max[1]-track->pat_min[1])/2.0f); + dx = MIN2(dx, (track->pat_max[0] - track->pat_min[0]) / 2.0f); + dy = MIN2(dy, (track->pat_max[1] - track->pat_min[1]) / 2.0f); - return co[0]>=pos[0]-dx && co[0]<=pos[0]+dx && co[1]>=pos[1]-dy && co[1]<=pos[1]+dy; + return co[0] >= pos[0] - dx && co[0] <= pos[0] + dx && co[1] >= pos[1] - dy && co[1] <= pos[1] + dy; } static void hide_cursor(bContext *C) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); WM_cursor_set(win, CURSOR_NONE); } static void show_cursor(bContext *C) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); WM_cursor_set(win, CURSOR_STD); } static void *slide_marker_customdata(bContext *C, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; int width, height; float co[2]; - void *customdata= NULL; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + void *customdata = NULL; + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); 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; + track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); + 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 ((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); + 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 (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); + 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)) - customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, 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 (!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); + 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)) - customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); } if (customdata) @@ -457,7 +457,7 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) } } - track= track->next; + track = track->next; } return customdata; @@ -465,16 +465,16 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SlideMarkerData *slidedata= slide_marker_customdata(C, event); + SlideMarkerData *slidedata = slide_marker_customdata(C, event); if (slidedata) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; - tracking->act_track= slidedata->track; + tracking->act_track = slidedata->track; - op->customdata= slidedata; + op->customdata = slidedata; hide_cursor(C); WM_event_add_modal_handler(C, op); @@ -491,20 +491,20 @@ static void cancel_mouse_slide(SlideMarkerData *data) { /* cancel sliding */ if (data->area == TRACK_AREA_POINT) { - if (data->action==SLIDE_ACTION_OFFSET) + 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) { + if (data->action == SLIDE_ACTION_SIZE) { copy_v2_v2(data->min, data->smin); copy_v2_v2(data->max, data->smax); } else { int a; - for (a= 0; a<data->track->markersnr; a++) + for (a = 0; a<data->track->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -514,14 +514,16 @@ 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); } static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc= CTX_wm_space_clip(C); - SlideMarkerData *data= (SlideMarkerData *)op->customdata; + SpaceClip *sc = CTX_wm_space_clip(C); + SlideMarkerData *data = (SlideMarkerData *)op->customdata; float dx, dy, mdelta[2]; switch(event->type) { @@ -529,72 +531,76 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTCTRLKEY: case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - if (data->action==SLIDE_ACTION_SIZE) + if (data->action == SLIDE_ACTION_SIZE) if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) - data->lock= event->val==KM_RELEASE; + data->lock = event->val == KM_RELEASE; if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) - data->accurate= event->val==KM_PRESS; + data->accurate = event->val == KM_PRESS; /* no break! update area size */ case MOUSEMOVE: - mdelta[0]= event->mval[0]-data->mval[0]; - mdelta[1]= event->mval[1]-data->mval[1]; + mdelta[0] = event->mval[0]-data->mval[0]; + mdelta[1] = event->mval[1]-data->mval[1]; - dx= mdelta[0]/data->width/sc->zoom; + dx = mdelta[0] / data->width / sc->zoom; - if (data->lock) dy= -dx/data->height*data->width; - else dy= mdelta[1]/data->height/sc->zoom; + if (data->lock) + dy = -dx / data->height * data->width; + else + dy = mdelta[1] / data->height / sc->zoom; if (data->accurate) { - dx/= 5; - dy/= 5; + dx /= 5; + dy /= 5; } - 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; + 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 { - data->pos[0]= data->spos[0]+dx; - data->pos[1]= data->spos[1]+dy; + data->pos[0] = data->spos[0] + dx; + data->pos[1] = data->spos[1] + dy; - data->marker->flag&= ~MARKER_TRACKED; + data->marker->flag &= ~MARKER_TRACKED; } 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) { - data->min[0]= data->smin[0]-dx; - data->max[0]= data->smax[0]+dx; + 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; + 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); - else BKE_tracking_clamp_track(data->track, CLAMP_PAT_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 { - float d[2]={dx, dy}; + 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 { int a; - for (a= 0; a<data->track->markersnr; a++) + for (a = 0; a<data->track->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); } } @@ -604,7 +610,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); @@ -653,10 +659,14 @@ 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); - return (co[0]>=x1-epsx && co[0]<=x2+epsx) && (co[1]>=y1-epsy && co[1]<=y2+epsy); + if (y1 > y2) + SWAP(float, y1, y2); + + return (co[0] >= x1 - epsx && co[0] <= x2 + epsx) && (co[1] >= y1 - epsy && co[1] <= y2 + epsy); } static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy) @@ -669,31 +679,32 @@ static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); float epsx, epsy; int width, height; ED_space_clip_size(sc, &width, &height); - epsx= MIN4(track->pat_min[0]-track->search_min[0], track->search_max[0]-track->pat_max[0], + epsx = MIN4(track->pat_min[0]-track->search_min[0], track->search_max[0]-track->pat_max[0], fabsf(track->pat_min[0]), fabsf(track->pat_max[0])) / 2; - epsy= MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1], + epsy = MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1], fabsf(track->pat_min[1]), fabsf(track->pat_max[1])) / 2; - epsx= MAX2(epsx, 2.0f / width); - epsy= MAX2(epsy, 2.0f / height); + epsx = MAX2(epsx, 2.0f / width); + epsy = MAX2(epsy, 2.0f / height); - if (sc->flag&SC_SHOW_MARKER_SEARCH) + 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 ((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; + 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) return TRACK_AREA_POINT; @@ -705,51 +716,51 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) { float d1, d2, d3, d4; - float p[2]= {co[0]-pos[0], co[1]-pos[1]}; - float v1[2]= {min[0], min[1]}, v2[2]= {max[0], min[1]}, - v3[2]= {max[0], max[1]}, v4[2]= {min[0], max[1]}; + float p[2] = {co[0]-pos[0], co[1]-pos[1]}; + float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}, + v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; - d1= dist_to_line_segment_v2(p, v1, v2); - d2= dist_to_line_segment_v2(p, v2, v3); - d3= dist_to_line_segment_v2(p, v3, v4); - d4= dist_to_line_segment_v2(p, v4, v1); + d1 = dist_to_line_segment_v2(p, v1, v2); + d2 = dist_to_line_segment_v2(p, v2, v3); + d3 = dist_to_line_segment_v2(p, v3, v4); + d4 = dist_to_line_segment_v2(p, v4, v1); return MIN4(d1, d2, d3, d4); } static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2]) { - MovieTrackingTrack *track= NULL, *cur; - float mindist= 0.0f; + MovieTrackingTrack *track = NULL, *cur; + float mindist = 0.0f; - cur= tracksbase->first; + cur = tracksbase->first; while (cur) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(cur, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_get_marker(cur, sc->user.framenr); - if (((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) { - float dist, d1, d2=FLT_MAX, d3=FLT_MAX; + 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); + dist = MIN3(d1, d2, d3); - if (track==NULL || dist<mindist) { - track= cur; - mindist= dist; + if (track == NULL || dist<mindist) { + track = cur; + mindist = dist; } } - cur= cur->next; + cur = cur->next; } return track; @@ -757,39 +768,39 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas static int mouse_select(bContext *C, float co[2], int extend) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - MovieTrackingTrack *track= NULL; /* selected marker */ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); + MovieTrackingTrack *track = NULL; /* selected marker */ - track= find_nearest_track(sc, tracksbase, co); + track = find_nearest_track(sc, tracksbase, co); if (track) { - int area= track_mouse_area(sc, co, track); + int area = track_mouse_area(sc, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) - area= TRACK_AREA_ALL; + area = TRACK_AREA_ALL; if (extend && TRACK_AREA_SELECTED(track, area)) { - if (track==act_track) + if (track == act_track) BKE_tracking_deselect_track(track, area); else - clip->tracking.act_track= track; + clip->tracking.act_track = track; } else { - if (area==TRACK_AREA_POINT) - area= TRACK_AREA_ALL; + if (area == TRACK_AREA_POINT) + area = TRACK_AREA_ALL; BKE_tracking_select_track(tracksbase, track, area, extend); - clip->tracking.act_track= track; + clip->tracking.act_track = track; } } if (!extend) { - sc->xlockof= 0.0f; - sc->ylockof= 0.0f; + sc->xlockof = 0.0f; + sc->ylockof = 0.0f; } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -803,7 +814,7 @@ static int select_exec(bContext *C, wmOperator *op) int extend; RNA_float_get_array(op->ptr, "location", co); - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); return mouse_select(C, co, extend); } @@ -811,16 +822,16 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { float co[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); + int extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) { - SlideMarkerData *slidedata= slide_marker_customdata(C, event); + SlideMarkerData *slidedata = slide_marker_customdata(C, event); if (slidedata) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); - clip->tracking.act_track= slidedata->track; + clip->tracking.act_track = slidedata->track; WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -862,13 +873,13 @@ void CLIP_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); rcti rect; rctf rectf; - int change= 0, mode, extend; + int change = FALSE, mode, extend; /* get rectangle from operator */ rect.xmin = RNA_int_get(op->ptr, "xmin"); @@ -879,14 +890,14 @@ static int border_select_exec(bContext *C, wmOperator *op) ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - mode= RNA_int_get(op->ptr, "gesture_mode"); - extend= RNA_boolean_get(op->ptr, "extend"); + mode = RNA_int_get(op->ptr, "gesture_mode"); + extend = RNA_boolean_get(op->ptr, "extend"); /* do actual selection */ - track= tracksbase->first; + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); + 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])) { @@ -896,11 +907,11 @@ static int border_select_exec(bContext *C, wmOperator *op) BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); } - change= 1; + change = TRUE; } } - track= track->next; + track = track->next; } if (change) { @@ -939,52 +950,52 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f /* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */ float x, y; - x= (marker->pos[0] - offset[0])*ellipse[0]; - y= (marker->pos[1] - offset[1])*ellipse[1]; + x = (marker->pos[0] - offset[0])*ellipse[0]; + y = (marker->pos[1] - offset[1])*ellipse[1]; return x*x + y*y < 1.0f; } static int circle_select_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - ARegion *ar= CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + ARegion *ar = CTX_wm_region(C); MovieTrackingTrack *track; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); - int x, y, radius, width, height, mode, change= 0; + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; /* get operator properties */ - x= RNA_int_get(op->ptr, "x"); - y= RNA_int_get(op->ptr, "y"); - radius= RNA_int_get(op->ptr, "radius"); + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); + radius = RNA_int_get(op->ptr, "radius"); - mode= RNA_int_get(op->ptr, "gesture_mode"); + mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ ED_space_clip_size(sc, &width, &height); ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ellipse[0]= width*zoomx/radius; - ellipse[1]= height*zoomy/radius; + ellipse[0] = width * zoomx / radius; + ellipse[1] = height * zoomy / radius; ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]); /* do selection */ - track= tracksbase->first; + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); + 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)) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); - change= 1; + change = TRUE; } } - track= track->next; + track = track->next; } if (change) { @@ -1023,66 +1034,66 @@ void CLIP_OT_select_circle(wmOperatorType *ot) static int select_all_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTrackingTrack *track= NULL; /* selected track */ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTrackingTrack *track = NULL; /* selected track */ MovieTrackingMarker *marker; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); - int action= RNA_enum_get(op->ptr, "action"); - int framenr= sc->user.framenr; - int has_selection= 0; + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + int action = RNA_enum_get(op->ptr, "action"); + int framenr = sc->user.framenr; + int has_selection = FALSE; if (action == SEL_TOGGLE) { - action= SEL_SELECT; - track= tracksbase->first; + action = SEL_SELECT; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - marker= BKE_tracking_get_marker(track, framenr); + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { - action= SEL_DESELECT; + action = SEL_DESELECT; break; } } - track= track->next; + track = track->next; } } - track= tracksbase->first; + track = tracksbase->first; while (track) { - if ((track->flag&TRACK_HIDDEN)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if ((track->flag & TRACK_HIDDEN)==0) { + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, marker)) { switch (action) { case SEL_SELECT: - track->flag|= SELECT; - track->pat_flag|= SELECT; - track->search_flag|= SELECT; + track->flag |= SELECT; + track->pat_flag |= SELECT; + track->search_flag |= SELECT; break; case SEL_DESELECT: - track->flag&= ~SELECT; - track->pat_flag&= ~SELECT; - track->search_flag&= ~SELECT; + track->flag &= ~SELECT; + track->pat_flag &= ~SELECT; + track->search_flag &= ~SELECT; break; case SEL_INVERT: - track->flag^= SELECT; - track->pat_flag^= SELECT; - track->search_flag^= SELECT; + track->flag ^= SELECT; + track->pat_flag ^= SELECT; + track->search_flag ^= SELECT; break; } } } if (TRACK_VIEW_SELECTED(sc, track)) - has_selection= 1; + has_selection = TRUE; - track= track->next; + track = track->next; } if (!has_selection) - sc->flag&= ~SC_LOCK_SELECTION; + sc->flag &= ~SC_LOCK_SELECTION; WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -1110,56 +1121,58 @@ void CLIP_OT_select_all(wmOperatorType *ot) static int select_groped_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; MovieTrackingMarker *marker; - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - int group= RNA_enum_get(op->ptr, "group"); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + int group = RNA_enum_get(op->ptr, "group"); - track= tracksbase->first; + track = tracksbase->first; while (track) { - int ok= 0; + int ok = FALSE; - marker= BKE_tracking_get_marker(track, sc->user.framenr); + marker = BKE_tracking_get_marker(track, sc->user.framenr); - if (group==0) { /* Keyframed */ - ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED)==0; + if (group == 0) { /* Keyframed */ + ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED)==0; } - else if (group==1) { /* Estimated */ - ok= marker->framenr!=sc->user.framenr; + else if (group == 1) { /* Estimated */ + ok = marker->framenr != sc->user.framenr; } - else if (group==2) { /* tracked */ - ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED); + else if (group == 2) { /* tracked */ + ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED); } - else if (group==3) { /* locked */ - ok= track->flag&TRACK_LOCKED; + else if (group == 3) { /* locked */ + ok = track->flag & TRACK_LOCKED; } - else if (group==4) { /* disabled */ - ok= marker->flag&MARKER_DISABLED; + else if (group == 4) { /* disabled */ + ok = marker->flag & MARKER_DISABLED; } - else if (group==5) { /* color */ - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + else if (group == 5) { /* color */ + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); if (act_track) { - ok= (track->flag&TRACK_CUSTOMCOLOR) == (act_track->flag&TRACK_CUSTOMCOLOR); + ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR); - if (ok && track->flag&TRACK_CUSTOMCOLOR) - ok= equals_v3v3(track->color, act_track->color); + if (ok && track->flag & TRACK_CUSTOMCOLOR) + ok = equals_v3v3(track->color, act_track->color); } } - else if (group==6) { /* failed */ - ok= (track->flag&TRACK_HAS_BUNDLE) == 0; + else if (group == 6) { /* failed */ + ok = (track->flag & TRACK_HAS_BUNDLE) == 0; } 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; + 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; } - track= track->next; + track = track->next; } WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -1217,21 +1230,21 @@ static int track_markers_testbreak(void) static int track_count_markers(SpaceClip *sc, MovieClip *clip) { - int tot= 0; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + int tot = 0; + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr= sc->user.framenr; + int framenr = sc->user.framenr; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); + 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) + if (!marker || (marker->flag & MARKER_DISABLED) == 0) tot++; } - track= track->next; + track = track->next; } return tot; @@ -1239,13 +1252,13 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) { - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); int hidden = 0; - if ((sc->flag&SC_SHOW_MARKER_PATTERN)==0) + if ((sc->flag & SC_SHOW_MARKER_PATTERN)==0) hidden |= TRACK_AREA_PAT; - if ((sc->flag&SC_SHOW_MARKER_SEARCH)==0) + if ((sc->flag & SC_SHOW_MARKER_SEARCH)==0) hidden |= TRACK_AREA_SEARCH; if (hidden) { @@ -1262,128 +1275,139 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit_r) { - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr= sc->user.framenr; - int frames_limit= 0; + int framenr = sc->user.framenr; + int frames_limit = 0; clear_invisible_track_selection(sc, clip); - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { + 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) - frames_limit= track->frames_limit; + if (frames_limit == 0) + frames_limit = track->frames_limit; else - frames_limit= MIN2(frames_limit, track->frames_limit); + frames_limit = MIN2(frames_limit, track->frames_limit); } } } - track= track->next; + track = track->next; } - *frames_limit_r= frames_limit; + *frames_limit_r = frames_limit; } static int track_markers_check_direction(int backwards, int curfra, int efra) { if (backwards) { - if (curfra<efra) return 0; + if (curfra < efra) + return FALSE; } else { - if (curfra>efra) return 0; + if (curfra > efra) + return FALSE; } - return 1; + return TRUE; } static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwards) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - Scene *scene= CTX_data_scene(C); - MovieTrackingSettings *settings= &clip->tracking.settings; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); + MovieTrackingSettings *settings = &clip->tracking.settings; int frames_limit; track_init_markers(sc, clip, &frames_limit); - tmj->sfra= sc->user.framenr; - tmj->clip= clip; - tmj->backwards= backwards; + tmj->sfra = sc->user.framenr; + tmj->clip = clip; + tmj->backwards = backwards; - if (backwards) tmj->efra= SFRA; - else tmj->efra= EFRA; + 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); - else tmj->efra= MIN2(tmj->efra, tmj->sfra+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) { - tmj->delay= 1.0f/scene->r.frs_sec*1000.0f; + 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); + tmj->context = BKE_tracking_context_new(clip, &sc->user, backwards, 1); - clip->tracking_context= tmj->context; + clip->tracking_context = tmj->context; - tmj->lastfra= tmj->sfra; + tmj->lastfra = tmj->sfra; /* XXX: silly to store this, but this data is needed to update scene and movie-clip * frame numbers when tracking is finished. This introduces better feedback for artists. * Maybe there's another way to solve this problem, but can't think better way atm. * Anyway, this way isn't more unstable as animation rendering animation * which uses the same approach (except storing screen). */ - tmj->scene= scene; - tmj->main= CTX_data_main(C); - tmj->screen= CTX_wm_screen(C); + tmj->scene = scene; + tmj->main = CTX_data_main(C); + tmj->screen = CTX_wm_screen(C); return track_markers_check_direction(backwards, tmj->sfra, tmj->efra); } static void track_markers_startjob(void *tmv, short *stop, short *do_update, float *progress) { - TrackMarkersJob *tmj= (TrackMarkersJob *)tmv; - int framenr= tmj->sfra; - //double t= PIL_check_seconds_timer(); + TrackMarkersJob *tmj = (TrackMarkersJob *)tmv; + int framenr = tmj->sfra; + //double t = PIL_check_seconds_timer(); while (framenr != tmj->efra) { - if (tmj->delay>0) { + if (tmj->delay > 0) { /* tracking should happen with fixed fps. Calculate time * using current timer value before tracking frame and after. * * Small (and maybe unneeded optimization): do not calculate exec_time * for "Fastest" tracking */ - double start_time= PIL_check_seconds_timer(), exec_time; + double start_time = PIL_check_seconds_timer(), exec_time; if (!BKE_tracking_next(tmj->context)) break; - exec_time= PIL_check_seconds_timer()-start_time; + exec_time = PIL_check_seconds_timer()-start_time; if (tmj->delay > (float)exec_time) PIL_sleep_ms(tmj->delay-(float)exec_time); } else if (!BKE_tracking_next(tmj->context)) break; - *do_update= 1; - *progress=(float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); + *do_update = TRUE; + *progress = (float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); - if (tmj->backwards) framenr--; - else framenr++; + if (tmj->backwards) + framenr--; + else + framenr++; - tmj->lastfra= framenr; + tmj->lastfra = framenr; if (*stop || track_markers_testbreak()) break; @@ -1394,17 +1418,17 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo static void track_markers_updatejob(void *tmv) { - TrackMarkersJob *tmj= (TrackMarkersJob *)tmv; + TrackMarkersJob *tmj = (TrackMarkersJob *)tmv; BKE_tracking_sync(tmj->context); } static void track_markers_freejob(void *tmv) { - TrackMarkersJob *tmj= (TrackMarkersJob *)tmv; + TrackMarkersJob *tmj = (TrackMarkersJob *)tmv; - tmj->clip->tracking_context= NULL; - tmj->scene->r.cfra= tmj->lastfra; + tmj->clip->tracking_context = NULL; + tmj->scene->r.cfra = tmj->lastfra; ED_update_for_newframe(tmj->main, tmj->scene, tmj->screen, 0); BKE_tracking_sync(tmj->context); @@ -1417,14 +1441,14 @@ static void track_markers_freejob(void *tmv) static int track_markers_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - Scene *scene= CTX_data_scene(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); struct MovieTrackingContext *context; - int framenr= sc->user.framenr; - int sfra= framenr, efra; - int backwards= RNA_boolean_get(op->ptr, "backwards"); - int sequence= RNA_boolean_get(op->ptr, "sequence"); + int framenr = sc->user.framenr; + int sfra = framenr, efra; + int backwards = RNA_boolean_get(op->ptr, "backwards"); + int sequence = RNA_boolean_get(op->ptr, "sequence"); int frames_limit; if (track_count_markers(sc, clip)==0) @@ -1432,20 +1456,22 @@ static int track_markers_exec(bContext *C, wmOperator *op) track_init_markers(sc, clip, &frames_limit); - if (backwards) efra= SFRA; - else efra= EFRA; + 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); - else efra= MIN2(efra, sfra+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)) 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); + context = BKE_tracking_context_new(clip, &sc->user, backwards, sequence); while (framenr != efra) { if (!BKE_tracking_next(context)) @@ -1462,7 +1488,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) BKE_tracking_context_free(context); /* update scene current frame to the lastes tracked frame */ - scene->r.cfra= framenr; + scene->r.cfra = framenr; WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -1473,12 +1499,12 @@ static int track_markers_exec(bContext *C, wmOperator *op) static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { TrackMarkersJob *tmj; - ScrArea *sa= CTX_wm_area(C); - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + ScrArea *sa = CTX_wm_area(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); wmJob *steve; - int backwards= RNA_boolean_get(op->ptr, "backwards"); - int sequence= RNA_boolean_get(op->ptr, "sequence"); + 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))) { /* only one tracking is allowed at a time */ @@ -1494,7 +1520,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve if (!sequence) return track_markers_exec(C, op); - tmj= MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); + tmj = MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); if (!track_markers_initjob(C, tmj, backwards)) { track_markers_freejob(tmj); @@ -1502,7 +1528,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve } /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", WM_JOB_PROGRESS); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", WM_JOB_PROGRESS); WM_jobs_customdata(steve, tmj, track_markers_freejob); /* if there's delay set in tracking job, tracking should happen @@ -1514,7 +1540,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); - G.afbreek= 0; + G.afbreek = 0; WM_jobs_start(CTX_wm_manager(C), steve); WM_cursor_wait(0); @@ -1578,12 +1604,12 @@ typedef struct { static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op, char *error_msg, int max_error) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - Scene *scene= CTX_data_scene(C); - MovieTracking *tracking= &clip->tracking; - MovieTrackingSettings *settings= &clip->tracking.settings; - MovieTrackingObject *object= BKE_tracking_active_object(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); + MovieTracking *tracking = &clip->tracking; + MovieTrackingSettings *settings = &clip->tracking.settings; + MovieTrackingObject *object = BKE_tracking_active_object(tracking); int width, height; if (!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error)) @@ -1592,30 +1618,30 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op /* could fail if footage uses images with different sizes */ BKE_movieclip_get_size(clip, &sc->user, &width, &height); - scj->clip= clip; - scj->scene= scene; - scj->reports= op->reports; - scj->user= sc->user; + scj->clip = clip; + scj->scene = scene; + scj->reports = op->reports; + scj->user = sc->user; - scj->context= BKE_tracking_reconstruction_context_new(tracking, object, + scj->context = BKE_tracking_reconstruction_context_new(tracking, object, settings->keyframe1, settings->keyframe2, width, height); - tracking->stats= MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats"); + tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats"); return 1; } static void solve_camera_updatejob(void *scv) { - SolveCameraJob *scj= (SolveCameraJob *)scv; - MovieTracking *tracking= &scj->clip->tracking; + SolveCameraJob *scj = (SolveCameraJob *)scv; + MovieTracking *tracking = &scj->clip->tracking; BLI_strncpy(tracking->stats->message, scj->stats_message, sizeof(tracking->stats->message)); } static void solve_camera_startjob(void *scv, short *stop, short *do_update, float *progress) { - SolveCameraJob *scj= (SolveCameraJob *)scv; + SolveCameraJob *scj = (SolveCameraJob *)scv; BKE_tracking_solve_reconstruction(scj->context, stop, do_update, progress, scj->stats_message, sizeof(scj->stats_message)); @@ -1623,10 +1649,10 @@ static void solve_camera_startjob(void *scv, short *stop, short *do_update, floa static void solve_camera_freejob(void *scv) { - SolveCameraJob *scj= (SolveCameraJob *)scv; - MovieTracking *tracking= &scj->clip->tracking; - Scene *scene= scj->scene; - MovieClip *clip= scj->clip; + SolveCameraJob *scj = (SolveCameraJob *)scv; + MovieTracking *tracking = &scj->clip->tracking; + Scene *scene = scj->scene; + MovieClip *clip = scj->clip; int solved; if (!scj->context) { @@ -1635,7 +1661,7 @@ static void solve_camera_freejob(void *scv) return; } - solved= BKE_tracking_finish_reconstruction(scj->context, tracking); + solved = BKE_tracking_finish_reconstruction(scj->context, tracking); if (!solved) BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details"); @@ -1646,12 +1672,12 @@ static void solve_camera_freejob(void *scv) if (scene->clip) id_us_min(&clip->id); - scene->clip= clip; + scene->clip = clip; id_us_plus(&clip->id); /* set blender camera focal length so result would look fine there */ if (scene->camera) { - Camera *camera= (Camera*)scene->camera->data; + Camera *camera = (Camera*)scene->camera->data; int width, height; BKE_movieclip_get_size(clip, &scj->user, &width, &height); @@ -1662,7 +1688,7 @@ static void solve_camera_freejob(void *scv) } MEM_freeN(tracking->stats); - tracking->stats= NULL; + tracking->stats = NULL; DAG_id_tag_update(&clip->id, 0); @@ -1679,9 +1705,9 @@ static void solve_camera_freejob(void *scv) static int solve_camera_exec(bContext *C, wmOperator *op) { SolveCameraJob *scj; - char error_msg[256]= "\0"; + char error_msg[256] = "\0"; - scj= MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); + scj = MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); @@ -1701,20 +1727,20 @@ static int solve_camera_exec(bContext *C, wmOperator *op) static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SolveCameraJob *scj; - ScrArea *sa= CTX_wm_area(C); - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking); + ScrArea *sa = CTX_wm_area(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking); wmJob *steve; - char error_msg[256]= "\0"; + char error_msg[256] = "\0"; 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"); + scj = MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); @@ -1727,16 +1753,16 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even BLI_strncpy(tracking->stats->message, "Solving camera | Preparing solve", sizeof(tracking->stats->message)); /* hide reconstruction statistics from previous solve */ - reconstruction->flag&= ~TRACKING_RECONSTRUCTED; + reconstruction->flag &= ~TRACKING_RECONSTRUCTED; WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); WM_jobs_customdata(steve, scj, solve_camera_freejob); WM_jobs_timer(steve, 0.1, NC_MOVIECLIP|NA_EVALUATED, 0); WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); - G.afbreek= 0; + G.afbreek = 0; WM_jobs_start(CTX_wm_manager(C), steve); WM_cursor_wait(0); @@ -1750,7 +1776,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 */ @@ -1784,26 +1810,26 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); - MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking); - MovieTrackingTrack *track= tracksbase->first; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + MovieTrackingReconstruction *reconstruction = BKE_tracking_get_reconstruction(tracking); + MovieTrackingTrack *track = tracksbase->first; while (track) { - track->flag&= ~TRACK_HAS_BUNDLE; + track->flag &= ~TRACK_HAS_BUNDLE; - track= track->next; + track = track->next; } if (reconstruction->cameras) MEM_freeN(reconstruction->cameras); - reconstruction->cameras= NULL; - reconstruction->camnr= 0; + reconstruction->cameras = NULL; + reconstruction->camnr = 0; - reconstruction->flag&= ~TRACKING_RECONSTRUCTED; + reconstruction->flag &= ~TRACKING_RECONSTRUCTED; DAG_id_tag_update(&clip->id, 0); @@ -1832,24 +1858,24 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) static int clear_track_path_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); - int action= RNA_enum_get(op->ptr, "action"); - int clear_active= RNA_boolean_get(op->ptr, "clear_active"); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + int action = RNA_enum_get(op->ptr, "action"); + int clear_active = RNA_boolean_get(op->ptr, "clear_active"); if (clear_active) { - track= BKE_tracking_active_track(&clip->tracking); + track = BKE_tracking_active_track(&clip->tracking); BKE_tracking_clear_path(track, sc->user.framenr, action); } else { - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) BKE_tracking_clear_path(track, sc->user.framenr, action); - track= track->next; + track = track->next; } } @@ -1888,23 +1914,25 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) static int disable_markers_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track= tracksbase->first; - int action= RNA_enum_get(op->ptr, "action"); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + 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) { - 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; - else marker->flag^= MARKER_DISABLED; + 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; + else marker->flag ^= MARKER_DISABLED; } - track= track->next; + track = track->next; } DAG_id_tag_update(&clip->id, 0); @@ -1943,22 +1971,22 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) { - Object *camera= scene->camera; + Object *camera = scene->camera; Base *base; if (camera && object_get_movieclip(scene, camera, 0)==clip) return camera; - base= scene->base.first; + base = scene->base.first; while (base) { if (base->object->type == OB_CAMERA) { if (object_get_movieclip(scene, base->object, 0)==clip) { - camera= base->object; + camera = base->object; break; } } - base= base->next; + base = base->next; } return camera; @@ -1966,22 +1994,22 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) static Object *get_orientation_object(bContext *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); - Object *object= NULL; + 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); + Object *object = NULL; - if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { - object= get_camera_with_movieclip(scene, clip); + if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { + object = get_camera_with_movieclip(scene, clip); } else { - object= OBACT; + object = OBACT; } if (object && object->parent) - object= object->parent; + object = object->parent; return object; } @@ -1989,37 +2017,37 @@ static Object *get_orientation_object(bContext *C) static int set_orientation_poll(bContext *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) { - return 1; + 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) { + return TRUE; } else { return OBACT != NULL; } } - return 0; + return FALSE; } static int count_selected_bundles(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - int tot= 0; + int tot = 0; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_HAS_BUNDLE)) tot++; - track= track->next; + track = track->next; } return tot; @@ -2028,26 +2056,26 @@ static int count_selected_bundles(bContext *C) static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat[4][4]) { bConstraint *con; - int found= 0; + int found = FALSE; - for (con= ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (!cti) continue; - if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { - bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; + if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) { + bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data; if (!found) { - Object *cam= data->camera ? data->camera : scene->camera; + Object *cam = data->camera ? data->camera : scene->camera; where_is_object_mat(scene, cam, invmat); } mult_m4_m4m4(invmat, invmat, data->invmat); - found= 1; + found = TRUE; } } @@ -2061,14 +2089,14 @@ static Object *object_solver_camera(Scene *scene, Object *ob) { bConstraint *con; - for (con= ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (!cti) continue; - if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { - bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; + if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) { + bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data; return data->camera ? data->camera : scene->camera; } @@ -2079,43 +2107,43 @@ static Object *object_solver_camera(Scene *scene, Object *ob) static int set_origin_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *object; - Object *camera= get_camera_with_movieclip(scene, clip); + Object *camera = get_camera_with_movieclip(scene, clip); ListBase *tracksbase; float mat[4][4], vec[3], median[3]; - int selected_count= count_selected_bundles(C); + 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); + object = get_orientation_object(C); if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; } - tracking_object= BKE_tracking_active_object(tracking); + tracking_object = BKE_tracking_active_object(tracking); - tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); + tracksbase = BKE_tracking_object_tracks(tracking, tracking_object); - track= tracksbase->first; + track = tracksbase->first; zero_v3(median); while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_HAS_BUNDLE)) { add_v3_v3(median, track->bundle_pos); } - track= track->next; + track = track->next; } mul_v3_fl(median, 1.0f/selected_count); @@ -2123,7 +2151,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 { @@ -2164,9 +2192,9 @@ void CLIP_OT_set_origin(wmOperatorType *ot) static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingObject *tracking_object, MovieTrackingTrack *track, char axis) { - Object *camera= get_camera_with_movieclip(scene, clip); - int is_camera= tracking_object->flag&TRACKING_OBJECT_CAMERA; - int flip= 0; + Object *camera = get_camera_with_movieclip(scene, clip); + int is_camera = tracking_object->flag & TRACKING_OBJECT_CAMERA; + int flip = FALSE; float mat[4][4], vec[3], obmat[4][4], dvec[3]; object_to_mat4(ob, obmat); @@ -2192,24 +2220,24 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb unit_m4(mat); - if (axis=='X') { - if (fabsf(dvec[1])<1e-3f) { - flip= 1; + if (axis == 'X') { + if (fabsf(dvec[1]) < 1e-3f) { + flip = TRUE; - 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; + 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 { copy_v3_v3(mat[0], vec); - 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; + 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]); } else { - vec[2]= 0.0f; + vec[2] = 0.0f; cross_v3_v3v3(mat[1], mat[0], vec); cross_v3_v3v3(mat[2], mat[0], mat[1]); @@ -2217,23 +2245,23 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb } } else { - if (fabsf(dvec[0])<1e-3f) { - flip= 1; + if (fabsf(dvec[0]) < 1e-3f) { + flip = TRUE; - 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; + 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 { copy_v3_v3(mat[1], vec); 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; + 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]); } else { - vec[2]= 0.0f; + vec[2] = 0.0f; cross_v3_v3v3(mat[0], vec, mat[1]); cross_v3_v3v3(mat[2], mat[0], mat[1]); @@ -2274,22 +2302,22 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb static int set_plane_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - Scene *scene= CTX_data_scene(C); - MovieTracking *tracking= &clip->tracking; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); + MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; - MovieTrackingTrack *track, *axis_track= NULL, *act_track; + MovieTrackingTrack *track, *axis_track = NULL, *act_track; ListBase *tracksbase; Object *object; - Object *camera= get_camera_with_movieclip(scene, clip); - int tot= 0; - float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3]= {0.0f, 0.0f, 0.0f}; - int plane= RNA_enum_get(op->ptr, "plane"); - float rot[4][4]={{0.0f, 0.0f, -1.0f, 0.0f}, - {0.0f, 1.0f, 0.0f, 0.0f}, - {1.0f, 0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ + Object *camera = get_camera_with_movieclip(scene, clip); + int tot = 0; + float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f}; + int plane = RNA_enum_get(op->ptr, "plane"); + float rot[4][4] = {{0.0f, 0.0f, -1.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, 0.0f}, + {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) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); @@ -2297,11 +2325,11 @@ static int set_plane_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - tracking_object= BKE_tracking_active_object(tracking); - tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); - act_track= BKE_tracking_active_track(tracking); + tracking_object = BKE_tracking_active_object(tracking); + tracksbase = BKE_tracking_object_tracks(tracking, tracking_object); + act_track = BKE_tracking_active_track(tracking); - object= get_orientation_object(C); + object = get_orientation_object(C); if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); @@ -2311,20 +2339,20 @@ static int set_plane_exec(bContext *C, wmOperator *op) BKE_get_tracking_mat(scene, camera, mat); /* get 3 bundles to use as reference */ - track= tracksbase->first; + track = tracksbase->first; while (track && tot<3) { - if (track->flag&TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { + 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; + axis_track = track; tot++; } - track= track->next; + track = track->next; } sub_v3_v3(vec[1], vec[0]); @@ -2349,11 +2377,11 @@ static int set_plane_exec(bContext *C, wmOperator *op) normalize_v3(mat[2]); /* move to origin point */ - mat[3][0]= orig[0]; - mat[3][1]= orig[1]; - mat[3][2]= orig[2]; + mat[3][0] = orig[0]; + 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); @@ -2412,15 +2440,15 @@ void CLIP_OT_set_plane(wmOperatorType *ot) static int set_axis_exec(bContext *C, wmOperator *op) { - 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); + 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); MovieTrackingTrack *track; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *object; ListBase *tracksbase; - int axis= RNA_enum_get(op->ptr, "axis"); + int axis = RNA_enum_get(op->ptr, "axis"); if (count_selected_bundles(C)!=1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); @@ -2428,24 +2456,24 @@ static int set_axis_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - object= get_orientation_object(C); + object = get_orientation_object(C); if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; } - tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); + tracksbase = BKE_tracking_object_tracks(tracking, tracking_object); - track=tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) break; - track= track->next; + track = track->next; } - set_axis(scene, object, clip, tracking_object, track, axis==0?'X':'Y'); + set_axis(scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y'); DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); @@ -2484,26 +2512,26 @@ void CLIP_OT_set_axis(wmOperatorType *ot) static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) { - 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); + 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); MovieTrackingTrack *track; - Scene *scene= CTX_data_scene(C); - Object *object= NULL; - Object *camera= get_camera_with_movieclip(scene, clip); - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - int tot= 0; + Scene *scene = CTX_data_scene(C); + Object *object = NULL; + Object *camera = get_camera_with_movieclip(scene, clip); + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + int tot = 0; float vec[2][3], mat[4][4], scale; - float dist= RNA_float_get(op->ptr, "distance"); + 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); + object = get_orientation_object(C); if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); @@ -2512,38 +2540,38 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) BKE_get_tracking_mat(scene, camera, mat); - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); tot++; } - track= track->next; + track = track->next; } sub_v3_v3(vec[0], vec[1]); if (len_v3(vec[0])>1e-5f) { - scale= dist / len_v3(vec[0]); + 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) { - Object *solver_camera= object_solver_camera(scene, object); + Object *solver_camera = object_solver_camera(scene, object); - object->size[0]= object->size[1]= object->size[2]= 1.0f/scale; + object->size[0] = object->size[1] = object->size[2] = 1.0f/scale; if (solver_camera) { - object->size[0]/= solver_camera->size[0]; - object->size[1]/= solver_camera->size[1]; - object->size[2]/= solver_camera->size[2]; + object->size[0] /= solver_camera->size[0]; + object->size[1] /= solver_camera->size[1]; + object->size[2] /= solver_camera->size[2]; } } else { - tracking_object->scale= scale; + tracking_object->scale = scale; } DAG_id_tag_update(&clip->id, 0); @@ -2565,8 +2593,8 @@ static int set_scale_exec(bContext *C, wmOperator *op) 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); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist); @@ -2599,12 +2627,12 @@ void CLIP_OT_set_scale(wmOperatorType *ot) static int set_solution_scale_poll(bContext *C) { if (space_clip_frame_poll(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); + 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); - return (tracking_object->flag&TRACKING_OBJECT_CAMERA) == 0; + return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0; } return 0; @@ -2617,8 +2645,8 @@ static int set_solution_scale_exec(bContext *C, wmOperator *op) static int set_solution_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.object_distance); @@ -2650,17 +2678,17 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); int width, height; 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; - clip->tracking.camera.principal[1]= ((float)height)/2.0f; + clip->tracking.camera.principal[0] = ((float)width)/2.0f; + clip->tracking.camera.principal[1] = ((float)height)/2.0f; WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); @@ -2686,34 +2714,34 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) static int hide_tracks_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); int unselected; - unselected= RNA_boolean_get(op->ptr, "unselected"); + unselected = RNA_boolean_get(op->ptr, "unselected"); - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (unselected==0 && TRACK_VIEW_SELECTED(sc, track)) { - track->flag|= TRACK_HIDDEN; + if (unselected == 0 && TRACK_VIEW_SELECTED(sc, track)) { + track->flag |= TRACK_HIDDEN; } - else if (unselected==1 && !TRACK_VIEW_SELECTED(sc, track)) { - track->flag|= TRACK_HIDDEN; + else if (unselected == 1 && !TRACK_VIEW_SELECTED(sc, track)) { + track->flag |= TRACK_HIDDEN; } - track= track->next; + track = track->next; } - if (act_track && act_track->flag&TRACK_HIDDEN) - clip->tracking.act_track= NULL; + 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; + sc->flag &= ~SC_LOCK_SELECTION; } WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); @@ -2743,16 +2771,16 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - track= tracksbase->first; + track = tracksbase->first; while (track) { - track->flag&= ~TRACK_HIDDEN; + track->flag &= ~TRACK_HIDDEN; - track= track->next; + track = track->next; } WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); @@ -2784,12 +2812,12 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) if (!clip->gpd) return NULL; - layer= clip->gpd->layers.first; + layer = clip->gpd->layers.first; while (layer) { - if (layer->flag&GP_LAYER_ACTIVE) + if (layer->flag & GP_LAYER_ACTIVE) return layer; - layer= layer->next; + layer = layer->next; } return NULL; @@ -2797,32 +2825,32 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) static int detect_features_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - int clip_flag= clip->flag&MCLIP_TIMECODE_FLAGS; - ImBuf *ibuf= BKE_movieclip_get_ibuf_flag(clip, &sc->user, clip_flag, MOVIECLIP_CACHE_SKIP); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track= tracksbase->first; - int placement= RNA_enum_get(op->ptr, "placement"); - int margin= RNA_int_get(op->ptr, "margin"); - int min_trackability= RNA_int_get(op->ptr, "min_trackability"); - int min_distance= RNA_int_get(op->ptr, "min_distance"); - int place_outside_layer= 0; - bGPDlayer *layer= NULL; - - if (placement!=0) { - layer= detect_get_layer(clip); - place_outside_layer= placement==2; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + int clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; + ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, &sc->user, clip_flag, MOVIECLIP_CACHE_SKIP); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *track = tracksbase->first; + int placement = RNA_enum_get(op->ptr, "placement"); + int margin = RNA_int_get(op->ptr, "margin"); + int min_trackability = RNA_int_get(op->ptr, "min_trackability"); + int min_distance = RNA_int_get(op->ptr, "min_distance"); + int place_outside_layer = 0; + bGPDlayer *layer = NULL; + + if (placement != 0) { + layer = detect_get_layer(clip); + place_outside_layer = placement == 2; } /* deselect existing tracks */ while (track) { - track->flag&= ~SELECT; - track->pat_flag&= ~SELECT; - track->search_flag&= ~SELECT; + track->flag &= ~SELECT; + track->pat_flag &= ~SELECT; + track->search_flag &= ~SELECT; - track= track->next; + track = track->next; } BKE_tracking_detect_fast(tracking, tracksbase, ibuf, sc->user.framenr, margin, @@ -2867,58 +2895,58 @@ void CLIP_OT_detect_features(wmOperatorType *ot) static int frame_jump_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + Scene *scene = CTX_data_scene(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; - int pos= RNA_enum_get(op->ptr, "position"); + int pos = RNA_enum_get(op->ptr, "position"); int delta; - if (pos<=1) { /* jump to path */ - track= BKE_tracking_active_track(&clip->tracking); + if (pos <= 1) { /* jump to path */ + track = BKE_tracking_active_track(&clip->tracking); if (!track) return OPERATOR_CANCELLED; - delta= pos == 1 ? 1 : -1; + delta = pos == 1 ? 1 : -1; while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { - MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, sc->user.framenr+delta); + 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; + sc->user.framenr += delta; } } else { /* to to failed frame */ - if (clip->tracking.reconstruction.flag&TRACKING_RECONSTRUCTED) { - int a= sc->user.framenr; - MovieTracking *tracking= &clip->tracking; - MovieTrackingObject *object= BKE_tracking_active_object(tracking); + if (clip->tracking.reconstruction.flag & TRACKING_RECONSTRUCTED) { + int a = sc->user.framenr; + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object = BKE_tracking_active_object(tracking); - delta= pos == 3 ? 1 : -1; + delta = pos == 3 ? 1 : -1; - a+= delta; + a += delta; while (a+delta >= SFRA && a+delta <= EFRA) { MovieReconstructedCamera *cam; - cam= BKE_tracking_get_reconstructed_camera(tracking, object, a); + cam = BKE_tracking_get_reconstructed_camera(tracking, object, a); if (!cam) { - sc->user.framenr= a; + sc->user.framenr = a; break; } - a+= delta; + a += delta; } } } - if (CFRA!=sc->user.framenr) { - CFRA= sc->user.framenr; + if (CFRA != sc->user.framenr) { + CFRA = sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -2959,34 +2987,34 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) static int join_tracks_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track, *track, *next; - act_track= BKE_tracking_active_track(tracking); + act_track = BKE_tracking_active_track(tracking); if (!act_track) { BKE_report(op->reports, RPT_ERROR, "No active track to join to"); return OPERATOR_CANCELLED; } - track= tracksbase->first; + track = tracksbase->first; while (track) { - next= track->next; + 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) - tracking->stabilization.rot_track= act_track; + tracking->stabilization.rot_track = act_track; BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); } - track= next; + track = next; } WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); @@ -3013,21 +3041,23 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) static int lock_tracks_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track= tracksbase->first; - int action= RNA_enum_get(op->ptr, "action"); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + 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; - else track->flag^= TRACK_LOCKED; + if (action == 0) + track->flag |= TRACK_LOCKED; + else if (action == 1) + track->flag &= ~TRACK_LOCKED; + else track->flag ^= TRACK_LOCKED; } - track= track->next; + track = track->next; } WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); @@ -3064,27 +3094,27 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track, *act_track= BKE_tracking_active_track(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *track, *act_track = BKE_tracking_active_track(tracking); if (!act_track) return OPERATOR_CANCELLED; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { - track->flag&= ~TRACK_CUSTOMCOLOR; + 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; + track->flag |= TRACK_CUSTOMCOLOR; } } - track= track->next; + track = track->next; } WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -3111,28 +3141,28 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; - MovieTrackingStabilization *stab= &tracking->stabilization; - int update= 0; + MovieTrackingStabilization *stab = &tracking->stabilization; + int update = 0; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_USE_2D_STAB)==0) { - track->flag|= TRACK_USE_2D_STAB; + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB)==0) { + track->flag |= TRACK_USE_2D_STAB; stab->tot_track++; - update= 1; + update = 1; } - track= track->next; + track = track->next; } if (update) { - stab->ok= 0; + stab->ok = 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -3160,27 +3190,27 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingStabilization *stab= &tracking->stabilization; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingStabilization *stab = &tracking->stabilization; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; - int a= 0, update= 0; + int a = 0, update = 0; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (track->flag&TRACK_USE_2D_STAB) { - if (a==stab->act_track) { - track->flag&= ~TRACK_USE_2D_STAB; + 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) - stab->act_track= 0; + stab->act_track = 0; - update= 1; + update = 1; break; } @@ -3188,11 +3218,11 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) a++; } - track= track->next; + track = track->next; } if (update) { - stab->ok= 0; + stab->ok = 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -3220,22 +3250,22 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; - int update= 0; + int update = 0; - track= tracksbase->first; + track = tracksbase->first; while (track) { - if (track->flag&TRACK_USE_2D_STAB) { + if (track->flag & TRACK_USE_2D_STAB) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0); - update= 1; + update = 1; } - track= track->next; + track = track->next; } if (update) @@ -3263,16 +3293,16 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); if (act_track) { - MovieTrackingStabilization *stab= &tracking->stabilization; + MovieTrackingStabilization *stab = &tracking->stabilization; - stab->rot_track= act_track; - stab->ok= 0; + stab->rot_track = act_track; + stab->ok = 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -3300,43 +3330,43 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) static int is_track_clean(MovieTrackingTrack *track, int frames, int del) { - int ok= 1, a, prev= -1, count= 0; - MovieTrackingMarker *markers= track->markers, *new_markers= NULL; - int start_disabled= 0; - int markersnr= track->markersnr; + int ok = 1, a, prev = -1, count = 0; + MovieTrackingMarker *markers = track->markers, *new_markers = NULL; + int start_disabled = 0; + int markersnr = track->markersnr; if (del) - new_markers= MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); + new_markers = MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for (a= 0; a<markersnr; a++) { - int end= 0; + for (a = 0; a<markersnr; a++) { + int end = 0; - if (prev==-1) { - if ((markers[a].flag&MARKER_DISABLED)==0) - prev= a; + if (prev == -1) { + if ((markers[a].flag & MARKER_DISABLED)==0) + prev = a; else - start_disabled= 1; + start_disabled = 1; } if (prev >= 0) { - end= a == markersnr-1; - end|= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || - markers[a].flag&MARKER_DISABLED); + end = a == markersnr-1; + end |= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || + markers[a].flag & MARKER_DISABLED); } if (end) { - int segok= 1, len= 0; + int segok = 1, len = 0; if (a != prev && markers[a].framenr != markers[a-1].framenr+1) - len= a-prev; - else if (markers[a].flag&MARKER_DISABLED) - len= a-prev; - else len= a-prev+1; + len = a-prev; + else if (markers[a].flag & MARKER_DISABLED) + len = a-prev; + else len = a-prev+1; if (frames) { if (len < frames) { - segok= 0; - ok= 0; + segok = 0; + ok = 0; if (!del) break; @@ -3345,32 +3375,32 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) if (del) { if (segok) { - int t= len; + 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) { memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; - new_markers[count].flag|= MARKER_DISABLED; + new_markers[count].flag |= MARKER_DISABLED; count++; - start_disabled= 0; + start_disabled = 0; } memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); - count+= t; + 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; + start_disabled = 1; } } - prev= -1; + prev = -1; } } @@ -3378,14 +3408,14 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) MEM_freeN(track->markers); if (count) { - track->markers= new_markers; + track->markers = new_markers; } else { - track->markers= NULL; + track->markers = NULL; MEM_freeN(new_markers); } - track->markersnr= count; + track->markersnr = count; } return ok; @@ -3393,45 +3423,45 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) static int clean_tracks_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; - ListBase *tracksbase= BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track, *next, *act_track= BKE_tracking_active_track(tracking); - int frames= RNA_int_get(op->ptr, "frames"); - int action= RNA_enum_get(op->ptr, "action"); - float error= RNA_float_get(op->ptr, "error"); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingTrack *track, *next, *act_track = BKE_tracking_active_track(tracking); + int frames = RNA_int_get(op->ptr, "frames"); + int action = RNA_enum_get(op->ptr, "action"); + float error = RNA_float_get(op->ptr, "error"); - if (error && action==TRACKING_CLEAN_DELETE_SEGMENT) - action= TRACKING_CLEAN_DELETE_TRACK; + if (error && action == TRACKING_CLEAN_DELETE_SEGMENT) + action = TRACKING_CLEAN_DELETE_TRACK; - track= tracksbase->first; + track = tracksbase->first; while (track) { - next= track->next; + next = track->next; - if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { - int ok= 1; + 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); + 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 (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) - clip->tracking.act_track= NULL; + else if (action == TRACKING_CLEAN_DELETE_TRACK) { + if (track == act_track) + clip->tracking.act_track = NULL; BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); - track= NULL; + track = NULL; } /* happens when all tracking segments are not long enough */ - if (track && track->markersnr==0) { - if (track==act_track) - clip->tracking.act_track= NULL; + if (track && track->markersnr == 0) { + if (track == act_track) + clip->tracking.act_track = NULL; BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); @@ -3439,7 +3469,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) } } - track= next; + track = next; } WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); @@ -3449,8 +3479,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); @@ -3496,9 +3526,9 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; BKE_tracking_new_object(tracking, "Object"); @@ -3526,14 +3556,14 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) static int tracking_object_remove_exec(bContext *C, wmOperator *op) { - SpaceClip *sc= CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); - MovieTracking *tracking= &clip->tracking; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; - object= BKE_tracking_active_object(tracking); + 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; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 68b7268596c..71bca7bfce8 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -163,8 +163,8 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) View2D *v2d = t->view; float divx, divy; - divx= v2d->mask.xmax-v2d->mask.xmin; - divy= v2d->mask.ymax-v2d->mask.ymin; + divx = v2d->mask.xmax-v2d->mask.xmin; + divy = v2d->mask.ymax-v2d->mask.ymin; r_vec[0] = (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx; r_vec[1] = (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy; @@ -337,8 +337,8 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) else ED_area_tag_redraw(t->sa); } else if (t->spacetype==SPACE_CLIP) { - SpaceClip *sc= (SpaceClip*)t->sa->spacedata.first; - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = (SpaceClip*)t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); /* objects could be parented to tracking data, so send this for viewport refresh */ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 60ec08fcb5d..3f15a05d843 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4941,8 +4941,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ED_node_link_intersect_test(t->sa, 0); } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc= t->sa->spacedata.first; - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, @@ -5448,10 +5448,10 @@ typedef struct TransDataTracking { short coord; } TransDataTracking; -static void markerToTransDataInit(TransData *td, TransData2D *td2d, - TransDataTracking *tdt, MovieTrackingTrack *track, int area, float *loc, float *rel, float *off) +static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTracking *tdt, MovieTrackingTrack *track, + int area, float *loc, float *rel, float *off) { - int anchor = area==TRACK_AREA_POINT && off; + int anchor = area == TRACK_AREA_POINT && off; tdt->mode = transDataTracking_ModeTracks; @@ -5470,16 +5470,16 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, } td2d->loc[2] = 0.0f; - tdt->relative= rel; - tdt->area= area; + tdt->relative = rel; + tdt->area = area; - tdt->markersnr= track->markersnr; - tdt->markers= track->markers; + tdt->markersnr = track->markersnr; + tdt->markers = track->markers; if (rel) { if (!anchor) { - td2d->loc[0]+= rel[0]; - td2d->loc[1]+= rel[1]; + td2d->loc[0] += rel[0]; + td2d->loc[1] += rel[1]; } copy_v2_v2(tdt->srelative, rel); @@ -5496,34 +5496,35 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - td->ext= NULL; td->val= NULL; + td->ext= NULL; + td->val= NULL; td->flag |= TD_SELECTED; - td->dist= 0.0; + td->dist = 0.0; unit_m3(td->mtx); unit_m3(td->smtx); } static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, - TransDataTracking *tdt, MovieTrackingTrack *track) + TransDataTracking *tdt, MovieTrackingTrack *track) { - MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr); - tdt->flag= marker->flag; - marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED); + tdt->flag = marker->flag; + marker->flag &= ~(MARKER_DISABLED|MARKER_TRACKED); markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, track->offset, marker->pos, track->offset); - if (track->flag&SELECT) + if (track->flag & SELECT) markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, marker->pos, NULL, NULL); - if (track->pat_flag&SELECT) { + if (track->pat_flag & SELECT) { markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_min, marker->pos, NULL); markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_max, marker->pos, NULL); } - if (track->search_flag&SELECT) { + if (track->search_flag & SELECT) { markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_min, marker->pos, NULL); markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_max, marker->pos, NULL); } @@ -5531,10 +5532,12 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, static void transDataTrackingFree(TransInfo *t) { - TransDataTracking *tdt= t->customData; + TransDataTracking *tdt = t->customData; if (tdt) { - if (tdt->smarkers) MEM_freeN(tdt->smarkers); + if (tdt->smarkers) + MEM_freeN(tdt->smarkers); + MEM_freeN(tdt); } } @@ -5545,7 +5548,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) TransData2D *td2d; SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; TransDataTracking *tdt; @@ -5556,33 +5559,38 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + marker = BKE_tracking_get_marker(track, framenr); t->total++; /* offset */ - if (track->flag&SELECT) t->total++; - if (track->pat_flag&SELECT) t->total+= 2; - if (track->search_flag&SELECT) t->total+= 2; + if (track->flag & SELECT) + t->total++; + + if (track->pat_flag & SELECT) + t->total+= 2; + + if (track->search_flag & SELECT) + t->total+= 2; } track = track->next; } - if (t->total==0) + if (t->total == 0) return; td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData"); td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransTracking TransData2D"); tdt = t->customData = MEM_callocN(t->total*sizeof(TransDataTracking), "TransTracking TransDataTracking"); - t->customFree= transDataTrackingFree; + t->customFree = transDataTrackingFree; /* create actual data */ track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { - marker= BKE_tracking_get_marker(track, framenr); + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { + marker = BKE_tracking_get_marker(track, framenr); trackToTransData(sc, td, td2d, tdt, track); @@ -5591,20 +5599,29 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) td2d++; tdt++; - if ((marker->flag&MARKER_DISABLED)==0) { - if (track->flag&SELECT) {td++; td2d++; tdt++;} - if (track->pat_flag&SELECT) {td+= 2; td2d+= 2;tdt+=2;} + if ((marker->flag & MARKER_DISABLED) == 0) { + if (track->flag & SELECT) { + td++; + td2d++; + tdt++; + } + + if (track->pat_flag & SELECT) { + td += 2; + td2d += 2; + tdt +=2; + } } - if (track->search_flag&SELECT) { - td+= 2; - td2d+= 2; - tdt+= 2; + if (track->search_flag & SELECT) { + td += 2; + td2d += 2; + tdt += 2; - if (marker->flag&MARKER_DISABLED) { - td+= 3; - td2d+= 3; - tdt+= 3; + if (marker->flag & MARKER_DISABLED) { + td += 3; + td2d += 3; + tdt += 3; }; } } @@ -5614,7 +5631,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) } static void markerToTransCurveDataInit(TransData *td, TransData2D *td2d, TransDataTracking *tdt, - MovieTrackingMarker *marker, MovieTrackingMarker *prev_marker, + MovieTrackingMarker *marker, MovieTrackingMarker *prev_marker, short coord, float size) { float frames_delta = (marker->framenr - prev_marker->framenr); @@ -5642,10 +5659,11 @@ static void markerToTransCurveDataInit(TransData *td, TransData2D *td2d, TransDa memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - td->ext= NULL; td->val= NULL; + td->ext= NULL; + td->val= NULL; td->flag |= TD_SELECTED; - td->dist= 0.0; + td->dist = 0.0; unit_m3(td->mtx); unit_m3(td->smtx); @@ -5689,7 +5707,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) track = track->next; } - if (t->total==0) + if (t->total == 0) return; td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData"); @@ -5756,9 +5774,9 @@ static void createTransTrackingData(bContext *C, TransInfo *t) static void cancelTransTracking(TransInfo *t) { TransDataTracking *tdt = t->customData; - SpaceClip *sc= t->sa->spacedata.first; - MovieClip *clip= ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + SpaceClip *sc = t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; int a, framenr = sc->user.framenr; @@ -5772,9 +5790,14 @@ static void cancelTransTracking(TransInfo *t) tdt++; - if (track->flag&SELECT) tdt++; - if (track->pat_flag&SELECT) tdt += 2; - if (track->search_flag&SELECT) tdt += 2; + if (track->flag & SELECT) + tdt++; + + if (track->pat_flag & SELECT) + tdt += 2; + + if (track->search_flag & SELECT) + tdt += 2; } track = track->next; @@ -5817,13 +5840,13 @@ void flushTransTracking(TransInfo *t) /* flush to 2d vector from internally used 3d vector */ for (a=0, td= t->data, td2d= t->data2d, tdt= t->customData; a<t->total; a++, td2d++, td++, tdt++) { if (tdt->mode == transDataTracking_ModeTracks) { - if (t->flag&T_ALT_TRANSFORM) { - if (tdt->area==TRACK_AREA_POINT && tdt->relative) { + if (t->flag & T_ALT_TRANSFORM) { + if (tdt->area == TRACK_AREA_POINT && tdt->relative) { float d[2], d2[2]; if (!tdt->smarkers) { - tdt->smarkers= MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers"); - for (a= 0; a<tdt->markersnr; a++) + tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers"); + for (a = 0; a < tdt->markersnr; a++) copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6dbab08ba7f..19dc968a8d2 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -637,14 +637,14 @@ static void recalcData_image(TransInfo *t) /* helper for recalcData() - for Movie Clip transforms */ static void recalcData_clip(TransInfo *t) { - SpaceClip *sc= t->sa->spacedata.first; - MovieClip *clip= ED_space_clip(sc); - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + SpaceClip *sc = t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; flushTransTracking(t); - track= tracksbase->first; + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { if (t->mode == TFM_TRANSLATION) { @@ -661,7 +661,7 @@ static void recalcData_clip(TransInfo *t) } } - track= track->next; + track = track->next; } DAG_id_tag_update(&clip->id, 0); |