mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Fix various clang-tidy reported performance-type-promotion-in-math-fn
This commit is contained in:
parent
baca933b6b
commit
67a4cb7d8a
@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
|
#include <cmath>
|
||||||
#include "mapblock.h"
|
#include "mapblock.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
@ -564,7 +565,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
|
|||||||
box.MinEdge += *pos_f;
|
box.MinEdge += *pos_f;
|
||||||
box.MaxEdge += *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;
|
result.touching_ground = true;
|
||||||
|
|
||||||
if (box_info.is_object)
|
if (box_info.is_object)
|
||||||
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "genericobject.h"
|
#include "genericobject.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
std::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
|
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);
|
float move_d = m_base_position.getDistanceFrom(m_last_sent_position);
|
||||||
move_d += m_last_sent_move_precision;
|
move_d += m_last_sent_move_precision;
|
||||||
float vel_d = m_velocity.getDistanceFrom(m_last_sent_velocity);
|
float vel_d = m_velocity.getDistanceFrom(m_last_sent_velocity);
|
||||||
if(move_d > minchange || vel_d > minchange ||
|
if (move_d > minchange || vel_d > minchange ||
|
||||||
fabs(m_yaw - m_last_sent_yaw) > 1.0){
|
std::fabs(m_yaw - m_last_sent_yaw) > 1.0) {
|
||||||
sendPosition(true, false);
|
sendPosition(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,11 +347,11 @@ float MapgenCarpathian::terrainLevelAtPoint(s16 x, s16 z)
|
|||||||
|
|
||||||
// Ridged mountains
|
// Ridged mountains
|
||||||
float ridge_mnt = hilliness * (1.f - std::fabs(n_ridge_mnt));
|
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
|
// Step (terraced) mountains
|
||||||
float step_mnt = hilliness * getSteps(n_step_mnt);
|
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
|
// Final terrain level
|
||||||
float mountains = hills + ridged_mountains + step_mountains;
|
float mountains = hills + ridged_mountains + step_mountains;
|
||||||
|
@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "content_sao.h"
|
#include "content_sao.h"
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "voxelalgorithms.h"
|
#include "voxelalgorithms.h"
|
||||||
//#include "profiler.h" // For TimeTaker
|
|
||||||
#include "settings.h" // For g_settings
|
#include "settings.h" // For g_settings
|
||||||
#include "emerge.h"
|
#include "emerge.h"
|
||||||
#include "dungeongen.h"
|
#include "dungeongen.h"
|
||||||
@ -575,7 +574,7 @@ void MapgenV7::generateRidgeTerrain()
|
|||||||
|
|
||||||
float altitude = y - water_level;
|
float altitude = y - water_level;
|
||||||
float height_mod = (altitude + 17) / 2.5;
|
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;
|
float nridge = noise_ridge->result[index] * MYMAX(altitude, 0) / 7.0;
|
||||||
|
|
||||||
if (nridge + width_mod * height_mod < 0.6)
|
if (nridge + width_mod * height_mod < 0.6)
|
||||||
|
@ -433,7 +433,7 @@ int MapgenValleys::getSpawnLevelAtPoint(v2s16 p)
|
|||||||
{
|
{
|
||||||
// Check to make sure this isn't a request for a location in a river.
|
// 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);
|
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
|
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
|
||||||
|
|
||||||
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
|
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
|
||||||
|
@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "serveractiveobjectmap.h"
|
#include "serveractiveobjectmap.h"
|
||||||
|
#include <cmath>
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "serverobject.h"
|
#include "serverobject.h"
|
||||||
@ -27,12 +28,12 @@ static constexpr float granularity = 16.0 * BS;
|
|||||||
static aabb3s16 calcBox(const aabb3f &cb)
|
static aabb3s16 calcBox(const aabb3f &cb)
|
||||||
{
|
{
|
||||||
return aabb3s16(
|
return aabb3s16(
|
||||||
floor(cb.MinEdge.X / granularity),
|
std::floor(cb.MinEdge.X / granularity),
|
||||||
floor(cb.MinEdge.Y / granularity),
|
std::floor(cb.MinEdge.Y / granularity),
|
||||||
floor(cb.MinEdge.Z / granularity),
|
std::floor(cb.MinEdge.Z / granularity),
|
||||||
ceil(cb.MaxEdge.X / granularity),
|
std::ceil(cb.MaxEdge.X / granularity),
|
||||||
ceil(cb.MaxEdge.Y / granularity),
|
std::ceil(cb.MaxEdge.Y / granularity),
|
||||||
ceil(cb.MaxEdge.Z / granularity));
|
std::ceil(cb.MaxEdge.Z / granularity));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerActiveObjectMap::addObject(ServerActiveObject *object)
|
void ServerActiveObjectMap::addObject(ServerActiveObject *object)
|
||||||
|
@ -119,7 +119,8 @@ void TestUtilities::testAngleWrapAround()
|
|||||||
UASSERT(std::fabs(modulo360f(f) - fmodf(f, 360)) < 0.001);
|
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_180(f) - ref_WrapDegrees180(f)) < 0.001);
|
||||||
UASSERT(std::fabs(wrapDegrees_0_360(f) - ref_WrapDegrees_0_360(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +172,6 @@ s16 adjustDist(s16 dist, float zoom_fov)
|
|||||||
return dist;
|
return dist;
|
||||||
|
|
||||||
// new_dist = dist * ((1 - cos(FOV / 2)) / (1-cos(zoomFOV /2))) ^ (1/3)
|
// new_dist = dist * ((1 - cos(FOV / 2)) / (1-cos(zoomFOV /2))) ^ (1/3)
|
||||||
return round(dist * cbrt((1.0f - cos(default_fov / 2.0f)) /
|
return round(dist * cbrt((1.0f - std::cos(default_fov / 2.0f)) /
|
||||||
(1.0f - cos(zoom_fov / 2.0f))));
|
(1.0f - std::cos(zoom_fov / 2.0f))));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user