diff options
Diffstat (limited to 'source/blender/blenkernel/intern/deform.c')
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 38d4d722a46..a4c8e589f26 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -115,6 +115,28 @@ void copy_defvert (MDeformVert *dvert_r, const MDeformVert *dvert) } } +void normalize_defvert (MDeformVert *dvert) +{ + if(dvert->totweight<=0) { + /* nothing */ + } + else if (dvert->totweight==1) { + dvert->dw[0].weight= 1.0f; + } + else { + int i; + float tot= 0.0f; + MDeformWeight *dw; + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) + tot += dw->weight; + + if(tot > 0.0f) { + for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) + dw->weight /= tot; + } + } +} + void flip_defvert (MDeformVert *dvert, int *flip_map) { MDeformWeight *dw; |