diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
commit | 874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch) | |
tree | 5971e577cf7c02e05a1e37b5ad058c71a6744877 /source/blender/blenkernel/intern/effect.c | |
parent | 7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff) | |
parent | c5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff) |
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes:
* blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'source/blender/blenkernel/intern/effect.c')
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 5217464c2c9..077a0c437d4 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -299,24 +299,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) @@ -443,14 +441,11 @@ void do_physical_effector(Scene *scene, Object *ob, float *opco, short type, flo else VecCopyf(mag_vec,vec_to_part); - Normalize(mag_vec); - VecMulf(mag_vec,force_val*falloff); VecSubf(field,field,mag_vec); VecCopyf(mag_vec,velocity); - /* 1.9 is an experimental value to get critical damping at damp=1.0 */ - VecMulf(mag_vec,damp*1.9f*(float)sqrt(force_val)); + VecMulf(mag_vec,damp*2.0f*(float)sqrt(force_val)); VecSubf(field,field,mag_vec); break; case PFIELD_CHARGE: |