|
Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
|
Handles rendering of the editor GUI using ImGui, scene hierarchy, inspector, gizmos, and raycast picking. More...
#include <EditorUI.hpp>
Public Types | |
| using | BuildGameCallback = std::function<int(const std::string& projectPath, const std::string& outPath)> |
| using | ComponentInspectorCallback = std::function<void(Registry&, Entity)> |
| using | ComponentAddCallback = std::function<void(Registry&, Entity)> |
Public Member Functions | |
| EditorUI (Registry ®istry, VulkanRenderer &renderer, SceneManager &sceneManager, EditorModeState &editorMode, const std::string &startScenePath="assets/scenes/test_scene.json", BuildGameCallback buildGameCallback={}) | |
| Construct a new Editor UI object. | |
| ~EditorUI () | |
| Destroy the Editor UI object. | |
| void | initialize (GLFWwindow *window) |
| Initializes ImGui bindings and structures. | |
| void | shutdown () |
| Shuts down ImGui and releases descriptor pools. | |
| void | beginFrame () |
| Starts a new ImGui frame. | |
| void | drawPanels () |
| Processes and populates ImGui panel layout commands. | |
| void | render (VkCommandBuffer commandBuffer) |
| Submits ImGui draw data to the current Vulkan command buffer. | |
| void | toggleFlyMode () |
| Toggles between first-person fly camera controls and editor UI control modes. | |
Static Public Member Functions | |
| static void | registerComponentInspector (const std::string &name, ComponentInspectorCallback callback) |
| static void | registerComponentAddCallback (const std::string &name, ComponentAddCallback callback) |
| static std::vector< std::pair< std::string, ComponentInspectorCallback > > & | getDynamicInspectors () |
| static std::vector< std::pair< std::string, ComponentAddCallback > > & | getDynamicAddCallbacks () |
Private Member Functions | |
| void | handleViewportPicking () |
| Processes viewport clicking rays for entity selection. | |
| void | createDescriptorPool () |
| Creates Vulkan descriptor pool specifically for ImGui. | |
| void | destroyDescriptorPool () |
| Releases ImGui Vulkan descriptor pool resources. | |
| void | drawSceneControls () |
| Renders panel controls for scene operations (New/Load/Save/Spawn). | |
| void | drawHierarchyPanel () |
| Renders hierarchical entity list panel. | |
| void | drawInspectorPanel () |
| Renders detail inspector panel for the selected entity. | |
| void | drawTransformEditor () |
| Renders inline controls for Transform component fields. | |
| void | drawMaterialEditor () |
| Renders inline controls for Material component fields. | |
| void | drawAssetBrowser () |
| Renders the asset browser panel. | |
| void | drawImportSettingsWindow () |
| Renders the floating asset import settings window. | |
| void | drawTilesetEditorWindow () |
| Renders the Tileset Editor window. | |
| void | drawAnimationEditorWindow () |
| void | drawNodeGraphDemoWindow () |
| void | drawAnimatorControllerWindow () |
| void | drawTilemapInspector () |
| Renders the Tilemap component inspector panel. | |
| void | drawSpriteRendererInspector () |
| Renders the SpriteRenderer component inspector panel. | |
| void | drawUIComponentsEditor () |
| Renders custom editor inspectors for all game UI components. | |
| void | drawTilemapGridOverlay () |
| Renders a 3D grid overlay on the tilemap for editor visual feedback. | |
| void | drawMeshEditor () |
| Renders inline controls for Mesh component fields. | |
| void | drawGridEditor () |
| Renders inline controls for Grid component fields. | |
| void | drawCameraEditor () |
| Renders inline controls for Camera component fields. | |
| void | drawSkeletonEditor () |
| Renders inline controls for Skeleton component fields. | |
| void | drawAnimatorEditor () |
| Renders inline controls for Animator component fields. | |
| void | drawHierarchyEditor () |
| Renders inline controls for Hierarchy component fields. | |
| void | drawIKSolverEditor () |
| Renders inline controls for IK Solver component fields. | |
| void | drawAnimationControllerEditor () |
| Renders inline controls for Animation Controller component fields. | |
| void | drawReflectedComponentsEditor () |
| Renders inline controls for all reflected component fields dynamically. | |
| void | drawColliderEditor () |
| Renders inline controls for Collider component fields. | |
| void | drawSectionHeader (const std::string &title) |
| Draws a styled banner title inside component panels. | |
| bool | drawVec3Control (const char *label, float *values, float speed=0.05f) |
| Renders custom controls for editing glm::vec3 variables. | |
| void | applyInputMode () |
| Applies mouse visibility cursor mode according to active editor mode. | |
| void | drawDebugPanel () |
| Renders the debug metrics and raycast state panel. | |
| void | drawGizmo () |
| Processes and displays transformation gizmo overlay on the selected entity. | |
| void | drawBuildSettingsPanel () |
| Renders the Build Settings panel for packaging the game. | |
| void | decomposeMatrixToTransform (const glm::mat4 &mat, Transform &t) |
| Helper function to extract Euler transform fields from a 4x4 matrix. | |
| glm::mat4 | getEntityWorldMatrix (Entity entity, int depth=0) |
| Recursively traverses parent references to build the entity's absolute world transform. | |
| void | drawColliderDebugOverlay () |
| Draws wireframe overlays for all active colliders when enabled. | |
| void | drawPhysgunDebugOverlay () |
| Draws physics gun debug rays when activated by the user. | |
Private Attributes | |
| Registry & | registry |
| Reference to registry. | |
| VulkanRenderer & | renderer |
| Reference to Vulkan renderer. | |
| SceneManager & | sceneManager |
| Reference to scene manager. | |
| EditorModeState & | editorMode |
| Reference to editor mode state tracker. | |
| GLFWwindow * | window = nullptr |
| Pointer to GLFW window. | |
| VkDescriptorPool | descriptorPool = VK_NULL_HANDLE |
| ImGui dedicated descriptor pool. | |
| bool | initialized = false |
| State flag for ImGui initialization status. | |
| std::string | scenePath = "assets/scenes/test_scene.json" |
| Target json file path for scene serialization. | |
| std::string | statusMessage = "Scene not saved yet." |
| Status info message printed on UI panel. | |
| std::string | renameBuffer |
| Cache buffer string for renaming entities. | |
| Entity | selectedEntity {} |
| The entity currently selected. | |
| bool | hasSelection = false |
| Selection flag. | |
| bool | previousLeftMouseDown = false |
| Mouse click state tracking. | |
| glm::vec3 | lastPickRayOrigin { 0.0f } |
| Raycast origin caching. | |
| glm::vec3 | lastPickRayDirection { 0.0f, 0.0f, -1.0f } |
| Raycast direction caching. | |
| std::string | lastPickNearestEntityName = "None" |
| Name of the picked entity. | |
| float | lastPickNearestDistance = -1.0f |
| Distance to the picked entity. | |
| std::string | lastPickResult = "No pick attempted yet." |
| Human-readable pick results. | |
| bool | previousToggleKeyDown = false |
| Editor/Fly toggle key state cache. | |
| bool | showColliders = false |
| Flag to toggle drawing collider wireframes in the viewport. | |
| bool | showBuildSettings = false |
| Whether the Build Settings panel is open. | |
| std::string | buildOutputPath = "build/" |
| Output path for game builds. | |
| std::string | buildStatusMessage |
| Status message from last build attempt. | |
| bool | buildInProgress = false |
| Whether a build is currently in progress. | |
| BuildGameCallback | buildGameCallback |
| Optional callback used to build the game while the editor is running. | |
Handles rendering of the editor GUI using ImGui, scene hierarchy, inspector, gizmos, and raycast picking.
| using EditorUI::BuildGameCallback = std::function<int(const std::string& projectPath, const std::string& outPath)> |
| using EditorUI::ComponentAddCallback = std::function<void(Registry&, Entity)> |
| using EditorUI::ComponentInspectorCallback = std::function<void(Registry&, Entity)> |
| EditorUI::EditorUI | ( | Registry & | registry, |
| VulkanRenderer & | renderer, | ||
| SceneManager & | sceneManager, | ||
| EditorModeState & | editorMode, | ||
| const std::string & | startScenePath = "assets/scenes/test_scene.json", | ||
| BuildGameCallback | buildGameCallback = {} ) |
| EditorUI::~EditorUI | ( | ) |
Destroy the Editor UI object.
|
private |
Applies mouse visibility cursor mode according to active editor mode.
| void EditorUI::beginFrame | ( | ) |
Starts a new ImGui frame.
|
private |
Creates Vulkan descriptor pool specifically for ImGui.
|
private |
Helper function to extract Euler transform fields from a 4x4 matrix.
| mat | Input matrix. |
| t | Output transform parameters. |
|
private |
Releases ImGui Vulkan descriptor pool resources.
|
private |
Renders inline controls for Animation Controller component fields.
|
private |
|
private |
|
private |
Renders inline controls for Animator component fields.
|
private |
Renders the asset browser panel.
|
private |
Renders the Build Settings panel for packaging the game.
|
private |
Renders inline controls for Camera component fields.
|
private |
Draws wireframe overlays for all active colliders when enabled.
|
private |
Renders inline controls for Collider component fields.
|
private |
Renders the debug metrics and raycast state panel.
|
private |
Processes and displays transformation gizmo overlay on the selected entity.
|
private |
Renders inline controls for Grid component fields.
|
private |
Renders inline controls for Hierarchy component fields.
|
private |
Renders hierarchical entity list panel.
|
private |
Renders inline controls for IK Solver component fields.
|
private |
Renders the floating asset import settings window.
|
private |
Renders detail inspector panel for the selected entity.
|
private |
Renders inline controls for Material component fields.
|
private |
Renders inline controls for Mesh component fields.
|
private |
| void EditorUI::drawPanels | ( | ) |
Processes and populates ImGui panel layout commands.
|
private |
Draws physics gun debug rays when activated by the user.
|
private |
Renders inline controls for all reflected component fields dynamically.
|
private |
Renders panel controls for scene operations (New/Load/Save/Spawn).
|
private |
Draws a styled banner title inside component panels.
| title | Header title text. |
|
private |
Renders inline controls for Skeleton component fields.
|
private |
Renders the SpriteRenderer component inspector panel.
|
private |
Renders a 3D grid overlay on the tilemap for editor visual feedback.
|
private |
Renders the Tilemap component inspector panel.
|
private |
Renders the Tileset Editor window.
|
private |
Renders inline controls for Transform component fields.
|
private |
Renders custom editor inspectors for all game UI components.
|
private |
Renders custom controls for editing glm::vec3 variables.
| label | The control's label. |
| values | Pointer to the float array of 3 values. |
| speed | Interaction speed/step. |
|
static |
|
static |
|
private |
Recursively traverses parent references to build the entity's absolute world transform.
|
private |
Processes viewport clicking rays for entity selection.
| void EditorUI::initialize | ( | GLFWwindow * | window | ) |
Initializes ImGui bindings and structures.
| window | Pointer to the GLFW window. |
|
static |
|
static |
| void EditorUI::render | ( | VkCommandBuffer | commandBuffer | ) |
Submits ImGui draw data to the current Vulkan command buffer.
| commandBuffer | Command buffer to write commands to. |
| void EditorUI::shutdown | ( | ) |
Shuts down ImGui and releases descriptor pools.
| void EditorUI::toggleFlyMode | ( | ) |
Toggles between first-person fly camera controls and editor UI control modes.
|
private |
Optional callback used to build the game while the editor is running.
|
private |
Whether a build is currently in progress.
|
private |
Output path for game builds.
|
private |
Status message from last build attempt.
|
private |
ImGui dedicated descriptor pool.
|
private |
Reference to editor mode state tracker.
|
private |
Selection flag.
|
private |
State flag for ImGui initialization status.
|
private |
Distance to the picked entity.
|
private |
Name of the picked entity.
|
private |
Raycast direction caching.
|
private |
Raycast origin caching.
|
private |
Human-readable pick results.
|
private |
Mouse click state tracking.
|
private |
Editor/Fly toggle key state cache.
|
private |
Reference to registry.
|
private |
Cache buffer string for renaming entities.
|
private |
Reference to Vulkan renderer.
|
private |
Reference to scene manager.
|
private |
Target json file path for scene serialization.
|
private |
The entity currently selected.
|
private |
Whether the Build Settings panel is open.
|
private |
Flag to toggle drawing collider wireframes in the viewport.
|
private |
Status info message printed on UI panel.
|
private |
Pointer to GLFW window.