|
|
@ -14,13 +14,26 @@ const std::map<int, glm::vec3> moveDirections { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void Camera::update(float dt) { |
|
|
|
void Camera::update(float dt) { |
|
|
|
glm::vec3 add {}; |
|
|
|
glm::vec3 velocity {}; |
|
|
|
|
|
|
|
|
|
|
|
for (const auto &[key, dir] : moveDirections) |
|
|
|
for (const auto &[key, dir] : moveDirections) |
|
|
|
if (Input::KeyIsDown[key]) |
|
|
|
if (Input::KeyIsDown[key]) |
|
|
|
add += dir; |
|
|
|
velocity += dir; |
|
|
|
|
|
|
|
|
|
|
|
position += localToWorld(add) * dt; |
|
|
|
if (velocity == glm::vec3(0)) |
|
|
|
|
|
|
|
velocityMultiplier = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const float baseModifier = 3; |
|
|
|
|
|
|
|
float modifier = 1; |
|
|
|
|
|
|
|
if (Input::KeyIsDown[GLFW_KEY_LEFT_SHIFT]) |
|
|
|
|
|
|
|
modifier *= baseModifier; |
|
|
|
|
|
|
|
if (Input::KeyIsDown[GLFW_KEY_LEFT_CONTROL]) |
|
|
|
|
|
|
|
modifier /= baseModifier; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
velocityMultiplier += modifier * dt; |
|
|
|
|
|
|
|
velocity *= (1 + velocityMultiplier) * modifier; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position += localToWorld(velocity) * dt; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
glm::mat4 Camera::view() const { |
|
|
|
glm::mat4 Camera::view() const { |
|
|
|