Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移除了onCursorPos函数中对m_mouse_x和 m_mouse_y的判断 #371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions engine/source/editor/source/editor_input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down