diff options
author | Martin Poirier <theeth@yahoo.com> | 2005-03-13 23:17:39 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2005-03-13 23:17:39 +0300 |
commit | 60b0e67e328e23d64713887d60bf4714c42ed820 (patch) | |
tree | 480d6ccd5c6bf4769b1aaf5d3a6b5918b9b43ed2 | |
parent | e76a63635bfb320ddf47a12d06c9250b36dd830f (diff) |
Fixed edit mode armature bug reported by Gabio (transdata conversion wasn't setting data center correctly).
Brought back Shrink/Fatten. Changed the behavior a bit, move the cursor to the right to move toward the normal, to the left to move backward. Please comment.
Only works with meshes, defaults to resize otherwise.
-rwxr-xr-x | source/blender/include/BIF_transform.h | 4 | ||||
-rw-r--r-- | source/blender/src/space.c | 4 | ||||
-rwxr-xr-x | source/blender/src/transform.c | 110 | ||||
-rwxr-xr-x | source/blender/src/transform.h | 8 |
4 files changed, 122 insertions, 4 deletions
diff --git a/source/blender/include/BIF_transform.h b/source/blender/include/BIF_transform.h index 5b4ef3e113e..07faf2a615d 100755 --- a/source/blender/include/BIF_transform.h +++ b/source/blender/include/BIF_transform.h @@ -44,8 +44,10 @@ #define TFM_RESIZE 3 #define TFM_TOSPHERE 4 #define TFM_SHEAR 5 -#define TFM_LAMP_ENERGY 6 #define TFM_WARP 7 +#define TFM_SHRINKFATTEN 8 + +#define TFM_LAMP_ENERGY 10 // not sure if adding modes is the right way... context detecting could be done different (ton) #define TFM_TEX 32 diff --git a/source/blender/src/space.c b/source/blender/src/space.c index e08bb98fce5..1dee3072025 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1499,7 +1499,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) case SKEY: if(G.obedit) { if(G.qual==LR_ALTKEY) +#ifdef NEWTRANSFORM + Transform(TFM_SHRINKFATTEN); +#else transform('N'); /* scale along normal */ +#endif else if(G.qual==LR_CTRLKEY) #ifdef NEWTRANSFORM Transform(TFM_SHEAR); diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 0664a534dff..c00929c0dda 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -397,6 +397,7 @@ static void createTransArmatureVerts(void) for (ebo=G.edbo.first;ebo;ebo=ebo->next){ if (ebo->flag & BONE_TIPSEL){ VECCOPY (td->iloc, ebo->tail); + VECCOPY (td->center, td->iloc); td->loc= ebo->tail; td->flag= TD_SELECTED; @@ -410,6 +411,7 @@ static void createTransArmatureVerts(void) } if (ebo->flag & BONE_ROOTSEL){ VECCOPY (td->iloc, ebo->head); + VECCOPY (td->center, td->iloc); td->loc= ebo->head; td->flag= TD_SELECTED; @@ -657,6 +659,16 @@ static void VertsToTransData(TransData *td, EditVert *eve) td->loc = eve->co; VECCOPY(td->center, td->loc); VECCOPY(td->iloc, td->loc); + + // Setting normals + VECCOPY(td->axismtx[2], eve->no); + td->axismtx[0][0] = + td->axismtx[0][1] = + td->axismtx[0][2] = + td->axismtx[1][0] = + td->axismtx[1][1] = + td->axismtx[1][2] = 0.0f; + td->ext = NULL; td->tdi = NULL; } @@ -1263,6 +1275,9 @@ void Transform(int mode) case TFM_WARP: initWarp(&Trans); break; + case TFM_SHRINKFATTEN: + initShrinkFatten(&Trans); + break; } // Emptying event queue @@ -1507,8 +1522,8 @@ void initWarp(TransInfo *t) } if (t->flag & T_EDIT) { - Mat3MulVecfl(G.obedit->obmat, min); - Mat3MulVecfl(G.obedit->obmat, max); + Mat4MulVecfl(G.obedit->obmat, min); + Mat4MulVecfl(G.obedit->obmat, max); } Mat4MulVecfl(G.vd->viewmat, min); Mat4MulVecfl(G.vd->viewmat, max); @@ -2234,3 +2249,94 @@ int Translation(TransInfo *t, short mval[2]) return 1; } + +/* ************************** SHRINK/FATTEN *************************** */ + +void initShrinkFatten(TransInfo *t) +{ + if (G.obedit->type != OB_MESH) { + initResize(t); + return; + } + + t->val /= (float)t->total; + + Trans.fac = (float)sqrt( (float) + ( + (Trans.center2d[1] - Trans.imval[1])*(Trans.center2d[1] - Trans.imval[1]) + + + (Trans.center2d[0] - Trans.imval[0])*(Trans.center2d[0] - Trans.imval[0]) + ) ); + + t->idx_max = 0; + t->num.idx_max = 0; + t->snap[0] = 0.0f; + t->snap[1] = G.vd->grid * 0.1f; + t->snap[2] = t->snap[1] * 0.1f; + t->transform = ShrinkFatten; +} + + + +int ShrinkFatten(TransInfo *t, short mval[2]) +{ + float vec[3], center[3]; + float ratio; + int i; + char str[50]; + TransData *td = t->data; + + ratio = (float)sqrt( (float) + ( + (t->center2d[1] - mval[1])*(t->center2d[1] - mval[1]) + + + (t->center2d[0] - mval[0])*(t->center2d[0] - mval[0]) + ) ) / t->fac; + + ratio -= 1.0f; + + if (ratio < 0.0f) + ratio = 0.0f; + + if (mval[0] < t->center2d[0]) + ratio *= -1; + + snapGrid(t, &ratio); + + applyNumInput(&t->num, &ratio); + + /* header print for NumInput */ + if (hasNumInput(&t->num)) { + char c[20]; + + outputNumInput(&(t->num), c); + + sprintf(str, "Shrink/Fatten: %s %s", c, t->proptext); + } + else { + /* default header print */ + sprintf(str, "Shrink/Fatten: %.4f %s", ratio, t->proptext); + } + + + for(i = 0 ; i < t->total; i++, td++) { + if (td->flag & TD_NOACTION) + continue; + + VECCOPY(vec, td->axismtx[2]); + VecMulf(vec, ratio); + VecMulf(vec, td->factor); + + VecAddf(td->loc, td->iloc, vec); + } + + recalcData(t); + + headerprint(str); + + force_draw(0); + + helpline (t->center); + + return 1; +} diff --git a/source/blender/src/transform.h b/source/blender/src/transform.h index 299a7d6d694..44e9b184742 100755 --- a/source/blender/src/transform.h +++ b/source/blender/src/transform.h @@ -141,7 +141,10 @@ typedef struct TransInfo { #define TFM_RESIZE 3 #define TFM_TOSPHERE 4 #define TFM_SHEAR 5 -#define TFM_LAMP_ENERGY 6 +#define TFM_WARP 7 +#define TFM_SHRINKFATTEN 8 + +#define TFM_LAMP_ENERGY 10 /* transinfo->flag */ #define T_OBJECT 1 @@ -188,5 +191,8 @@ int ToSphere(TransInfo *t, short mval[2]); void initRotation(TransInfo *t); int Rotation(TransInfo *t, short mval[2]); +void initShrinkFatten(TransInfo *t); +int ShrinkFatten(TransInfo *t, short mval[2]); + #endif |