Page MenuHome

bone_roll_02.patch

bone_roll_02.patch

Index: source/blender/include/BIF_transform.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BIF_transform.h,v
retrieving revision 1.39
diff -u -r1.39 BIF_transform.h
--- source/blender/include/BIF_transform.h 13 Aug 2006 07:37:51 -0000 1.39
+++ source/blender/include/BIF_transform.h 22 Nov 2006 00:58:45 -0000
@@ -53,6 +53,7 @@
#define TFM_BONESIZE 15
#define TFM_BONE_ENVELOPE 16
#define TFM_CURVE_SHRINKFATTEN 17
+#define TFM_BONE_ROLL 18
/* TRANSFORM CONTEXTS */
#define CTX_NONE 0
Index: source/blender/include/transform.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/transform.h,v
retrieving revision 1.28
diff -u -r1.28 transform.h
--- source/blender/include/transform.h 25 Oct 2006 23:56:59 -0000 1.28
+++ source/blender/include/transform.h 22 Nov 2006 01:55:09 -0000
@@ -300,6 +300,9 @@
void initBoneEnvelope(TransInfo *t);
int BoneEnvelope(TransInfo *t, short mval[2]);
+void initBoneRoll(TransInfo *t);
+int BoneRoll(TransInfo *t, short mval[2]);
+
/*********************** transform_conversions.c ********** */
struct ListBase;
void flushTransUVs(TransInfo *t);
Index: source/blender/src/header_view3d.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_view3d.c,v
retrieving revision 1.202
diff -u -r1.202 header_view3d.c
--- source/blender/src/header_view3d.c 21 Nov 2006 01:38:28 -0000 1.202
+++ source/blender/src/header_view3d.c 22 Nov 2006 03:52:24 -0000
@@ -3530,6 +3530,9 @@
case 13: /* flip left and right names */
armature_flip_names();
break;
+ case 14: /* interactively set bone roll */
+ initTransform(TFM_BONE_ROLL, CTX_NONE);
+ Transform();
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -3551,6 +3554,7 @@
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, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Bone Roll Angle|Ctrl R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Bone Roll Angle|Ctrl N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
Index: source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.406
diff -u -r1.406 space.c
--- source/blender/src/space.c 23 Nov 2006 03:35:12 -0000 1.406
+++ source/blender/src/space.c 24 Nov 2006 00:46:28 -0000
@@ -1789,9 +1789,14 @@
selectrow_nurb();
}
else if(G.qual==LR_CTRLKEY) {
- if (G.obedit->type==OB_MESH)
+ if (G.obedit->type==OB_MESH) {
CutEdgeloop(1);
BIF_undo_push("Cut Edgeloop");
+ }
+ else if (G.obedit->type==OB_ARMATURE) {
+ initTransform(TFM_BONE_ROLL, CTX_NONE);
+ Transform();
+ }
}
else if((G.qual==0)) {
initTransform(TFM_ROTATION, CTX_NONE);
Index: source/blender/src/transform.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform.c,v
retrieving revision 1.144
diff -u -r1.144 transform.c
--- source/blender/src/transform.c 25 Oct 2006 23:56:59 -0000 1.144
+++ source/blender/src/transform.c 24 Nov 2006 02:51:16 -0000
@@ -809,6 +809,9 @@
case TFM_BONE_ENVELOPE:
initBoneEnvelope(&Trans);
break;
+ case TFM_BONE_ROLL:
+ initBoneRoll(&Trans);
+ break;
}
}
@@ -2873,6 +2876,102 @@
) );
if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
+}
+
+/* ******************** EditBone roll *************** */
+
+int BoneRoll(TransInfo *t, short mval[2])
+{
+ TransData *td = t->data;
+ int i;
+ char str[50];
+
+ float final;
+
+ int dx2 = t->center2d[0] - mval[0];
+ int dy2 = t->center2d[1] - mval[1];
+ double B = sqrt(dx2*dx2+dy2*dy2);
+
+ int dx1 = t->center2d[0] - t->imval[0];
+ int dy1 = t->center2d[1] - t->imval[1];
+ double A = sqrt(dx1*dx1+dy1*dy1);
+
+ int dx3 = mval[0] - t->imval[0];
+ int dy3 = mval[1] - t->imval[1];
+ /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
+ double deler= ((double)((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3) ))
+ / (2.0 * (A*B?A*B:1.0));
+ /* (A*B?A*B:1.0f) this takes care of potential divide by zero errors */
+
+ float dphi;
+
+ dphi = saacos((float)deler);
+ if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+
+ if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
+ else t->fac += dphi;
+
+ /*
+ clamping angle between -2 PI and 2 PI (not sure if useful so commented out - theeth)
+ if (t->fac >= 2 * M_PI)
+ t->fac -= 2 * M_PI;
+ else if (t->fac <= -2 * M_PI)
+ t->fac -= -2 * M_PI;
+ */
+
+ final = t->fac;
+
+ snapGrid(t, &final);
+
+ t->imval[0] = mval[0];
+ t->imval[1] = mval[1];
+
+ if (hasNumInput(&t->num)) {
+ char c[20];
+
+ applyNumInput(&t->num, &final);
+
+ outputNumInput(&(t->num), c);
+
+ sprintf(str, "Roll: %s", &c[0]);
+
+ final *= (float)(M_PI / 180.0);
+ }
+ else {
+ sprintf(str, "Roll: %.2f", 180.0*final/M_PI);
+ }
+
+ /* set roll values */
+ for (i = 0; i < t->total; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ *(td->val) = final;
+ }
+
+ recalcData(t);
+
+ headerprint(str);
+
+ viewRedrawForce(t);
+
+ if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
+
+ return 1;
+}
+
+void initBoneRoll(TransInfo *t)
+{
+ t->idx_max = 0;
+ t->num.idx_max = 0;
+ t->snap[0] = 0.0f;
+ t->snap[1] = (float)((5.0/180)*M_PI);
+ t->snap[2] = t->snap[1] * 0.2f;
+
+ //t->fac= t->data->ival;
+ if(t->fac==0.0f) t->fac= 1.0f; // prevent Inf
+
+ t->transform = BoneRoll;
}
/* ************************************ */
Index: source/blender/src/transform_conversions.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform_conversions.c,v
retrieving revision 1.84
diff -u -r1.84 transform_conversions.c
--- source/blender/src/transform_conversions.c 22 Nov 2006 11:25:39 -0000 1.84
+++ source/blender/src/transform_conversions.c 24 Nov 2006 02:56:59 -0000
@@ -825,6 +825,10 @@
if (ebo->flag & BONE_SELECTED)
t->total++;
}
+ else if (t->mode==TFM_BONE_ROLL) {
+ if (ebo->flag & BONE_SELECTED)
+ t->total++;
+ }
else {
if (ebo->flag & BONE_TIPSEL)
t->total++;
@@ -836,6 +840,12 @@
if (!t->total) return;
+ /* turn on axes for armature drawing if doing bone roll */
+ if (t->mode==TFM_BONE_ROLL) {
+ if ((arm->flag & ARM_DRAWAXES)==0)
+ arm->flag |= ARM_DRAWAXES;
+ }
+
Mat3CpyMat4(mtx, G.obedit->obmat);
Mat3Inv(smtx, mtx);
@@ -909,6 +919,25 @@
td->tdi = NULL;
td++;
+ }
+ }
+ else if (t->mode==TFM_BONE_ROLL) {
+ if (ebo->flag & BONE_SELECTED) {
+ td->loc= NULL;
+ td->val= &(ebo->roll);
+ td->ival= ebo->roll;
+
+ VECCOPY (td->center, ebo->head);
+ td->flag= TD_SELECTED;
+
+ td->ext = NULL;
+ td->tdi = NULL;
+
+ td++;
+ }
+ if (ebo->flag & BONE_ACTIVE) {
+ /* hack to get t->fac to equal something meaningful */
+ t->fac = ebo->roll;
}
}
else {
Index: source/blender/src/transform_snap.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform_snap.c,v
retrieving revision 1.3
diff -u -r1.3 transform_snap.c
--- source/blender/src/transform_snap.c 22 Nov 2006 02:16:29 -0000 1.3
+++ source/blender/src/transform_snap.c 24 Nov 2006 02:08:44 -0000
@@ -196,7 +196,7 @@
int invert;
GearsType action;
- if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL)
+ if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL || t->mode==TFM_BONE_ROLL)
invert = U.flag & USER_AUTOROTGRID;
else if(t->mode==TFM_RESIZE || t->mode==TFM_SHEAR || t->mode==TFM_BONESIZE || t->mode==TFM_SHRINKFATTEN || t->mode==TFM_CURVE_SHRINKFATTEN)
invert = U.flag & USER_AUTOSIZEGRID;

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ef/61/fdc926005011ac4a50c898afbf82

Event Timeline