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:
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_manipulator.c100
-rw-r--r--source/blender/editors/transform/transform_orientations.c7
3 files changed, 59 insertions, 50 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index bf3562cbe65..4b7d24dc1fa 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -534,7 +534,7 @@ void flushTransNodes(TransInfo *t);
void flushTransSeq(TransInfo *t);
/*********************** exported from transform_manipulator.c ********** */
-void gimbal_axis(struct Object *ob, float gmat[][3]);
+int gimbal_axis(struct Object *ob, float gmat[][3]); /* return 0 when no gimbal for selection */
int calc_manipulator_stats(const struct bContext *C);
float get_drawsize(struct ARegion *ar, float *co);
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) {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 8847d0ccd58..98067291e07 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -523,9 +523,10 @@ void initTransformOrientation(bContext *C, TransInfo *t)
case V3D_MANIP_GIMBAL:
unit_m3(t->spacemtx);
- if(ob)
- gimbal_axis(ob, t->spacemtx);
- break;
+ if (gimbal_axis(ob, t->spacemtx)) {
+ break;
+ }
+ /* no gimbal fallthrough to normal */
case V3D_MANIP_NORMAL:
if(obedit || (ob && ob->mode & OB_MODE_POSE)) {
strcpy(t->spacename, "normal");