From a4c120764a26311d05e3f7d167dfd4859371119d Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 23 Oct 2015 16:01:22 +0200 Subject: [PATCH] Ball rotation fix --- src/game/Game/BallSystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/Game/BallSystem.cpp b/src/game/Game/BallSystem.cpp index b669b45..ad95ff4 100644 --- a/src/game/Game/BallSystem.cpp +++ b/src/game/Game/BallSystem.cpp @@ -216,7 +216,8 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID auto transform = m_World->GetComponent(entity); glm::vec2 dir = glm::normalize(glm::vec2(transform->Velocity.x, transform->Velocity.y)); glm::vec2 up = glm::vec2(0.f, 1.f); - float angle = glm::acos(glm::dot(dir, up)) * glm::sign(dir.x); + + float angle = atan2(dir.x, dir.y); transform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f)); } }