From a4824656592279a6b22c754e0a01c28dea942253 Mon Sep 17 00:00:00 2001 From: "Curtis L. Olson" Date: Thu, 5 May 2011 14:13:18 -0500 Subject: [PATCH] Fix a problem with the YASim turbulence model. This change has been coordinated with and approved by Andy. The lattice(x,y) arguments were being "WRAP()'d" but the WRAP() function didn't make sense. Instead it was forcing the value to zero if it was greater than the wrap limit. This was creating large areas of constant values in the perlin noise maps which resulted in a "constant" turbulence vector over time -- which is just weird. Andy couldn't see any reason why the values should be wrapped and couldn't remember any reason why the WRAP() function was set up like it was. Andy wanted me to make sure and mention that he was INSANE when he wrote that code (but now he's sane ... err, mostly.) --- src/FDM/YASim/Turbulence.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/FDM/YASim/Turbulence.cpp b/src/FDM/YASim/Turbulence.cpp index 4a6183680..1b4048d1e 100644 --- a/src/FDM/YASim/Turbulence.cpp +++ b/src/FDM/YASim/Turbulence.cpp @@ -270,12 +270,10 @@ float Turbulence::iturb(unsigned int x, unsigned int y) xfrac = xfrac*xfrac*(3 - 2*xfrac); // ... as cubics yfrac = yfrac*yfrac*(3 - 2*yfrac); -#define WRAP(a) (a) >= wrapmax ? 0 : (a) - float p00 = lattice(WRAP(xl), WRAP(yl)); // lattice values - float p01 = lattice(WRAP(xl), WRAP(yl+1)); - float p10 = lattice(WRAP(xl+1), WRAP(yl)); - float p11 = lattice(WRAP(xl+1), WRAP(yl+1)); -#undef WRAP + float p00 = lattice(xl, yl); // lattice values + float p01 = lattice(xl, yl+1); + float p10 = lattice(xl+1, yl); + float p11 = lattice(xl+1, yl+1); float p0 = p00 * (1-yfrac) + p01 * yfrac; float p1 = p10 * (1-yfrac) + p11 * yfrac; -- 2.39.5