[Bf-blender-cvs] [3573f49bfdc] master: Masks: Split layer evaluation into separate function

Sergey Sharybin noreply at git.blender.org
Thu Sep 14 13:12:25 CEST 2017


Commit: 3573f49bfdc63dce7cde51cc50bc6b52b2194566
Author: Sergey Sharybin
Date:   Thu Sep 14 16:09:06 2017 +0500
Branches: master
https://developer.blender.org/rB3573f49bfdc63dce7cde51cc50bc6b52b2194566

Masks: Split layer evaluation into separate function

This way we can easily re-use bits of code for new dependency graph.

Currently should be no functional changes.

===================================================================

M	source/blender/blenkernel/BKE_mask.h
M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/mask_evaluate.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index 6e154241af7..127d1944233 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -233,6 +233,9 @@ float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct Mas
                                            int width, int height,
                                            unsigned int *tot_feather_point);
 
+void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, const float ctime);
+void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, const float ctime);
+
 /* mask_rasterize.c */
 struct MaskRasterHandle;
 typedef struct MaskRasterHandle MaskRasterHandle;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 435bc949af0..aa8cfe1d36d 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1179,17 +1179,6 @@ void BKE_mask_point_parent_matrix_get(MaskSplinePoint *point, float ctime, float
 	}
 }
 
-static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
-{
-	float parent_matrix[3][3];
-
-	BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
-
-	mul_m3_v2(parent_matrix, point->bezt.vec[0]);
-	mul_m3_v2(parent_matrix, point->bezt.vec[1]);
-	mul_m3_v2(parent_matrix, point->bezt.vec[2]);
-}
-
 static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *point_prev, MaskSplinePoint *point_next)
 {
 	BezTriple *bezt = &point->bezt;
@@ -1405,80 +1394,12 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
 
 void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
 {
-	/* animation if available */
+	/* Animation if available. */
 	if (do_newframe) {
-		MaskLayerShape *masklay_shape_a;
-		MaskLayerShape *masklay_shape_b;
-		int found;
-
-		if ((found = BKE_mask_layer_shape_find_frame_range(masklay, ctime,
-		                                                   &masklay_shape_a, &masklay_shape_b)))
-		{
-			if (found == 1) {
-#if 0
-				printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
-				       masklay_shape_a->frame);
-#endif
-
-				BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
-			}
-			else if (found == 2) {
-				float w = masklay_shape_b->frame - masklay_shape_a->frame;
-#if 0
-				printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
-				       masklay_shape_a->frame, masklay_shape_b->frame);
-#endif
-				BKE_mask_layer_shape_to_mask_interp(masklay, masklay_shape_a, masklay_shape_b,
-				                                    (ctime - masklay_shape_a->frame) / w);
-			}
-			else {
-				/* always fail, should never happen */
-				BLI_assert(found == 2);
-			}
-		}
-	}
-	/* animation done... */
-
-	BKE_mask_layer_calc_handles(masklay);
-
-	/* update deform */
-	{
-		MaskSpline *spline;
-
-		for (spline = masklay->splines.first; spline; spline = spline->next) {
-			int i;
-			bool need_handle_recalc = false;
-
-			BKE_mask_spline_ensure_deform(spline);
-
-			for (i = 0; i < spline->tot_point; i++) {
-				MaskSplinePoint *point = &spline->points[i];
-				MaskSplinePoint *point_deform = &spline->points_deform[i];
-
-				BKE_mask_point_free(point_deform);
-
-				*point_deform = *point;
-				point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
-
-				mask_evaluate_apply_point_parent(point_deform, ctime);
-
-				if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
-					need_handle_recalc = true;
-				}
-			}
-
-			/* if the spline has auto or vector handles, these need to be recalculated after deformation */
-			if (need_handle_recalc) {
-				for (i = 0; i < spline->tot_point; i++) {
-					MaskSplinePoint *point_deform = &spline->points_deform[i];
-					if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
-						BKE_mask_calc_handle_point(spline, point_deform);
-					}
-				}
-			}
-			/* end extra calc handles loop */
-		}
+		BKE_mask_layer_evaluate_animation(masklay, ctime);
 	}
+	/* Update deform. */
+	BKE_mask_layer_evaluate_deform(masklay, ctime);
 }
 
 void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 1b275f455f4..594896c86b4 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -810,3 +810,88 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point,
 
 	return diff_points;
 }
+
+
+static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
+{
+	float parent_matrix[3][3];
+	BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
+	mul_m3_v2(parent_matrix, point->bezt.vec[0]);
+	mul_m3_v2(parent_matrix, point->bezt.vec[1]);
+	mul_m3_v2(parent_matrix, point->bezt.vec[2]);
+}
+
+void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
+{
+	/* animation if available */
+	MaskLayerShape *masklay_shape_a;
+	MaskLayerShape *masklay_shape_b;
+	int found;
+	if ((found = BKE_mask_layer_shape_find_frame_range(
+	           masklay, ctime, &masklay_shape_a, &masklay_shape_b)))
+	{
+		if (found == 1) {
+#if 0
+			printf("%s: exact %d %d (%d)\n",
+			       __func__,
+			       (int)ctime,
+			       BLI_listbase_count(&masklay->splines_shapes),
+			       masklay_shape_a->frame);
+#endif
+			BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
+		}
+		else if (found == 2) {
+			float w = masklay_shape_b->frame - masklay_shape_a->frame;
+#if 0
+			printf("%s: tween %d %d (%d %d)\n",
+			       __func__,
+			       (int)ctime,
+			       BLI_listbase_count(&masklay->splines_shapes),
+			       masklay_shape_a->frame, masklay_shape_b->frame);
+#endif
+			BKE_mask_layer_shape_to_mask_interp(
+			        masklay,
+			        masklay_shape_a, masklay_shape_b,
+			        (ctime - masklay_shape_a->frame) / w);
+		}
+		else {
+			/* always fail, should never happen */
+			BLI_assert(found == 2);
+		}
+	}
+}
+
+void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
+{
+	BKE_mask_layer_calc_handles(masklay);
+	for (MaskSpline *spline = masklay->splines.first;
+	     spline != NULL;
+	     spline = spline->next)
+	{
+		bool need_handle_recalc = false;
+		BKE_mask_spline_ensure_deform(spline);
+		for (int i = 0; i < spline->tot_point; i++) {
+			MaskSplinePoint *point = &spline->points[i];
+			MaskSplinePoint *point_deform = &spline->points_deform[i];
+			BKE_mask_point_free(point_deform);
+			*point_deform = *point;
+			point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
+			mask_evaluate_apply_point_parent(point_deform, ctime);
+			if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
+				need_handle_recalc = true;
+			}
+		}
+		/* if the spline has auto or vector handles, these need to be
+		 * recalculated after deformation.
+		 */
+		if (need_handle_recalc) {
+			for (int i = 0; i < spline->tot_point; i++) {
+				MaskSplinePoint *point_deform = &spline->points_deform[i];
+				if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
+					BKE_mask_calc_handle_point(spline, point_deform);
+				}
+			}
+		}
+		/* end extra calc handles loop */
+	}
+}



More information about the Bf-blender-cvs mailing list