[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47541] trunk/blender/source/blender/ blenkernel: fix for bug where auto-handles were not calculated correctly for animated curves .

Campbell Barton ideasman42 at gmail.com
Wed Jun 6 22:26:36 CEST 2012


Revision: 47541
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47541
Author:   campbellbarton
Date:     2012-06-06 20:26:26 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
fix for bug where auto-handles were not calculated correctly for animated curves.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_mask.h
    trunk/blender/source/blender/blenkernel/intern/mask.c

Modified: trunk/blender/source/blender/blenkernel/BKE_mask.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mask.h	2012-06-06 20:05:58 UTC (rev 47540)
+++ trunk/blender/source/blender/blenkernel/BKE_mask.h	2012-06-06 20:26:26 UTC (rev 47541)
@@ -129,7 +129,10 @@
                                      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 */

Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c	2012-06-06 20:05:58 UTC (rev 47540)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c	2012-06-06 20:26:26 UTC (rev 47541)
@@ -1231,12 +1231,11 @@
 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_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) {
+		BKE_mask_layer_calc_handles(masklay);
+	}
+}
 
+void BKE_mask_calc_handles_deform(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]);
-
-				/* could be done in a different function... */
-				if (spline->points_deform) {
-					BKE_mask_calc_handle_point(spline, &spline->points[i]);
-				}
-			}
-		}
+		BKE_mask_layer_calc_handles_deform(masklay);
 	}
 }
 
@@ -1525,6 +1540,9 @@
 			}
 		}
 	}
+
+	/* 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.




More information about the Bf-blender-cvs mailing list