feat: move rendering to an imgui window
This commit is contained in:
@@ -27,7 +27,8 @@ public:
|
||||
void customCleanup() override;
|
||||
void customFixedUpdate(float dt) override;
|
||||
|
||||
void onWindowResize(int newWidth, int newHeight) override;
|
||||
void onViewportResize(int newWidth, int newHeight) override;
|
||||
void drawViewportOverlay() override;
|
||||
void customWindowsMenu() override;
|
||||
void onPlayModeChanged(bool nowPlaying) override;
|
||||
|
||||
@@ -42,7 +43,6 @@ private:
|
||||
void updateDebugUi();
|
||||
void drawDebugMenuBar();
|
||||
void drawWindowMenu();
|
||||
void drawSelectionGizmo();
|
||||
void drawTestWindow();
|
||||
void spawnBall();
|
||||
void saveCurrentScene();
|
||||
|
||||
@@ -166,6 +166,7 @@ void LightKeeper::customDraw()
|
||||
.clearColor = {{0.f, 0.f, 0.5f, 1.f}},
|
||||
.drawImageBlitRect = glm::ivec4{},
|
||||
.imguiPass = &imguiPass,
|
||||
.copyDrawImageToSwapchain = !usesEditorViewport(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -204,9 +205,8 @@ void LightKeeper::onPlayModeChanged(bool nowPlaying)
|
||||
}
|
||||
}
|
||||
|
||||
void LightKeeper::onWindowResize(int newWidth, int newHeight)
|
||||
void LightKeeper::onViewportResize(int newWidth, int newHeight)
|
||||
{
|
||||
renderer.resize(gfxDevice, glm::ivec2{newWidth, newHeight});
|
||||
const float aspectRatio = static_cast<float>(newWidth) / static_cast<float>(newHeight);
|
||||
camera.setAspectRatio(aspectRatio);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,11 @@ void LightKeeper::updateDebugUi()
|
||||
|
||||
drawDebugMenuBar();
|
||||
if (showTransformGizmo && !isPlayerViewActive()) {
|
||||
drawSelectionGizmo();
|
||||
GameObject* selected = SceneManager::GetInstance().GetCurrentScene().GetSelectedObject();
|
||||
if (selected != nullptr && !RectGizmo::CanManipulate(*selected)) {
|
||||
transformGizmo.HandleShortcuts();
|
||||
transformGizmo.DrawToolbar();
|
||||
}
|
||||
}
|
||||
if (showTestWindow) {
|
||||
drawTestWindow();
|
||||
@@ -183,22 +187,31 @@ void LightKeeper::drawDebugMenuBar()
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
void LightKeeper::drawSelectionGizmo()
|
||||
void LightKeeper::drawViewportOverlay()
|
||||
{
|
||||
if (!showTransformGizmo || isPlayerViewActive()) {
|
||||
return;
|
||||
}
|
||||
GameObject* selected = SceneManager::GetInstance().GetCurrentScene().GetSelectedObject();
|
||||
if (selected == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ViewportRect& view = getViewportRect();
|
||||
if (RectGizmo::CanManipulate(*selected)) {
|
||||
const VkExtent3D extent = renderer.getDrawImage().extent;
|
||||
rectGizmo.Manipulate(*selected, glm::vec2{static_cast<float>(extent.width), static_cast<float>(extent.height)});
|
||||
rectGizmo.Manipulate(*selected, glm::vec2{static_cast<float>(extent.width), static_cast<float>(extent.height)},
|
||||
view.min, view.size);
|
||||
if (rectGizmo.IsInteracting()) {
|
||||
claimViewportMouse();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
transformGizmo.HandleShortcuts();
|
||||
transformGizmo.DrawToolbar();
|
||||
transformGizmo.Manipulate(*selected, getViewCamera());
|
||||
transformGizmo.Manipulate(*selected, getViewCamera(), view.min, view.size);
|
||||
if (transformGizmo.IsOver() || transformGizmo.IsUsing()) {
|
||||
claimViewportMouse();
|
||||
}
|
||||
}
|
||||
|
||||
void LightKeeper::drawWindowMenu()
|
||||
|
||||
Reference in New Issue
Block a user