Bug fix (y and z axis) + pragma
This commit is contained in:
parent
15ee31c30e
commit
538930bd71
1 changed files with 14 additions and 14 deletions
|
@ -44,7 +44,7 @@ PerlinNoise::PerlinNoise(unsigned int seed) : ImplicitSurface(Point(0,0,0)) {
|
|||
}
|
||||
|
||||
double PerlinNoise::operator() (double x, double y, double z) const {
|
||||
return z - noise(x, y, 0);
|
||||
return z - noise(x, 0, y);
|
||||
}
|
||||
|
||||
double PerlinNoise::noise(double _x, double _y, double _z) const {
|
||||
|
@ -60,31 +60,31 @@ double PerlinNoise::noise(double _x, double _y, double _z) const {
|
|||
double v = fade(_y);
|
||||
double w = fade(_z);
|
||||
|
||||
int A = p[X] + Y;
|
||||
int AA = p[A] + Z;
|
||||
int AB = p[A + 1] + Z;
|
||||
int B = p[X + 1] + Y;
|
||||
int BA = p[B] + Z;
|
||||
int BB = p[B + 1] + Z;
|
||||
int A = p[X] + Z;
|
||||
int AA = p[A] + Y;
|
||||
int AB = p[A + 1] + Y;
|
||||
int B = p[X + 1] + Z;
|
||||
int BA = p[B] + Y;
|
||||
int BB = p[B + 1] + Y;
|
||||
|
||||
double res = lerp(
|
||||
w,
|
||||
lerp(
|
||||
v,
|
||||
lerp(u, grad(p[AA], _x, _y, _z), grad(p[BA], _x-1, _y, _z)),
|
||||
lerp(u, grad(p[AB], _x, _y-1, _z), grad(p[BB], _x-1, _y-1, _z))
|
||||
lerp(u, grad(p[AA], _x, _z, _y), grad(p[BA], _x-1, _z, _y)),
|
||||
lerp(u, grad(p[AB], _x, _z-1, _y), grad(p[BB], _x-1, _z-1, _y))
|
||||
),
|
||||
lerp(
|
||||
v,
|
||||
lerp(
|
||||
u,
|
||||
grad(p[AA+1], _x, _y, _z-1),
|
||||
grad(p[BA+1], _x-1, _y, _z-1)
|
||||
grad(p[AA+1], _x, _z, _y-1),
|
||||
grad(p[BA+1], _x-1, _z, _y-1)
|
||||
),
|
||||
lerp(
|
||||
u,
|
||||
grad(p[AB+1], _x, _y-1, _z-1),
|
||||
grad(p[BB+1], _x-1, _y-1, _z-1)
|
||||
grad(p[AB+1], _x, _z-1, _y-1),
|
||||
grad(p[BB+1], _x-1, _z-1, _y-1)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -92,7 +92,7 @@ double PerlinNoise::noise(double _x, double _y, double _z) const {
|
|||
}
|
||||
|
||||
double PerlinNoise::noise(double _x, double _y) const {
|
||||
return noise(_x, _y, 0);
|
||||
return noise(_x, 0, _y);
|
||||
}
|
||||
|
||||
double PerlinNoise::fade(double t) const {
|
||||
|
|
Loading…
Reference in a new issue