Engine-layer SceneSerializer (yaml-cpp submodule): entities/components
to versioned YAML, atomic clear-and-rebuild on load with per-entity
fault tolerance, missing-field defaults, unknown-component skip and
UUID dedup. Asset references are {Guid, Path} pairs resolved through
the new AssetManager GUID registry (assets/asset_registry.yaml) with
path fallback; procedural:// pseudo-paths rebuild from parameters.
Editor File menu gets Save/Load Scene modals; app re-resolves stale
entity handles via onSceneLoaded callback.
49 lines
1.8 KiB
C++
49 lines
1.8 KiB
C++
//
|
||
// EditorContext:Editor 层与 SandboxApp 之间的桥接上下文。
|
||
//
|
||
// Editor 是 App 层代码(不属于引擎),它需要的引擎门面与沙盒能力
|
||
// 全部经此聚合注入——面板只认识 EditorContext,不反向依赖 main.cpp。
|
||
//
|
||
|
||
#ifndef HELLOVULKAN_EDITORCONTEXT_H
|
||
#define HELLOVULKAN_EDITORCONTEXT_H
|
||
|
||
#include <Engine/Core/Application.h>
|
||
#include <Engine/ECS/Scene.h>
|
||
#include <Engine/Assets/AssetManager.h>
|
||
#include <Engine/Renderer/Renderer.h>
|
||
#include <Engine/Renderer/SceneTypes.h> // kDisplayViewport / kDisplayDirect
|
||
|
||
#include <functional>
|
||
|
||
// 可切换环境(IBL 动态切换):StatsPanel 的 Combo 与 SandboxApp 的
|
||
// 加载逻辑共用这一张表(下标即身份)。
|
||
inline constexpr const char *kEnvPaths[] = {
|
||
"assets/textures/venice_dawn_1_4k.hdr",
|
||
"assets/textures/rooitou_park_4k.hdr",
|
||
"assets/textures/pink_sunrise_4k.hdr",
|
||
"assets/textures/birchwood_4k.hdr",
|
||
};
|
||
inline constexpr const char *kEnvNames[] = {
|
||
"Venice Dawn", "Rooitou Park", "Pink Sunrise", "Birchwood",
|
||
};
|
||
inline constexpr int kEnvCount = 4;
|
||
inline constexpr int kDefaultEnv = 0;
|
||
|
||
// 沙盒特有状态(面板可选读取,空指针 = 该面板区块不显示)
|
||
struct EditorContext {
|
||
// 引擎门面
|
||
Engine::Renderer *renderer = nullptr;
|
||
Engine::ECS::Scene *scene = nullptr;
|
||
Engine::Assets::AssetManager *assets = nullptr;
|
||
Engine::Application *app = nullptr;
|
||
|
||
std::function<int()> getEnvIndex; // 当前环境表下标
|
||
std::function<void(int)> setEnvIndex;
|
||
// 场景加载成功后由 SandboxApp 重解析悬空句柄(registry 清场重建后
|
||
// 应用层持有的 EntityHandle 全部悬空,见 Scene::Clear 注释)
|
||
std::function<void()> onSceneLoaded;
|
||
};
|
||
|
||
#endif //HELLOVULKAN_EDITORCONTEXT_H
|