Merge pull request #35 from antopilo/NK-133-editor-camera-not-updating

NK-133 Editor camera not updating
This commit is contained in:
Antoine Pilote
2023-07-19 16:57:04 -04:00
committed by GitHub
3 changed files with 17 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ namespace Nuake {
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
std::string name = ICON_FA_GAMEPAD + std::string(" Scene");
if (ImGui::Begin(name.c_str()))
{
ImGui::PopStyleVar();
@@ -242,8 +243,11 @@ namespace Nuake {
}
}
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing())
m_IsViewportFocused = ImGui::IsWindowFocused();
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_2) && !ImGuizmo::IsUsing())
{
ImGui::FocusWindow(ImGui::GetCurrentWindow());
const auto windowPosNuake = Vector2(windowPos.x, windowPos.y);
auto& gbuffer = Engine::GetCurrentScene()->mSceneRenderer->GetGBuffer();
auto pixelPos = Input::GetMousePosition() - windowPosNuake;
@@ -1513,7 +1517,11 @@ namespace Nuake {
}
auto& editorCam = Engine::GetCurrentScene()->m_EditorCamera;
editorCam->Update(ts, m_IsHoveringViewport);
if (m_IsViewportFocused)
{
editorCam->Update(ts, m_IsHoveringViewport);
}
const bool entityIsSelected = Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid();
if (entityIsSelected && Input::IsKeyPressed(GLFW_KEY_F))

View File

@@ -26,6 +26,8 @@ namespace Nuake
bool m_DebugCollisions = true;
bool m_ShowOverlay = true;
bool m_IsHoveringViewport = false;
bool m_IsViewportFocused = false;
Vector2 m_ViewportPos = {0, 0};
Vector2 m_ViewportSize = {};

View File

@@ -164,6 +164,8 @@ namespace Nuake
mouseLastX = x;
mouseLastY = y;
controlled = true;
SetDirection(glm::normalize(Direction));
}
else if (Input::YScroll != 0)
{
@@ -171,6 +173,7 @@ namespace Nuake
Input::YScroll = 0.0f;
}
SetDirection(glm::normalize(Direction));
mouseLastX = x;
mouseLastY = y;
}
@@ -192,7 +195,8 @@ namespace Nuake
Direction.y = sin(glm::radians(Pitch));
Direction.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch));
Direction = glm::normalize(Direction);
Right = glm::normalize(glm::cross(Up, Direction));
SetDirection(Direction);
}
void EditorCamera::SetYaw(float yaw)