Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-05 07:53:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-05 07:53:26 +0400
commit1ba71e2caf0f7e425eaefc24891a1752247ef6bd (patch)
treed226f143567ac6d0b30e60135b9920540e91acff /source/blender/modifiers
parent5fd8ffd242da37ff12e56b05b0e44b0053e5143b (diff)
change proximity method since minimum distance of 0.0 wasnt working at all.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 3bd39b0417f..6519d781f05 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -205,11 +205,13 @@ static float get_ob2ob_distance(const Object* ob, const Object* obr)
*/
void do_map(float *weights, const int nidx, const float min_d, const float max_d)
{
- int i;
- float b = min_d / (min_d - max_d);
- float a = -b / min_d;
- for (i = 0; i < nidx; i++)
- weights[i] = a * weights[i] + b;
+ 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;
+ }
}
/*a min_d + b = 0.0*/