[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46636] branches/soc-2011-tomato/source/ blender/editors/mask/mask_ops.c: when adding new points to mask

Campbell Barton ideasman42 at gmail.com
Mon May 14 17:59:55 CEST 2012


Revision: 46636
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46636
Author:   campbellbarton
Date:     2012-05-14 15:59:53 +0000 (Mon, 14 May 2012)
Log Message:
-----------
when adding new points to mask
- base when adding between 2 points use their handle types.
- when extruding an existing point use its handle type.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c

Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c	2012-05-14 15:50:35 UTC (rev 46635)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c	2012-05-14 15:59:53 UTC (rev 46636)
@@ -1086,8 +1086,11 @@
 /******************** add vertex *********************/
 
 static void setup_vertex_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point,
-                               float point_co[2], float tangent[2])
+                               const float point_co[2], const float tangent[2],
+                               MaskSplinePoint *reference_point, const short reference_adjacent)
 {
+	MaskSplinePoint *prev_point = NULL;
+	MaskSplinePoint *next_point = NULL;
 	BezTriple *bezt;
 	int width, height;
 	float co[3];
@@ -1103,6 +1106,21 @@
 
 	bezt->h1 = bezt->h2 = HD_ALIGN;
 
+	if (reference_point) {
+		bezt->h1 = bezt->h2 = MAX2(reference_point->bezt.h2, reference_point->bezt.h1);
+	}
+	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];
+
+			bezt->h1 = bezt->h2 = MAX2(prev_point->bezt.h2, next_point->bezt.h1);
+
+			/* note, we may want to copy other attributes later, radius? pressure? color? */
+		}
+	}
+
 	copy_v3_v3(bezt->vec[0], co);
 	copy_v3_v3(bezt->vec[1], co);
 	copy_v3_v3(bezt->vec[2], co);
@@ -1214,7 +1232,7 @@
 
 		new_point = &new_point_array[point_index + 1];
 
-		setup_vertex_point(C, mask, spline, new_point, co, tangent);
+		setup_vertex_point(C, mask, spline, new_point, co, tangent, NULL, TRUE);
 
 		shape->act_point = new_point;
 
@@ -1273,7 +1291,8 @@
 {
 	MaskShape *shape;
 	MaskSpline *spline;
-	MaskSplinePoint *point, *new_point = NULL;
+	MaskSplinePoint *point;
+	MaskSplinePoint *new_point = NULL, *ref_point = NULL;
 
 	/* adding _could_ deselect, for now don't */
 #if 0
@@ -1312,6 +1331,7 @@
 			spline->tot_point++;
 
 			new_point = &spline->points[spline->tot_point - 1];
+			ref_point = &spline->points[spline->tot_point - 2];
 		}
 		else if (point == &spline->points[0]) {
 			MASKPOINT_DESEL(point);
@@ -1322,6 +1342,7 @@
 			spline->tot_point++;
 
 			new_point = &spline->points[0];
+			ref_point = &spline->points[1];
 		}
 		else {
 			spline = BKE_mask_spline_add(shape);
@@ -1332,7 +1353,7 @@
 
 	shape->act_point = new_point;
 
-	setup_vertex_point(C, mask, spline, new_point, co, NULL);
+	setup_vertex_point(C, mask, spline, new_point, co, NULL, ref_point, FALSE);
 	WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
 
 	return TRUE;




More information about the Bf-blender-cvs mailing list