summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2018-04-03 21:58:29 +0200
committerLoic Blot <loic.blot@unix-experience.fr>2018-04-03 21:58:29 +0200
commit4827f754ec9efc1e1fa8e519eaa211ed768e25c0 (patch)
tree182f2e12267fb2a282df17b95fbcff1750f47fca
parent67a4cb7d8a4461fe7d5206189fd4e9539beb20b7 (diff)
downloadminetest-4827f754ec9efc1e1fa8e519eaa211ed768e25c0.tar.gz
minetest-4827f754ec9efc1e1fa8e519eaa211ed768e25c0.tar.bz2
minetest-4827f754ec9efc1e1fa8e519eaa211ed768e25c0.zip
Fix more clang-tidy reported problems for performance-type-promotion-in-math-fn
Based on https://travis-ci.org/minetest/minetest/jobs/361714253 output
-rw-r--r--src/localplayer.cpp6
-rw-r--r--src/minimap.cpp9
-rw-r--r--src/noise.cpp34
3 files changed, 25 insertions, 24 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index de200910c..de32c6f2b 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "localplayer.h"
-
+#include <cmath>
#include "event.h"
#include "collision.h"
#include "nodedef.h"
@@ -941,8 +941,8 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
v2f node_p2df(pf.X, pf.Z);
f32 distance_f = player_p2df.getDistanceFrom(node_p2df);
f32 max_axis_distance_f = MYMAX(
- fabs(player_p2df.X - node_p2df.X),
- fabs(player_p2df.Y - node_p2df.Y));
+ std::fabs(player_p2df.X - node_p2df.X),
+ std::fabs(player_p2df.Y - node_p2df.Y));
if (distance_f > min_distance_f ||
max_axis_distance_f > 0.5 * BS + sneak_max + 0.1 * BS)
diff --git a/src/minimap.cpp b/src/minimap.cpp
index 59753e246..98bb7d9c3 100644
--- a/src/minimap.cpp
+++ b/src/minimap.cpp
@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "minimap.h"
+#include <cmath>
#include "client.h"
#include "clientmap.h"
#include "settings.h"
@@ -428,8 +429,8 @@ v3f Minimap::getYawVec()
{
if (data->minimap_shape_round) {
return v3f(
- cos(m_angle * core::DEGTORAD),
- sin(m_angle * core::DEGTORAD),
+ std::cos(m_angle * core::DEGTORAD),
+ std::sin(m_angle * core::DEGTORAD),
1.0);
}
@@ -531,8 +532,8 @@ void Minimap::drawMinimap()
core::rect<s32> img_rect(0, 0, imgsize.Width, imgsize.Height);
static const video::SColor col(255, 255, 255, 255);
static const video::SColor c[4] = {col, col, col, col};
- f32 sin_angle = sin(m_angle * core::DEGTORAD);
- f32 cos_angle = cos(m_angle * core::DEGTORAD);
+ f32 sin_angle = std::sin(m_angle * core::DEGTORAD);
+ f32 cos_angle = std::cos(m_angle * core::DEGTORAD);
s32 marker_size2 = 0.025 * (float)size;
for (std::list<v2f>::const_iterator
i = m_active_markers.begin();
diff --git a/src/noise.cpp b/src/noise.cpp
index 8b84803b3..255d3faee 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -324,7 +324,7 @@ float noise2d_perlin_abs(float x, float y, s32 seed,
float f = 1.0;
float g = 1.0;
for (int i = 0; i < octaves; i++) {
- a += g * fabs(noise2d_gradient(x * f, y * f, seed + i, eased));
+ a += g * std::fabs(noise2d_gradient(x * f, y * f, seed + i, eased));
f *= 2.0;
g *= persistence;
}
@@ -354,7 +354,7 @@ float noise3d_perlin_abs(float x, float y, float z, s32 seed,
float f = 1.0;
float g = 1.0;
for (int i = 0; i < octaves; i++) {
- a += g * fabs(noise3d_gradient(x * f, y * f, z * f, seed + i, eased));
+ a += g * std::fabs(noise3d_gradient(x * f, y * f, z * f, seed + i, eased));
f *= 2.0;
g *= persistence;
}
@@ -364,7 +364,7 @@ float noise3d_perlin_abs(float x, float y, float z, s32 seed,
float contour(float v)
{
- v = fabs(v);
+ v = std::fabs(v);
if (v >= 1.0)
return 0.0;
return (1.0 - v);
@@ -389,7 +389,7 @@ float NoisePerlin2D(NoiseParams *np, float x, float y, s32 seed)
np->flags & (NOISE_FLAG_DEFAULTS | NOISE_FLAG_EASED));
if (np->flags & NOISE_FLAG_ABSVALUE)
- noiseval = fabs(noiseval);
+ noiseval = std::fabs(noiseval);
a += g * noiseval;
f *= np->lacunarity;
@@ -416,7 +416,7 @@ float NoisePerlin3D(NoiseParams *np, float x, float y, float z, s32 seed)
np->flags & NOISE_FLAG_EASED);
if (np->flags & NOISE_FLAG_ABSVALUE)
- noiseval = fabs(noiseval);
+ noiseval = std::fabs(noiseval);
a += g * noiseval;
f *= np->lacunarity;
@@ -522,9 +522,9 @@ void Noise::resizeNoiseBuf(bool is3d)
// + 2 for the two initial endpoints
// + 1 for potentially crossing a boundary due to offset
- size_t nlx = (size_t)ceil(num_noise_points_x) + 3;
- size_t nly = (size_t)ceil(num_noise_points_y) + 3;
- size_t nlz = is3d ? (size_t)ceil(num_noise_points_z) + 3 : 1;
+ size_t nlx = (size_t)std::ceil(num_noise_points_x) + 3;
+ size_t nly = (size_t)std::ceil(num_noise_points_y) + 3;
+ size_t nlz = is3d ? (size_t)std::ceil(num_noise_points_z) + 3 : 1;
delete[] noise_buf;
try {
@@ -561,8 +561,8 @@ void Noise::gradientMap2D(
Interp2dFxn interpolate = eased ?
biLinearInterpolation : biLinearInterpolationNoEase;
- x0 = floor(x);
- y0 = floor(y);
+ x0 = std::floor(x);
+ y0 = std::floor(y);
u = x - (float)x0;
v = y - (float)y0;
orig_u = u;
@@ -626,9 +626,9 @@ void Noise::gradientMap3D(
Interp3dFxn interpolate = (np.flags & NOISE_FLAG_EASED) ?
triLinearInterpolation : triLinearInterpolationNoEase;
- x0 = floor(x);
- y0 = floor(y);
- z0 = floor(z);
+ x0 = std::floor(x);
+ y0 = std::floor(y);
+ z0 = std::floor(z);
u = x - (float)x0;
v = y - (float)y0;
w = z - (float)z0;
@@ -730,7 +730,7 @@ float *Noise::perlinMap2D(float x, float y, float *persistence_map)
g *= np.persist;
}
- if (fabs(np.offset - 0.f) > 0.00001 || fabs(np.scale - 1.f) > 0.00001) {
+ if (std::fabs(np.offset - 0.f) > 0.00001 || std::fabs(np.scale - 1.f) > 0.00001) {
for (size_t i = 0; i != bufsize; i++)
result[i] = result[i] * np.scale + np.offset;
}
@@ -768,7 +768,7 @@ float *Noise::perlinMap3D(float x, float y, float z, float *persistence_map)
g *= np.persist;
}
- if (fabs(np.offset - 0.f) > 0.00001 || fabs(np.scale - 1.f) > 0.00001) {
+ if (std::fabs(np.offset - 0.f) > 0.00001 || std::fabs(np.scale - 1.f) > 0.00001) {
for (size_t i = 0; i != bufsize; i++)
result[i] = result[i] * np.scale + np.offset;
}
@@ -785,12 +785,12 @@ void Noise::updateResults(float g, float *gmap,
if (np.flags & NOISE_FLAG_ABSVALUE) {
if (persistence_map) {
for (size_t i = 0; i != bufsize; i++) {
- result[i] += gmap[i] * fabs(gradient_buf[i]);
+ result[i] += gmap[i] * std::fabs(gradient_buf[i]);
gmap[i] *= persistence_map[i];
}
} else {
for (size_t i = 0; i != bufsize; i++)
- result[i] += g * fabs(gradient_buf[i]);
+ result[i] += g * std::fabs(gradient_buf[i]);
}
} else {
if (persistence_map) {