feat(editor): q and e for vertical movement

This commit is contained in:
maelstrom 2025-07-07 22:26:14 +02:00
parent c2135b2f8c
commit f80e9c4cc3
2 changed files with 11 additions and 0 deletions

View file

@ -93,6 +93,10 @@ void processInput(GLFWwindow* window) {
camera.processMovement(DIRECTION_LEFT, deltaTime); camera.processMovement(DIRECTION_LEFT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
camera.processMovement(DIRECTION_RIGHT, deltaTime); camera.processMovement(DIRECTION_RIGHT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
camera.processMovement(DIRECTION_UP, deltaTime);
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
camera.processMovement(DIRECTION_DOWN, deltaTime);
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
camera.processMovement(DIRECTION_UP, deltaTime); camera.processMovement(DIRECTION_UP, deltaTime);
if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS)

View file

@ -496,6 +496,7 @@ void MainGLWidget::buildContextMenu() {
static int moveZ = 0; static int moveZ = 0;
static int moveX = 0; static int moveX = 0;
static int moveYw = 0; // World Y
static std::chrono::time_point lastTime = std::chrono::steady_clock::now(); static std::chrono::time_point lastTime = std::chrono::steady_clock::now();
void MainGLWidget::updateCycle() { void MainGLWidget::updateCycle() {
@ -506,6 +507,8 @@ void MainGLWidget::updateCycle() {
camera.processMovement(moveZ == 1 ? DIRECTION_FORWARD : DIRECTION_BACKWARDS, deltaTime); camera.processMovement(moveZ == 1 ? DIRECTION_FORWARD : DIRECTION_BACKWARDS, deltaTime);
if (moveX) if (moveX)
camera.processMovement(moveX == 1 ? DIRECTION_LEFT : DIRECTION_RIGHT, deltaTime); camera.processMovement(moveX == 1 ? DIRECTION_LEFT : DIRECTION_RIGHT, deltaTime);
if (moveYw)
camera.processMovement(moveYw == 1 ? DIRECTION_UP : DIRECTION_DOWN, deltaTime);
} }
@ -517,6 +520,9 @@ void MainGLWidget::keyPressEvent(QKeyEvent* evt) {
if (evt->key() == Qt::Key_A) moveX = 1; if (evt->key() == Qt::Key_A) moveX = 1;
else if (evt->key() == Qt::Key_D) moveX = -1; else if (evt->key() == Qt::Key_D) moveX = -1;
if (evt->key() == Qt::Key_E) moveYw = 1;
else if (evt->key() == Qt::Key_Q) moveYw = -1;
if (evt->key() == Qt::Key_F) { if (evt->key() == Qt::Key_F) {
gWorkspace()->AddChild(lastPart = Part::New({ gWorkspace()->AddChild(lastPart = Part::New({
.position = camera.cameraPos + camera.cameraFront * glm::vec3(3), .position = camera.cameraPos + camera.cameraFront * glm::vec3(3),
@ -539,6 +545,7 @@ void MainGLWidget::keyPressEvent(QKeyEvent* evt) {
void MainGLWidget::keyReleaseEvent(QKeyEvent* evt) { void MainGLWidget::keyReleaseEvent(QKeyEvent* evt) {
if (evt->key() == Qt::Key_W || evt->key() == Qt::Key_S) moveZ = 0; if (evt->key() == Qt::Key_W || evt->key() == Qt::Key_S) moveZ = 0;
else if (evt->key() == Qt::Key_A || evt->key() == Qt::Key_D) moveX = 0; else if (evt->key() == Qt::Key_A || evt->key() == Qt::Key_D) moveX = 0;
else if (evt->key() == Qt::Key_E || evt->key() == Qt::Key_Q) moveYw = 0;
} }
MainWindow* MainGLWidget::mainWindow() { MainWindow* MainGLWidget::mainWindow() {