Option for shrink-fatten to maintain shell thickness (hold Alt).

This commit is contained in:
Campbell Barton 2012-11-09 05:37:36 +00:00
parent 56ae13be99
commit 0f2c27b855
2 changed files with 22 additions and 9 deletions

@ -1223,8 +1223,10 @@ int transformEvent(TransInfo *t, wmEvent *event)
break;
case LEFTALTKEY:
case RIGHTALTKEY:
if (t->spacetype == SPACE_SEQ)
if (ELEM(t->spacetype ,SPACE_SEQ, SPACE_VIEW3D)) {
t->flag |= T_ALT_TRANSFORM;
t->redraw |= TREDRAW_HARD;
}
break;
default:
@ -1262,8 +1264,10 @@ int transformEvent(TransInfo *t, wmEvent *event)
// break;
case LEFTALTKEY:
case RIGHTALTKEY:
if (t->spacetype == SPACE_SEQ)
if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
t->flag &= ~T_ALT_TRANSFORM;
t->redraw |= TREDRAW_HARD;
}
break;
default:
@ -3947,10 +3951,8 @@ void initShrinkFatten(TransInfo *t)
}
int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
float vec[3];
float distance;
int i;
char str[64];
@ -3978,17 +3980,20 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
t->values[0] = -distance;
for (i = 0; i < t->total; i++, td++) {
float tdistance; /* temp dist */
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
copy_v3_v3(vec, td->axismtx[2]);
mul_v3_fl(vec, distance);
mul_v3_fl(vec, td->factor);
/* get the final offset */
tdistance = distance * td->factor;
if (td->ext && (t->flag & T_ALT_TRANSFORM)) {
tdistance *= td->ext->isize[0]; /* shell factor */
}
add_v3_v3v3(td->loc, td->iloc, vec);
madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance);
}
recalcData(t);

@ -1917,6 +1917,10 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
tx->size = vs->radius;
td->val = vs->radius;
}
else if (t->mode == TFM_SHRINKFATTEN) {
td->ext = tx;
tx->isize[0] = BM_vert_calc_shell_factor(eve);
}
}
static void createTransEditVerts(TransInfo *t)
@ -2029,7 +2033,11 @@ static void createTransEditVerts(TransInfo *t)
else t->total = countsel;
tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
if (t->mode == TFM_SKIN_RESIZE) {
if (ELEM(t->mode, TFM_SKIN_RESIZE, TFM_SHRINKFATTEN)) {
/* warning, this is overkill, we only need 2 extra floats,
* but this stores loads of extra stuff, for TFM_SHRINKFATTEN its even more overkill
* since we may not use the 'alt' transform mode to maintain shell thickness,
* but with generic transform code its hard to lazy init vars */
tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension),
"TransObData ext");
}