From 6d72150312f7644126b5454e939b86dbcae9b370 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Jun 2010 19:56:13 +0000 Subject: wave modifier was dividing by zero for each vertex with default settings of falloff == 0.0f. annoying with --debug-fpe and better to use multiply in the loop. --- source/blender/modifiers/intern/MOD_wave.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_wave.c') diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 8a328021a0e..23e13266d80 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -293,7 +293,9 @@ static void waveModifier_do(WaveModifierData *md, wavemod_get_texture_coords(wmd, ob, dm, vertexCos, tex_co, numVerts); } - if(lifefac != 0.0) { + if(lifefac != 0.0) { + /* avoid divide by zero checks within the loop */ + float falloff_inv= wmd->falloff ? 1.0f / wmd->falloff : 1.0; int i; for(i = 0; i < numVerts; i++) { @@ -338,8 +340,7 @@ static void waveModifier_do(WaveModifierData *md, dist = fabs(y); } - falloff_fac = (1.0-(dist / wmd->falloff)); - CLAMP(falloff_fac,0,1); + falloff_fac = (1.0f - (dist * falloff_inv)); if(wmd->flag & MOD_WAVE_X) { if(wmd->flag & MOD_WAVE_Y) amplit = (float)sqrt(x*x + y*y); -- cgit v1.2.3