[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17132] branches/etch-a-ton/source/blender : Quick Strokes option

Martin Poirier theeth at yahoo.com
Mon Oct 20 20:55:09 CEST 2008


Revision: 17132
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17132
Author:   theeth
Date:     2008-10-20 20:55:09 +0200 (Mon, 20 Oct 2008)

Log Message:
-----------
Quick Strokes option

When turned on, edit mode armature act as usual, but LMB can be directly used to paint strokes or poly lines which will be directly converted to bones once ended (with RMB).

Esc now cancels the current stroke instead of ending it (more useful with quick strokes).

Video online:

http://blenderartists.org/~theeth/bf/etch-a-ton/quick_strokes.ogv

Modified Paths:
--------------
    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/edit.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/include/BIF_sketch.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_sketch.h	2008-10-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/include/BIF_sketch.h	2008-10-20 18:55:09 UTC (rev 17132)
@@ -29,5 +29,7 @@
 void BIF_deleteSketch();
 void BIF_selectAllSketch(int mode); /* -1: deselect, 0: select, 1: toggle */
 int BIF_validSketchMode();
+int BIF_fullSketchMode(); /* full sketch turned on (not Quick) */
+void BIF_cancelStrokeSketch();
 
 #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-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-10-20 18:55:09 UTC (rev 17132)
@@ -858,7 +858,8 @@
 #define SKGEN_SHARPEN			2
 
 /* toolsettings->bone_sketching */
-#define BONE_SKETCHING		1
+#define BONE_SKETCHING			1
+#define BONE_SKETCHING_QUICK	2
 
 #ifdef __cplusplus
 }

Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c	2008-10-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/src/drawview.c	2008-10-20 18:55:09 UTC (rev 17132)
@@ -2300,7 +2300,8 @@
 		uiBlockBeginAlign(block);
 		
 		/* use real flag instead of 1 */
-		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");
+		uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, 225, 130, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
+		uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 140, 225, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
 		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/edit.c
===================================================================
--- branches/etch-a-ton/source/blender/src/edit.c	2008-10-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/src/edit.c	2008-10-20 18:55:09 UTC (rev 17132)
@@ -1839,7 +1839,7 @@
 
 void delete_context_selected(void) 
 {
-	if(BIF_validSketchMode())
+	if(BIF_fullSketchMode())
 	{
 		BIF_deleteSketch();
 	}

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-20 18:55:09 UTC (rev 17132)
@@ -467,6 +467,25 @@
 	stk->nb_points = size;
 }
 
+void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk)
+{
+	if (sketch->active_stroke == stk)
+	{
+		sketch->active_stroke = NULL;
+	}
+	
+	BLI_remlink(&sketch->strokes, stk);
+	sk_freeStroke(stk);
+}
+
+void sk_cancelStroke(SK_Sketch *sketch)
+{
+	if (sketch->active_stroke != NULL)
+	{
+		sk_removeStroke(sketch, sketch->active_stroke);
+	}
+}
+
 /* Apply reverse Chaikin filter to simplify the polyline
  * */
 void sk_filterStroke(SK_Stroke *stk, int start, int end)
@@ -1616,8 +1635,7 @@
 		{
 			isect = isect->next;
 			
-			BLI_remlink(&sketch->strokes, isect->stroke);
-			sk_freeStroke(isect->stroke);
+			sk_removeStroke(sketch, isect->stroke);
 		}
 	}
 }
@@ -1746,7 +1764,7 @@
 
 /********************************************/
 
-void sk_deleteStrokes(SK_Sketch *sketch)
+void sk_deleteSelectedStrokes(SK_Sketch *sketch)
 {
 	SK_Stroke *stk, *next;
 	
@@ -1756,8 +1774,7 @@
 		
 		if (stk->selected == 1)
 		{
-			BLI_remlink(&sketch->strokes, stk);
-			sk_freeStroke(stk);
+			sk_removeStroke(sketch, stk);
 		}
 	}
 }
@@ -1994,9 +2011,24 @@
 	{
 		if (sketch->active_stroke != NULL)
 		{
+			SK_Stroke *stk = sketch->active_stroke;
+			
 			sk_endStroke(sketch);
+			
+			if (G.scene->toolsettings->bone_sketching & BONE_SKETCHING_QUICK)
+			{
+				sk_convertStroke(stk);
+				sk_removeStroke(sketch, stk);
+				allqueue(REDRAWBUTSEDIT, 0);
+			}
+			
 			allqueue(REDRAWVIEW3D, 0);
 		}
+		/* no gestures in quick mode */
+		else if (G.scene->toolsettings->bone_sketching & BONE_SKETCHING_QUICK)
+		{
+			retval = 0; /* return zero for default click behavior */
+		}
 		else
 		{
 			SK_DrawData dd;
@@ -2095,13 +2127,25 @@
 	}
 }
 
+void BIF_cancelStrokeSketch()
+{
+	if (BIF_validSketchMode())
+	{
+		if (GLOBAL_sketch != NULL)
+		{
+			sk_cancelStroke(GLOBAL_sketch);
+			allqueue(REDRAWVIEW3D, 0);
+		}
+	}
+}
+
 void BIF_deleteSketch()
 {
 	if (BIF_validSketchMode())
 	{
 		if (GLOBAL_sketch != NULL)
 		{
-			sk_deleteStrokes(GLOBAL_sketch);
+			sk_deleteSelectedStrokes(GLOBAL_sketch);
 			allqueue(REDRAWVIEW3D, 0);
 		}
 	}
@@ -2175,3 +2219,18 @@
 		return 0;
 	}
 }
+
+int BIF_fullSketchMode()
+{
+	if (G.obedit && 
+		G.obedit->type == OB_ARMATURE && 
+		G.scene->toolsettings->bone_sketching & BONE_SKETCHING && 
+		(G.scene->toolsettings->bone_sketching & BONE_SKETCHING_QUICK) == 0)
+	{
+		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-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/src/space.c	2008-10-20 18:55:09 UTC (rev 17132)
@@ -1908,7 +1908,7 @@
 							deselectall_Latt();
 						else if(G.obedit->type==OB_ARMATURE)
 						{
-							if (G.scene->toolsettings->bone_sketching & BONE_SKETCHING)
+							if (BIF_fullSketchMode())
 							{
 								BIF_selectAllSketch(1);
 							}
@@ -1984,7 +1984,7 @@
 				else if(G.qual==LR_ALTKEY) {
 					if(ob && (ob->flag & OB_POSEMODE))
 						pose_clear_constraints();	/* poseobject.c */
-					else if (BIF_validSketchMode())
+					else if (BIF_fullSketchMode())
 					{
 						BIF_convertSketch();
 					}
@@ -2959,7 +2959,7 @@
 			case ESCKEY:
 				if (G.qual == 0 && BIF_validSketchMode())
 				{
-					BIF_endStrokeSketch();
+					BIF_cancelStrokeSketch();
 				}
 				else if(G.qual==0) {
 					if (G.vd->flag & V3D_DISPIMAGE) {

Modified: branches/etch-a-ton/source/blender/src/view.c
===================================================================
--- branches/etch-a-ton/source/blender/src/view.c	2008-10-20 13:36:18 UTC (rev 17131)
+++ branches/etch-a-ton/source/blender/src/view.c	2008-10-20 18:55:09 UTC (rev 17132)
@@ -75,6 +75,7 @@
 #include "BIF_space.h"
 #include "BIF_screen.h"
 #include "BIF_toolbox.h"
+#include "BIF_sketch.h"
 
 #include "BSE_view.h"
 #include "BSE_edit.h"		/* For countall */
@@ -1885,7 +1886,7 @@
 		draw_object(BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
 	}
 	else if ((G.obedit && G.obedit->type==OB_ARMATURE)) {
-		if (G.scene->toolsettings->bone_sketching & BONE_SKETCHING)
+		if (BIF_fullSketchMode())
 		{
 			BDR_drawSketchNames();
 		}





More information about the Bf-blender-cvs mailing list