]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a problem with the YASim turbulence model. This change has been
authorCurtis L. Olson <curt0001@flightgear.org>
Thu, 5 May 2011 19:13:18 +0000 (14:13 -0500)
committerCurtis L. Olson <curt0001@flightgear.org>
Thu, 5 May 2011 19:13:18 +0000 (14:13 -0500)
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

index 4a618368098f69889b156339615fb65d79051e55..1b4048d1ed31db1ee589df741f149ed63c5912c7 100644 (file)
@@ -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;