diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2011-09-08 11:36:59 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2011-09-08 11:36:59 +0400 |
commit | 1f0bb0e0353687c17738608d884077dc6779638d (patch) | |
tree | 0f9f0a4fc3726adb87590b2572b58e3b2180da3f /source/blender/modifiers | |
parent | 3dccd96ac705011ac396a3eb1d3b07a18ef485a7 (diff) |
Vertex Weight Proximity: minor updates and fixes.
*Updated UI code (replaced “row columns” by splits ;) ).
*Clamped global influence to [0.0, 1.0] range!
*Added/edited some tooltips for Proximity.
*Proximity distance mapping can now be reversed by entering Lowest Dist > Highest Dist.
*Moved mapping before masking in Proximity, much more sensible this way!
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgproximity.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 561a021ce0c..0dbf8a91d21 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -199,10 +199,24 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d { const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */ unsigned int i= nidx; - while (i-- > 0) { - if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */ - else if(weights[i] <= min_d) weights[i]= 0.0f; - else weights[i]= (weights[i] - min_d) * range_inv; + if(max_d == min_d) { + while (i-- > 0) { + weights[i] = (weights[i] >= max_d) ? 1.0f : 0.0f; /* "Step" behavior... */ + } + } + else if(max_d > min_d) { + while (i-- > 0) { + if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */ + else if(weights[i] <= min_d) weights[i]= 0.0f; + else weights[i]= (weights[i] - min_d) * range_inv; + } + } + else { + while (i-- > 0) { + if (weights[i] <= max_d) weights[i]= 1.0f; /* most likely case first */ + else if(weights[i] >= min_d) weights[i]= 0.0f; + else weights[i]= (weights[i] - min_d) * range_inv; + } } if(!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) { @@ -495,14 +509,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der } } + /* Map distances to weights. */ + do_map(new_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->falloff_type); + /* Do masking. */ weightvg_do_mask(numIdx, indices, org_w, new_w, ob, ret, wmd->mask_constant, wmd->mask_defgrp_name, wmd->mask_texture, wmd->mask_tex_use_channel, wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); - /* Map distances to weights. */ - do_map(org_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->falloff_type); - /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ weightvg_update_vg(dvert, defgrp_idx, numIdx, indices, org_w, 0, 0.0f, 0, 0.0f); |