[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17026] branches/etch-a-ton/source/blender : Bone sketching clean up

Martin Poirier theeth at yahoo.com
Sat Oct 11 21:53:40 CEST 2008


Revision: 17026
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17026
Author:   theeth
Date:     2008-10-11 21:53:39 +0200 (Sat, 11 Oct 2008)

Log Message:
-----------
Bone sketching clean up

Armature edit mode only (panel accessible in Armature header menu)
Can be turned on or off
Ctrl also snaps to edit bones' head and tail

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/blenkernel/BKE_global.h
    branches/etch-a-ton/source/blender/include/BIF_space.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/header_view3d.c

Modified: branches/etch-a-ton/source/blender/blenkernel/BKE_global.h
===================================================================
--- branches/etch-a-ton/source/blender/blenkernel/BKE_global.h	2008-10-11 19:34:48 UTC (rev 17025)
+++ branches/etch-a-ton/source/blender/blenkernel/BKE_global.h	2008-10-11 19:53:39 UTC (rev 17026)
@@ -151,6 +151,8 @@
 	
 	/* confusing... G.f and G.flags */
 	int flags;
+	
+	int bone_sketching; /* regroup with edbo into an EditArmature struct */
 
 } Global;
 

Modified: branches/etch-a-ton/source/blender/include/BIF_space.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_space.h	2008-10-11 19:34:48 UTC (rev 17025)
+++ branches/etch-a-ton/source/blender/include/BIF_space.h	2008-10-11 19:53:39 UTC (rev 17026)
@@ -54,6 +54,7 @@
 #define VIEW3D_HANDLER_MULTIRES         5
 #define VIEW3D_HANDLER_TRANSFORM	6
 #define VIEW3D_HANDLER_GREASEPENCIL 7
+#define VIEW3D_HANDLER_BONESKETCH 8
 
 /* ipo handler codes */
 #define IPO_HANDLER_PROPERTIES	20

Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c	2008-10-11 19:34:48 UTC (rev 17025)
+++ branches/etch-a-ton/source/blender/src/drawview.c	2008-10-11 19:53:39 UTC (rev 17026)
@@ -2268,7 +2268,35 @@
 	if(yco < 0) uiNewPanelHeight(block, height-yco);
 }
 
+static void view3d_panel_bonesketch_spaces(short cntrl)
+{
+	uiBlock *block;
+//	uiBut *but;
+	int xco = 20, yco = 70, height = 140;
+//	int index;
 
+	/* replace with check call to sketching lib */
+	if (G.obedit && G.obedit->type == OB_ARMATURE)
+	{
+		block= uiNewBlock(&curarea->uiblocks, "view3d_panel_transform", UI_EMBOSS, UI_HELV, curarea->win);
+		uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE  | cntrl);
+		uiSetPanelHandler(VIEW3D_HANDLER_TRANSFORM);  // for close and esc
+	
+		if(uiNewPanel(curarea, block, "Bone Sketching", "View3d", 10, 230, 318, height)==0) return;
+	
+		uiNewPanelHeight(block, height);
+	
+		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");
+	
+		uiBlockEndAlign(block);
+		
+		if(yco < 0) uiNewPanelHeight(block, height-yco);
+	}
+}
+
 static void view3d_panel_object(short cntrl)	// VIEW3D_HANDLER_OBJECT
 {
 	uiBlock *block;
@@ -2659,6 +2687,9 @@
 		case VIEW3D_HANDLER_GREASEPENCIL:
 			view3d_panel_gpencil(v3d->blockhandler[a+1]);
 			break;
+		case VIEW3D_HANDLER_BONESKETCH:
+			view3d_panel_bonesketch_spaces(v3d->blockhandler[a+1]);
+			break;
 		}
 		/* clear action value for event */
 		v3d->blockhandler[a+1]= 0;

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-11 19:34:48 UTC (rev 17025)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-10-11 19:53:39 UTC (rev 17026)
@@ -29,6 +29,7 @@
 #include "DNA_view3d_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_armature_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -46,6 +47,7 @@
 #include "BIF_screen.h"
 #include "BIF_space.h"
 #include "BIF_mywindow.h"
+#include "BIF_editarmature.h"
 
 #include "blendef.h"
 #include "mydevice.h"
@@ -87,6 +89,7 @@
 } SK_Sketch;
 
 SK_Sketch *GLOBAL_sketch = NULL;
+SK_Point boneSnap;
 
 /******************** PROTOTYPES ******************************/
 
@@ -580,6 +583,47 @@
 	return pt;
 }
 
+SK_Point *sk_snapPointArmature(ListBase *ebones, short mval[2], int *dist)
+{
+	SK_Point *pt = NULL;
+	EditBone *bone;
+	
+	for (bone = ebones->first; bone; bone = bone->next)
+	{
+		short pval[2];
+		int pdist;
+		
+		if ((bone->flag & BONE_CONNECTED) == 0)
+		{
+			project_short_noclip(bone->head, pval);
+			
+			pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
+			
+			if (pdist < *dist)
+			{
+				*dist = pdist;
+				pt = &boneSnap;
+				VECCOPY(pt->p, bone->head);
+				pt->type = PT_EXACT;
+			}
+		}
+		
+		
+		project_short_noclip(bone->tail, pval);
+		
+		pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
+		
+		if (pdist < *dist)
+		{
+			*dist = pdist;
+			pt = &boneSnap;
+			VECCOPY(pt->p, bone->tail);
+			pt->type = PT_EXACT;
+		}
+	}
+	
+	return pt;
+}
 
 SK_Point *sk_snapPoint(SK_Sketch *sketch, short mval[2], int min_dist)
 {
@@ -597,6 +641,16 @@
 		}
 	}
 	
+	/* check on bones */
+	{
+		SK_Point *spt = sk_snapPointArmature(&G.edbo, mval, &dist);
+		
+		if (spt != NULL)
+		{
+			pt = spt;
+		}
+	}
+	
 	return pt;
 }
 
@@ -984,26 +1038,39 @@
 
 void BDR_drawSketch()
 {
-	if (GLOBAL_sketch != NULL)
+	if (G.bone_sketching & 1)
 	{
-		sk_drawSketch(GLOBAL_sketch);
+		if (GLOBAL_sketch != NULL)
+		{
+			sk_drawSketch(GLOBAL_sketch);
+		}
 	}
 }
 
 int BIF_paintSketch(short mbut)
 {
-	if (GLOBAL_sketch == NULL)
+	if (G.bone_sketching & 1)
 	{
-		GLOBAL_sketch = sk_createSketch();
+		if (GLOBAL_sketch == NULL)
+		{
+			GLOBAL_sketch = sk_createSketch();
+		}
+		
+		return sk_paint(GLOBAL_sketch, mbut);
 	}
-	
-	return sk_paint(GLOBAL_sketch, mbut);
+	else
+	{
+		return 0;
+	}
 }
 
 void BDR_queueDrawSketch()
 {
-	if (GLOBAL_sketch != NULL)
+	if (G.bone_sketching & 1)
 	{
-		sk_queueRedrawSketch(GLOBAL_sketch);
+		if (GLOBAL_sketch != NULL)
+		{
+			sk_queueRedrawSketch(GLOBAL_sketch);
+		}
 	}
 }

Modified: branches/etch-a-ton/source/blender/src/header_view3d.c
===================================================================
--- branches/etch-a-ton/source/blender/src/header_view3d.c	2008-10-11 19:34:48 UTC (rev 17025)
+++ branches/etch-a-ton/source/blender/src/header_view3d.c	2008-10-11 19:53:39 UTC (rev 17026)
@@ -3951,6 +3951,9 @@
 	case 22: /* separate */
 		separate_armature();
 		break;
+	case 23: /* bone sketching panel */
+		add_blockhandler(curarea, VIEW3D_HANDLER_BONESKETCH, UI_PNL_UNSTOW);
+		break;
 	}
 	
 	allqueue(REDRAWVIEW3D, 0);
@@ -4027,6 +4030,7 @@
 	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	
 	uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Bone Sketching|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, "");
 	uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
 	uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");
 	uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, "");





More information about the Bf-blender-cvs mailing list