diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-14 12:36:27 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-14 12:36:27 +0400 |
commit | de724a258eda45d1fed2b2176006c3b2df8abea2 (patch) | |
tree | a472a24defdce561a27ed0b8780dbce91c279d05 /source/blender/editors/mask | |
parent | a4ba73311b4c2d862145f86ca078216b7ecbb56f (diff) | |
parent | c08e7e1dc0366c485dbea5ef1209f2cdb616fbb3 (diff) |
Merge branch 'master' into texture_nodes_refactor
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r-- | source/blender/editors/mask/mask_add.c | 20 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_intern.h | 8 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_ops.c | 24 |
3 files changed, 37 insertions, 15 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index b816103de13..cb47adbe73e 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -57,12 +57,14 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, struct Mask *mask, const float normal_co[2], int threshold, bool feather, + float tangent[2], + const bool use_deform, + const bool use_project, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, - float *u_r, float tangent[2], - const bool use_deform, - const bool use_project) + float *u_r, + float *score_r) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -171,6 +173,10 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, *u_r = u; } + if (score_r) { + *score_r = dist; + } + return true; } @@ -339,7 +345,9 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2 float tangent[2]; float u; - if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, false, &masklay, &spline, &point, &u, tangent, true, true)) { + if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, false, tangent, true, true, + &masklay, &spline, &point, &u, NULL)) + { MaskSplinePoint *new_point; int point_index = point - spline->points; @@ -624,7 +632,9 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) if (point) return OPERATOR_FINISHED; - if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, true, &masklay, &spline, &point, &u, NULL, true, true)) { + if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, true, NULL, true, true, + &masklay, &spline, &point, &u, NULL)) + { Scene *scene = CTX_data_scene(C); float w = BKE_mask_point_weight(spline, point, u); float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u); diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index 6899cf7e6f5..5cdb224ce21 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -44,12 +44,14 @@ bool ED_mask_find_nearest_diff_point(const struct bContext *C, struct Mask *mask, const float normal_co[2], int threshold, bool feather, + float tangent[2], + const bool use_deform, + const bool use_project, struct MaskLayer **masklay_r, struct MaskSpline **spline_r, struct MaskSplinePoint **point_r, - float *u_r, float tangent[2], - const bool use_deform, - const bool use_project); + float *u_r, + float *score_r); void MASK_OT_add_vertex(struct wmOperatorType *ot); void MASK_OT_add_feather_vertex(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index b27baaf22be..93e59f3244e 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -510,6 +510,7 @@ static bool spline_under_mouse_get(const bContext *C, MaskLayer **mask_layer_r, MaskSpline **mask_spline_r) { + const float threshold = 19.0f; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); MaskLayer *mask_layer; @@ -580,10 +581,18 @@ static bool spline_under_mouse_get(const bContext *C, } } } - /* TODO(sergey): Chech whether tessellated spline point is closer - * to the mouse than the spline center. - */ - if (closest_dist_squared < 32.0f * 32.0f && closest_spline != NULL) { + if (closest_dist_squared < SQUARE(threshold) && closest_spline != NULL) { + float diff_score; + if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, + false, NULL, true, false, + NULL, NULL, NULL, NULL, + &diff_score)) + { + if (SQUARE(diff_score) < closest_dist_squared) { + return false; + } + } + *mask_layer_r = closest_layer; *mask_spline_r = closest_spline; return true; @@ -1167,7 +1176,7 @@ static bool slide_spline_curvature_check(bContext *C, const wmEvent *event) { Mask *mask = CTX_data_edit_mask(C); float co[2]; - const float threshold = 19; + const float threshold = 19.0f; ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, co); @@ -1185,7 +1194,7 @@ static bool slide_spline_curvature_check(bContext *C, const wmEvent *event) static SlideSplineCurvatureData *slide_spline_curvature_customdata( bContext *C, const wmEvent *event) { - const float threshold = 19; + const float threshold = 19.0f; Mask *mask = CTX_data_edit_mask(C); SlideSplineCurvatureData *slide_data; @@ -1198,8 +1207,9 @@ static SlideSplineCurvatureData *slide_spline_curvature_customdata( ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, co); if (!ED_mask_find_nearest_diff_point(C, mask, co, threshold, false, + NULL, true, false, &mask_layer, &spline, &point, &u, - NULL, true, false)) + NULL)) { return NULL; } |