mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-26 04:12:41 +01:00
Replace uses of cmath constants by glm
This commit is contained in:
parent
772876afdb
commit
bdfa30729f
@ -140,10 +140,6 @@ add_library(rwengine
|
|||||||
${RWENGINE_SOURCES}
|
${RWENGINE_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MINGW)
|
|
||||||
add_definitions(-D _USE_MATH_DEFINES)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(rwengine
|
target_link_libraries(rwengine
|
||||||
rwlib
|
rwlib
|
||||||
${MAD_LIBRARY}
|
${MAD_LIBRARY}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#define _USE_MATH_DEFINES
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <render/GameRenderer.hpp>
|
#include <render/GameRenderer.hpp>
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
#include <engine/Animator.hpp>
|
#include <engine/Animator.hpp>
|
||||||
@ -26,7 +23,7 @@
|
|||||||
#include <core/Logger.hpp>
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <cmath>
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
@ -163,9 +160,9 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
|||||||
for( size_t r = 0, i = 0; r < rows; ++r) {
|
for( size_t r = 0, i = 0; r < rows; ++r) {
|
||||||
for( size_t s = 0; s < segments; ++s) {
|
for( size_t s = 0; s < segments; ++s) {
|
||||||
skydomeVerts[i++].position = glm::vec3(
|
skydomeVerts[i++].position = glm::vec3(
|
||||||
cos(2.f * M_PI * s * S) * cos(M_PI_2 * r * R),
|
cos(2.f * glm::pi<float>() * s * S) * cos(glm::half_pi<float>() * r * R),
|
||||||
sin(2.f * M_PI * s * S) * cos(M_PI_2 * r * R),
|
sin(2.f * glm::pi<float>() * s * S) * cos(glm::half_pi<float>() * r * R),
|
||||||
sin(M_PI_2 * r * R)
|
sin(glm::half_pi<float>() * r * R)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ target_link_libraries(rwgame
|
|||||||
${SDL2_LIBRARY}
|
${SDL2_LIBRARY}
|
||||||
)
|
)
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
add_definitions(-D _USE_MATH_DEFINES)
|
|
||||||
target_link_libraries(rwgame
|
target_link_libraries(rwgame
|
||||||
mman)
|
mman)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#define _USE_MATH_DEFINES
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "DrawUI.hpp"
|
#include "DrawUI.hpp"
|
||||||
#include <render/GameRenderer.hpp>
|
#include <render/GameRenderer.hpp>
|
||||||
#include <ai/PlayerController.hpp>
|
#include <ai/PlayerController.hpp>
|
||||||
@ -8,6 +5,7 @@
|
|||||||
#include <engine/GameState.hpp>
|
#include <engine/GameState.hpp>
|
||||||
#include <items/WeaponItem.hpp>
|
#include <items/WeaponItem.hpp>
|
||||||
|
|
||||||
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
constexpr size_t ui_textSize = 25;
|
constexpr size_t ui_textSize = 25;
|
||||||
@ -34,7 +32,7 @@ void drawMap(ViewCamera& currentView, PlayerController* player, GameWorld* worl
|
|||||||
|
|
||||||
glm::quat camRot = currentView.rotation;
|
glm::quat camRot = currentView.rotation;
|
||||||
|
|
||||||
map.rotation = glm::roll(camRot) - M_PI/2.f;
|
map.rotation = glm::roll(camRot) - glm::half_pi<float>();
|
||||||
map.worldSize = ui_worldSizeMin;
|
map.worldSize = ui_worldSizeMin;
|
||||||
map.worldSize = ui_worldSizeMax;
|
map.worldSize = ui_worldSizeMax;
|
||||||
if( player )
|
if( player )
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <script/ScriptMachine.hpp>
|
#include <script/ScriptMachine.hpp>
|
||||||
#include <dynamics/RaycastCallbacks.hpp>
|
#include <dynamics/RaycastCallbacks.hpp>
|
||||||
|
|
||||||
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
constexpr float kAutoLookTime = 2.f;
|
constexpr float kAutoLookTime = 2.f;
|
||||||
@ -343,7 +344,7 @@ void IngameState::tick(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float length = glm::length(movement);
|
float length = glm::length(movement);
|
||||||
float movementAngle = angleYaw - M_PI/2.f;
|
float movementAngle = angleYaw - glm::half_pi<float>();
|
||||||
if (length > 0.1f)
|
if (length > 0.1f)
|
||||||
{
|
{
|
||||||
glm::vec3 direction = glm::normalize(movement);
|
glm::vec3 direction = glm::normalize(movement);
|
||||||
|
Loading…
Reference in New Issue
Block a user