From 1ba71e2caf0f7e425eaefc24891a1752247ef6bd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Sep 2011 03:53:26 +0000 Subject: change proximity method since minimum distance of 0.0 wasnt working at all. --- source/blender/modifiers/intern/MOD_weightvgproximity.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 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*/ -- cgit v1.2.3