summaryrefslogtreecommitdiff
path: root/src/mapgen/mapgen_v7.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2018-04-02 23:51:08 +0200
committerGitHub <noreply@github.com>2018-04-02 23:51:08 +0200
commit2481ea27ce0f423f3e6f3522539d20e1500cf572 (patch)
tree73251dcbf9146d7499177f59b266d8c60b0eaae7 /src/mapgen/mapgen_v7.cpp
parente98fd934ce17a7af0b4629fc88158373303c88a0 (diff)
downloadminetest-2481ea27ce0f423f3e6f3522539d20e1500cf572.tar.gz
minetest-2481ea27ce0f423f3e6f3522539d20e1500cf572.tar.bz2
minetest-2481ea27ce0f423f3e6f3522539d20e1500cf572.zip
Fix many issues reported by clang-tidy (#7189)
* Fix many issues reported by clang-tidy We have many issues in code related to some performance to float <-> double. Clang-tidy reported it in performance-type-promotion-in-math-fn I fixed many of them. It's not ready for a promote to blocking Also fix some value which should be const-ref
Diffstat (limited to 'src/mapgen/mapgen_v7.cpp')
-rw-r--r--src/mapgen/mapgen_v7.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp
index 55a81c531..fba2defef 100644
--- a/src/mapgen/mapgen_v7.cpp
+++ b/src/mapgen/mapgen_v7.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"
@@ -228,7 +229,7 @@ int MapgenV7::getSpawnLevelAtPoint(v2s16 p)
if (spflags & MGV7_RIDGES) {
float width = 0.2;
float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
- if (fabs(uwatern) <= width)
+ if (std::fabs(uwatern) <= width)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
}
@@ -426,9 +427,9 @@ bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y)
{
// Make rim 2 nodes thick to match floatland base terrain
float density_gradient = (y >= floatland_level) ?
- -pow((float)(y - floatland_level) / float_mount_height,
+ -std::pow((float)(y - floatland_level) / float_mount_height,
float_mount_exponent) :
- -pow((float)(floatland_level - 1 - y) / float_mount_height,
+ -std::pow((float)(floatland_level - 1 - y) / float_mount_height,
float_mount_exponent);
float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
@@ -456,7 +457,7 @@ void MapgenV7::floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max,
base_max = floatland_level - (amp - ridge * 2.0f) / 2.0f;
} else {
// Hills and ridges
- float diff = fabs(amp - ridge) / ridge;
+ float diff = std::fabs(amp - ridge) / ridge;
// Smooth ridges using the 'smoothstep function'
float smooth_diff = diff * diff * (3.0f - 2.0f * diff);
base_max = floatland_level + ridge - smooth_diff * ridge;
@@ -569,7 +570,7 @@ void MapgenV7::generateRidgeTerrain()
int j = (z - node_min.Z) * csize.X + (x - node_min.X);
float uwatern = noise_ridge_uwater->result[j] * 2;
- if (fabs(uwatern) > width)
+ if (std::fabs(uwatern) > width)
continue;
float altitude = y - water_level;