From bdfa30729fd65a6e237be4c33c2f29fce1becc18 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Tue, 16 Aug 2016 18:53:35 +0200 Subject: [PATCH] Replace uses of cmath constants by glm --- rwengine/CMakeLists.txt | 4 ---- rwengine/src/render/GameRenderer.cpp | 11 ++++------- rwgame/CMakeLists.txt | 1 - rwgame/DrawUI.cpp | 6 ++---- rwgame/states/IngameState.cpp | 3 ++- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index 147a05b2..f63ad3f5 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -140,10 +140,6 @@ add_library(rwengine ${RWENGINE_SOURCES} ) -if(MINGW) - add_definitions(-D _USE_MATH_DEFINES) -endif() - target_link_libraries(rwengine rwlib ${MAD_LIBRARY} diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index 95ce2dd3..92bbaef9 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -1,6 +1,3 @@ -#define _USE_MATH_DEFINES -#include - #include #include #include @@ -26,7 +23,7 @@ #include #include -#include +#include #include #include @@ -163,9 +160,9 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data) for( size_t r = 0, i = 0; r < rows; ++r) { for( size_t s = 0; s < segments; ++s) { skydomeVerts[i++].position = glm::vec3( - cos(2.f * M_PI * s * S) * cos(M_PI_2 * r * R), - sin(2.f * M_PI * s * S) * cos(M_PI_2 * r * R), - sin(M_PI_2 * r * R) + cos(2.f * glm::pi() * s * S) * cos(glm::half_pi() * r * R), + sin(2.f * glm::pi() * s * S) * cos(glm::half_pi() * r * R), + sin(glm::half_pi() * r * R) ); } } diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index 7e44019c..c0430e64 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -50,7 +50,6 @@ target_link_libraries(rwgame ${SDL2_LIBRARY} ) if(MINGW) - add_definitions(-D _USE_MATH_DEFINES) target_link_libraries(rwgame mman) endif() diff --git a/rwgame/DrawUI.cpp b/rwgame/DrawUI.cpp index 41491287..70ebdfdc 100644 --- a/rwgame/DrawUI.cpp +++ b/rwgame/DrawUI.cpp @@ -1,6 +1,3 @@ -#define _USE_MATH_DEFINES -#include - #include "DrawUI.hpp" #include #include @@ -8,6 +5,7 @@ #include #include +#include #include constexpr size_t ui_textSize = 25; @@ -34,7 +32,7 @@ void drawMap(ViewCamera& currentView, PlayerController* player, GameWorld* worl glm::quat camRot = currentView.rotation; - map.rotation = glm::roll(camRot) - M_PI/2.f; + map.rotation = glm::roll(camRot) - glm::half_pi(); map.worldSize = ui_worldSizeMin; map.worldSize = ui_worldSizeMax; if( player ) diff --git a/rwgame/states/IngameState.cpp b/rwgame/states/IngameState.cpp index 06289ca8..09557fbc 100644 --- a/rwgame/states/IngameState.cpp +++ b/rwgame/states/IngameState.cpp @@ -16,6 +16,7 @@ #include