EditorCamera (UE FEditorViewportClient semantics) owned by SceneRenderer:
own TransformComponent + reused Camera controller. BuildFrame dispatches
render source by display mode — editor form always renders from the
editor camera (usable in empty scenes), game form renders from the
scene's primary camera entity. AlignTo copies an entity pose into the
editor camera ("Align Viewport to Camera" button in Inspector). F focus
and viewport gizmo now follow the same dispatch. main.cpp stripped of
dangling sandbox camera/spinner state; onSceneLoaded hook removed.
50 lines
1.8 KiB
C++
50 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/EditorCamera.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;
|
||
// 编辑器相机(Scene view 专用,归 Renderer 持有——与场景相机实体
|
||
// 无关;面板经此做 F 焦点/Gizmo 视图/对齐跳转)
|
||
Engine::EditorCamera *editorCamera = nullptr;
|
||
|
||
std::function<int()> getEnvIndex; // 当前环境表下标
|
||
std::function<void(int)> setEnvIndex;
|
||
};
|
||
|
||
#endif //HELLOVULKAN_EDITORCONTEXT_H
|