[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17063] branches/etch-a-ton/source/blender : Embed point looks at last point, whether it was part of a continuous stroke or not ( gives better results for poly lines)

Martin Poirier theeth at yahoo.com
Tue Oct 14 03:25:31 CEST 2008


Revision: 17063
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17063
Author:   theeth
Date:     2008-10-14 03:25:30 +0200 (Tue, 14 Oct 2008)

Log Message:
-----------
Embed point looks at last point, whether it was part of a continuous stroke or not (gives better results for poly lines)

Stroke selection (LMB and Shift-LMB).
	Selected strokes drawn in red.
	Eventually convert and delete will work on selection.

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/include/BDR_sketch.h
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c
    branches/etch-a-ton/source/blender/src/view.c

Modified: branches/etch-a-ton/source/blender/include/BDR_sketch.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BDR_sketch.h	2008-10-13 23:41:38 UTC (rev 17062)
+++ branches/etch-a-ton/source/blender/include/BDR_sketch.h	2008-10-14 01:25:30 UTC (rev 17063)
@@ -25,5 +25,6 @@
 
 void BDR_queueDrawSketch();
 void BDR_drawSketch();
+void BDR_drawSketchNames();
 
 #endif /* BDR_SKETCH_H */

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-13 23:41:38 UTC (rev 17062)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-14 01:25:30 UTC (rev 17063)
@@ -79,6 +79,7 @@
 	SK_Point *points;
 	int nb_points;
 	int buf_size;
+	int selected;
 } SK_Stroke;
 
 #define SK_Stroke_BUFFER_INIT_SIZE 20
@@ -370,6 +371,7 @@
 	
 	stk = MEM_callocN(sizeof(SK_Stroke), "SK_Stroke");
 	
+	stk->selected = 0;
 	stk->nb_points = 0;
 	stk->buf_size = SK_Stroke_BUFFER_INIT_SIZE;
 	
@@ -523,11 +525,23 @@
 	return pt;
 }
 
-void sk_drawStroke(SK_Stroke *stk)
+void sk_drawStroke(SK_Stroke *stk, int id)
 {
 	int i;
 	
-	glColor3f(1, 0.5, 0);
+	if (id != -1)
+	{
+		glLoadName(id);
+	}
+	
+	if (stk->selected)
+	{
+		glColor3f(1, 0, 0);
+	}
+	else
+	{
+		glColor3f(1, 0.5, 0);
+	}
 	glBegin(GL_LINE_STRIP);
 	
 	for (i = 0; i < stk->nb_points; i++)
@@ -810,7 +824,7 @@
 	peelObjects(&depth_peels, dd->mval);
 	
 	
-	if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS)
+	if (stk->nb_points > 0) // && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS)
 	{
 		last_pt = stk->points + (stk->nb_points - 1);
 	}
@@ -988,6 +1002,51 @@
 }
 /********************************************/
 
+void sk_selectStroke(SK_Sketch *sketch)
+{
+	SK_Stroke *stk = NULL;
+	unsigned int buffer[MAXPICKBUF];
+	short hits, mval[2];
+
+	persp(PERSP_VIEW);
+
+	getmouseco_areawin(mval);
+	hits = view3d_opengl_select(buffer, MAXPICKBUF, mval[0]-5, mval[1]-5, mval[0]+5, mval[1]+5);
+	if(hits==0)
+		hits = view3d_opengl_select(buffer, MAXPICKBUF, mval[0]-12, mval[1]-12, mval[0]+12, mval[1]+12);
+		
+	if (hits>0)
+	{
+		int besthitresult = -1;
+			
+		if(hits == 1) {
+			besthitresult = buffer[3];
+		}
+		else {
+			besthitresult = buffer[3];
+			/* loop and get best hit */
+		}
+		
+		if (besthitresult != -1)
+		{
+			SK_Stroke *selected_stk = BLI_findlink(&sketch->strokes, besthitresult);
+			
+			selected_stk->selected ^= 1;
+			
+			if ((G.qual & LR_SHIFTKEY) == 0)
+			{
+				for (stk = sketch->strokes.first; stk; stk = stk->next)
+				{
+					if (stk != selected_stk)
+					{
+						stk->selected = 0;
+					}
+				}
+			}
+		}
+	}
+}
+
 void sk_queueRedrawSketch(SK_Sketch *sketch)
 {
 	if (sketch->active_stroke != NULL)
@@ -1001,7 +1060,7 @@
 	}
 }
 
-void sk_drawSketch(SK_Sketch *sketch)
+void sk_drawSketch(SK_Sketch *sketch, int with_names)
 {
 	SK_Stroke *stk;
 	
@@ -1009,11 +1068,22 @@
 
 	glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE));
 	glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-
-	for (stk = sketch->strokes.first; stk; stk = stk->next)
+	
+	if (with_names)
 	{
-		sk_drawStroke(stk);
+		int id;
+		for (id = 0, stk = sketch->strokes.first; stk; id++, stk = stk->next)
+		{
+			sk_drawStroke(stk, id);
+		}
 	}
+	else
+	{
+		for (stk = sketch->strokes.first; stk; stk = stk->next)
+		{
+			sk_drawStroke(stk, -1);
+		}
+	}
 	
 	if (sketch->active_stroke != NULL)
 	{
@@ -1132,11 +1202,26 @@
 			sk_endStroke(sketch);
 			allqueue(REDRAWVIEW3D, 0);
 		}
+		else
+		{
+			sk_selectStroke(sketch);
+			allqueue(REDRAWVIEW3D, 0);
+		}
 	}
 	
 	return retval;
 }
 
+void BDR_drawSketchNames()
+{
+	if (G.bone_sketching & 1)
+	{
+		if (GLOBAL_sketch != NULL)
+		{
+			sk_drawSketch(GLOBAL_sketch, 1);
+		}
+	}
+}
 
 void BDR_drawSketch()
 {
@@ -1144,7 +1229,7 @@
 	{
 		if (GLOBAL_sketch != NULL)
 		{
-			sk_drawSketch(GLOBAL_sketch);
+			sk_drawSketch(GLOBAL_sketch, 0);
 		}
 	}
 }

Modified: branches/etch-a-ton/source/blender/src/view.c
===================================================================
--- branches/etch-a-ton/source/blender/src/view.c	2008-10-13 23:41:38 UTC (rev 17062)
+++ branches/etch-a-ton/source/blender/src/view.c	2008-10-14 01:25:30 UTC (rev 17063)
@@ -1883,7 +1883,14 @@
 		draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
 	}
 	else if ((G.obedit && G.obedit->type==OB_ARMATURE)) {
-		draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
+		if (G.bone_sketching & 1)
+		{
+			BDR_drawSketchNames();
+		}
+		else
+		{
+			draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
+		}
 	}
 	else {
 		Base *base;





More information about the Bf-blender-cvs mailing list