[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12189] trunk/blender/source/blender/src: == Bone Size Transform Tool ==

Joshua Leung aligorith at gmail.com
Tue Oct 2 12:45:23 CEST 2007


Revision: 12189
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12189
Author:   aligorith
Date:     2007-10-02 12:45:22 +0200 (Tue, 02 Oct 2007)

Log Message:
-----------
== Bone Size Transform Tool ==

Fixed a few bugs with the Alt-S transform tool when the armature drawtype is set to B-Bone:

* Transform constraints seem to have been turned off for this sometime in the past few weeks. Re-enabled this.
* Numeric input for this tool was not working correctly. You could only set the value of the x-axis width only. Also, giblish was being displayed for the other channels
* The char array used in the BoneSize function was smaller than the one used in the headerBoneSize (new function added for this transform mode instead of reusing some old one).

Also, I've added some menu entries for both Alt-S tools in editmode, which did not exist in the past. How were the users supposed to figure this out???

Modified Paths:
--------------
    trunk/blender/source/blender/src/header_view3d.c
    trunk/blender/source/blender/src/transform.c

Modified: trunk/blender/source/blender/src/header_view3d.c
===================================================================
--- trunk/blender/source/blender/src/header_view3d.c	2007-10-02 09:47:08 UTC (rev 12188)
+++ trunk/blender/source/blender/src/header_view3d.c	2007-10-02 10:45:22 UTC (rev 12189)
@@ -3703,12 +3703,17 @@
 	case 13: /* flip left and right names */
 		armature_flip_names();
 		break;
-		break;
 	case 15: /* subdivide multi */
 		if(button(&numcuts, 1, 128, "Number of Cuts:")==0) return;
 		waitcursor(1);
 		subdivide_armature(numcuts);
+		break;
+	case 16: /* Alt-S transform (BoneSize) */
+		initTransform(TFM_BONESIZE, CTX_NONE);
+		Transform();
+		break;
 	}
+	
 	allqueue(REDRAWVIEW3D, 0);
 }
 
@@ -3765,6 +3770,11 @@
 	uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, "");
 	uiDefIconTextBlockBut(block, view3d_edit_armature_rollmenu, NULL, ICON_RIGHTARROW_THIN, "Bone Roll", 0, yco-=20, 120, 19, "");
 	
+	if (arm->drawtype==ARM_ENVELOPE)
+		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale Envelope Distance|Alt S",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
+	else if (arm->drawtype==ARM_B_BONE)
+		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale B-Bone Width|Alt S",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
+	
 	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extrude|E",				0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");

Modified: trunk/blender/source/blender/src/transform.c
===================================================================
--- trunk/blender/source/blender/src/transform.c	2007-10-02 09:47:08 UTC (rev 12188)
+++ trunk/blender/source/blender/src/transform.c	2007-10-02 10:45:22 UTC (rev 12189)
@@ -2875,14 +2875,13 @@
 	t->mode = TFM_BONESIZE;
 	t->transform = BoneSize;
 	
-	t->idx_max = 0;
-	t->num.idx_max = 0;
+	t->idx_max = 2;
+	t->num.idx_max = 2;
+	t->num.flag |= NUM_NULL_ONE;
 	t->snap[0] = 0.0f;
 	t->snap[1] = 0.1f;
 	t->snap[2] = t->snap[1] * 0.1f;
-
-	t->flag |= T_NO_CONSTRAINT;
-
+	
 	t->fac = (float)sqrt( (
 					   ((float)(t->center2d[1] - t->imval[1]))*((float)(t->center2d[1] - t->imval[1]))
 					   +
@@ -2892,6 +2891,29 @@
 	if(t->fac==0.0f) t->fac= 1.0f;	// prevent Inf
 }
 
+static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
+	char tvec[60];
+	if (hasNumInput(&t->num)) {
+		outputNumInput(&(t->num), tvec);
+	}
+	else {
+		sprintf(&tvec[0], "%.4f", vec[0]);
+		sprintf(&tvec[20], "%.4f", vec[1]);
+		sprintf(&tvec[40], "%.4f", vec[2]);
+	}
+
+	/* hmm... perhaps the y-axis values don't need to be shown? */
+	if (t->con.mode & CON_APPLY) {
+		if (t->num.idx_max == 0)
+			sprintf(str, "ScaleB: %s%s %s", &tvec[0], t->con.text, t->proptext);
+		else 
+			sprintf(str, "ScaleB: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+	}
+	else {
+		sprintf(str, "ScaleB X: %s  Y: %s  Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+	}
+}
+
 static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) 
 {
 	float tmat[3][3], smat[3][3], oldy;
@@ -2918,7 +2940,7 @@
 	float size[3], mat[3][3];
 	float ratio;
 	int i;
-	char str[50];
+	char str[60];
 	
 	/* for manipulator, center handle, the scaling can't be done relative to center */
 	if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
@@ -2966,7 +2988,7 @@
 	
 	Mat3CpyMat3(t->mat, mat);	// used in manipulator
 	
-	headerResize(t, size, str);
+	headerBoneSize(t, size, str);
 	
 	for(i = 0 ; i < t->total; i++, td++) {
 		if (td->flag & TD_NOACTION)





More information about the Bf-blender-cvs mailing list