fix camera not updating when undock/dock
This commit is contained in:
parent
f9f818b49c
commit
001c25f554
|
@ -13,6 +13,7 @@
|
|||
#include <Editor/IconsFontAwesome6.h>
|
||||
|
||||
#include "Camera/SHCameraSystem.h"
|
||||
#include "FRC/SHFramerateController.h"
|
||||
|
||||
constexpr std::string_view windowName = "\xef\x80\x95 Viewport";
|
||||
|
||||
|
@ -27,14 +28,19 @@ namespace SHADE
|
|||
{
|
||||
SHEditorWindow::Init();
|
||||
transformGizmo.Init();
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
camSystem->UpdateEditorCamera(0.016f);
|
||||
}
|
||||
|
||||
void SHEditorViewport::Update()
|
||||
{
|
||||
SHEditorWindow::Update();
|
||||
if (shouldUpdateCamera)
|
||||
{
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
camSystem->UpdateEditorCamera(SHFrameRateController::GetRawDeltaTime());
|
||||
shouldUpdateCamera = false;
|
||||
}
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
|
||||
if (Begin())
|
||||
{
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
@ -56,8 +62,7 @@ namespace SHADE
|
|||
ImGui::Text(ICON_FA_EYE);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
camSystem->UpdateEditorCamera(0.016f);
|
||||
shouldUpdateCamera = true;
|
||||
}
|
||||
if (ImGui::IsWindowFocused() && !ImGui::IsMouseDown(ImGuiMouseButton_Right))
|
||||
{
|
||||
|
@ -99,8 +104,7 @@ namespace SHADE
|
|||
beginContentRegionAvailable = windowSize;
|
||||
}
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(beginContentRegionAvailable.x), static_cast<uint32_t>(beginContentRegionAvailable.y));
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
camSystem->UpdateEditorCamera(0.016f);
|
||||
shouldUpdateCamera = true;
|
||||
}
|
||||
|
||||
void SHEditorViewport::OnPosChange()
|
||||
|
|
|
@ -28,5 +28,6 @@ namespace SHADE
|
|||
private:
|
||||
void DrawMenuBar() noexcept;
|
||||
SHVec2 beginCursorPos;
|
||||
bool shouldUpdateCamera = false;
|
||||
};//class SHEditorViewport
|
||||
}//namespace SHADE
|
||||
|
|
Loading…
Reference in New Issue