diff options
author | Chris Want <cwant@ualberta.ca> | 2007-11-13 09:56:55 +0300 |
---|---|---|
committer | Chris Want <cwant@ualberta.ca> | 2007-11-13 09:56:55 +0300 |
commit | e66f325dd7115351a40ddb72af8d347b141886c5 (patch) | |
tree | cf035bce9272602b8b0f78d7449a83d91d04999a /source/blender/src/transform_generics.c | |
parent | 924f7e514612e653eea7a2b941351b62c737df62 (diff) |
==Mirror Modifier==
Support for using the axes of a different object as the line of mirror
symmetry for a mirror modifier. As a nice consequence, this allows
"clipping" to arbitrary planes in editmode.
A fun example of using a couple of mirror modifiers and an array
modifier to easily make a nice flower type model is here:
http://bebop.cns.ualberta.ca/~cwant/chocolateC05.blend
Diffstat (limited to 'source/blender/src/transform_generics.c')
-rw-r--r-- | source/blender/src/transform_generics.c | 79 |
1 files changed, 60 insertions, 19 deletions
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index bf9de8d4e3f..72937fb10b6 100644 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -154,6 +154,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) MirrorModifierData *mmd = (MirrorModifierData*) md; if(mmd->flag & MOD_MIR_CLIPPING) { + axis = 0; if(mmd->flag & MOD_MIR_AXIS_X) { axis |= 1; tolerance[0] = mmd->tolerance; @@ -166,28 +167,68 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) axis |= 4; tolerance[2] = mmd->tolerance; } - } - } - } - if (axis) { - TransData *td = t->data; - int i; + if (axis) { + float mtx[4][4], imtx[4][4]; + int i; + TransData *td = t->data; - for(i = 0 ; i < t->total; i++, td++) { - if (td->flag & TD_NOACTION) - break; - if (td->loc==NULL) - break; + if (mmd->mirror_ob) { + float obinv[4][4]; + + Mat4Invert(obinv, mmd->mirror_ob->obmat); + Mat4MulMat4(mtx, ob->obmat, obinv); + Mat4Invert(imtx, mtx); + } + + for(i = 0 ; i < t->total; i++, td++) { + int clip; + float loc[3], iloc[3]; + + if (td->flag & TD_NOACTION) + break; + if (td->loc==NULL) + break; - if(axis & 1) { - if(fabs(td->iloc[0])<=tolerance[0] || td->loc[0]*td->iloc[0]<0.0f) td->loc[0]= 0.0f; - } + VecCopyf(loc, td->loc); + VecCopyf(iloc, td->iloc); + + if (mmd->mirror_ob) { + VecMat4MulVecfl(loc, mtx, loc); + VecMat4MulVecfl(iloc, mtx, iloc); + } + + clip = 0; + if(axis & 1) { + if(fabs(iloc[0])<=tolerance[0] || + loc[0]*iloc[0]<0.0f) { + loc[0]= 0.0f; + clip = 1; + } + } - if(axis & 2) { - if(fabs(td->iloc[1])<=tolerance[1] || td->loc[1]*td->iloc[1]<0.0f) td->loc[1]= 0.0f; - } - if(axis & 4) { - if(fabs(td->iloc[2])<=tolerance[2] || td->loc[2]*td->iloc[2]<0.0f) td->loc[2]= 0.0f; + if(axis & 2) { + if(fabs(iloc[1])<=tolerance[1] || + loc[1]*iloc[1]<0.0f) { + loc[1]= 0.0f; + clip = 1; + } + } + if(axis & 4) { + if(fabs(iloc[2])<=tolerance[2] || + loc[2]*iloc[2]<0.0f) { + loc[2]= 0.0f; + clip = 1; + } + } + if (clip) { + if (mmd->mirror_ob) { + VecMat4MulVecfl(loc, imtx, loc); + } + VecCopyf(td->loc, loc); + } + } + } + } } } |