Skip to content
Merged

Dev #226

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ed22b58
fix: recognize pure emissive materials in GLTF loader
gameknife Jan 25, 2026
58c8aec
build: optimize CMake build system
gameknife Jan 26, 2026
a0bb186
fix light power
gameknife Jan 26, 2026
2c271c3
feat: add gizmo selection editing
gameknife Jan 27, 2026
c11225e
docs: record gizmo notes
gameknife Jan 27, 2026
1a817c0
feat: add focus and orbit camera controls
gameknife Jan 28, 2026
ae43493
feat: add scene saving to GLTF/GLB format
gameknife Jan 28, 2026
68f5daf
feat: add undoable node duplicate/delete commands
gameknife Jan 28, 2026
42f710e
feat: implement additive scene loading
gameknife Jan 28, 2026
080aac6
delete wrong method
gameknife Jan 28, 2026
f48e78f
Refactor editor UI panels and actions
gameknife Jan 29, 2026
8271017
fix compile
gameknife Jan 29, 2026
da2f81e
fix build.sh on macos
gameknife Jan 29, 2026
e2f8284
magicalego md
gameknife Jan 29, 2026
132c0f6
drag with assets & editor refactor
gameknife Jan 29, 2026
d399973
feat(reflection): add unified property reflection system with entt::meta
gameknife Jan 29, 2026
14ba228
refactor: unify command history and add panel
gameknife Jan 30, 2026
83693bb
ui: align viewport overlay and gizmo toolbar
gameknife Jan 30, 2026
f582520
docs: update agent guidelines and remove line length limits
gameknife Feb 1, 2026
770a9e7
fix(cpu-as): trigger voxelization update when scene is dirty after gi…
gameknife Feb 1, 2026
2ef549a
fix(runtime): enable Linux TypeScript compilation
gameknife Feb 1, 2026
c0e636d
feat(script): expose reflected components to QuickJS
gameknife Feb 1, 2026
b3590fd
feat(script): stabilize TS hot reload
gameknife Feb 1, 2026
f7ffbab
refactor(camera): improve ModelViewController with MovementInput and …
gameknife Feb 1, 2026
6a77528
feat(script): reflect engine scene node API
gameknife Feb 1, 2026
4e4355a
fix on msvc
gameknife Feb 1, 2026
e8a72fc
refactor(runtime): move config files to Runtime/Config/
gameknife Feb 2, 2026
d57c460
refactor(runtime): move TaskCoordinator to Runtime/Utilities/
gameknife Feb 2, 2026
b37c033
refactor(runtime): move scene files to Runtime/Scene/
gameknife Feb 2, 2026
3241fe0
refactor(runtime): move camera files to Runtime/Camera/
gameknife Feb 2, 2026
fad29be
refactor(runtime): move editor files to Runtime/Editor/
gameknife Feb 2, 2026
9087f84
refactor(runtime): move subsystem files to Runtime/Subsystems/
gameknife Feb 2, 2026
b0d267d
fix(runtime): fix missing include paths in subsystems
gameknife Feb 2, 2026
c84812c
fix(runtime): fix Unity Build compilation issues
gameknife Feb 2, 2026
3e2d566
refactor(runtime): reorganize files per user feedback
gameknife Feb 2, 2026
2fc74eb
refactor(assets): move data structures to Assets/Data/
gameknife Feb 2, 2026
5fb7f0e
refactor(assets): move acceleration structures to Assets/Acceleration/
gameknife Feb 2, 2026
1ea9c99
refactor(assets): move loaders and savers to dedicated subdirectories
gameknife Feb 2, 2026
2d4ef19
refactor(assets): move GPU resources to Assets/GPU/
gameknife Feb 2, 2026
6013e83
refactor(assets): move core data models to Assets/Core/
gameknife Feb 2, 2026
4dbed12
refactor(vulkan): merge Window, Surface, WindowConfig into WindowSurface
gameknife Feb 2, 2026
51dabf0
refactor(vulkan): merge Fence, Semaphore, VulkanGpuTimer into SyncAnd…
gameknife Feb 2, 2026
88b1bc2
refactor(vulkan): merge CommandPool, CommandBuffers, and SingleTimeCo…
gameknife Feb 2, 2026
0c4f36f
refactor(vulkan): merge descriptor system into DescriptorSystem
gameknife Feb 2, 2026
778aae3
refactor(vulkan): merge RenderPass, FrameBuffer, PipelineLayout, Pipe…
gameknife Feb 2, 2026
878bdf4
refactor(vulkan): merge Image, ImageView, Buffer, DepthBuffer, Render…
gameknife Feb 2, 2026
a8eeb3e
refactor(vulkan): merge DeviceMemory, Sampler, ShaderModule into Memo…
gameknife Feb 2, 2026
b78220e
refactor(vulkan): merge debug utilities into DebugUtilities
gameknife Feb 2, 2026
00e9003
Merge aggressive Vulkan refactoring: 42 -> 11.5 file pairs
gameknife Feb 2, 2026
2cb2062
build: restore MinGW presets and tooling
gameknife Feb 2, 2026
6f760d6
fix ci issue
gameknife Feb 3, 2026
f119506
fix
gameknife Feb 3, 2026
2c20100
fix for mobile platform
gameknife Feb 3, 2026
a98be4f
fix for ios build
gameknife Feb 3, 2026
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 .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
build:

runs-on: ubuntu-22.04
env:
SDK_VERSION: 1.4.309
env:
SDK_VERSION: 1.4.313
steps:
- uses: actions/setup-java@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
build:

runs-on: macos-latest
env:
SDK_VERSION: 1.4.313.1
env:
SDK_VERSION: 1.4.313.0
steps:
- uses: actions/checkout@v4
- name: Install Vulkan SDK
Expand All @@ -32,7 +32,7 @@ jobs:

- name: Download and setup slangc
run: |
curl -L https://github.com/shader-slang/slang/releases/download/vulkan-sdk-1.4.313.0/slang-vulkan-sdk-1.4.313.0-macos-aarch64.zip -o slang.zip
curl -L https://github.com/shader-slang/slang/releases/download/vulkan-sdk-${SDK_VERSION}/slang-vulkan-sdk-${SDK_VERSION}-macos-aarch64.zip -o slang.zip
mkdir -p slang
unzip slang.zip -d slang
echo "$PWD/slang/bin" >> $GITHUB_PATH
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
build:

runs-on: macos-latest
env:
SDK_VERSION: 1.4.313.1
env:
SDK_VERSION: 1.4.313.0
steps:
- uses: actions/checkout@v4
- name: Install Vulkan SDK
Expand All @@ -32,7 +32,7 @@ jobs:

- name: Download and setup slangc
run: |
curl -L https://github.com/shader-slang/slang/releases/download/vulkan-sdk-1.4.313.0/slang-vulkan-sdk-1.4.313.0-macos-aarch64.zip -o slang.zip
curl -L https://github.com/shader-slang/slang/releases/download/vulkan-sdk-${SDK_VERSION}/slang-vulkan-sdk-${SDK_VERSION}-macos-aarch64.zip -o slang.zip
mkdir -p slang
unzip slang.zip -d slang
echo "$PWD/slang/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

runs-on: windows-latest
env:
SDK_VERSION: 1.4.313.1
SDK_VERSION: 1.4.313.2
steps:
- uses: actions/checkout@v4
- name: Download Vulkan SDK
Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Build (Android):
- macOS/Linux: `./build.sh --android`

Optional build flags (via CMake args):
- Example: `./build.sh --preset default-linux -- -DGK_ENABLE_AVIF=ON`
- Windows example: `./build.bat --preset default-windows -- -DGK_ENABLE_AVIF=ON`
- Example: `./build.sh --preset default-linux -- -DENABLE_AVIF=ON`
- Windows example: `./build.bat --preset default-windows -- -DENABLE_AVIF=ON`

Run (native):
- `./run.sh --preset <preset>`
Expand Down Expand Up @@ -108,7 +108,6 @@ Language and formatting:
- C++20 and C11; prefer modern C++ (RAII, smart pointers, range-based for).
- Indentation: 4 spaces, no tabs.
- Braces: Allman style (opening brace on the next line).
- Line length: keep under 120 columns where practical.

Naming (enforced by `.clang-tidy`):
- Types (class/struct/enum/typedef/namespace): PascalCase.
Expand Down Expand Up @@ -174,3 +173,4 @@ Notes for Agents
- Prefer scripted workflows (`build.sh`, `build.ps1`, `run.sh`) over manual CMake.
- If you add a new dependency, update `vcpkg.json` accordingly.
- If unsure about a preset name, use `cmake --list-presets=configure`.
- When creating commits, add an AI co-author line matching the model you used (e.g., `Co-authored-by: gpt-5.2-codex <gpt-5.2-codex@openai.com>`).
115 changes: 115 additions & 0 deletions AGENT_GUIDE/MagicaLego.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# MagicaLego 小游戏代码梳理

本文档梳理 `src/Application/MagicaLego` 目录下乐高搭建小游戏的结构与关键流程,便于后续扩展与维护。

## 功能概览
- 玩法:基于网格的乐高方块搭建,支持放置/挖掘/选择、朝向旋转、基座尺寸切换。
- 视觉:基于引擎渲染与 GPU Raycast,提供预览框、缩略图刷子与场景重建。
- 辅助:存档读写、时间轴回放、截图与录屏、背景音乐。

## 目录与入口
- `src/Application/MagicaLego/MagicaLegoGameInstance.hpp`
- `MagicaLegoGameInstance`:核心运行逻辑。
- 枚举:`ELegoMode`、`ECamMode`、`EBasePlane`、`EOrientation`。
- 数据结构:`FBasicBlock`、`FPlacedBlock`、`FMagicaLegoSave`。
- `src/Application/MagicaLego/MagicaLegoGameInstance.cpp`
- 主要运行流程与核心行为实现。
- `CreateGameInstance` 为游戏入口工厂。
- `src/Application/MagicaLego/MagicaLegoUserInterface.hpp/.cpp`
- `MagicaLegoUserInterface`:ImGui UI 逻辑。

## 核心数据结构
- `FBasicBlock`
- `brushId_`:刷子索引。
- `modelId_`:引擎模型 ID。
- `matType` / `color`:材质与颜色。
- `name` / `type`:显示用名称与类型。
- `FPlacedBlock`
- `location`:格子坐标(int16)。
- `orientation`:朝向。
- `modelId_`:刷子索引(< 0 表示删除)。
- `FMagicaLegoSave`
- `Save` / `Load`:写入/读取 `.mls` 存档。
- 保存内容为 `brushs` + `records`。

## 运行流程
- `OnInit`
- 加载 BGM 列表并播放。
- 请求加载场景 `assets/models/legobricks.glb`。
- `OnSceneLoaded`
- 隐藏基础板节点,复制基座并生成 21x21 网格。
- 扫描并注册基础方块类型(`AddBlockGroup`)。
- 初始化预览块 `previewNode_`。
- 初始化基座显示与清理记录。
- `OnTick`
- 触发 CPU Raycast 与指示器更新。
- 相机中心与指示框缓动。
- 预览块朝向与位置更新。
- `OnRenderUI` / `OnInitUI`
- 委托给 `MagicaLegoUserInterface`。

## 放置与交互逻辑
- Raycast
- `CPURaycast` 通过 `ProjectScreenToWorld` 产生射线,再由引擎 `RayCastGPU` 返回结果。
- 命中后走 `OnRayHitResponse`。
- 放置/挖掘/选择
- `ELM_Place`:根据 `currentBlockIdx_` 和 `currentOrientation_` 放置。
- `ELM_Dig`:将目标位置写入 `modelId_ = -1`,等价删除。
- `ELM_Select`:更新选中节点,并在 AutoFocus 下对焦。
- 动态块管理
- `BlocksDynamics`:位置 hash -> `FPlacedBlock`。
- `BlockRecords`:操作记录序列(用于回放与存档)。
- `RebuildScene`:清理动态实例并重建所有放置块。

## 相机与操作
- 相机模式
- `ECM_Orbit`:围绕中心旋转。
- `ECM_Pan`:平移相机中心。
- `ECM_AutoFocus`:选择/放置后自动对焦。
- 鼠标/键盘
- 键盘:`Q/W/E` 模式,`A/S/D` 相机,`1/2/3` 基座,`R` 旋转。
- 鼠标:左键放置/选择,右键旋转视角,滚轮控制 FOV。

## UI 模块概览
- 标题栏 `DrawTitleBar`
- 窗口控制、截图/录屏、BGM、质量切换、帮助入口。
- 左侧栏 `DrawLeftBar`
- 模式、相机、基座、光照参数、存档管理。
- 右侧栏 `DrawRightBar`
- 类型选择 + 方块缩略图刷子。
- 时间轴 `DrawTimeline`
- 回放步数、播放/暂停、回滚到某一步。
- 引导与提示
- `DrawOpening` / `DrawHelp` / `DrawNotify`。

## 资源与文件路径
- 场景模型:`assets/models/legobricks.glb`
- pak:`assets/paks/lego.pak`、`assets/paks/thumbs.pak`
- 缩略图:`assets/textures/thumb/thumb_<type>_<name>.jpg`
- 存档:`assets/legos/*.mls`
- 截图:`screenshots/`
- 录屏:`captures/` + `temps/`,通过 ffmpeg 拼接。

## 常见扩展点
- 新增方块类型
- 在场景中添加对应命名的节点;`AddBlockGroup` 会自动收集。
- 增加 `BasicNodeIndicatorMap` 尺寸配置。
- 提供对应缩略图资源。
- 存档版本升级
- `MAGICALEGO_SAVE_VERSION` 与 `FMagicaLegoSave::Load`。
- 需要兼容旧版 `brushId_` 映射逻辑。
- 交互扩展
- 在 `OnRayHitResponse` 中新增模式或额外处理。
- 在 `MagicaLegoUserInterface` 添加工具/按钮入口。

## 已知注意点
- `RebuildScene` 会清空动态实例并重建,放置频繁时可能有性能压力。
- `BlocksDynamics` 以 hash 作为 key,需保证 `GetHashFromBlockLocation` 不冲突。
- 缩略图在非 Apple 平台按文件名动态加载。
- 录屏依赖系统 `ffmpeg`,缺失时会失败。

## 关联文件速查
- `src/Application/MagicaLego/MagicaLegoGameInstance.hpp`
- `src/Application/MagicaLego/MagicaLegoGameInstance.cpp`
- `src/Application/MagicaLego/MagicaLegoUserInterface.hpp`
- `src/Application/MagicaLego/MagicaLegoUserInterface.cpp`
Loading