Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-04-03 16:15:04 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-04-03 16:20:17 +0400
commit0102d57c1de344fc3dd14e93d0593ed616d29d7b (patch)
treed56c86749dc7b7d99b6a62094f5f14b19b6d481c /source/blender/editors/mask/mask_add.c
parent0ebade55fcef5acb9b5e34dbc7cc5ab2a4a3d964 (diff)
Slide mask spline segment to define it's curvature
This actually implements the idea used in Gimp which is grabbing an arbitrary point on the spline and dragging it, ensuring spline goes over this point. This is really useful way to tweak spline curvature. Currently only affects on a closest handle, meaning no weighting on changes for both handles which are adjacent to the same segment will happen just yet, Another limitation is that currently such a slide is a big jumpy when you start sliding. This is because projection is not used to calculate u value because projection used to fail a lot for me here and didn't find a nice solution for this yet. But this is to be improved for sure!
Diffstat (limited to 'source/blender/editors/mask/mask_add.c')
-rw-r--r--source/blender/editors/mask/mask_add.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index ecaa73754ba..d2c1d844326 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -54,10 +54,16 @@
#include "mask_intern.h" /* own include */
-static bool find_nearest_diff_point(const bContext *C, Mask *mask, const float normal_co[2], int threshold, bool feather,
- MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r,
- float *u_r, float tangent[2],
- const bool use_deform)
+bool ED_mask_find_nearest_diff_point(const bContext *C,
+ struct Mask *mask,
+ const float normal_co[2],
+ int threshold, bool feather,
+ MaskLayer **masklay_r,
+ MaskSpline **spline_r,
+ MaskSplinePoint **point_r,
+ float *u_r, float tangent[2],
+ const bool use_deform,
+ const bool use_project)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -135,7 +141,6 @@ static bool find_nearest_diff_point(const bContext *C, Mask *mask, const float n
point = use_deform ? &spline->points[(cur_point - spline->points_deform)] : cur_point;
dist = cur_dist;
u = (float)j / tot_point;
-
}
}
@@ -159,7 +164,10 @@ static bool find_nearest_diff_point(const bContext *C, Mask *mask, const float n
*point_r = point;
if (u_r) {
- u = BKE_mask_spline_project_co(point_spline, point, u, normal_co, MASK_PROJ_ANY);
+ /* TODO(sergey): Projection fails in some weirdo cases.. */
+ if (use_project) {
+ u = BKE_mask_spline_project_co(point_spline, point, u, normal_co, MASK_PROJ_ANY);
+ }
*u_r = u;
}
@@ -332,7 +340,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
float tangent[2];
float u;
- if (find_nearest_diff_point(C, mask, co, threshold, false, &masklay, &spline, &point, &u, tangent, true)) {
+ if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, false, &masklay, &spline, &point, &u, tangent, true, true)) {
MaskSplinePoint *new_point;
int point_index = point - spline->points;
@@ -617,7 +625,7 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
if (point)
return OPERATOR_FINISHED;
- if (find_nearest_diff_point(C, mask, co, threshold, true, &masklay, &spline, &point, &u, NULL, true)) {
+ if (ED_mask_find_nearest_diff_point(C, mask, co, threshold, true, &masklay, &spline, &point, &u, NULL, true, true)) {
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);