I have a fix. Local testing works. I have no idea how to get it to you.
Fixes both bugs, and allows for users to revert to this (broken) function
in the future, if required, following the author's existing pattern for
internal versioning.
30c30,31
< // - Set to 2 to use the current version.
---
> // - Set to 3 to use the current version.
> // - Set to 2 to use the version with GradientNoise3D scale 2.12.
35c36
< #define NOISE_VERSION 2
---
> #define NOISE_VERSION 3
63,68c64,69
<   int x0 = (x > 0.0? (int)x: (int)x - 1);
<   int x1 = x0 + 1;
<   int y0 = (y > 0.0? (int)y: (int)y - 1);
<   int y1 = y0 + 1;
<   int z0 = (z > 0.0? (int)z: (int)z - 1);
<   int z1 = z0 + 1;
---
>   double x0 = x - 1;
>   int x1 = (int)x0 + 1;
>   double y0 = y - 1;
>   int y1 = (int)y0 + 1;
>   double z0 = z - 1;
>   int z1 = (int)z0 + 1;
75,77c76,78
<       xs = (x - (double)x0);
<       ys = (y - (double)y0);
<       zs = (z - (double)z0);
---
>       xs = (x - x0);
>       ys = (y - y0);
>       zs = (z - z0);
80,82c81,83
<       xs = SCurve3 (x - (double)x0);
<       ys = SCurve3 (y - (double)y0);
<       zs = SCurve3 (z - (double)z0);
---
>       xs = SCurve3 (x - x0);
>       ys = SCurve3 (y - y0);
>       zs = SCurve3 (z - z0);
85,87c86,88
<       xs = SCurve5 (x - (double)x0);
<       ys = SCurve5 (y - (double)y0);
<       zs = SCurve5 (z - (double)z0);
---
>       xs = SCurve5 (x - x0);
>       ys = SCurve5 (y - y0);
>       zs = SCurve5 (z - z0);
143,144c144,149
<     + (yvGradient * yvPoint)
<     + (zvGradient * zvPoint)) * 2.12;
---
>   + (yvGradient * yvPoint)
>   #if (NOISE_VERSION < 3)
>   + (zvGradient * zvPoint)) * 2.12;
>   #else
>   + (zvGradient * zvPoint)) * 0.57735026919;
>   #endif

Reply via email to