From 1f0bb0e0353687c17738608d884077dc6779638d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 8 Sep 2011 07:36:59 +0000 Subject: =?UTF-8?q?Vertex=20Weight=20Proximity:=20minor=20updates=20and=20?= =?UTF-8?q?fixes.=20*Updated=20UI=20code=20(replaced=20=E2=80=9Crow=20colu?= =?UTF-8?q?mns=E2=80=9D=20by=20splits=20;)=20).=20*Clamped=20global=20infl?= =?UTF-8?q?uence=20to=20[0.0,=201.0]=20range!=20*Added/edited=20some=20too?= =?UTF-8?q?ltips=20for=20Proximity.=20*Proximity=20distance=20mapping=20ca?= =?UTF-8?q?n=20now=20be=20reversed=20by=20entering=20Lowest=20Dist=20>=20H?= =?UTF-8?q?ighest=20Dist.=20*Moved=20mapping=20before=20masking=20in=20Pro?= =?UTF-8?q?ximity,=20much=20more=20sensible=20this=20way!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modifiers/intern/MOD_weightvgproximity.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'source/blender/modifiers') 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); -- cgit v1.2.3