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 {
|
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 {
|
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 v = fade(_y);
|
||||||
double w = fade(_z);
|
double w = fade(_z);
|
||||||
|
|
||||||
int A = p[X] + Y;
|
int A = p[X] + Z;
|
||||||
int AA = p[A] + Z;
|
int AA = p[A] + Y;
|
||||||
int AB = p[A + 1] + Z;
|
int AB = p[A + 1] + Y;
|
||||||
int B = p[X + 1] + Y;
|
int B = p[X + 1] + Z;
|
||||||
int BA = p[B] + Z;
|
int BA = p[B] + Y;
|
||||||
int BB = p[B + 1] + Z;
|
int BB = p[B + 1] + Y;
|
||||||
|
|
||||||
double res = lerp(
|
double res = lerp(
|
||||||
w,
|
w,
|
||||||
lerp(
|
lerp(
|
||||||
v,
|
v,
|
||||||
lerp(u, grad(p[AA], _x, _y, _z), grad(p[BA], _x-1, _y, _z)),
|
lerp(u, grad(p[AA], _x, _z, _y), grad(p[BA], _x-1, _z, _y)),
|
||||||
lerp(u, grad(p[AB], _x, _y-1, _z), grad(p[BB], _x-1, _y-1, _z))
|
lerp(u, grad(p[AB], _x, _z-1, _y), grad(p[BB], _x-1, _z-1, _y))
|
||||||
),
|
),
|
||||||
lerp(
|
lerp(
|
||||||
v,
|
v,
|
||||||
lerp(
|
lerp(
|
||||||
u,
|
u,
|
||||||
grad(p[AA+1], _x, _y, _z-1),
|
grad(p[AA+1], _x, _z, _y-1),
|
||||||
grad(p[BA+1], _x-1, _y, _z-1)
|
grad(p[BA+1], _x-1, _z, _y-1)
|
||||||
),
|
),
|
||||||
lerp(
|
lerp(
|
||||||
u,
|
u,
|
||||||
grad(p[AB+1], _x, _y-1, _z-1),
|
grad(p[AB+1], _x, _z-1, _y-1),
|
||||||
grad(p[BB+1], _x-1, _y-1, _z-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 {
|
double PerlinNoise::noise(double _x, double _y) const {
|
||||||
return noise(_x, _y, 0);
|
return noise(_x, 0, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double PerlinNoise::fade(double t) const {
|
double PerlinNoise::fade(double t) const {
|
||||||
|
|
Loading…
Reference in a new issue