feat: add scene view editor camera controls
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Actions/ActionRouting.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "SceneViewPanel.h"
|
||||
#include "ViewportPanelContent.h"
|
||||
#include "UI/UI.h"
|
||||
@@ -15,7 +16,40 @@ void SceneViewPanel::Render() {
|
||||
return;
|
||||
}
|
||||
|
||||
RenderViewportPanelContent(*m_context, EditorViewportKind::Scene);
|
||||
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)) {
|
||||
m_orbitDragging = true;
|
||||
}
|
||||
if (!m_panDragging && content.hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Middle)) {
|
||||
m_panDragging = true;
|
||||
}
|
||||
|
||||
if (m_orbitDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
|
||||
m_orbitDragging = false;
|
||||
}
|
||||
if (m_panDragging && !ImGui::IsMouseDown(ImGuiMouseButton_Middle)) {
|
||||
m_panDragging = false;
|
||||
}
|
||||
|
||||
SceneViewportInput input = {};
|
||||
input.viewportSize = content.availableSize;
|
||||
input.hovered = content.hovered;
|
||||
input.focused = content.focused;
|
||||
input.mouseWheel = content.hovered ? io.MouseWheel : 0.0f;
|
||||
input.orbiting = m_orbitDragging;
|
||||
input.panning = m_panDragging;
|
||||
input.focusSelectionRequested =
|
||||
content.focused && !io.WantTextInput && ImGui::IsKeyPressed(ImGuiKey_F, false);
|
||||
|
||||
if (m_orbitDragging || m_panDragging) {
|
||||
input.mouseDelta = io.MouseDelta;
|
||||
}
|
||||
|
||||
viewportHostService->UpdateSceneViewInput(*m_context, input);
|
||||
}
|
||||
|
||||
Actions::ObserveInactiveActionRoute(*m_context);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user