diff options
Diffstat (limited to 'src/mapgen/mapgen_fractal.cpp')
-rw-r--r-- | src/mapgen/mapgen_fractal.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mapgen/mapgen_fractal.cpp b/src/mapgen/mapgen_fractal.cpp index d0c670acc..45526b138 100644 --- a/src/mapgen/mapgen_fractal.cpp +++ b/src/mapgen/mapgen_fractal.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen.h" +#include <cmath> #include "voxel.h" #include "noise.h" #include "mapblock.h" @@ -306,45 +307,45 @@ bool MapgenFractal::getFractalAtPoint(s16 x, s16 y, s16 z) break; case 6: // 3D "Christmas Tree" // Altering the formula here is necessary to avoid division by zero - if (fabs(oz) < 0.000000001f) { + if (std::fabs(oz) < 0.000000001f) { nx = ox * ox - oy * oy - oz * oz + cx; ny = 2.0f * oy * ox + cy; nz = 4.0f * oz * ox + cz; } else { - float a = (2.0f * ox) / (sqrt(oy * oy + oz * oz)); + float a = (2.0f * ox) / (std::sqrt(oy * oy + oz * oz)); nx = ox * ox - oy * oy - oz * oz + cx; ny = a * (oy * oy - oz * oz) + cy; nz = a * 2.0f * oy * oz + cz; } break; case 7: // 3D "Mandelbulb" - if (fabs(oy) < 0.000000001f) { + if (std::fabs(oy) < 0.000000001f) { nx = ox * ox - oz * oz + cx; ny = cy; - nz = -2.0f * oz * sqrt(ox * ox) + cz; + nz = -2.0f * oz * std::sqrt(ox * ox) + cz; } else { float a = 1.0f - (oz * oz) / (ox * ox + oy * oy); nx = (ox * ox - oy * oy) * a + cx; ny = 2.0f * ox * oy * a + cy; - nz = -2.0f * oz * sqrt(ox * ox + oy * oy) + cz; + nz = -2.0f * oz * std::sqrt(ox * ox + oy * oy) + cz; } break; case 8: // 3D "Cosine Mandelbulb" - if (fabs(oy) < 0.000000001f) { + if (std::fabs(oy) < 0.000000001f) { nx = 2.0f * ox * oz + cx; ny = 4.0f * oy * oz + cy; nz = oz * oz - ox * ox - oy * oy + cz; } else { - float a = (2.0f * oz) / sqrt(ox * ox + oy * oy); + float a = (2.0f * oz) / std::sqrt(ox * ox + oy * oy); nx = (ox * ox - oy * oy) * a + cx; ny = 2.0f * ox * oy * a + cy; nz = oz * oz - ox * ox - oy * oy + cz; } break; case 9: // 4D "Mandelbulb" - float rxy = sqrt(ox * ox + oy * oy); - float rxyz = sqrt(ox * ox + oy * oy + oz * oz); - if (fabs(ow) < 0.000000001f && fabs(oz) < 0.000000001f) { + float rxy = std::sqrt(ox * ox + oy * oy); + float rxyz = std::sqrt(ox * ox + oy * oy + oz * oz); + if (std::fabs(ow) < 0.000000001f && std::fabs(oz) < 0.000000001f) { nx = (ox * ox - oy * oy) + cx; ny = 2.0f * ox * oy + cy; nz = -2.0f * rxy * oz + cz; |