diff options
author | Martin Poirier <theeth@yahoo.com> | 2008-03-10 03:27:17 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2008-03-10 03:27:17 +0300 |
commit | cbfbe53ebe39ece9a0c0bf05e87d3f7241ebe006 (patch) | |
tree | 73805c5f627a0d58ef89f1ab4230c9c479b09fac /source/blender/src/transform.c | |
parent | 1a4f7a861ef6008b10a9e5ef65d4f4a34f5ca548 (diff) |
== Align to Transform Orientation ==
New rotation alignement fonction
Rotates objects/Pose bones to match the selected transform orientation.
Can be used to align to view, active object (normal) and custom transform orientations.
Accessible in the Object -> Transform submenu and through the hotkey Ctrl-Alt-A (which was previously a fall through for Apply but only Ctrl-A and Ctrl-Shift-A did anything special).
Can be eventually made to work in edit mode (not too hard).
Diffstat (limited to 'source/blender/src/transform.c')
-rw-r--r-- | source/blender/src/transform.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index b7bc6a2f027..5d4e110a75e 100644 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -943,6 +943,7 @@ void initTransform(int mode, int context) { if(Trans.spacetype==SPACE_VIEW3D) { calc_manipulator_stats(curarea); Mat3CpyMat4(Trans.spacemtx, G.vd->twmat); + Mat3Ortho(Trans.spacemtx); } else Mat3One(Trans.spacemtx); @@ -1041,6 +1042,9 @@ void initTransform(int mode, int context) { case TFM_BWEIGHT: initBevelWeight(&Trans); break; + case TFM_ALIGN: + initAlign(&Trans); + break; } } @@ -4024,6 +4028,61 @@ int Mirror(TransInfo *t, short mval[2]) return 1; } +/* ************************** ALIGN *************************** */ + +void initAlign(TransInfo *t) +{ + t->flag |= T_NO_CONSTRAINT; + + t->transform = Align; +} + +int Align(TransInfo *t, short mval[2]) +{ + TransData *td = t->data; + float center[3]; + int i; + + /* saving original center */ + VECCOPY(center, t->center); + + for(i = 0 ; i < t->total; i++, td++) + { + float mat[3][3], invmat[3][3]; + + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + /* around local centers */ + if (t->flag & (T_OBJECT|T_POSE)) { + VECCOPY(t->center, td->center); + } + else { + if(G.scene->selectmode & SCE_SELECT_FACE) { + VECCOPY(t->center, td->center); + } + } + + Mat3Inv(invmat, td->axismtx); + + Mat3MulMat3(mat, t->spacemtx, invmat); + + ElementRotation(t, td, mat); + } + + /* restoring original center */ + VECCOPY(t->center, center); + + recalcData(t); + + headerprint("Align"); + + return 1; +} + /* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */ /* ---------------- Special Helpers for Various Settings ------------- */ |