Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-10-28 23:30:33 +0300
committerMartin Poirier <theeth@yahoo.com>2009-10-28 23:30:33 +0300
commit3187e365d90f5c0e46d721370c0d381f83813c66 (patch)
tree754be9c6f41f10e671a77ea59cce820214c8e09c /source/blender/editors
parentc2f9cfb40a740f926d78cbdb20f1f8b09cc7aadd (diff)
Gimbal Transform orientations
Will use rotation gimbal axis when an object or bone set to Euler rotation mode is selected (global axis otherwise) Use case: being able to do rotations that only affect one animation curve in the 3d view instead of just in the curve editor. I'm committing this right now despite what follows because it's already useful as is. Known bug: manipulator arrows can look slightly skewed (not really a big problem), but more importantly, rotation circles for the rotation manipulator are skewed and will not perfectly reflect the rotation axis (it will still use the correct one though). That will be fixed shortly. To do: This orientation should act like Local, where each object/bone uses its own orientation and not just the one of the active object/bone. Note: Saved files with custom orientations might end up with other orientations selected when being opened up. I don't think it's that useful to make a do_version for that, but I can if warranted.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/transform/transform_constraints.c4
-rw-r--r--source/blender/editors/transform/transform_manipulator.c70
-rw-r--r--source/blender/editors/transform/transform_orientations.c10
3 files changed, 79 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 1143203217b..f80084f7820 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -575,6 +575,10 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
sprintf(text, ftext, "view");
setConstraint(t, t->spacemtx, mode, text);
break;
+ case V3D_MANIP_GIMBAL:
+ sprintf(text, ftext, "gimbal");
+ setConstraint(t, t->spacemtx, mode, text);
+ break;
default: /* V3D_MANIP_CUSTOM */
sprintf(text, ftext, t->spacename);
setConstraint(t, t->spacemtx, mode, text);
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index bdf0a91bf89..2247977ef87 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -175,6 +175,61 @@ static void stats_editbone(View3D *v3d, EditBone *ebo)
protectflag_to_drawflags(OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE, &v3d->twdrawflag);
}
+
+static int test_rotmode_euler(short rotmode)
+{
+ return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0:1;
+}
+
+void gimbalAxis(Object *ob, float gmat[][3])
+{
+ if(ob->mode & OB_MODE_POSE)
+ {
+ bPoseChannel *pchan= NULL;
+
+ /* use channels to get stats */
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (pchan->bone && pchan->bone->flag & BONE_ACTIVE) {
+ if(test_rotmode_euler(pchan->rotmode)) {
+ break;
+ }
+ }
+ }
+
+ if(pchan) {
+ int i;
+
+ EulToGimbalAxis(gmat, pchan->eul, pchan->rotmode);
+
+ for (i=0; i<3; i++)
+ Mat3MulVecfl(pchan->bone->bone_mat, gmat[i]);
+
+ if(pchan->parent) {
+ bPoseChannel *pchan_par= pchan->parent;
+
+ float tmat[3][3];
+ Mat3CpyMat4(tmat, pchan_par->pose_mat);
+
+ for (i=0; i<3; i++)
+ Mat3MulVecfl(tmat, gmat[i]);
+ }
+
+ /* needed if object trans isnt identity */
+ for (i=0; i<3; i++) {
+ float tmat[3][3];
+ Mat3CpyMat4(tmat, ob->obmat);
+ Mat3MulVecfl(tmat, gmat[i]);
+ }
+ }
+ }
+ else {
+ if(test_rotmode_euler(ob->rotmode)) {
+ EulToGimbalAxis(gmat, ob->rot, ob->rotmode);
+ }
+ }
+}
+
+
/* centroid, boundbox, of selection */
/* returns total items selected */
int calc_manipulator_stats(const bContext *C)
@@ -416,6 +471,14 @@ int calc_manipulator_stats(const bContext *C)
case V3D_MANIP_GLOBAL:
break; /* nothing to do */
+ case V3D_MANIP_GIMBAL:
+ {
+ float mat[3][3];
+ Mat3One(mat);
+ gimbalAxis(ob, mat);
+ Mat4CpyMat3(rv3d->twmat, mat);
+ break;
+ }
case V3D_MANIP_NORMAL:
if(obedit || ob->mode & OB_MODE_POSE) {
float mat[3][3];
@@ -1404,9 +1467,10 @@ void BIF_draw_manipulator(const bContext *C)
int totsel;
if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return;
- if(G.moving && (G.moving & G_TRANSFORM_MANIP)==0) return;
+// if(G.moving && (G.moving & G_TRANSFORM_MANIP)==0) return;
- if(G.moving==0) {
+// if(G.moving==0) {
+ {
v3d->twflag &= ~V3D_DRAW_MANIPULATOR;
totsel= calc_manipulator_stats(C);
@@ -1454,7 +1518,7 @@ void BIF_draw_manipulator(const bContext *C)
else draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB);
}
else
- draw_manipulator_rotate(v3d, rv3d, G.moving, drawflags, v3d->twtype);
+ draw_manipulator_rotate(v3d, rv3d, 0 /* G.moving*/, drawflags, v3d->twtype);
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index c9344b97fb2..e790b38dd67 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -434,7 +434,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
}
char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
- char menu[] = "%t|Global%x0|Local%x1|Normal%x2|View%x3";
+ char menu[] = "%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3";
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int i = V3D_MANIP_CUSTOM;
@@ -510,6 +510,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
return total;
}
+extern void gimbalAxis(Object *ob, float gimbal_vecs[][3]);
void initTransformOrientation(bContext *C, TransInfo *t)
{
View3D *v3d = CTX_wm_view3d(C);
@@ -522,7 +523,12 @@ void initTransformOrientation(bContext *C, TransInfo *t)
case V3D_MANIP_GLOBAL:
strcpy(t->spacename, "global");
break;
-
+
+ case V3D_MANIP_GIMBAL:
+ Mat3One(t->spacemtx);
+ if(ob)
+ gimbalAxis(ob, t->spacemtx);
+ break;
case V3D_MANIP_NORMAL:
if(obedit || ob->mode & OB_MODE_POSE) {
float mat[3][3];