== Mirror modifier upgrade ==
authorBen Batt <benbatt@gmail.com>
Sun, 18 Mar 2007 13:46:26 +0000 (13:46 +0000)
committerBen Batt <benbatt@gmail.com>
Sun, 18 Mar 2007 13:46:26 +0000 (13:46 +0000)
Upgraded the Mirror modifier to support mirroring of UV coordinates in the
faces created by the modifier.

source/blender/blenkernel/intern/modifier.c
source/blender/makesdna/DNA_modifier_types.h
source/blender/src/buttons_editing.c

index efec74d8cae902f85b1932c77015eed60493dace..02af4ab903d1ebae423533836269c4d367ffeddd 100644 (file)
@@ -1349,6 +1349,20 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
                        mf2->v3 += indexMap[inMF.v3][1];
                        if(inMF.v4) mf2->v4 += indexMap[inMF.v4][1];
 
+                       /* mirror UVs if enabled */
+                       if(mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) {
+                               MTFace *tf = result->getFaceData(result, numFaces, CD_MTFACE);
+                               if(tf) {
+                                       int j;
+                                       for(j = 0; j < 4; ++j) {
+                                               if(mmd->flag & MOD_MIR_MIRROR_U)
+                                                       tf->uv[j][0] = 1.0f - tf->uv[j][0];
+                                               if(mmd->flag & MOD_MIR_MIRROR_V)
+                                                       tf->uv[j][1] = 1.0f - tf->uv[j][1];
+                                       }
+                               }
+                       }
+
                        /* Flip face normal */
                        SWAP(int, mf2->v1, mf2->v3);
                        DM_swap_face_data(result, numFaces, corner_indices);
index 9b79ee3458355118f2e4b2376e760929285e68bb..278e04c3f44ec614cb4ed7d9a1d23b44e5e501b3 100644 (file)
@@ -159,7 +159,9 @@ typedef struct MirrorModifierData {
 } MirrorModifierData;
 
 /* MirrorModifierData->flag */
-#define MOD_MIR_CLIPPING       1
+#define MOD_MIR_CLIPPING       1<<0
+#define MOD_MIR_MIRROR_U       1<<1
+#define MOD_MIR_MIRROR_V       1<<2
 
 typedef struct EdgeSplitModifierData {
        ModifierData modifier;
index 20282a8a4c6853471fefa9c48b38e3b039df2ee2..4413c82e16dc9be10ab42c0f75ff1f33916c5c13 100644 (file)
@@ -1581,7 +1581,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 = 48;
+                       height = 67;
                } else if (md->type==eModifierType_EdgeSplit) {
                        EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md;
                        height = 48;
@@ -1680,6 +1680,18 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
                        uiDefButS(block, ROW, B_MODIFIER_RECALC, "Y",   lx+20, cy, 20,19, &mmd->axis, 1, 1, 0, 0, "Specify the axis to mirror about");
                        uiDefButS(block, ROW, B_MODIFIER_RECALC, "Z",   lx+40, cy, 20,19, &mmd->axis, 1, 2, 0, 0, "Specify the axis to mirror about");
                        uiDefButBitS(block, TOG, MOD_MIR_CLIPPING, B_MODIFIER_RECALC, "Do Clipping",    lx+60, cy, buttonWidth-60,19, &mmd->flag, 1, 2, 0, 0, "Prevents during Transform vertices to go through Mirror");
+                       uiDefButBitS(block, TOG, MOD_MIR_MIRROR_U, B_MODIFIER_RECALC,
+                                    "Mirror U",
+                                    lx, (cy-=19), buttonWidth/2, 19,
+                                    &mmd->flag, 0, 0, 0, 0,
+                                    "Mirror the U texture coordinate around "
+                                    "the 0.5 point");
+                       uiDefButBitS(block, TOG, MOD_MIR_MIRROR_V, B_MODIFIER_RECALC,
+                                    "Mirror V",
+                                    lx + buttonWidth/2 + 1, cy, buttonWidth/2, 19,
+                                    &mmd->flag, 0, 0, 0, 0,
+                                    "Mirror the V texture coordinate around "
+                                    "the 0.5 point");
                } else if (md->type==eModifierType_EdgeSplit) {
                        EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md;
                        uiDefButBitI(block, TOG, MOD_EDGESPLIT_FROMANGLE,