Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Want <cwant@ualberta.ca>2007-11-13 09:56:55 +0300
committerChris Want <cwant@ualberta.ca>2007-11-13 09:56:55 +0300
commite66f325dd7115351a40ddb72af8d347b141886c5 (patch)
treecf035bce9272602b8b0f78d7449a83d91d04999a /source/blender/src
parent924f7e514612e653eea7a2b941351b62c737df62 (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')
-rw-r--r--source/blender/src/buttons_editing.c7
-rw-r--r--source/blender/src/editmesh_lib.c56
-rw-r--r--source/blender/src/transform_generics.c79
3 files changed, 110 insertions, 32 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index affa06ae6b2..24964b30ce9 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -1604,7 +1604,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
} else if (md->type==eModifierType_Build) {
height = 86;
} else if (md->type==eModifierType_Mirror) {
- height = 67;
+ height = 86;
} else if (md->type==eModifierType_EdgeSplit) {
EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md;
height = 48;
@@ -1728,6 +1728,11 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
&mmd->flag, 0, 0, 0, 0,
"Mirror the V texture coordinate around "
"the 0.5 point");
+ uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CHANGEDEP,
+ "Ob: ", lx, (cy -= 19), buttonWidth, 19,
+ &mmd->mirror_ob,
+ "Object to use as mirrot");
+
} else if (md->type==eModifierType_EdgeSplit) {
EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md;
uiDefButBitI(block, TOG, MOD_EDGESPLIT_FROMANGLE,
diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c
index 14a522bdbff..d9b8fa93eb9 100644
--- a/source/blender/src/editmesh_lib.c
+++ b/source/blender/src/editmesh_lib.c
@@ -1142,22 +1142,38 @@ static short extrudeflag_edge(short flag, float *nor)
MirrorModifierData *mmd = (MirrorModifierData*) md;
if(mmd->flag & MOD_MIR_CLIPPING) {
+ float mtx[4][4];
+ if (mmd->mirror_ob) {
+ float imtx[4][4];
+ Mat4Invert(imtx, mmd->mirror_ob->obmat);
+ Mat4MulMat4(mtx, G.obedit->obmat, imtx);
+ }
+
for (eed= em->edges.first; eed; eed= eed->next) {
if(eed->f2 == 1) {
+ float co1[3], co2[3];
+
+ VecCopyf(co1, eed->v1->co);
+ VecCopyf(co2, eed->v2->co);
+
+ if (mmd->mirror_ob) {
+ VecMat4MulVecfl(co1, mtx, co1);
+ VecMat4MulVecfl(co2, mtx, co2);
+ }
if (mmd->flag & MOD_MIR_AXIS_X)
- if ( (fabs(eed->v1->co[0]) < mmd->tolerance) &&
- (fabs(eed->v2->co[0]) < mmd->tolerance) )
+ if ( (fabs(co1[0]) < mmd->tolerance) &&
+ (fabs(co2[0]) < mmd->tolerance) )
++eed->f2;
if (mmd->flag & MOD_MIR_AXIS_Y)
- if ( (fabs(eed->v1->co[1]) < mmd->tolerance) &&
- (fabs(eed->v2->co[1]) < mmd->tolerance) )
+ if ( (fabs(co1[1]) < mmd->tolerance) &&
+ (fabs(co2[1]) < mmd->tolerance) )
++eed->f2;
if (mmd->flag & MOD_MIR_AXIS_Z)
- if ( (fabs(eed->v1->co[2]) < mmd->tolerance) &&
- (fabs(eed->v2->co[2]) < mmd->tolerance) )
+ if ( (fabs(co1[2]) < mmd->tolerance) &&
+ (fabs(co2[2]) < mmd->tolerance) )
++eed->f2;
}
}
@@ -1408,21 +1424,37 @@ short extrudeflag_vert(short flag, float *nor)
MirrorModifierData *mmd = (MirrorModifierData*) md;
if(mmd->flag & MOD_MIR_CLIPPING) {
+ float mtx[4][4];
+ if (mmd->mirror_ob) {
+ float imtx[4][4];
+ Mat4Invert(imtx, mmd->mirror_ob->obmat);
+ Mat4MulMat4(mtx, G.obedit->obmat, imtx);
+ }
+
for (eed= em->edges.first; eed; eed= eed->next) {
if(eed->f2 == 2) {
+ float co1[3], co2[3];
+
+ VecCopyf(co1, eed->v1->co);
+ VecCopyf(co2, eed->v2->co);
+
+ if (mmd->mirror_ob) {
+ VecMat4MulVecfl(co1, mtx, co1);
+ VecMat4MulVecfl(co2, mtx, co2);
+ }
if (mmd->flag & MOD_MIR_AXIS_X)
- if ( (fabs(eed->v1->co[0]) < mmd->tolerance) &&
- (fabs(eed->v2->co[0]) < mmd->tolerance) )
+ if ( (fabs(co1[0]) < mmd->tolerance) &&
+ (fabs(co2[0]) < mmd->tolerance) )
++eed->f2;
if (mmd->flag & MOD_MIR_AXIS_Y)
- if ( (fabs(eed->v1->co[1]) < mmd->tolerance) &&
- (fabs(eed->v2->co[1]) < mmd->tolerance) )
+ if ( (fabs(co1[1]) < mmd->tolerance) &&
+ (fabs(co2[1]) < mmd->tolerance) )
++eed->f2;
if (mmd->flag & MOD_MIR_AXIS_Z)
- if ( (fabs(eed->v1->co[2]) < mmd->tolerance) &&
- (fabs(eed->v2->co[2]) < mmd->tolerance) )
+ if ( (fabs(co1[2]) < mmd->tolerance) &&
+ (fabs(co2[2]) < mmd->tolerance) )
++eed->f2;
}
}
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);
+ }
+ }
+ }
+
}
}
}