Particle effector falloff maxdist etc. didn't work like it was supposed to.
authorJanne Karhu <jhkarh@gmail.com>
Thu, 9 Apr 2009 23:43:25 +0000 (23:43 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Thu, 9 Apr 2009 23:43:25 +0000 (23:43 +0000)
source/blender/blenkernel/intern/effect.c

index a6514ae7b87e707a5089cb93e7f2e473c6bfec7d..cca5d68167e74084b2fe0aed94a02a938cb2a822 100644 (file)
@@ -298,24 +298,22 @@ static float wind_func(struct RNG *rng, float strength)
        return ret;
 }
 
-
+/* maxdist: zero effect from this distance outwards (if usemax) */
+/* mindist: full effect up to this distance (if usemin) */
+/* power: falloff with formula 1/r^power */
 static float falloff_func(float fac, int usemin, float mindist, int usemax, float maxdist, float power)
 {
-       if(!usemin)
-               mindist= 0.0f;
+       /* first quick checks */
+       if(usemax && fac > maxdist)
+               return 0.0f;
 
-       if(fac < mindist) {
+       if(usemin && fac < mindist)
                return 1.0f;
-       }
-       else if(usemax) {
-               if(fac>maxdist || (maxdist-mindist)<=0.0f)
-                       return 0.0f;
 
-               fac= (fac-mindist)/(maxdist-mindist);
-               return 1.0f - (float)pow((double)fac, (double)power);
-       }
-       else
-               return pow((double)1.0f+fac-mindist, (double)-power);
+       if(!usemin)
+               mindist = 0.0;
+
+       return pow((double)1.0+fac-mindist, (double)-power);
 }
 
 static float falloff_func_dist(PartDeflect *pd, float fac)