1
0
Fork 0

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.)
This commit is contained in:
Curtis L. Olson 2011-05-05 14:13:18 -05:00
parent 5566c79873
commit a482465659

View 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;