diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-11-06 12:44:34 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-11-06 12:44:34 +0300 |
commit | e2504c2ff1aa3bfb2df446e007ee9fae0993a9ee (patch) | |
tree | 57db6b729c9b42cce7993746c6e0d611af7883ab /source | |
parent | f1c6a69aad1f94f406cfa5172b7ddb941e80649d (diff) |
Mesh Deform Modifier
====================
Added a button to invert the vertex group influence, to make blending
between mdef and armature deform easier.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 35 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 4 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 3 |
3 files changed, 26 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 243a24bc3b8..b805e3827d2 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5067,7 +5067,28 @@ static void meshdeformModifier_do( } /* do deformation */ + fac= 1.0f; + for(b=0; b<totvert; b++) { + if(dvert) { + for(dw=NULL, a=0; a<dvert[b].totweight; a++) { + if(dvert[b].dw[a].def_nr == defgrp_index) { + dw = &dvert[b].dw[a]; + break; + } + } + + if(mmd->flag & MOD_MDEF_INVERT_VGROUP) { + if(!dw) fac= 1.0f; + else if(dw->weight == 0.0f) continue; + else fac=1.0f-dw->weight; + } + else { + if(!dw) continue; + else fac= dw->weight; + } + } + totweight= 0.0f; co[0]= co[1]= co[2]= 0.0f; @@ -5080,20 +5101,6 @@ static void meshdeformModifier_do( } if(totweight > 0.0f) { - if(dvert) { - for(dw=NULL, a=0; a<dvert[b].totweight; a++) { - if(dvert[b].dw[a].def_nr == defgrp_index) { - dw = &dvert[b].dw[a]; - break; - } - } - if(!dw) continue; - - fac= dw->weight; - } - else - fac= 1.0f; - VecMulf(co, fac/totweight); Mat3MulVecfl(icmat, co); VECADD(vertexCos[b], vertexCos[b], co); diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index c8dcba4fae7..42016ad1c16 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -348,6 +348,8 @@ typedef struct BooleanModifierData { int operation, pad; } BooleanModifierData; +#define MOD_MDEF_INVERT_VGROUP (1<<0) + typedef struct MeshDeformModifierData { ModifierData modifier; @@ -356,7 +358,7 @@ typedef struct MeshDeformModifierData { float *bindweights, *bindcos; /* computed binding weights */ short gridsize, needbind; - int pad; + short flag, pad; int totvert, totcagevert; } MeshDeformModifierData; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 40e2643a390..c9bc9a4b296 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -2120,8 +2120,9 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiBlockBeginAlign(block); uiDefIDPoinBut(block, test_meshobpoin_but, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &mmd->object, "Mesh object to be use as cage"); - but=uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-=19), buttonWidth,19, &mmd->defgrp_name, 0.0, 31.0, 0, 0, "Vertex Group name to control overall meshdeform influence"); + but=uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-19), buttonWidth-40,19, &mmd->defgrp_name, 0.0, 31.0, 0, 0, "Vertex Group name to control overall meshdeform influence"); uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ob); + uiDefButBitS(block, TOG, MOD_MDEF_INVERT_VGROUP, B_MODIFIER_RECALC, "Inv", lx+buttonWidth-40, (cy-=19), 40,19, &mmd->flag, 0.0, 31.0, 0, 0, "Invert vertex group influence"); uiBlockBeginAlign(block); if(mmd->bindweights) { |