From e66f325dd7115351a40ddb72af8d347b141886c5 Mon Sep 17 00:00:00 2001 From: Chris Want Date: Tue, 13 Nov 2007 06:56:55 +0000 Subject: ==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 --- source/blender/src/transform_generics.c | 79 +++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 19 deletions(-) (limited to 'source/blender/src/transform_generics.c') 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); + } + } + } + } } } -- cgit v1.2.3