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:
authorCampbell Barton <ideasman42@gmail.com>2016-04-27 06:11:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-04-27 06:12:55 +0300
commit6483b9cb076b2988732dc19e354092ccbd653f72 (patch)
treed5c04f840611563772161073825c40d41fd4103e
parent9bd51735a10280af3cf56edf3698961a1e230d4d (diff)
Fix T48282: Newly added mask points don't follow parent
-rw-r--r--source/blender/editors/mask/mask_add.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 3730cff731c..1bca23c57ea 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -198,8 +198,6 @@ static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *
const float point_co[2], const float u,
const MaskSplinePoint *reference_point, const bool reference_adjacent)
{
- MaskSplinePoint *prev_point = NULL;
- MaskSplinePoint *next_point = NULL;
BezTriple *bezt;
float co[3];
@@ -247,14 +245,44 @@ static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *
else {
bezt->h1 = bezt->h2 = MAX2(reference_point->bezt.h2, reference_point->bezt.h1);
}
+
+ new_point->parent = reference_point->parent;
}
else if (reference_adjacent) {
if (spline->tot_point != 1) {
- int index = (int)(new_point - spline->points);
- prev_point = &spline->points[(index - 1) % spline->tot_point];
- next_point = &spline->points[(index + 1) % spline->tot_point];
+ MaskSplinePoint *prev_point, *next_point, *close_point;
+
+ const int index = (int)(new_point - spline->points);
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
+ prev_point = &spline->points[mod_i(index - 1, spline->tot_point)];
+ next_point = &spline->points[mod_i(index + 1, spline->tot_point)];
+ }
+ else {
+ prev_point = (index != 0) ? &spline->points[index - 1] : NULL;
+ next_point = (index != spline->tot_point - 1) ? &spline->points[index + 1] : NULL;
+ }
+
+ if (prev_point && next_point) {
+ close_point = (len_squared_v2v2(new_point->bezt.vec[1], prev_point->bezt.vec[1]) <
+ len_squared_v2v2(new_point->bezt.vec[1], next_point->bezt.vec[1])) ?
+ prev_point : next_point;
+ }
+ else {
+ close_point = prev_point ? prev_point : next_point;
+ }
+
+ /* handle type */
+ char handle_type = 0;
+ if (prev_point) {
+ handle_type = prev_point->bezt.h2;
+ }
+ if (next_point) {
+ handle_type = MAX2(next_point->bezt.h2, handle_type);
+ }
+ bezt->h1 = bezt->h2 = handle_type;
- bezt->h1 = bezt->h2 = MAX2(prev_point->bezt.h2, next_point->bezt.h1);
+ /* parent */
+ new_point->parent = close_point->parent;
/* note, we may want to copy other attributes later, radius? pressure? color? */
}