diff --git a/include/reactive/Scene/Camera.hpp b/include/reactive/Scene/Camera.hpp index 6a05cf0..76bbe6f 100644 --- a/include/reactive/Scene/Camera.hpp +++ b/include/reactive/Scene/Camera.hpp @@ -39,7 +39,11 @@ class Camera { } } - void processKey(int key); + // キー入力は関数内で rv::Window から直接取得する + void processKey(); + + // マウス入力は rv::Window 以外で計測される場合もあるため + // 外部から引数で受け取る void processMouseDragLeft(glm::vec2 dragDelta); void processMouseDragRight(glm::vec2 dragDelta); void processMouseScroll(float scroll); diff --git a/src/Scene/Camera.cpp b/src/Scene/Camera.cpp index 7914b10..089bd0e 100644 --- a/src/Scene/Camera.cpp +++ b/src/Scene/Camera.cpp @@ -1,28 +1,29 @@ #include "Scene/Camera.hpp" #include "App.hpp" +#include "Window.hpp" #include #include namespace rv { -void Camera::processKey(int key) { +void Camera::processKey() { if (type == Type::FirstPerson) { auto& _params = std::get(params); glm::vec3 front = getFront(); glm::vec3 right = getRight(); - if (key == GLFW_KEY_W) { + if (Window::isKeyDown(GLFW_KEY_W)) { _params.position += front * 0.15f * _params.speed; } - if (key == GLFW_KEY_S) { + if (Window::isKeyDown(GLFW_KEY_S)) { _params.position -= front * 0.15f * _params.speed; } - if (key == GLFW_KEY_D) { + if (Window::isKeyDown(GLFW_KEY_D)) { _params.position += right * 0.1f * _params.speed; } - if (key == GLFW_KEY_A) { + if (Window::isKeyDown(GLFW_KEY_A)) { _params.position -= right * 0.1f * _params.speed; } - if (key == GLFW_KEY_SPACE) { + if (Window::isKeyDown(GLFW_KEY_SPACE)) { _params.position += glm::vec3{0, 1, 0} * 0.05f * _params.speed; } }