diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-04-02 23:51:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 23:51:08 +0200 |
commit | 2481ea27ce0f423f3e6f3522539d20e1500cf572 (patch) | |
tree | 73251dcbf9146d7499177f59b266d8c60b0eaae7 /src/mapgen/mapgen_valleys.cpp | |
parent | e98fd934ce17a7af0b4629fc88158373303c88a0 (diff) | |
download | hax-minetest-server-2481ea27ce0f423f3e6f3522539d20e1500cf572.tar.gz hax-minetest-server-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_valleys.cpp')
-rw-r--r-- | src/mapgen/mapgen_valleys.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp index 5fd3455a6..54643583b 100644 --- a/src/mapgen/mapgen_valleys.cpp +++ b/src/mapgen/mapgen_valleys.cpp @@ -366,7 +366,7 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn) float base = tn->terrain_height + valley_d; // "river" represents the distance from the river, in arbitrary units. - float river = fabs(*tn->rivers) - river_size_factor; + float river = std::fabs(*tn->rivers) - river_size_factor; // Use the curve of the function 1-exp(-(x/a)^2) to model valleys. // Making "a" vary (0 < a <= 1) changes the shape of the valleys. @@ -375,7 +375,7 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn) // "valley" represents the height of the terrain, from the rivers. { float t = std::fmax(river / tn->valley_profile, 0.0f); - *tn->valley = valley_d * (1.f - exp(- MYSQUARE(t))); + *tn->valley = valley_d * (1.f - std::exp(- MYSQUARE(t))); } // approximate height of the terrain at this point @@ -392,7 +392,7 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn) float depth; { float t = river / river_size_factor + 1; - depth = (river_depth_bed * sqrt(MYMAX(0, 1.f - MYSQUARE(t)))); + depth = (river_depth_bed * std::sqrt(MYMAX(0, 1.f - MYSQUARE(t)))); } // base - depth : height of the bottom of the river @@ -496,7 +496,7 @@ int MapgenValleys::generateTerrain() heightmap[index_2d] = -MAX_MAP_GENERATION_LIMIT; if (surface_y > surface_max_y) - surface_max_y = ceil(surface_y); + surface_max_y = std::ceil(surface_y); if (humid_rivers) { // Derive heat from (base) altitude. This will be most correct @@ -562,7 +562,7 @@ int MapgenValleys::generateTerrain() float t_alt = MYMAX(noise_rivers->result[index_2d], (float)heightmap[index_2d]); float humid = m_bgen->humidmap[index_2d]; float water_depth = (t_alt - river_y) / humidity_dropoff; - humid *= 1.f + pow(0.5f, MYMAX(water_depth, 1.f)); + humid *= 1.f + std::pow(0.5f, MYMAX(water_depth, 1.f)); // Reduce humidity with altitude (ignoring riverbeds). // This is similar to the lua version's seawater adjustment, @@ -637,11 +637,12 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth) // lava_depth varies between one and ten as you approach // the bottom of the world. - s16 lava_depth = ceil((lava_max_height - node_min.Y + 1) * 10.f / mapgen_limit); + s16 lava_depth = std::ceil((lava_max_height - node_min.Y + 1) * 10.f / mapgen_limit); // This allows random lava spawns to be less common at the surface. s16 lava_chance = MYCUBE(lava_features_lim) * lava_depth; // water_depth varies between ten and one on the way down. - s16 water_depth = ceil((mapgen_limit - abs(node_min.Y) + 1) * 10.f / mapgen_limit); + s16 water_depth = std::ceil((mapgen_limit - std::abs(node_min.Y) + 1) * 10.f / + mapgen_limit); // This allows random water spawns to be more common at the surface. s16 water_chance = MYCUBE(water_features_lim) * water_depth; |