From 1f35fd7929fafe80e1768d99a80ec903024ec015 Mon Sep 17 00:00:00 2001 From: Ben Batt Date: Mon, 29 Jan 2007 16:28:11 +0000 Subject: [PATCH] = Addendum to UVProject's multiple UV handling - "Override Image" button = * Added an "Override Image" button to the UVProject modifier; this overrides faces' currently assigned image with the one given in the modifier panel. This provides some of the functionality previously provided by the "Add UVs" button - you still need to add a UV layer manually, but you only need to change the image in one place. * Note that the "Override Image" option uses the bit position previously used by the "Add UVs" option, so old files which had "Add UVs" enabled will now have "Override Image" enabled. --- source/blender/blenkernel/intern/modifier.c | 9 ++++----- source/blender/makesdna/DNA_modifier_types.h | 3 +++ source/blender/src/buttons_editing.c | 8 +++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 4894a238634..9ff5b005af3 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -2616,7 +2616,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int i, numVerts, numFaces; Image *image = umd->image; MFace *mface, *mf; - int new_tfaces = 0; + int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0); Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; int num_projectors = 0; float aspect; @@ -2729,7 +2729,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* apply coords as UVs, and apply image if tfaces are new */ for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tface) { - if(new_tfaces || !image || tface->tpage == image) { + if(override_image || !image || tface->tpage == image) { if(num_projectors == 1) { /* apply transformed coords as UVs */ tface->uv[0][0] = coords[mf->v1][0]; @@ -2799,10 +2799,9 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - if(new_tfaces) { + if(override_image) { tface->mode = TF_TEX; - if(image) - tface->tpage = image; + tface->tpage = image; } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 704c54afcd5..dffd99c8aee 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -214,6 +214,9 @@ typedef struct UVProjectModifierData { #define MOD_UVPROJECT_MAXPROJECTORS 10 +/* UVProjectModifierData->flags */ +#define MOD_UVPROJECT_OVERRIDEIMAGE 1<<0 + typedef struct DecimateModifierData { ModifierData modifier; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 23580dd78ad..f0d403d61af 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1559,7 +1559,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco dmd->texmapping == MOD_DISP_MAP_UV) height += 19; } else if (md->type==eModifierType_UVProject) { - height = 105 + ((UVProjectModifierData *)md)->num_projectors * 19; + height = 114 + ((UVProjectModifierData *)md)->num_projectors * 19; } else if (md->type==eModifierType_Decimate) { height = 48; } else if (md->type==eModifierType_Wave) { @@ -1759,6 +1759,12 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco "Image to project (only faces with this image " "will be altered"); uiButSetCompleteFunc(but, autocomplete_image, (void *)ob); + uiDefButBitI(block, TOG, MOD_UVPROJECT_OVERRIDEIMAGE, + B_MODIFIER_RECALC, "Override Image", + lx, (cy -= 19), buttonWidth, 19, + &umd->flags, 0, 0, 0, 0, + "Override faces' current images with the " + "given image"); } else if (md->type==eModifierType_Decimate) { DecimateModifierData *dmd = (DecimateModifierData*) md; uiDefButF(block, NUM, B_MODIFIER_RECALC, "Ratio:", lx,(cy-=19),buttonWidth,19, &dmd->percent, 0.0, 1.0, 10, 0, "Defines the percentage of triangles to reduce to");