Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ ThirdParty/ConanRecipes/**/CMakeUserPresets.json
!ThirdParty/ConanRecipes/build_recipes.py
aqtinstall.log

# Agents
# Local agent settings
CLAUDE.md
AGENTS.md
/AGENTS.local.md

# Test Project (generated from the editor's Default project template by CI / tooling)
/TestProject
Expand Down
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Explosion

Before starting any work, agents must read `AGENTS.local.md` at the repository root if it exists.

## Code

- Prioritize sound abstractions and a single source of truth over a minimal diff.
- Prefer clear names and small functions; comment only when intent cannot be expressed in code.
- Avoid excessive defensive programming and validation. Write only meaningful tests. Do not overengineer compatibility
or guard against scenarios that will not occur in practice.
- Use English exclusively throughout this project. Code, comments, and documentation must not contain other languages.
- Code has no line-length limit; wrap only for readability. Wrap comments at about 120 characters with roughly even lines.
- In headers, declare the complete interface first, then put out-of-line definitions in a second namespace block.
Do not put function bodies inside class definitions. Put helper types in `Common::Internal`.
- Repeat class template-heads on out-of-line definitions; add a second template-head for member templates.
- In `.cpp` files, put translation-unit-local helpers in named `Xxx::Internal` namespaces and mark functions `static`
to avoid unity-build ODR collisions. Namespace-scope `const`/`constexpr` variables need no `static`.
- Reference header layouts: `Delegate.h`, `Utility.h`, and `Result.h` in `Engine/Source/Common/Include/Common/`.

## CMake

- Keep global toolchain/compile settings in `CMake/Common.cmake` and target helpers in `CMake/Target.cmake`.
- Create targets through `exp_add_library`, `exp_add_executable`, `exp_add_test`, or `exp_add_benchmark`.
Extend helpers instead of appending ad hoc `target_*` calls to their targets.
- Helpers are lower_snake_case `exp_*` functions using `cmake_parse_arguments(arg ...)`; read values as `arg_<KEYWORD>`.
- Keywords are UPPER_SNAKE_CASE; use `PRIVATE_*` / `PUBLIC_*` pairs for include/link/lib/compile-option inputs.
- Project options and cache variables are UPPER_SNAKE_CASE. Ordinary/local variables, including compiler-flag check
results, are lower_snake_case without `EXP`/`EXP_` prefixes.
- Define platform/compiler flags as unprefixed 0/1 macros via `add_compile_definitions` in `Common.cmake`,
e.g. `PLATFORM_WINDOWS` and `COMPILER_MSVC`.

## Build

- Default to Debug in `cmake-build-debug` with Ninja. Use `cmake-build-<config>` for other configurations when needed.
- Build incrementally; do not clear build directories or the Conan cache without a concrete reason.
- Never run concurrent configure/Conan processes against the same Conan cache.
- Keep machine-specific tool paths and parallelism in the ignored `AGENTS.local.md`.

## Git

- Commit subjects use `type: description` without a parenthesized scope, e.g. `fix: ...` or `refactor: ...`.
3 changes: 2 additions & 1 deletion Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ exp_add_executable(
)

file(GLOB editor_test_sources Test/*.cpp)
file(GLOB editor_project_sources Src/Project/*.cpp)
exp_add_test(
NAME Editor.Test
SRC ${editor_test_sources} Src/Asset/AssetFileSystem.cpp
SRC ${editor_test_sources} Src/Asset/AssetFileSystem.cpp ${editor_project_sources}
INC Include
)

Expand Down
38 changes: 8 additions & 30 deletions Editor/Include/Editor/EditorApplication.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//
// Created by johnk on 2026/7/7.
//

#pragma once

#include <Common/Memory.h>
#include <Editor/EditorContext.h>
#include <Editor/EditorWindow.h>
#include <Editor/Frame/EditorFrame.h>
#include <Editor/Frame/ProjectHubFrame.h>
#include <Runtime/Canvas.h>
#include <Editor/Project/ProjectLauncher.h>
#include <Editor/Project/ProjectService.h>
#include <Editor/Project/RecentProjectStore.h>
#include <Runtime/Window.h>

namespace Editor {
enum class EditorApplicationMode : uint8_t {
Expand All @@ -36,31 +32,13 @@ namespace Editor {
int Run();

private:
void InitializeImGui();
void ShutdownImGui();
void InstallCallbacks();
void BeginImGuiFrame(float inDeltaSeconds) const;
void DrawDockSpace() const;
void RenderEditorFrame(float inDeltaSeconds);
void RenderProjectHubFrame();
void HandleKey(int inKey, int inScancode, int inAction, int inMods);
void HandleChar(uint32_t inCodepoint) const;
void HandleMouseButton(int inButton, int inAction, int inMods);
void HandleCursor(double inX, double inY);
void HandleScroll(double inXOffset, double inYOffset) const;
float NextDeltaSeconds();

EditorApplicationDesc desc;
std::string imguiIniFilename;
Common::UniquePtr<EditorWindow> window;
Common::UniquePtr<EditorContext> context;
Common::UniquePtr<Runtime::Canvas> sceneRenderCanvas;
Common::UniquePtr<ProjectHubFrame> projectHubFrame;
EditorFrame editorFrame;
Common::UniquePtr<ProjectService> projectService;
Common::UniquePtr<RecentProjectStore> recentProjects;
Common::UniquePtr<ProjectLauncher> projectLauncher;
Common::UniquePtr<Runtime::Window> mainWindow;
double lastFrameSeconds;
double lastCursorX;
double lastCursorY;
bool hasLastCursor;
bool requestQuit;
};
}
17 changes: 8 additions & 9 deletions Editor/Include/Editor/EditorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#pragma once

#include <Common/Memory.h>
#include <Editor/SceneClient.h>
#include <Core/Uri.h>
#include <Runtime/World.h>
#include <Mirror/Mirror.h>

namespace Editor {
Expand All @@ -14,7 +15,9 @@ namespace Editor {
EditorContext();
~EditorContext();

SceneClient& GetSceneClient() const;
Runtime::World& GetWorld();
void OpenProjectLevel();
void SaveLevel();
Runtime::Entity GetSelectedEntity() const;
bool CanAddComponent(const Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity, Runtime::CompClass inClass) const;
bool CanRemoveComponent(const Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity, Runtime::CompClass inClass) const;
Expand All @@ -24,15 +27,11 @@ namespace Editor {
void DestroyEntity(Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity);
bool AddComponent(Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity, Runtime::CompClass inClass);
bool RemoveComponent(Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity, Runtime::CompClass inClass);
bool SetComponentMember(
Runtime::ECRegistry& inRegistry,
Runtime::Entity inEntity,
Runtime::CompClass inClass,
const Mirror::MemberVariable& inMemberVariable,
const Mirror::Any& inValue);
bool SetComponentMember(Runtime::ECRegistry& inRegistry, Runtime::Entity inEntity, Runtime::CompClass inClass, const Mirror::MemberVariable& inMemberVariable, const Mirror::Any& inValue);

private:
Common::UniquePtr<SceneClient> sceneClient;
Core::Uri levelUri;
Runtime::World world;
Runtime::Entity selectedEntity;
};
}
2 changes: 1 addition & 1 deletion Editor/Include/Editor/EditorLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Editor {
// log stream attached to the engine logger that keeps a bounded history and forwards structured entries to
// listeners (the log panel backend), log calls arrive from arbitrary threads so everything is mutex-guarded and
// listeners (the log tab backend), log calls arrive from arbitrary threads so everything is mutex-guarded and
// listeners must marshal to their own thread themselves
class EditorLogStream final : public Core::LogStream {
public:
Expand Down
34 changes: 34 additions & 0 deletions Editor/Include/Editor/EditorMainWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include <Editor/SceneViewport.h>
#include <Editor/Tab/EditorTabs.h>
#include <Editor/ImGui/ImGuiWindow.h>

namespace Editor {
class EditorContext;
class EditorLogStream;

class EditorMainWindow final : public ImGuiWindow {
public:
EditorMainWindow(EditorContext& inContext, EditorLogStream& inLogStream, Common::Path inAssetDirectory);
~EditorMainWindow() override;

void Render(float inDeltaSeconds) override;

private:
void RenderContents() override;
void DrawDockSpace() const;
void RenderMenuBar();
void HandleKey(int inKey, int inAction);
void HandleMouseButton(int inButton, int inAction);
void HandleCursor(double inX, double inY);

EditorContext& context;
// Releasing viewport mouse capture during destruction can dispatch a cursor callback.
double lastCursorX;
double lastCursorY;
bool hasLastCursor;
SceneViewport sceneViewport;
EditorTabs tabs;
};
}
43 changes: 0 additions & 43 deletions Editor/Include/Editor/Frame/EditorFrame.h

This file was deleted.

62 changes: 0 additions & 62 deletions Editor/Include/Editor/Frame/ProjectHubFrame.h

This file was deleted.

23 changes: 23 additions & 0 deletions Editor/Include/Editor/ImGui/ImGuiDrawData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <imgui.h>

#include <Common/Utility.h>

namespace Editor {
// Owns draw buffers and copied callback payloads, resolving ImGui texture references before queueing. Texture
// views and external callback data are borrowed; their owners must drain rendering before releasing them.
class ImGuiDrawData final {
public:
explicit ImGuiDrawData(const ImDrawData& inDrawData);
~ImGuiDrawData();

NonCopyable(ImGuiDrawData)
NonMovable(ImGuiDrawData)

ImDrawData& Get();

private:
ImDrawData drawData;
};
}
26 changes: 26 additions & 0 deletions Editor/Include/Editor/ImGui/ImGuiPlatformBackend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <Common/Utility.h>

struct GLFWwindow;
struct ImGuiContext;

namespace Editor {
struct ImGuiWindowDesc;

class ImGuiPlatformBackend final {
public:
ImGuiPlatformBackend(GLFWwindow* inWindow, const ImGuiWindowDesc& inDesc);
~ImGuiPlatformBackend();

NonCopyable(ImGuiPlatformBackend)
NonMovable(ImGuiPlatformBackend)

void NewFrame(float inDeltaSeconds) const;

private:
GLFWwindow* window;
const ImGuiWindowDesc& desc;
ImGuiContext* context;
};
}
Loading
Loading