From a69a728887e749df3bab1bc9869a3cdd1f2ee781 Mon Sep 17 00:00:00 2001 From: sorvon Date: Thu, 13 Oct 2022 10:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BA=86onCursorPos=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=AD=E5=AF=B9m=5Fmouse=5Fx=E5=92=8C=20m=5Fmouse?= =?UTF-8?q?=5Fy=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/source/editor_input_manager.cpp | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/engine/source/editor/source/editor_input_manager.cpp b/engine/source/editor/source/editor_input_manager.cpp index e64fd20ce..06db798cb 100644 --- a/engine/source/editor/source/editor_input_manager.cpp +++ b/engine/source/editor/source/editor_input_manager.cpp @@ -192,38 +192,35 @@ namespace Piccolo float angularVelocity = 180.0f / Math::max(m_engine_window_size.x, m_engine_window_size.y); // 180 degrees while moving full screen - if (m_mouse_x >= 0.0f && m_mouse_y >= 0.0f) + if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_RIGHT)) { - if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_RIGHT)) - { - glfwSetInputMode( - g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); - g_editor_global_context.m_scene_manager->getEditorCamera()->rotate( - Vector2(ypos - m_mouse_y, xpos - m_mouse_x) * angularVelocity); - } - else if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_LEFT)) - { - g_editor_global_context.m_scene_manager->moveEntity( - xpos, - ypos, - m_mouse_x, - m_mouse_y, - m_engine_window_pos, - m_engine_window_size, - m_cursor_on_axis, - g_editor_global_context.m_scene_manager->getSelectedObjectMatrix()); - glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } - else - { - glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); + glfwSetInputMode( + g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); + g_editor_global_context.m_scene_manager->getEditorCamera()->rotate( + Vector2(ypos - m_mouse_y, xpos - m_mouse_x) * angularVelocity); + } + else if (g_editor_global_context.m_window_system->isMouseButtonDown(GLFW_MOUSE_BUTTON_LEFT)) + { + g_editor_global_context.m_scene_manager->moveEntity( + xpos, + ypos, + m_mouse_x, + m_mouse_y, + m_engine_window_pos, + m_engine_window_size, + m_cursor_on_axis, + g_editor_global_context.m_scene_manager->getSelectedObjectMatrix()); + glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } + else + { + glfwSetInputMode(g_editor_global_context.m_window_system->getWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); - if (isCursorInRect(m_engine_window_pos, m_engine_window_size)) - { - Vector2 cursor_uv = Vector2((m_mouse_x - m_engine_window_pos.x) / m_engine_window_size.x, - (m_mouse_y - m_engine_window_pos.y) / m_engine_window_size.y); - updateCursorOnAxis(cursor_uv); - } + if (isCursorInRect(m_engine_window_pos, m_engine_window_size)) + { + Vector2 cursor_uv = Vector2((m_mouse_x - m_engine_window_pos.x) / m_engine_window_size.x, + (m_mouse_y - m_engine_window_pos.y) / m_engine_window_size.y); + updateCursorOnAxis(cursor_uv); } } m_mouse_x = xpos;