diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-08-01 18:05:53 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-08-01 18:05:53 +0300 |
commit | 03bbd5f9dedf7b3dfea7119c172c61f0b50ae28c (patch) | |
tree | 79ab34e79af6a700c6f73f331e4ee4e253ab3751 /source/blender/editors/space_clip/clip_graph_ops.c | |
parent | 2204bfcf9e1c3a38e60830bd97775dd72158f4d6 (diff) | |
parent | 49b2162309da6abf66764d41d9fc4c45ad01936c (diff) |
Merge branch 'master' into temp-gpencil-drw-engine
Diffstat (limited to 'source/blender/editors/space_clip/clip_graph_ops.c')
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index a3722433e33..58a00d2e6b9 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -64,7 +64,7 @@ static bool clip_graph_knots_poll(bContext *C) if (ED_space_clip_graph_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); - return (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) != 0; + return (sc->flag & (SC_SHOW_GRAPH_TRACKS_MOTION | SC_SHOW_GRAPH_TRACKS_ERROR)) != 0; } return false; } @@ -93,13 +93,14 @@ static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker) /******************** mouse select operator ********************/ typedef struct { - int coord; /* coordinate index of found entuty (0 = X-axis, 1 = Y-axis) */ + SpaceClip *sc; + eClipCurveValueSource value_source; bool has_prev; /* if there's valid coordinate of previous point of curve segment */ - float min_dist_sq, /* minimal distance between mouse and currently found entity */ - mouse_co[2], /* mouse coordinate */ - prev_co[2], /* coordinate of previeous point of segment */ - min_co[2]; /* coordinate of entity with minimal distance */ + float min_dist_sq; /* minimal distance between mouse and currently found entity */ + float mouse_co[2]; /* mouse coordinate */ + float prev_co[2]; /* coordinate of previous point of segment */ + float min_co[2]; /* coordinate of entity with minimal distance */ MovieTrackingTrack *track; /* nearest found track */ MovieTrackingMarker *marker; /* nearest found marker */ @@ -108,20 +109,24 @@ typedef struct { static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *UNUSED(marker), - int coord, + eClipCurveValueSource value_source, int scene_framenr, float val) { MouseSelectUserData *data = userdata; float co[2] = {scene_framenr, val}; + if (!clip_graph_value_visible(data->sc, value_source)) { + return; + } + if (data->has_prev) { float dist_sq = dist_squared_to_line_segment_v2(data->mouse_co, data->prev_co, co); if (data->track == NULL || dist_sq < data->min_dist_sq) { data->track = track; data->min_dist_sq = dist_sq; - data->coord = coord; + data->value_source = value_source; copy_v2_v2(data->min_co, co); } } @@ -130,7 +135,8 @@ static void find_nearest_tracking_segment_cb(void *userdata, copy_v2_v2(data->prev_co, co); } -static void find_nearest_tracking_segment_end_cb(void *userdata, int UNUSED(coord)) +static void find_nearest_tracking_segment_end_cb(void *userdata, + eClipCurveValueSource UNUSED(source_value)) { MouseSelectUserData *data = userdata; @@ -140,7 +146,7 @@ static void find_nearest_tracking_segment_end_cb(void *userdata, int UNUSED(coor static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, - int coord, + eClipCurveValueSource value_source, int scene_framenr, float val) { @@ -148,20 +154,26 @@ static void find_nearest_tracking_knot_cb(void *userdata, float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]}; float dist_sq = len_squared_v2(mdiff); + if (!clip_graph_value_visible(data->sc, value_source)) { + return; + } + if (data->marker == NULL || dist_sq < data->min_dist_sq) { float co[2] = {scene_framenr, val}; data->track = track; data->marker = marker; data->min_dist_sq = dist_sq; - data->coord = coord; + data->value_source = value_source; copy_v2_v2(data->min_co, co); } } -static void mouse_select_init_data(MouseSelectUserData *userdata, const float co[2]) +static void mouse_select_init_data(bContext *C, MouseSelectUserData *userdata, const float co[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); memset(userdata, 0, sizeof(MouseSelectUserData)); + userdata->sc = sc; userdata->min_dist_sq = FLT_MAX; copy_v2_v2(userdata->mouse_co, co); } @@ -179,7 +191,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) if (act_track) { MouseSelectUserData userdata; - mouse_select_init_data(&userdata, co); + mouse_select_init_data(C, &userdata, co); clip_graph_tracking_values_iterate_track( sc, act_track, &userdata, find_nearest_tracking_knot_cb, NULL, NULL); @@ -199,7 +211,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) toggle_selection_cb); } - if (userdata.coord == 0) { + if (userdata.value_source == CLIP_VALUE_SOURCE_SPEED_X) { if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0) { userdata.marker->flag &= ~MARKER_GRAPH_SEL_X; } @@ -207,7 +219,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) userdata.marker->flag |= MARKER_GRAPH_SEL_X; } } - else { + else if (userdata.value_source == CLIP_VALUE_SOURCE_SPEED_Y) { if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0) { userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y; } @@ -232,7 +244,7 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend) MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MouseSelectUserData userdata; - mouse_select_init_data(&userdata, co); + mouse_select_init_data(C, &userdata, co); clip_graph_tracking_values_iterate(sc, (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, @@ -281,7 +293,7 @@ static int mouse_select(bContext *C, float co[2], bool extend) sel = mouse_select_knot(C, co, extend); if (!sel) { - /* if there's no close enough knot to mouse osition, select nearest curve */ + /* if there's no close enough knot to mouse position, select nearest curve */ sel = mouse_select_curve(C, co, extend); } @@ -356,16 +368,19 @@ typedef struct BoxSelectuserData { static void box_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *marker, - int coord, + eClipCurveValueSource value_source, int scene_framenr, float val) { BoxSelectuserData *data = (BoxSelectuserData *)userdata; + if (!ELEM(value_source, CLIP_VALUE_SOURCE_SPEED_X, CLIP_VALUE_SOURCE_SPEED_Y)) { + return; + } if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) { int flag = 0; - if (coord == 0) { + if (value_source == CLIP_VALUE_SOURCE_SPEED_X) { flag = MARKER_GRAPH_SEL_X; } else { @@ -591,7 +606,7 @@ typedef struct { static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *UNUSED(marker), - int UNUSED(coord), + eClipCurveValueSource UNUSED(value_source), int UNUSED(scene_framenr), float val) { |