From 3916414709d1baace6bd9d1e802be2730048da66 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Jun 2012 15:33:32 +0000 Subject: adding mask points now adds in the correct place relative to shape keys (updating other keys for the new points still needs work though) --- source/blender/editors/mask/mask_add.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/mask/mask_add.c') diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 7ffff2b06e5..f81496c377a 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -54,7 +54,8 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, - float *u_r, float tangent[2]) + float *u_r, float tangent[2], + const short use_deform) { MaskLayer *masklay, *point_masklay; MaskSpline *point_spline; @@ -80,9 +81,12 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_c for (spline = masklay->splines.first; spline; spline = spline->next) { int i; + MaskSplinePoint *cur_point; - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *cur_point = &spline->points[i]; + for (i = 0, cur_point = use_deform ? spline->points_deform : spline->points; + i < spline->tot_point; + i++, cur_point++) + { float *diff_points; int tot_diff_point; @@ -123,7 +127,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_c point_masklay = masklay; point_spline = spline; - point = cur_point; + point = use_deform ? &spline->points[(cur_point - spline->points_deform)] : cur_point; dist = cur_dist; u = (float)i / tot_point; @@ -370,7 +374,7 @@ static int add_vertex_subdivide(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)) { + if (find_nearest_diff_point(C, mask, co, threshold, FALSE, &masklay, &spline, &point, &u, tangent, TRUE)) { MaskSplinePoint *new_point; int point_index = point - spline->points; @@ -651,7 +655,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)) { + if (find_nearest_diff_point(C, mask, co, threshold, TRUE, &masklay, &spline, &point, &u, NULL, 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); -- cgit v1.2.3