== 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).
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
#define TFM_BAKE_TIME 23
|
#define TFM_BAKE_TIME 23
|
||||||
#define TFM_BEVEL 24
|
#define TFM_BEVEL 24
|
||||||
#define TFM_BWEIGHT 25
|
#define TFM_BWEIGHT 25
|
||||||
|
#define TFM_ALIGN 26
|
||||||
|
|
||||||
/* TRANSFORM CONTEXTS */
|
/* TRANSFORM CONTEXTS */
|
||||||
#define CTX_NONE 0
|
#define CTX_NONE 0
|
||||||
|
|||||||
@@ -373,6 +373,9 @@ int BakeTime(TransInfo *t, short mval[2]);
|
|||||||
void initMirror(TransInfo *t);
|
void initMirror(TransInfo *t);
|
||||||
int Mirror(TransInfo *t, short mval[2]);
|
int Mirror(TransInfo *t, short mval[2]);
|
||||||
|
|
||||||
|
void initAlign(TransInfo *t);
|
||||||
|
int Align(TransInfo *t, short mval[2]);
|
||||||
|
|
||||||
/*********************** transform_conversions.c ********** */
|
/*********************** transform_conversions.c ********** */
|
||||||
struct ListBase;
|
struct ListBase;
|
||||||
void flushTransIpoData(TransInfo *t);
|
void flushTransIpoData(TransInfo *t);
|
||||||
|
|||||||
@@ -1786,6 +1786,10 @@ static void do_view3d_transformmenu(void *arg, int event)
|
|||||||
case 20:
|
case 20:
|
||||||
G.scene->snap_target = SCE_SNAP_TARGET_ACTIVE;
|
G.scene->snap_target = SCE_SNAP_TARGET_ACTIVE;
|
||||||
break;
|
break;
|
||||||
|
case 21:
|
||||||
|
initTransform(TFM_ALIGN, CTX_NO_PET|CTX_AUTOCONFIRM);
|
||||||
|
Transform();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
}
|
}
|
||||||
@@ -1835,6 +1839,7 @@ static uiBlock *view3d_transformmenu(void *arg_unused)
|
|||||||
if (!G.obedit) {
|
if (!G.obedit) {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center New", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center New", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
|
||||||
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align to Transform Orientation", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 21, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BIF_snappingSupported())
|
if (BIF_snappingSupported())
|
||||||
|
|||||||
@@ -1743,7 +1743,15 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AKEY:
|
case AKEY:
|
||||||
if(G.qual & LR_CTRLKEY) apply_object(); /* also with shift! */
|
if (G.obedit == 0 && G.qual == (LR_CTRLKEY|LR_ALTKEY)) {
|
||||||
|
if(okee("Align to Transform Orientation")) {
|
||||||
|
initTransform(TFM_ALIGN, CTX_NO_PET|CTX_AUTOCONFIRM);
|
||||||
|
Transform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(G.qual & LR_CTRLKEY) { /* also with shift! */
|
||||||
|
apply_object();
|
||||||
|
}
|
||||||
else if((G.qual==LR_SHIFTKEY)) {
|
else if((G.qual==LR_SHIFTKEY)) {
|
||||||
toolbox_n_add();
|
toolbox_n_add();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -943,6 +943,7 @@ void initTransform(int mode, int context) {
|
|||||||
if(Trans.spacetype==SPACE_VIEW3D) {
|
if(Trans.spacetype==SPACE_VIEW3D) {
|
||||||
calc_manipulator_stats(curarea);
|
calc_manipulator_stats(curarea);
|
||||||
Mat3CpyMat4(Trans.spacemtx, G.vd->twmat);
|
Mat3CpyMat4(Trans.spacemtx, G.vd->twmat);
|
||||||
|
Mat3Ortho(Trans.spacemtx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Mat3One(Trans.spacemtx);
|
Mat3One(Trans.spacemtx);
|
||||||
@@ -1041,6 +1042,9 @@ void initTransform(int mode, int context) {
|
|||||||
case TFM_BWEIGHT:
|
case TFM_BWEIGHT:
|
||||||
initBevelWeight(&Trans);
|
initBevelWeight(&Trans);
|
||||||
break;
|
break;
|
||||||
|
case TFM_ALIGN:
|
||||||
|
initAlign(&Trans);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4024,6 +4028,61 @@ int Mirror(TransInfo *t, short mval[2])
|
|||||||
return 1;
|
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 *************************** */
|
/* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */
|
||||||
|
|
||||||
/* ---------------- Special Helpers for Various Settings ------------- */
|
/* ---------------- Special Helpers for Various Settings ------------- */
|
||||||
|
|||||||
Reference in New Issue
Block a user