diff options
author | Ton Roosendaal <ton@blender.org> | 2005-05-08 01:04:55 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-05-08 01:04:55 +0400 |
commit | d10862a9daecc05c6468bd6ebaed8194d3b4419e (patch) | |
tree | cb12461ae78d4c319ed4cdf6d1640e23b4fc0972 /source/blender/src/transform.c | |
parent | 4a123c082f7e4537df5586795de14bd4742fe5b4 (diff) |
Fix for negative scaling & Mirror menu in Object mode (CTRL+M)
Hope Martin likes this simple hack. :)
Also; added flag in constraint to denote whether its local or not. That
way its possible to:
- prevent local scale and rotate on multiple objects to change own position
- draw constraint lines cleaner
Diffstat (limited to 'source/blender/src/transform.c')
-rwxr-xr-x | source/blender/src/transform.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 4a2446ee138..87de92863ff 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -1004,6 +1004,28 @@ static void headerResize(TransInfo *t, float vec[3], char *str) { } } +#define SIGN(a) (a<-FLT_EPSILON?1:a>FLT_EPSILON?2:3) +#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0]))==0 || (SIGN(a[1]) & SIGN(b[1]))==0 || (SIGN(a[2]) & SIGN(b[2]))==0) + +/* smat is reference matrix, only scaled */ +static void TransMat3ToSize( float mat[][3], float smat[][3], float *size) +{ + float vec[3]; + + VecCopyf(vec, mat[0]); + size[0]= Normalise(vec); + VecCopyf(vec, mat[1]); + size[1]= Normalise(vec); + VecCopyf(vec, mat[2]); + size[2]= Normalise(vec); + + /* first tried with dotproduct... but the sign flip is crucial */ + if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0]; + if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1]; + if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2]; +} + + void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { float tmat[3][3], smat[3][3], center[3]; float vec[3]; @@ -1020,7 +1042,8 @@ void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { t->con.applySize(t, td, tmat); } - if (G.vd->around == V3D_LOCAL) { + /* local constraint shouldn't alter center */ + if (G.vd->around == V3D_LOCAL || (t->con.mode & CON_LOCAL)) { VECCOPY(center, td->center); } else { @@ -1035,7 +1058,7 @@ void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { // Reorient the size mat to fit the oriented object. Mat3MulMat3(obsizemat, tmat, td->axismtx); //printmatrix3("obsizemat", obsizemat); - Mat3ToSize(obsizemat, fsize); + TransMat3ToSize(obsizemat, td->axismtx, fsize); //printvecf("fsize", fsize); } else { @@ -1373,7 +1396,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) int i; /* saving original center */ - if (G.vd->around == V3D_LOCAL) { + if (G.vd->around == V3D_LOCAL || (t->con.mode & CON_LOCAL)) { VECCOPY(center, t->center); } @@ -1384,7 +1407,8 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) if (td->flag & TD_NOACTION) break; - if (G.vd->around == V3D_LOCAL) { + /* local constraint shouldn't alter center */ + if (G.vd->around == V3D_LOCAL || (t->con.mode & CON_LOCAL)) { VECCOPY(t->center, td->center); } @@ -1400,7 +1424,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) } /* restoring original center */ - if (G.vd->around == V3D_LOCAL) { + if (G.vd->around == V3D_LOCAL || (t->con.mode & CON_LOCAL)) { VECCOPY(t->center, center); } } |