[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18684] branches/etch-a-ton/source/blender /src/editarmature_sketch.c: - Made embbed point rely on last embbed preview ( when holding down shift and moving mouse around) for finding the proper depth.

Martin Poirier theeth at yahoo.com
Mon Jan 26 23:43:17 CET 2009


Revision: 18684
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18684
Author:   theeth
Date:     2009-01-26 23:43:12 +0100 (Mon, 26 Jan 2009)

Log Message:
-----------
- Made embbed point rely on last embbed preview (when holding down shift and moving mouse around) for finding the proper depth. This makes it much easier to do polylines on partially occluded areas: just shift-hover a visible section than move to where you want along the volume before clicking to place a point (this sounds complicated but it isn't).

- Replace Cutout command by Straighten. Fonctionnality is the same except that it now keeps points in between cuts, just straightens them.

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2009-01-26 21:32:22 UTC (rev 18683)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2009-01-26 22:43:12 UTC (rev 18684)
@@ -173,6 +173,8 @@
 
 SK_Sketch *GLOBAL_sketch = NULL;
 SK_Point boneSnap;
+int    LAST_SNAP_POINT_VALID = 0;
+float  LAST_SNAP_POINT[3];
 
 #define SNAP_MIN_DISTANCE 12
 
@@ -896,7 +898,7 @@
 	stk->nb_points++;
 }
 
-void sk_inserStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end)
+void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end)
 {
 	int size = end - start + 1;
 	
@@ -926,35 +928,42 @@
 	stk->nb_points = size;
 }
 
-void sk_cutoutStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3])
+void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3])
 {
-	int size = end - start + 1;
+	SK_Point pt1, pt2;
+	SK_Point *prev, *next;
+	float delta_p[3];
+	int i, total;
 	
-	if (size == 1)
-	{
-		int move_size = stk->nb_points - end;
-		
-		sk_growStrokeBuffer(stk);
-		
-		memmove(stk->points + end + 1, stk->points + end, move_size * sizeof(SK_Point));
-		end++;
-		size++; 
-		stk->nb_points++;
-	}
+	total = end - start + 1;
+
+	VecSubf(delta_p, p_end, p_start);
 	
-	stk->points[start].type = PT_EXACT;
-	VECCOPY(stk->points[start].p, p_start);
-	stk->points[end].type = PT_EXACT;
-	VECCOPY(stk->points[end].p, p_end);
+	prev = stk->points + start;
+	next = stk->points + end;
 	
-	if (size > 2)
+	VECCOPY(pt1.p, p_start);
+	VECCOPY(pt1.no, prev->no);
+	pt1.mode = prev->mode;
+	pt1.type = prev->type;
+	
+	VECCOPY(pt2.p, p_end);
+	VECCOPY(pt2.no, next->no);
+	pt2.mode = next->mode;
+	pt2.type = next->type;
+	
+	sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */
+	sk_insertStrokePoint(stk, &pt2, end); /* insert before end (since end was pushed back already) */
+	
+	for (i = 1; i < total; i++)
 	{
-		int move_size = stk->nb_points - end;
-		
-		memmove(stk->points + start + 1, stk->points + end, move_size * sizeof(SK_Point));
-		
-		stk->nb_points = stk->nb_points - (size - 2);
-	}
+		float delta = (float)i / (float)total;
+		float *p = stk->points[start + 1 + i].p;
+
+		VECCOPY(p, delta_p);
+		VecMulf(p, delta);
+		VecAddf(p, p, p_start);
+	} 
 }
 
 void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
@@ -1554,7 +1563,7 @@
 			sk_lastStrokePoint(stk)->type = sketch->over.target->points[end].type;
 		}
 		
-		sk_inserStrokePoints(sketch->over.target, stk->points, stk->nb_points, start, end);
+		sk_insertStrokePoints(sketch->over.target, stk->points, stk->nb_points, start, end);
 		
 		sk_removeStroke(sketch, stk);
 		
@@ -1768,7 +1777,7 @@
 {
 	ListBase depth_peels;
 	SK_DepthPeel *p1, *p2;
-	SK_Point *last_pt = NULL;
+	float *last_p = NULL;
 	float dist = FLT_MAX;
 	float p[3];
 	int point_added = 0;
@@ -1779,8 +1788,12 @@
 	
 	if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS)
 	{
-		last_pt = stk->points + (stk->nb_points - 1);
+		last_p = stk->points[stk->nb_points - 1].p;
 	}
+	else if (LAST_SNAP_POINT_VALID)
+	{
+		last_p = LAST_SNAP_POINT;
+	}
 	
 	
 	for (p1 = depth_peels.first; p1; p1 = p1->next)
@@ -1827,14 +1840,14 @@
 				VECCOPY(vec, p1->p);
 			}
 			
-			if (last_pt == NULL)
+			if (last_p == NULL)
 			{
 				VECCOPY(p, vec);
 				dist = 0;
 				break;
 			}
 			
-			new_dist = VecLenf(last_pt->p, vec);
+			new_dist = VecLenf(last_p, vec);
 			
 			if (new_dist < dist)
 			{
@@ -1944,7 +1957,13 @@
 	if (point_added == 0 && qual & LR_SHIFTKEY)
 	{
 		point_added = sk_getStrokeEmbedPoint(pt, sketch, stk, dd);
+		LAST_SNAP_POINT_VALID = 1;
+		VECCOPY(LAST_SNAP_POINT, pt->p);
 	}
+	else
+	{
+		LAST_SNAP_POINT_VALID = 0;
+	}
 	
 	if (point_added == 0)
 	{
@@ -2556,7 +2575,7 @@
 	SK_Intersection *isect;
 	int command;
 	
-	command = pupmenu("Action %t|Flatten %x1|Cut Out %x2|Polygonize %x3");
+	command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3");
 	if(command < 1) return;
 
 	for (isect = gest->intersections.first; isect; isect = isect->next)
@@ -2573,7 +2592,7 @@
 					sk_flattenStroke(isect->stroke, isect->before, i2->after);
 					break;
 				case 2:
-					sk_cutoutStroke(isect->stroke, isect->after, i2->before, isect->p, i2->p);
+					sk_straightenStroke(isect->stroke, isect->after, i2->before, isect->p, i2->p);
 					break;
 				case 3:
 					sk_polygonizeStroke(isect->stroke, isect->before, i2->after);





More information about the Bf-blender-cvs mailing list