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-11-29 21:20:26 +0300
committerMartin Poirier <theeth@yahoo.com>2009-11-29 21:20:26 +0300
commitedf32a6fb0213bf35748890dfbc84b20d384298e (patch)
tree859ae7feeb3e0f79617c1a18dc05aff86ea87aa7 /source/blender/editors/transform/transform_manipulator.c
parenta22cfe99db567fb34047b1cf3cacde1be271efac (diff)
Gimbal orientation defaults to Normal instead of Global when bone or object is not using euler orientation (Normal is bone axis for pose and Local axis for object, so this is more useful than defaulting to Global).
Diffstat (limited to 'source/blender/editors/transform/transform_manipulator.c')
-rw-r--r--source/blender/editors/transform/transform_manipulator.c100
1 files changed, 54 insertions, 46 deletions
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index fe79e9b4285..7530e015496 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -182,60 +182,67 @@ static int test_rotmode_euler(short rotmode)
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0:1;
}
-void gimbal_axis(Object *ob, float gmat[][3])
+int gimbal_axis(Object *ob, float gmat[][3])
{
- if(ob->mode & OB_MODE_POSE)
- {
- bPoseChannel *pchan= get_active_posechannel(ob);
+ if (ob) {
+ if(ob->mode & OB_MODE_POSE)
+ {
+ bPoseChannel *pchan= get_active_posechannel(ob);
- if(pchan && test_rotmode_euler(pchan->rotmode)) {
- float mat[3][3], tmat[3][3], obmat[3][3];
+ if(pchan && test_rotmode_euler(pchan->rotmode)) {
+ float mat[3][3], tmat[3][3], obmat[3][3];
- eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode);
+ eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode);
- /* apply bone transformation */
- mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat);
-
- if (pchan->parent)
- {
- float parent_mat[3][3];
+ /* apply bone transformation */
+ mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat);
- copy_m3_m4(parent_mat, pchan->parent->pose_mat);
- mul_m3_m3m3(mat, parent_mat, tmat);
+ if (pchan->parent)
+ {
+ float parent_mat[3][3];
- /* needed if object transformation isn't identity */
- copy_m3_m4(obmat, ob->obmat);
- mul_m3_m3m3(gmat, obmat, mat);
- }
- else
- {
- /* needed if object transformation isn't identity */
- copy_m3_m4(obmat, ob->obmat);
- mul_m3_m3m3(gmat, obmat, tmat);
- }
+ copy_m3_m4(parent_mat, pchan->parent->pose_mat);
+ mul_m3_m3m3(mat, parent_mat, tmat);
- normalize_m3(gmat);
+ /* needed if object transformation isn't identity */
+ copy_m3_m4(obmat, ob->obmat);
+ mul_m3_m3m3(gmat, obmat, mat);
+ }
+ else
+ {
+ /* needed if object transformation isn't identity */
+ copy_m3_m4(obmat, ob->obmat);
+ mul_m3_m3m3(gmat, obmat, tmat);
+ }
+
+ normalize_m3(gmat);
+ return 1;
+ }
}
- }
- else {
- if(test_rotmode_euler(ob->rotmode)) {
-
-
- if (ob->parent)
- {
- float parent_mat[3][3], amat[3][3];
+ else {
+ if(test_rotmode_euler(ob->rotmode)) {
+
- eulO_to_gimbal_axis(amat, ob->rot, ob->rotmode);
- copy_m3_m4(parent_mat, ob->parent->obmat);
- normalize_m3(parent_mat);
- mul_m3_m3m3(gmat, parent_mat, amat);
- }
- else
- {
- eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode);
+ if (ob->parent)
+ {
+ float parent_mat[3][3], amat[3][3];
+
+ eulO_to_gimbal_axis(amat, ob->rot, ob->rotmode);
+ copy_m3_m4(parent_mat, ob->parent->obmat);
+ normalize_m3(parent_mat);
+ mul_m3_m3m3(gmat, parent_mat, amat);
+ return 1;
+ }
+ else
+ {
+ eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode);
+ return 1;
+ }
}
}
}
+
+ return 0;
}
@@ -481,10 +488,11 @@ int calc_manipulator_stats(const bContext *C)
case V3D_MANIP_GIMBAL:
{
float mat[3][3];
- unit_m3(mat);
- gimbal_axis(ob, mat);
- copy_m4_m3(rv3d->twmat, mat);
- break;
+ if (gimbal_axis(ob, mat)) {
+ copy_m4_m3(rv3d->twmat, mat);
+ break;
+ }
+ /* if not gimbal, fall through to normal */
}
case V3D_MANIP_NORMAL:
if(obedit || ob->mode & OB_MODE_POSE) {