Fix clang-tidy type promotion errors

This commit is contained in:
sfan5 2024-02-24 00:07:46 +01:00
parent 229389b7f6
commit 9fcd7f2dc0
10 changed files with 20 additions and 17 deletions

@ -182,7 +182,7 @@ void ClientEnvironment::step(float dtime)
Stuff that has a maximum time increment Stuff that has a maximum time increment
*/ */
u32 steps = ceil(dtime / dtime_max_increment); u32 steps = std::ceil(dtime / dtime_max_increment);
f32 dtime_part = dtime / steps; f32 dtime_part = dtime / steps;
for (; steps > 0; --steps) { for (; steps > 0; --steps) {
/* /*

@ -1305,7 +1305,7 @@ void ClientMap::updateTransparentMeshBuffers()
ScopeProfiler sp(g_profiler, "CM::updateTransparentMeshBuffers", SPT_AVG); ScopeProfiler sp(g_profiler, "CM::updateTransparentMeshBuffers", SPT_AVG);
u32 sorted_blocks = 0; u32 sorted_blocks = 0;
u32 unsorted_blocks = 0; u32 unsorted_blocks = 0;
f32 sorting_distance_sq = pow(m_cache_transparency_sorting_distance * BS, 2.0f); f32 sorting_distance_sq = std::pow(m_cache_transparency_sorting_distance * BS, 2.0f);
// Update the order of transparent mesh buffers in each mesh // Update the order of transparent mesh buffers in each mesh

@ -1216,7 +1216,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
} }
} }
if (node && fabs(m_prop.automatic_rotate) > 0.001f) { if (node && std::abs(m_prop.automatic_rotate) > 0.001f) {
// This is the child node's rotation. It is only used for automatic_rotate. // This is the child node's rotation. It is only used for automatic_rotate.
v3f local_rot = node->getRotation(); v3f local_rot = node->getRotation();
local_rot.Y = modulo360f(local_rot.Y - dtime * core::RADTODEG * local_rot.Y = modulo360f(local_rot.Y - dtime * core::RADTODEG *

@ -2648,7 +2648,7 @@ f32 Game::getSensitivityScaleFactor() const
// Multiply by a constant such that it becomes 1.0 at 72 degree FOV and // Multiply by a constant such that it becomes 1.0 at 72 degree FOV and
// 16:9 aspect ratio to minimize disruption of existing sensitivity // 16:9 aspect ratio to minimize disruption of existing sensitivity
// settings. // settings.
return tan(fov_y / 2.0f) * 1.3763818698f; return std::tan(fov_y / 2.0f) * 1.3763819f;
} }
void Game::updateCameraOrientation(CameraOrientation *cam, float dtime) void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
@ -2711,8 +2711,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
client->activeObjectsReceived() && !player->isDead()) { client->activeObjectsReceived() && !player->isDead()) {
control.movement_speed = 1.0f; control.movement_speed = 1.0f;
// sideways movement only // sideways movement only
float dx = sin(control.movement_direction); float dx = std::sin(control.movement_direction);
control.movement_direction = atan2(dx, 1.0f); control.movement_direction = std::atan2(dx, 1.0f);
} }
/* For touch, simulate holding down AUX1 (fast move) if the user has /* For touch, simulate holding down AUX1 (fast move) if the user has
@ -4250,14 +4250,14 @@ void Game::updateShadows()
if (!shadow) if (!shadow)
return; return;
float in_timeofday = fmod(runData.time_of_day_smooth, 1.0f); float in_timeofday = std::fmod(runData.time_of_day_smooth, 1.0f);
float timeoftheday = getWickedTimeOfDay(in_timeofday); float timeoftheday = getWickedTimeOfDay(in_timeofday);
bool is_day = timeoftheday > 0.25 && timeoftheday < 0.75; bool is_day = timeoftheday > 0.25 && timeoftheday < 0.75;
bool is_shadow_visible = is_day ? sky->getSunVisible() : sky->getMoonVisible(); bool is_shadow_visible = is_day ? sky->getSunVisible() : sky->getMoonVisible();
shadow->setShadowIntensity(is_shadow_visible ? client->getEnv().getLocalPlayer()->getLighting().shadow_intensity : 0.0f); shadow->setShadowIntensity(is_shadow_visible ? client->getEnv().getLocalPlayer()->getLighting().shadow_intensity : 0.0f);
timeoftheday = fmod(timeoftheday + 0.75f, 0.5f) + 0.25f; timeoftheday = std::fmod(timeoftheday + 0.75f, 0.5f) + 0.25f;
const float offset_constant = 10000.0f; const float offset_constant = 10000.0f;
v3f light = is_day ? sky->getSunDirection() : sky->getMoonDirection(); v3f light = is_day ? sky->getSunDirection() : sky->getMoonDirection();

@ -318,12 +318,14 @@ float JoystickController::getAxisWithoutDead(JoystickAxis axis)
float JoystickController::getMovementDirection() float JoystickController::getMovementDirection()
{ {
return atan2(getAxisWithoutDead(JA_SIDEWARD_MOVE), -getAxisWithoutDead(JA_FORWARD_MOVE)); return std::atan2(getAxisWithoutDead(JA_SIDEWARD_MOVE),
-getAxisWithoutDead(JA_FORWARD_MOVE));
} }
float JoystickController::getMovementSpeed() float JoystickController::getMovementSpeed()
{ {
float speed = sqrt(pow(getAxisWithoutDead(JA_FORWARD_MOVE), 2) + pow(getAxisWithoutDead(JA_SIDEWARD_MOVE), 2)); float speed = std::sqrt(std::pow(getAxisWithoutDead(JA_FORWARD_MOVE), 2) +
std::pow(getAxisWithoutDead(JA_SIDEWARD_MOVE), 2));
if (speed > 1.0f) if (speed > 1.0f)
speed = 1.0f; speed = 1.0f;
return speed; return speed;

@ -600,7 +600,8 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
} }
} }
speedH = v3f(sin(control.movement_direction), 0.0f, cos(control.movement_direction)); speedH = v3f(std::sin(control.movement_direction), 0.0f,
std::cos(control.movement_direction));
if (m_autojump) { if (m_autojump) {
// release autojump after a given time // release autojump after a given time

@ -171,8 +171,8 @@ f32 ShadowRenderer::getMaxShadowFar() const
void ShadowRenderer::setShadowIntensity(float shadow_intensity) void ShadowRenderer::setShadowIntensity(float shadow_intensity)
{ {
m_shadow_strength = pow(shadow_intensity, 1.0f / m_shadow_strength_gamma); m_shadow_strength = std::pow(shadow_intensity, 1.0f / m_shadow_strength_gamma);
if (m_shadow_strength > 1E-2) if (m_shadow_strength > 1e-2f)
enable(); enable();
else else
disable(); disable();

@ -680,7 +680,7 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day)
float tod = wicked_time_of_day < 0.5f ? wicked_time_of_day : (1.0f - wicked_time_of_day); float tod = wicked_time_of_day < 0.5f ? wicked_time_of_day : (1.0f - wicked_time_of_day);
float day_opacity = clamp(m_star_params.day_opacity, 0.0f, 1.0f); float day_opacity = clamp(m_star_params.day_opacity, 0.0f, 1.0f);
float starbrightness = (0.25f - fabs(tod)) * 20.0f; float starbrightness = (0.25f - std::abs(tod)) * 20.0f;
float alpha = clamp(starbrightness, day_opacity, 1.0f); float alpha = clamp(starbrightness, day_opacity, 1.0f);
m_star_color = m_star_params.starcolor; m_star_color = m_star_params.starcolor;

@ -203,7 +203,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
} }
} }
if (fabs(m_prop.automatic_rotate) > 0.001f) { if (std::abs(m_prop.automatic_rotate) > 0.001f) {
m_rotation_add_yaw = modulo360f(m_rotation_add_yaw + dtime * core::RADTODEG * m_rotation_add_yaw = modulo360f(m_rotation_add_yaw + dtime * core::RADTODEG *
m_prop.automatic_rotate); m_prop.automatic_rotate);
} }

@ -31,11 +31,11 @@ void TileAnimationParams::serialize(std::ostream &os, u16 protocol_ver) const
if (type == TAT_VERTICAL_FRAMES) { if (type == TAT_VERTICAL_FRAMES) {
writeU16(os, vertical_frames.aspect_w); writeU16(os, vertical_frames.aspect_w);
writeU16(os, vertical_frames.aspect_h); writeU16(os, vertical_frames.aspect_h);
writeF32(os, need_abs ? fabs(vertical_frames.length) : vertical_frames.length); writeF32(os, need_abs ? std::abs(vertical_frames.length) : vertical_frames.length);
} else if (type == TAT_SHEET_2D) { } else if (type == TAT_SHEET_2D) {
writeU8(os, sheet_2d.frames_w); writeU8(os, sheet_2d.frames_w);
writeU8(os, sheet_2d.frames_h); writeU8(os, sheet_2d.frames_h);
writeF32(os, need_abs ? fabs(sheet_2d.frame_length) : sheet_2d.frame_length); writeF32(os, need_abs ? std::abs(sheet_2d.frame_length) : sheet_2d.frame_length);
} }
} }