Fix last clang-tidy reported problems for performance-type-promotion-in-math-fn
authorLoic Blot <loic.blot@unix-experience.fr>
Tue, 3 Apr 2018 21:05:22 +0000 (23:05 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Tue, 3 Apr 2018 21:05:22 +0000 (23:05 +0200)
Based on https://travis-ci.org/minetest/minetest/jobs/361810382 output

Also fix 2 missing copyright notices

src/client/hud.cpp
src/hud.cpp
src/script/lua_api/l_camera.cpp
src/util/numeric.cpp

index 5137c2f3e18d750ead8dcac77b738458eccaf216..fffe85e1df228af470fa6e856071370d6b297c28 100644 (file)
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "client/hud.h"
+#include <cmath>
 #include "settings.h"
 #include "util/numeric.h"
 #include "log.h"
@@ -50,7 +51,7 @@ Hud::Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
        this->inventory   = inventory;
 
        m_hud_scaling      = g_settings->getFloat("hud_scaling");
-       m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE *
+       m_hotbar_imagesize = std::floor(HOTBAR_IMAGE_SIZE *
                RenderingEngine::getDisplayDensity() + 0.5f);
        m_hotbar_imagesize *= m_hud_scaling;
        m_padding = m_hotbar_imagesize / 12;
@@ -336,7 +337,8 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
                        case HUD_ELEM_WAYPOINT: {
                                v3f p_pos = player->getPosition() / BS;
                                v3f w_pos = e->world_pos * BS;
-                               float distance = floor(10 * p_pos.getDistanceFrom(e->world_pos)) / 10;
+                               float distance = std::floor(10 * p_pos.getDistanceFrom(e->world_pos)) /
+                                       10.0f;
                                scene::ICameraSceneNode* camera =
                                        RenderingEngine::get_scene_manager()->getActiveCamera();
                                w_pos -= intToFloat(camera_offset, BS);
@@ -735,12 +737,12 @@ void drawItemStack(video::IVideoDriver *driver,
                //   wear = 0.5: yellow
                //   wear = 1.0: red
                video::SColor color(255,255,255,255);
-               int wear_i = MYMIN(floor(wear * 600), 511);
+               int wear_i = MYMIN(std::floor(wear * 600), 511);
                wear_i = MYMIN(wear_i + 10, 511);
-               if(wear_i <= 255)
+               if (wear_i <= 255)
                        color.set(255, wear_i, 255, 0);
                else
-                       color.set(255, 255, 511-wear_i, 0);
+                       color.set(255, 255, 511 - wear_i, 0);
 
                core::rect<s32> progressrect2 = progressrect;
                progressrect2.LowerRightCorner.X = progressmid;
index 0d2d092a7930f6d94213ce8b926d5ba2f24c0b59..e4a20190de27ad20409e1d1c0eb0432accc718c8 100644 (file)
@@ -1,5 +1,24 @@
-#include "hud.h"
+/*
+Minetest
+Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
 
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "hud.h"
+#include <cmath>
 
 const struct EnumString es_HudElementType[] =
 {
index 49622df00a20db178c95a7c06f65786392769068..326cc6d5304af96d34cc21cae1662f2ad52a647f 100644 (file)
@@ -1,5 +1,25 @@
-#include "script/common/c_converter.h"
+/*
+Minetest
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
 #include "l_camera.h"
+#include <cmath>
+#include "script/common/c_converter.h"
 #include "l_internal.h"
 #include "content_cao.h"
 #include "camera.h"
@@ -98,7 +118,8 @@ int LuaCamera::l_get_look_dir(lua_State *L)
 
        float pitch = -1.0 * player->getPitch() * core::DEGTORAD;
        float yaw = (player->getYaw() + 90.) * core::DEGTORAD;
-       v3f v(cos(pitch) * cos(yaw), sin(pitch), cos(pitch) * sin(yaw));
+       v3f v(std::cos(pitch) * std::cos(yaw), std::sin(pitch),
+                       std::cos(pitch) * std::sin(yaw));
 
        push_v3f(L, v);
        return 1;
index cb984d8cb5b60879f7f11bb158c2162afca11848..b88b4d5458db6742a5f3824b6e9ccf6a465c4d9a 100644 (file)
@@ -157,7 +157,7 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,
        // HOTFIX: use sligthly increased angle (+10%) to fix too agressive
        // culling. Somebody have to find out whats wrong with the math here.
        // Previous value: camera_fov / 2
-       if(cosangle < cos(camera_fov * 0.55))
+       if (cosangle < std::cos(camera_fov * 0.55f))
                return false;
 
        return true;
@@ -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 - std::cos(default_fov / 2.0f)) /
+       return round(dist * std::cbrt((1.0f - std::cos(default_fov / 2.0f)) /
                (1.0f - std::cos(zoom_fov / 2.0f))));
 }