refactor: align scene view camera controls with unity

This commit is contained in:
2026-03-28 18:21:18 +08:00
parent da486075e1
commit af2f30dad6
6 changed files with 123 additions and 29 deletions

View File

@@ -239,14 +239,22 @@ void SceneViewPanel::Render() {
const ViewportPanelContentResult content = RenderViewportPanelContent(*m_context, EditorViewportKind::Scene);
if (IViewportHostService* viewportHostService = m_context->GetViewportHostService()) {
const ImGuiIO& io = ImGui::GetIO();
if (!m_orbitDragging && content.hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
const bool altDown = io.KeyAlt;
if (!m_lookDragging && content.hovered && !altDown && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
m_lookDragging = true;
}
if (!m_orbitDragging && content.hovered && altDown && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
m_orbitDragging = true;
}
if (!m_panDragging && content.hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Middle)) {
m_panDragging = true;
}
if (m_orbitDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
if (m_lookDragging && (!ImGui::IsMouseDown(ImGuiMouseButton_Right) || altDown)) {
m_lookDragging = false;
}
if (m_orbitDragging && (!ImGui::IsMouseDown(ImGuiMouseButton_Left) || !altDown)) {
m_orbitDragging = false;
}
if (m_panDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Middle)) {
@@ -258,12 +266,13 @@ void SceneViewPanel::Render() {
input.hovered = content.hovered;
input.focused = content.focused;
input.mouseWheel = content.hovered ? io.MouseWheel : 0.0f;
input.looking = m_lookDragging;
input.orbiting = m_orbitDragging;
input.panning = m_panDragging;
input.focusSelectionRequested =
content.focused && !io.WantTextInput && ImGui::IsKeyPressed(ImGuiKey_F, false);
if (m_orbitDragging || m_panDragging) {
if (m_lookDragging || m_orbitDragging || m_panDragging) {
input.mouseDelta = io.MouseDelta;
}