[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17081] branches/etch-a-ton/source/blender : Convert and Delete only selected strokes.

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


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

Log Message:
-----------
Convert and Delete only selected strokes.
Convert no longer remove converted strokes.
Akey -> select all/deselect all strokes

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/blenkernel/BKE_global.h
    branches/etch-a-ton/source/blender/include/BIF_sketch.h
    branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
    branches/etch-a-ton/source/blender/src/drawview.c
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c
    branches/etch-a-ton/source/blender/src/space.c
    branches/etch-a-ton/source/blender/src/view.c

Modified: branches/etch-a-ton/source/blender/blenkernel/BKE_global.h
===================================================================
--- branches/etch-a-ton/source/blender/blenkernel/BKE_global.h	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/blenkernel/BKE_global.h	2008-10-14 20:03:21 UTC (rev 17081)
@@ -151,9 +151,6 @@
 	
 	/* confusing... G.f and G.flags */
 	int flags;
-	
-	int bone_sketching; /* regroup with edbo into an EditArmature struct */
-
 } Global;
 
 /* **************** GLOBAL ********************* */

Modified: branches/etch-a-ton/source/blender/include/BIF_sketch.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_sketch.h	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/include/BIF_sketch.h	2008-10-14 20:03:21 UTC (rev 17081)
@@ -23,8 +23,10 @@
 #ifndef BIF_SKETCH_H
 #define BIF_SKETCH_H
 
-int BIF_paintSketch();
+int BIF_paintSketch(short mbut);
 void BIF_convertSketch();
 void BIF_deleteSketch();
+void BIF_selectAllSketch(int mode); /* -1: deselect, 0: select, 1: toggle */
+int BIF_validSketchMode();
 
 #endif /* BIF_SKETCH_H */

Modified: branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-10-14 20:03:21 UTC (rev 17081)
@@ -438,9 +438,12 @@
 	char  skgen_postpro_passes;
 	char  skgen_subdivisions[3];
 	
+	/* Skeleton Sketching */
+	char bone_sketching;
+	
 	/* Alt+RMB option */
 	char edge_mode;
-	char pad3[4];
+	char pad3[3];
 } ToolSettings;
 
 /* Used by all brushes to store their properties, which can be directly set
@@ -854,6 +857,9 @@
 #define SKGEN_AVERAGE			1
 #define SKGEN_SHARPEN			2
 
+/* toolsettings->bone_sketching */
+#define BONE_SKETCHING		1
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/src/drawview.c	2008-10-14 20:03:21 UTC (rev 17081)
@@ -2300,7 +2300,7 @@
 		uiBlockBeginAlign(block);
 		
 		/* use real flag instead of 1 */
-		uiDefButBitI(block, TOG, 1, B_REDR, "Use Bone Sketching", 10, 225, 150, 20, &G.bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
+		uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, 225, 150, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
 		but = uiDefBut(block, BUT, B_REDR, "Convert", 10,205,150,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
 		uiButSetFunc(but, convert_sketch_armature, NULL, NULL);
 		but = uiDefBut(block, BUT, B_REDR, "Delete", 10,185,150,20, 0, 0, 0, 0, 0, "Delete sketch");

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-14 20:03:21 UTC (rev 17081)
@@ -48,6 +48,7 @@
 #include "BIF_space.h"
 #include "BIF_mywindow.h"
 #include "BIF_editarmature.h"
+#include "BIF_sketch.h"
 
 #include "blendef.h"
 #include "mydevice.h"
@@ -100,6 +101,8 @@
 SK_Sketch *GLOBAL_sketch = NULL;
 SK_Point boneSnap;
 
+#define SNAP_MIN_DISTANCE 12
+
 /******************** PROTOTYPES ******************************/
 
 void sk_freeStroke(SK_Stroke *stk);
@@ -762,13 +765,18 @@
 	}
 }
 
-void sk_addStrokeSnapPoint(SK_Stroke *stk, SK_DrawData *dd, SK_Point *snap_pt)
+int sk_addStrokeSnapPoint(SK_Stroke *stk, SK_DrawData *dd, SK_Point *snap_pt)
 {
 	SK_Point pt;
 	float distance;
 	float length;
 	int i, total;
 	
+	if (snap_pt == NULL)
+	{
+		return 0;
+	}
+	
 	pt.type = PT_EXACT;
 	pt.mode = PT_SNAP;
 	
@@ -797,9 +805,11 @@
 	}
 
 	VECCOPY(stk->points[stk->nb_points - 1].p, snap_pt->p);
+	
+	return 1;
 }
 
-void sk_addStrokeDrawPoint(SK_Stroke *stk, SK_DrawData *dd)
+int sk_addStrokeDrawPoint(SK_Stroke *stk, SK_DrawData *dd)
 {
 	SK_Point pt;
 	
@@ -809,15 +819,18 @@
 	sk_projectPaintData(stk, dd, pt.p);
 
 	sk_appendStrokePoint(stk, &pt);
+	
+	return 1;
 }
 
-void sk_addStrokeEmbedPoint(SK_Stroke *stk, SK_DrawData *dd)
+int sk_addStrokeEmbedPoint(SK_Stroke *stk, SK_DrawData *dd)
 {
 	ListBase depth_peels;
 	SK_DepthPeel *p1, *p2;
 	SK_Point *last_pt = NULL;
 	float dist = FLT_MAX;
 	float p[3];
+	int point_added = 0;
 	
 	depth_peels.first = depth_peels.last = NULL;
 	
@@ -874,12 +887,8 @@
 		}
 	}
 	
-	if (dist == FLT_MAX)
+	if (dist != FLT_MAX)
 	{
-		sk_addStrokeDrawPoint(stk, dd);
-	}
-	else
-	{
 		SK_Point pt;
 		float length, distance;
 		int total;
@@ -912,9 +921,13 @@
 		}
 		
 		VECCOPY(stk->points[stk->nb_points - 1].p, p);
+		
+		point_added = 1;
 	}
 	
 	BLI_freelistN(&depth_peels);
+	
+	return point_added;
 }
 
 void sk_endContinuousStroke(SK_Stroke *stk)
@@ -995,16 +1008,68 @@
 	
 	for (stk = sketch->strokes.first; stk; stk = stk->next)
 	{
-		sk_convertStroke(stk);
+		if (stk->selected == 1)
+		{
+			sk_convertStroke(stk);
+		}
 	}
-	
-	BLI_freelistN(&sketch->strokes);
 }
 /********************************************/
 
+void sk_deleteStrokes(SK_Sketch *sketch)
+{
+	SK_Stroke *stk, *next;
+	
+	for (stk = sketch->strokes.first; stk; stk = next)
+	{
+		next = stk->next;
+		
+		if (stk->selected == 1)
+		{
+			BLI_remlink(&sketch->strokes, stk);
+			sk_freeStroke(stk);
+		}
+	}
+}
+
+void sk_selectAllSketch(SK_Sketch *sketch, int mode)
+{
+	SK_Stroke *stk = NULL;
+	
+	if (mode == -1)
+	{
+		for (stk = sketch->strokes.first; stk; stk = stk->next)
+		{
+			stk->selected = 0;
+		}
+	}
+	else if (mode == 0)
+	{
+		for (stk = sketch->strokes.first; stk; stk = stk->next)
+		{
+			stk->selected = 1;
+		}
+	}
+	else if (mode == 1)
+	{
+		int selected = 1;
+		
+		for (stk = sketch->strokes.first; stk; stk = stk->next)
+		{
+			selected &= stk->selected;
+		}
+		
+		selected ^= 1;
+
+		for (stk = sketch->strokes.first; stk; stk = stk->next)
+		{
+			stk->selected = selected;
+		}
+	}
+}
+
 void sk_selectStroke(SK_Sketch *sketch)
 {
-	SK_Stroke *stk = NULL;
 	unsigned int buffer[MAXPICKBUF];
 	short hits, mval[2];
 
@@ -1031,18 +1096,18 @@
 		{
 			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;
-					}
-				}
+				sk_selectAllSketch(sketch, -1);
+				
+				selected_stk->selected = 1;
 			}
+			else
+			{
+				selected_stk->selected ^= 1;
+			}
+			
+			
 		}
 	}
 }
@@ -1110,7 +1175,7 @@
 			
 			if (G.qual & LR_CTRLKEY)
 			{
-				SK_Point *snap_pt = sk_snapPoint(sketch, dd.mval, 30);
+				SK_Point *snap_pt = sk_snapPoint(sketch, dd.mval, SNAP_MIN_DISTANCE);
 				
 				if (snap_pt != NULL)
 				{
@@ -1152,26 +1217,22 @@
 			
 			/* only add current point to buffer if mouse moved (otherwise wait until it does) */
 			if (sk_stroke_filtermval(&dd)) {
+				int point_added = 0;
+				
 				if (G.qual & LR_CTRLKEY)
 				{
-					SK_Point *snap_pt = sk_snapPoint(sketch, dd.mval, 30);
-					
-					if (snap_pt != NULL)
-					{
-						sk_addStrokeSnapPoint(sketch->active_stroke, &dd, snap_pt);
-					}
-					else
-					{
-						sk_addStrokeDrawPoint(sketch->active_stroke, &dd);
-					}
+					SK_Point *snap_pt = sk_snapPoint(sketch, dd.mval, SNAP_MIN_DISTANCE);
+					point_added = sk_addStrokeSnapPoint(sketch->active_stroke, &dd, snap_pt);
 				}
-				else if (G.qual & LR_SHIFTKEY)
+				
+				if (point_added == 0 && G.qual & LR_SHIFTKEY)
 				{
-					sk_addStrokeEmbedPoint(sketch->active_stroke, &dd);
+					point_added = sk_addStrokeEmbedPoint(sketch->active_stroke, &dd);
 				}
-				else
+				
+				if (point_added == 0)
 				{
-					sk_addStrokeDrawPoint(sketch->active_stroke, &dd);
+					point_added = sk_addStrokeDrawPoint(sketch->active_stroke, &dd);
 				}
 				
 				sk_updateDrawData(&dd);
@@ -1214,7 +1275,7 @@
 
 void BDR_drawSketchNames()
 {
-	if (G.bone_sketching & 1)
+	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch != NULL)
 		{
@@ -1225,7 +1286,7 @@
 
 void BDR_drawSketch()
 {
-	if (G.bone_sketching & 1)
+	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch != NULL)
 		{
@@ -1236,16 +1297,15 @@
 
 void BIF_deleteSketch()
 {
-	if (GLOBAL_sketch != NULL)
+	if (BIF_validSketchMode())
 	{
-		sk_freeSketch(GLOBAL_sketch);
-		GLOBAL_sketch = NULL;
+		sk_deleteStrokes(GLOBAL_sketch);
 	}
 }
 
 void BIF_convertSketch()
 {
-	if (G.bone_sketching & 1)
+	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch != NULL)
 		{
@@ -1256,7 +1316,7 @@
 
 int BIF_paintSketch(short mbut)
 {
-	if (G.bone_sketching & 1)
+	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch == NULL)
 		{
@@ -1273,7 +1333,7 @@
 
 void BDR_queueDrawSketch()
 {
-	if (G.bone_sketching & 1)
+	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch != NULL)
 		{
@@ -1281,3 +1341,29 @@
 		}
 	}
 }
+
+void BIF_selectAllSketch(int mode)
+{
+	if (BIF_validSketchMode())
+	{
+		if (GLOBAL_sketch != NULL)
+		{
+			sk_selectAllSketch(GLOBAL_sketch, mode);
+			allqueue(REDRAWVIEW3D, 0);
+		}
+	}
+}
+
+int BIF_validSketchMode()
+{
+	if (G.obedit && 
+		G.obedit->type == OB_ARMATURE && 
+		G.scene->toolsettings->bone_sketching & BONE_SKETCHING)
+	{
+		return 1;
+	}
+	else
+	{
+		return 0;
+	}
+}

Modified: branches/etch-a-ton/source/blender/src/space.c
===================================================================
--- branches/etch-a-ton/source/blender/src/space.c	2008-10-14 17:17:10 UTC (rev 17080)
+++ branches/etch-a-ton/source/blender/src/space.c	2008-10-14 20:03:21 UTC (rev 17081)
@@ -1899,7 +1899,16 @@
 						else if(G.obedit->type==OB_LATTICE)
 							deselectall_Latt();
 						else if(G.obedit->type==OB_ARMATURE)
-							deselectall_armature(1, 1);	/* 1 == toggle */
+						{
+							if (G.scene->toolsettings->bone_sketching & BONE_SKETCHING)
+							{
+								BIF_selectAllSketch(1);
+							}
+							else
+							{
+								deselectall_armature(1, 1);	/* 1 == toggle */
+							}
+						}
 					}
 					else if (ob && (ob->flag & OB_POSEMODE)){
 						deselectall_posearmature(ob, 1, 1);

Modified: branches/etch-a-ton/source/blender/src/view.c
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list