diff options
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 50 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_utils.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_select.c | 2 |
8 files changed, 104 insertions, 96 deletions
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 6c55d8d034e..76954ede522 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_string.h" #include "BLI_math_base.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_image.h" @@ -285,6 +286,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, MovieClip *clip = ED_space_clip_get_clip(sc); int filter = GL_LINEAR; int x, y; + rctf frame; /* find window pixel coordinates of origin */ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); @@ -308,10 +310,14 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter); - /* reset zoom */ glPixelZoom(1.0f, 1.0f); + BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); + + if (sc->flag & SC_SHOW_METADATA) + ED_region_image_metadata_draw(x, y, ibuf, frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y); + if (ibuf->planes == 32) glDisable(GL_BLEND); } @@ -1123,7 +1129,9 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane { bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0; bool is_selected_track = (plane_track->flag & SELECT) != 0; - bool draw_plane_quad = plane_track->image == NULL || plane_track->image_opacity == 0.0f; + const bool has_image = plane_track->image != NULL && + BKE_image_has_ibuf(plane_track->image, NULL); + const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f; float px[2]; if (draw_outline) { @@ -1692,29 +1700,29 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) } if (sc->flag & SC_SHOW_STABLE) { + float translation[2]; + float aspect = clip->tracking.camera.pixel_aspect; float smat[4][4], ismat[4][4]; - ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle); - - if (ibuf) { - float translation[2]; - float aspect = clip->tracking.camera.pixel_aspect; + if ((sc->flag & SC_MUTE_FOOTAGE) == 0) { + ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, + &sc->scale, &sc->angle); + } - if (width != ibuf->x) - mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x); - else - copy_v2_v2(translation, sc->loc); + if (ibuf != NULL && width != ibuf->x) + mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x); + else + copy_v2_v2(translation, sc->loc); - BKE_tracking_stabilization_data_to_mat4(width, height, aspect, - translation, sc->scale, sc->angle, sc->stabmat); + BKE_tracking_stabilization_data_to_mat4(width, height, aspect, translation, + sc->scale, sc->angle, sc->stabmat); - unit_m4(smat); - smat[0][0] = 1.0f / width; - smat[1][1] = 1.0f / height; - invert_m4_m4(ismat, smat); + unit_m4(smat); + smat[0][0] = 1.0f / width; + smat[1][1] = 1.0f / height; + invert_m4_m4(ismat, smat); - mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat); - } + mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat); } else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) { ibuf = ED_space_clip_get_buffer(sc); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 89693a403fe..dbedfaa1de4 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -52,6 +52,7 @@ #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_mask.h" #include "BKE_movieclip.h" #include "BKE_context.h" #include "BKE_tracking.h" @@ -64,6 +65,7 @@ #include "ED_screen.h" #include "ED_clip.h" +#include "ED_mask.h" #include "WM_api.h" #include "WM_types.h" @@ -219,6 +221,7 @@ int ED_space_clip_get_clip_frame_number(SpaceClip *sc) { MovieClip *clip = ED_space_clip_get_clip(sc); + /* Caller must ensure space does have a valid clip, otherwise it will crash, see T45017. */ return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); } @@ -329,7 +332,7 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -static bool selected_boundbox(SpaceClip *sc, float min[2], float max[2]) +static bool selected_tracking_boundbox(SpaceClip *sc, float min[2], float max[2]) { MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; @@ -377,6 +380,29 @@ static bool selected_boundbox(SpaceClip *sc, float min[2], float max[2]) return ok; } +static bool selected_boundbox(const bContext *C, float min[2], float max[2]) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + if (sc->mode == SC_MODE_TRACKING) { + return selected_tracking_boundbox(sc, min, max); + } + else { + if (ED_mask_selected_minmax(C, min, max)) { + MovieClip *clip = ED_space_clip_get_clip(sc); + int width, height; + ED_space_clip_get_size(sc, &width, &height); + BKE_mask_coord_to_movieclip(clip, &sc->user, min, min); + BKE_mask_coord_to_movieclip(clip, &sc->user, max, max); + min[0] *= width; + min[1] *= height; + max[0] *= width; + max[1] *= height; + return true; + } + return false; + } +} + bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -388,7 +414,7 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit) if ((frame_width == 0) || (frame_height == 0) || (sc->clip == NULL)) return false; - if (!selected_boundbox(sc, min, max)) + if (!selected_boundbox(C, min, max)) return false; /* center view */ @@ -626,8 +652,9 @@ static bool check_prefetch_break(void) } /* read file for specified frame number to the memory */ -static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_frame, short render_size, - short render_flag, size_t *size_r) +static unsigned char *prefetch_read_file_to_memory( + MovieClip *clip, int current_frame, short render_size, short render_flag, + size_t *r_size) { MovieClipUser user = {0}; char name[FILE_MAX]; @@ -660,7 +687,7 @@ static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_ return NULL; } - *size_r = size; + *r_size = size; close(file); @@ -698,8 +725,9 @@ static int prefetch_find_uncached_frame(MovieClip *clip, int from_frame, int end } /* get memory buffer for first uncached frame within prefetch frame range */ -static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip *clip, - size_t *size_r, int *current_frame_r) +static unsigned char *prefetch_thread_next_frame( + PrefetchQueue *queue, MovieClip *clip, + size_t *r_size, int *r_current_frame) { unsigned char *mem = NULL; @@ -728,9 +756,9 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip int frames_processed; mem = prefetch_read_file_to_memory(clip, current_frame, queue->render_size, - queue->render_flag, size_r); + queue->render_flag, r_size); - *current_frame_r = current_frame; + *r_current_frame = current_frame; queue->current_frame = current_frame; @@ -765,13 +793,15 @@ static void prefetch_task_func(TaskPool *pool, void *task_data, int UNUSED(threa int flag = IB_rect | IB_alphamode_detect; int result; char *colorspace_name = NULL; + const bool use_proxy = (clip->flag & MCLIP_USE_PROXY) && + (queue->render_size != MCLIP_PROXY_RENDER_SIZE_FULL); user.framenr = current_frame; user.render_size = queue->render_size; user.render_flag = queue->render_flag; /* Proxies are stored in the display space. */ - if (queue->render_flag & MCLIP_USE_PROXY) { + if (!use_proxy) { colorspace_name = clip->colorspace_settings.name; } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 2a2f15c94bb..e781d199d35 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -200,10 +200,18 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) toggle_selection_cb); } - if (userdata.coord == 0) - userdata.marker->flag |= MARKER_GRAPH_SEL_X; - else - userdata.marker->flag |= MARKER_GRAPH_SEL_Y; + if (userdata.coord == 0) { + if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0) + userdata.marker->flag &= ~MARKER_GRAPH_SEL_X; + else + userdata.marker->flag |= MARKER_GRAPH_SEL_X; + } + else { + if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0) + userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y; + else + userdata.marker->flag |= MARKER_GRAPH_SEL_Y; + } return true; } @@ -238,10 +246,12 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend) else if (act_track != userdata.track) { SelectUserData selectdata = {SEL_DESELECT}; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); - ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); tracking->act_track = userdata.track; - BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, true); + if ((sc->flag & SC_SHOW_GRAPH_SEL_ONLY) == 0) { + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); + BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, false); + } /* deselect all knots on newly selected curve */ clip_graph_tracking_iterate(sc, diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 322825ccc84..1d398177d9f 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -658,7 +658,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR; /* properties */ prop = RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX, "Factor", @@ -912,7 +912,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) SUBFRA = 0.0f; /* do updates */ - sound_seek_scene(CTX_data_main(C), scene); + BKE_sound_seek_scene(CTX_data_main(C), scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 5f919c9b51d..48f8f587106 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -177,9 +177,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) MovieTracking *tracking = &clip->tracking; MovieTrackingStabilization *stab = &tracking->stabilization; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); - MovieTrackingPlaneTrack *plane_track, *next_plane_track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); - ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking); bool has_bundle = false, update_stab = false; char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2]; @@ -197,49 +195,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) has_bundle = true; /* Make sure no plane will use freed track */ - for (plane_track = plane_tracks_base->first; - plane_track; - plane_track = next_plane_track) - { - bool found = false; - int i; - - next_plane_track = plane_track->next; - - for (i = 0; i < plane_track->point_tracksnr; i++) { - if (plane_track->point_tracks[i] == track) { - found = true; - break; - } - } - - if (!found) { - continue; - } - - if (plane_track->point_tracksnr > 4) { - int track_index; - MovieTrackingTrack **new_point_tracks; - - new_point_tracks = MEM_mallocN(sizeof(*new_point_tracks) * plane_track->point_tracksnr, - "new point tracks array"); - - for (i = 0, track_index = 0; i < plane_track->point_tracksnr; i++) { - if (plane_track->point_tracks[i] != track) { - new_point_tracks[track_index++] = plane_track->point_tracks[i]; - } - } - - MEM_freeN(plane_track->point_tracks); - plane_track->point_tracks = new_point_tracks; - plane_track->point_tracksnr--; - } - else { - /* Delete planes with less than 3 point tracks in it. */ - BKE_tracking_plane_track_free(plane_track); - BLI_freelinkN(plane_tracks_base, plane_track); - } - } + BKE_tracking_plane_tracks_remove_point_track(tracking, track); /* Delete f-curves associated with the track (such as weight, i.e.) */ BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped)); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index fc2c0d3d45c..5ba82f7f71f 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -206,7 +206,7 @@ static void clip_scopes_tag_refresh(ScrArea *sa) if (sc->mode != SC_MODE_TRACKING) return; - /* only while proeprties are visible */ + /* only while properties are visible */ for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN) return; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 742e58d80dd..91e11d30cc2 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -825,12 +825,8 @@ static void apply_mouse_slide(bContext *C, SlideMarkerData *data) plane_track = plane_track->next) { if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) { - int i; - for (i = 0; i < plane_track->point_tracksnr; i++) { - if (plane_track->point_tracks[i] == data->track) { - BKE_tracking_track_plane_from_existing_motion(plane_track, framenr); - break; - } + if (BKE_tracking_plane_track_has_point_track(plane_track, data->track)) { + BKE_tracking_track_plane_from_existing_motion(plane_track, framenr); } } } @@ -1070,7 +1066,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->modal = slide_marker_modal; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, @@ -1430,6 +1426,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS } clip = ED_space_clip_get_clip(sc); + BLI_assert(clip != NULL); framenr = ED_space_clip_get_clip_frame_number(sc); if (WM_jobs_test(CTX_wm_manager(C), sa, WM_JOB_TYPE_ANY)) { @@ -1508,6 +1505,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot) ot->exec = track_markers_exec; ot->invoke = track_markers_invoke; ot->modal = track_markers_modal; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_UNDO; @@ -1883,7 +1881,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* proeprties */ + /* properties */ RNA_def_enum(ot->srna, "action", clear_path_actions, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); RNA_def_boolean(ot->srna, "clear_active", 0, "Clear Active", "Clear active track only instead of all selected tracks"); } @@ -2042,7 +2040,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat bool found = false; for (con = ob->constraints.first; con; con = con->next) { - bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); + const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); if (!cti) continue; @@ -2073,7 +2071,7 @@ static Object *object_solver_camera(Scene *scene, Object *ob) bConstraint *con; for (con = ob->constraints.first; con; con = con->next) { - bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); + const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); if (!cti) continue; @@ -3054,7 +3052,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) if (CFRA != sc->user.framenr) { CFRA = sc->user.framenr; - sound_seek_scene(CTX_data_main(C), scene); + BKE_sound_seek_scene(CTX_data_main(C), scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } @@ -3117,6 +3115,12 @@ static int join_tracks_exec(bContext *C, wmOperator *op) if (tracking->stabilization.rot_track == track) tracking->stabilization.rot_track = act_track; + /* TODO(sergey): Re-evaluate planes with auto-key. */ + BKE_tracking_plane_tracks_replace_point_track(tracking, + track, + act_track); + + BKE_tracking_track_free(track); BLI_freelinkN(tracksbase, track); } @@ -4181,7 +4185,7 @@ void CLIP_OT_slide_plane_marker(wmOperatorType *ot) ot->modal = slide_plane_marker_modal; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; } /********************** Insert track keyframe operator *********************/ diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 0b29c253f3a..8a2bf17c667 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -997,6 +997,6 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* proeprties */ + /* properties */ RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); } |