diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 00:26:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 00:26:26 +0400 |
commit | 052e34cc3d52bee1678bd0b2a015b7de97ae7ad7 (patch) | |
tree | c86fd804e24cb51a43a7b74b4779ceb556084047 | |
parent | 3e8ad394af94a88791ced5aae573f105fb3d501d (diff) |
fix for bug where auto-handles were not calculated correctly for animated curves.
-rw-r--r-- | source/blender/blenkernel/BKE_mask.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 56 |
2 files changed, 40 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 2537e84a62c..a93e811557a 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -129,7 +129,10 @@ void BKE_mask_calc_handle_point_auto(struct MaskSpline *spline, struct MaskSplin const short do_recalc_length); void BKE_mask_get_handle_point_adjacent(struct MaskSpline *spline, struct MaskSplinePoint *point, struct MaskSplinePoint **r_point_prev, struct MaskSplinePoint **r_point_next); +void BKE_mask_layer_calc_handles(struct MaskLayer *masklay); +void BKE_mask_layer_calc_handles_deform(struct MaskLayer *masklay); void BKE_mask_calc_handles(struct Mask *mask); +void BKE_mask_calc_handles_deform(struct Mask *mask); void BKE_mask_spline_ensure_deform(struct MaskSpline *spline); /* animation */ diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 315b97c1866..f7679d473b9 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1231,12 +1231,11 @@ static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *poin void BKE_mask_get_handle_point_adjacent(MaskSpline *spline, MaskSplinePoint *point, MaskSplinePoint **r_point_prev, MaskSplinePoint **r_point_next) { - int i = (int)(point - spline->points); - BLI_assert(i >= i && i < spline->tot_point); - (void)i; /* quiet release builds */ + /* TODO, could avoid calling this at such low level */ + MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - *r_point_prev = mask_spline_point_prev(spline, spline->points, point); - *r_point_next = mask_spline_point_next(spline, spline->points, point); + *r_point_prev = mask_spline_point_prev(spline, points_array, point); + *r_point_next = mask_spline_point_next(spline, points_array, point); } /* calculates the tanget of a point by its previous and next @@ -1370,25 +1369,41 @@ void BKE_mask_calc_handle_point_auto(MaskSpline *spline, MaskSplinePoint *point, } } +void BKE_mask_layer_calc_handles(MaskLayer *masklay) +{ + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; + for (i = 0; i < spline->tot_point; i++) { + BKE_mask_calc_handle_point(spline, &spline->points[i]); + } + } +} + +void BKE_mask_layer_calc_handles_deform(MaskLayer *masklay) +{ + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; + for (i = 0; i < spline->tot_point; i++) { + BKE_mask_calc_handle_point(spline, &spline->points_deform[i]); + } + } +} + void BKE_mask_calc_handles(Mask *mask) { MaskLayer *masklay; - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - MaskSpline *spline; - - for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - - for (i = 0; i < spline->tot_point; i++) { - BKE_mask_calc_handle_point(spline, &spline->points[i]); + BKE_mask_layer_calc_handles(masklay); + } +} - /* could be done in a different function... */ - if (spline->points_deform) { - BKE_mask_calc_handle_point(spline, &spline->points[i]); - } - } - } +void BKE_mask_calc_handles_deform(Mask *mask) +{ + MaskLayer *masklay; + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + BKE_mask_layer_calc_handles_deform(masklay); } } @@ -1525,6 +1540,9 @@ void BKE_mask_evaluate(Mask *mask, float ctime, const int do_newframe) } } } + + /* TODO, move into loop above and only run if there are auto-handles */ + BKE_mask_calc_handles_deform(mask); } /* the purpose of this function is to ensure spline->points_deform is never out of date. |