Skip to content

Commit

Permalink
Shift modifier to set "sprint" in camera
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjaltesorgenfrei committed Sep 30, 2022
1 parent 37683cf commit 514f468
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ void App::keyCallback(GLFWwindow* window, int key, int scancode, int action, int
if(key == GLFW_KEY_E && action == GLFW_PRESS) {
app->showImguizmo = !app->showImguizmo;
}
if(key == GLFW_KEY_LEFT_SHIFT && action != GLFW_RELEASE) {
app->shiftPressed = true;
}
if(key == GLFW_KEY_LEFT_SHIFT && action == GLFW_RELEASE) {
app->shiftPressed = false;
}
}

void App::mainLoop() {
Expand Down Expand Up @@ -124,7 +130,10 @@ void App::drawImGuizmo(glm::mat4* matrix) {

void App::processPressedKeys(double delta) {
auto glfw_window = window->getGLFWwindow();
const float cameraSpeed = 0.005f * static_cast<float>(delta);
float cameraSpeed = 0.005f * static_cast<float>(delta);
if (shiftPressed) {
cameraSpeed *= 4;
}
if (glfwGetKey(glfw_window, GLFW_KEY_W) == GLFW_PRESS)
model->moveCameraForward(cameraSpeed);
if (glfwGetKey(glfw_window, GLFW_KEY_S) == GLFW_PRESS)
Expand Down
2 changes: 2 additions & 0 deletions src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ class App {
static void cursorEnterCallback(GLFWwindow *window, int enter);
static void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods);
static void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);

bool shiftPressed = false;
};

0 comments on commit 514f468

Please sign in to comment.