feat: move rendering to an imgui window
This commit is contained in:
@@ -51,6 +51,8 @@ public:
|
||||
virtual void customFixedUpdate(float dt) = 0;
|
||||
|
||||
virtual void onWindowResize(int, int) {};
|
||||
virtual void onViewportResize(int, int) {}
|
||||
virtual void drawViewportOverlay() {}
|
||||
|
||||
virtual void onPlayModeChanged(bool) {}
|
||||
|
||||
@@ -61,6 +63,15 @@ public:
|
||||
|
||||
virtual void customWindowsMenu() {}
|
||||
|
||||
struct ViewportRect {
|
||||
glm::vec2 min{0.0f};
|
||||
glm::vec2 size{0.0f};
|
||||
};
|
||||
|
||||
[[nodiscard]] bool usesEditorViewport() const { return m_params.showDebugUi; }
|
||||
[[nodiscard]] const ViewportRect& getViewportRect() const { return viewportRect; }
|
||||
void claimViewportMouse() { viewportMouseClaimed = true; }
|
||||
|
||||
protected:
|
||||
Window window;
|
||||
AppParams m_params{};
|
||||
@@ -105,6 +116,16 @@ protected:
|
||||
void drawPhysicsPanel(float dt, float fixedDt, float accumulator);
|
||||
|
||||
private:
|
||||
void drawDockSpace();
|
||||
void drawViewportWindow();
|
||||
void applyViewportResize();
|
||||
|
||||
ViewportRect viewportRect{};
|
||||
glm::ivec2 viewportDesiredSize{0};
|
||||
bool viewportHovered{false};
|
||||
bool viewportFocused{false};
|
||||
bool viewportMouseClaimed{false};
|
||||
|
||||
void drawPlayControls();
|
||||
void applyPlayModeToggle();
|
||||
bool enterPlayMode();
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
VkClearColorValue clearColor{{0.f, 0.f, 0.f, 1.f}};
|
||||
glm::ivec4 drawImageBlitRect{};
|
||||
ImguiPass* imguiPass{nullptr};
|
||||
bool copyDrawImageToSwapchain{true};
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -9,16 +9,17 @@ class RectGizmo final {
|
||||
public:
|
||||
[[nodiscard]] static bool CanManipulate(GameObject& object);
|
||||
|
||||
// drawImageSize is what the canvas renders into, it is stretched over the main ImGui viewport
|
||||
bool Manipulate(GameObject& object, const glm::vec2& drawImageSize);
|
||||
bool Manipulate(GameObject& object, const glm::vec2& drawImageSize, const glm::vec2& viewMin, const glm::vec2& viewSize);
|
||||
|
||||
[[nodiscard]] bool IsUsing() const { return m_ActiveHandle >= 0; }
|
||||
[[nodiscard]] bool IsInteracting() const { return m_ActiveHandle >= 0 || m_Hovered; }
|
||||
|
||||
bool snap{false};
|
||||
float snapStep{5.0f};
|
||||
|
||||
private:
|
||||
int m_ActiveHandle{-1};
|
||||
bool m_Hovered{false};
|
||||
glm::vec2 m_DragStartMouse{0.0f};
|
||||
glm::vec2 m_DragStartPosition{0.0f};
|
||||
glm::vec2 m_DragStartSize{0.0f};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef DESTRUM_TRANSFORMGIZMO_H
|
||||
#define DESTRUM_TRANSFORMGIZMO_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Camera;
|
||||
class GameObject;
|
||||
|
||||
@@ -19,7 +21,7 @@ class TransformGizmo final {
|
||||
public:
|
||||
void HandleShortcuts();
|
||||
void DrawToolbar();
|
||||
bool Manipulate(GameObject& object, const Camera& camera);
|
||||
bool Manipulate(GameObject& object, const Camera& camera, const glm::vec2& viewMin, const glm::vec2& viewSize);
|
||||
|
||||
[[nodiscard]] bool IsUsing() const;
|
||||
[[nodiscard]] bool IsOver() const;
|
||||
|
||||
Reference in New Issue
Block a user