fix for bug where auto-handles were not calculated correctly for animated curves.

This commit is contained in:
Campbell Barton
2012-06-06 20:26:26 +00:00
parent 3e8ad394af
commit 052e34cc3d
2 changed files with 40 additions and 19 deletions

View File

@@ -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 */

View File

@@ -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;
BKE_mask_layer_calc_handles(masklay);
}
}
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]);
/* 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.