aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Blot <loic.blot@unix-experience.fr>2018-04-03 18:16:17 +0200
committerLoïc Blot <loic.blot@unix-experience.fr>2018-04-03 18:16:17 +0200
commit67a4cb7d8a4461fe7d5206189fd4e9539beb20b7 (patch)
tree059f4bea1f880c297a54b02d8f8e99bb77d1359f
parentbaca933b6bcf8c321748defa19769a54b27a89ba (diff)
downloadminetest-67a4cb7d8a4461fe7d5206189fd4e9539beb20b7.tar.gz
minetest-67a4cb7d8a4461fe7d5206189fd4e9539beb20b7.tar.bz2
minetest-67a4cb7d8a4461fe7d5206189fd4e9539beb20b7.zip
Fix various clang-tidy reported performance-type-promotion-in-math-fn
-rw-r--r--src/collision.cpp3
-rw-r--r--src/content_sao.cpp5
-rw-r--r--src/mapgen/mapgen_carpathian.cpp4
-rw-r--r--src/mapgen/mapgen_v7.cpp3
-rw-r--r--src/mapgen/mapgen_valleys.cpp2
-rw-r--r--src/server/serveractiveobjectmap.cpp13
-rw-r--r--src/unittest/test_utilities.cpp3
-rw-r--r--src/util/numeric.cpp4
8 files changed, 20 insertions, 17 deletions
diff --git a/src/collision.cpp b/src/collision.cpp
index 24d22e825..e966ad19d 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "collision.h"
+#include <cmath>
#include "mapblock.h"
#include "map.h"
#include "nodedef.h"
@@ -564,7 +565,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
box.MinEdge += *pos_f;
box.MaxEdge += *pos_f;
}
- if (fabs(cbox.MaxEdge.Y - box.MinEdge.Y) < 0.15f * BS) {
+ if (std::fabs(cbox.MaxEdge.Y - box.MinEdge.Y) < 0.15f * BS) {
result.touching_ground = true;
if (box_info.is_object)
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 0e0c19fce..8f77d54c4 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "genericobject.h"
#include "settings.h"
#include <algorithm>
+#include <cmath>
std::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
@@ -411,8 +412,8 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
float move_d = m_base_position.getDistanceFrom(m_last_sent_position);
move_d += m_last_sent_move_precision;
float vel_d = m_velocity.getDistanceFrom(m_last_sent_velocity);
- if(move_d > minchange || vel_d > minchange ||
- fabs(m_yaw - m_last_sent_yaw) > 1.0){
+ if (move_d > minchange || vel_d > minchange ||
+ std::fabs(m_yaw - m_last_sent_yaw) > 1.0) {
sendPosition(true, false);
}
}
diff --git a/src/mapgen/mapgen_carpathian.cpp b/src/mapgen/mapgen_carpathian.cpp
index db276ffba..1e12eafc3 100644
--- a/src/mapgen/mapgen_carpathian.cpp
+++ b/src/mapgen/mapgen_carpathian.cpp
@@ -347,11 +347,11 @@ float MapgenCarpathian::terrainLevelAtPoint(s16 x, s16 z)
// Ridged mountains
float ridge_mnt = hilliness * (1.f - std::fabs(n_ridge_mnt));
- float ridged_mountains = pow(rter, 3.f) * ridge_mnt;
+ float ridged_mountains = std::pow(rter, 3.f) * ridge_mnt;
// Step (terraced) mountains
float step_mnt = hilliness * getSteps(n_step_mnt);
- float step_mountains = pow(ster, 3.f) * step_mnt;
+ float step_mountains = std::pow(ster, 3.f) * step_mnt;
// Final terrain level
float mountains = hills + ridged_mountains + step_mountains;
diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp
index fba2defef..a99a50f29 100644
--- a/src/mapgen/mapgen_v7.cpp
+++ b/src/mapgen/mapgen_v7.cpp
@@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
-//#include "profiler.h" // For TimeTaker
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
@@ -575,7 +574,7 @@ void MapgenV7::generateRidgeTerrain()
float altitude = y - water_level;
float height_mod = (altitude + 17) / 2.5;
- float width_mod = width - fabs(uwatern);
+ float width_mod = width - std::fabs(uwatern);
float nridge = noise_ridge->result[index] * MYMAX(altitude, 0) / 7.0;
if (nridge + width_mod * height_mod < 0.6)
diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp
index 54643583b..bef4629a8 100644
--- a/src/mapgen/mapgen_valleys.cpp
+++ b/src/mapgen/mapgen_valleys.cpp
@@ -433,7 +433,7 @@ int MapgenValleys::getSpawnLevelAtPoint(v2s16 p)
{
// Check to make sure this isn't a request for a location in a river.
float rivers = NoisePerlin2D(&noise_rivers->np, p.X, p.Y, seed);
- if (fabs(rivers) < river_size_factor)
+ if (std::fabs(rivers) < river_size_factor)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
diff --git a/src/server/serveractiveobjectmap.cpp b/src/server/serveractiveobjectmap.cpp
index e2def776d..ac89d5d18 100644
--- a/src/server/serveractiveobjectmap.cpp
+++ b/src/server/serveractiveobjectmap.cpp
@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "serveractiveobjectmap.h"
+#include <cmath>
#include "constants.h"
#include "log.h"
#include "serverobject.h"
@@ -27,12 +28,12 @@ static constexpr float granularity = 16.0 * BS;
static aabb3s16 calcBox(const aabb3f &cb)
{
return aabb3s16(
- floor(cb.MinEdge.X / granularity),
- floor(cb.MinEdge.Y / granularity),
- floor(cb.MinEdge.Z / granularity),
- ceil(cb.MaxEdge.X / granularity),
- ceil(cb.MaxEdge.Y / granularity),
- ceil(cb.MaxEdge.Z / granularity));
+ std::floor(cb.MinEdge.X / granularity),
+ std::floor(cb.MinEdge.Y / granularity),
+ std::floor(cb.MinEdge.Z / granularity),
+ std::ceil(cb.MaxEdge.X / granularity),
+ std::ceil(cb.MaxEdge.Y / granularity),
+ std::ceil(cb.MaxEdge.Z / granularity));
}
void ServerActiveObjectMap::addObject(ServerActiveObject *object)
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp
index 95c34a9c7..315cbf0fc 100644
--- a/src/unittest/test_utilities.cpp
+++ b/src/unittest/test_utilities.cpp
@@ -119,7 +119,8 @@ void TestUtilities::testAngleWrapAround()
UASSERT(std::fabs(modulo360f(f) - fmodf(f, 360)) < 0.001);
UASSERT(std::fabs(wrapDegrees_180(f) - ref_WrapDegrees180(f)) < 0.001);
UASSERT(std::fabs(wrapDegrees_0_360(f) - ref_WrapDegrees_0_360(f)) < 0.001);
- UASSERT(wrapDegrees_0_360(fabs(wrapDegrees_180(f) - wrapDegrees_0_360(f))) < 0.001);
+ UASSERT(wrapDegrees_0_360(
+ std::fabs(wrapDegrees_180(f) - wrapDegrees_0_360(f))) < 0.001);
}
}
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp
index 12c91be91..cb984d8cb 100644
--- a/src/util/numeric.cpp
+++ b/src/util/numeric.cpp
@@ -172,6 +172,6 @@ s16 adjustDist(s16 dist, float zoom_fov)
return dist;
// new_dist = dist * ((1 - cos(FOV / 2)) / (1-cos(zoomFOV /2))) ^ (1/3)
- return round(dist * cbrt((1.0f - cos(default_fov / 2.0f)) /
- (1.0f - cos(zoom_fov / 2.0f))));
+ return round(dist * cbrt((1.0f - std::cos(default_fov / 2.0f)) /
+ (1.0f - std::cos(zoom_fov / 2.0f))));
}