diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-06 13:38:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-06 13:38:00 +0300 |
commit | d4fe2595f7c350c90feba61ba8d520850648b06f (patch) | |
tree | 5740ccae324a64e4ab369fc07c01c22024a0d6ed /source/blender/editors/transform | |
parent | cc2476fde5f2ae4a3df625780b056580c7836712 (diff) |
bring back align to view to object
- In 2.4x this was numpad *, however that would only align on the Z axis.
- New behavior for VIEW3D_OT_viewnumpad, holding Shift with Numpad 1/3/7 sets the left/top/front etc on the normal axis.
- Uses active bone, face, edge, vert, curve handel & object (just like the view manipulator with 'Normal' selected).
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 44 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 91 |
3 files changed, 53 insertions, 85 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index ae4b1f446da..f6f8d3e4aa2 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -697,6 +697,9 @@ void applyTransformOrientation(const struct bContext *C, float mat[3][3], char * #define ORIENTATION_FACE 4 int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3], int activeOnly); + +/* also used in view3d_edit.c, todo - move outside of transform */ +void getTransformOrientationMatrix(const struct bContext *C, float twmat[][4], int use_active); int createSpaceNormal(float mat[3][3], float normal[3]); int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a1d62f93568..dd94fef4059 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -259,8 +259,6 @@ int calc_manipulator_stats(const bContext *C) RegionView3D *rv3d= ar->regiondata; Base *base; Object *ob= OBACT; - float normal[3]={0.0, 0.0, 0.0}; - float plane[3]={0.0, 0.0, 0.0}; int a, totsel= 0; /* transform widget matrix */ @@ -498,47 +496,7 @@ int calc_manipulator_stats(const bContext *C) } case V3D_MANIP_NORMAL: if(obedit || ob->mode & OB_MODE_POSE) { - float mat[3][3]; - int type; - - type = getTransformOrientation(C, normal, plane, (v3d->around == V3D_ACTIVE)); - - switch (type) - { - case ORIENTATION_NORMAL: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_VERT: - if (createSpaceNormal(mat, normal) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_EDGE: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_FACE: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - } - - if (type == ORIENTATION_NONE) - { - Mat4One(rv3d->twmat); - } - else - { - Mat4CpyMat3(rv3d->twmat, mat); - } + getTransformOrientationMatrix(C, rv3d->twmat, (v3d->around == V3D_ACTIVE)); break; } /* no break we define 'normal' as 'local' in Object mode */ diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 56160d66e25..8b4023a3352 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -531,49 +531,8 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_NORMAL: if(obedit || (ob && ob->mode & OB_MODE_POSE)) { - float mat[3][3]; - int type; - strcpy(t->spacename, "normal"); - - type = getTransformOrientation(C, normal, plane, (v3d->around == V3D_ACTIVE)); - - switch (type) - { - case ORIENTATION_NORMAL: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_VERT: - if (createSpaceNormal(mat, normal) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_EDGE: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - case ORIENTATION_FACE: - if (createSpaceNormalTangent(mat, normal, plane) == 0) - { - type = ORIENTATION_NONE; - } - break; - } - - if (type == ORIENTATION_NONE) - { - Mat3One(t->spacemtx); - } - else - { - Mat3CpyMat3(t->spacemtx, mat); - } + getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE)); break; } /* no break we define 'normal' as 'local' in Object mode */ @@ -967,3 +926,51 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], return result; } + +void getTransformOrientationMatrix(const bContext *C, float twmat[][4], int activeOnly) +{ + float normal[3]={0.0, 0.0, 0.0}; + float plane[3]={0.0, 0.0, 0.0}; + + float mat[3][3]; + int type; + + type = getTransformOrientation(C, normal, plane, activeOnly); + + switch (type) + { + case ORIENTATION_NORMAL: + if (createSpaceNormalTangent(mat, normal, plane) == 0) + { + type = ORIENTATION_NONE; + } + break; + case ORIENTATION_VERT: + if (createSpaceNormal(mat, normal) == 0) + { + type = ORIENTATION_NONE; + } + break; + case ORIENTATION_EDGE: + if (createSpaceNormalTangent(mat, normal, plane) == 0) + { + type = ORIENTATION_NONE; + } + break; + case ORIENTATION_FACE: + if (createSpaceNormalTangent(mat, normal, plane) == 0) + { + type = ORIENTATION_NONE; + } + break; + } + + if (type == ORIENTATION_NONE) + { + Mat4One(twmat); + } + else + { + Mat4CpyMat3(twmat, mat); + } +} |